LCOV - code coverage report
Current view: top level - dom/file/ipc - IPCBlobInputStreamChild.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 6 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef mozilla_dom_ipc_IPCBlobInputStreamChild_h
       8             : #define mozilla_dom_ipc_IPCBlobInputStreamChild_h
       9             : 
      10             : #include "mozilla/ipc/PIPCBlobInputStreamChild.h"
      11             : #include "mozilla/Mutex.h"
      12             : #include "mozilla/UniquePtr.h"
      13             : #include "nsIThread.h"
      14             : #include "nsTArray.h"
      15             : 
      16             : namespace mozilla {
      17             : namespace dom {
      18             : 
      19             : namespace workers {
      20             : class WorkerHolder;
      21             : }
      22             : 
      23             : class IPCBlobInputStream;
      24             : 
      25             : class IPCBlobInputStreamChild final
      26             :   : public mozilla::ipc::PIPCBlobInputStreamChild
      27             : {
      28             : public:
      29             :   enum ActorState
      30             :   {
      31             :     // The actor is connected via IPDL to the parent.
      32             :     eActive,
      33             : 
      34             :     // The actor is disconnected.
      35             :     eInactive,
      36             : 
      37             :     // The actor is waiting to be disconnected. Once it has been disconnected,
      38             :     // it will be reactivated on the DOM-File thread.
      39             :     eActiveMigrating,
      40             : 
      41             :     // The actor has been disconnected and it's waiting to be connected on the
      42             :     // DOM-File thread.
      43             :     eInactiveMigrating,
      44             :   };
      45             : 
      46           0 :   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(IPCBlobInputStreamChild)
      47             : 
      48             :   IPCBlobInputStreamChild(const nsID& aID, uint64_t aSize);
      49             : 
      50             :   void
      51             :   ActorDestroy(IProtocol::ActorDestroyReason aReason) override;
      52             : 
      53             :   ActorState
      54             :   State();
      55             : 
      56             :   already_AddRefed<nsIInputStream>
      57             :   CreateStream();
      58             : 
      59             :   void
      60             :   ForgetStream(IPCBlobInputStream* aStream);
      61             : 
      62             :   const nsID&
      63           0 :   ID() const
      64             :   {
      65           0 :     return mID;
      66             :   }
      67             : 
      68             :   uint64_t
      69           0 :   Size() const
      70             :   {
      71           0 :     return mSize;
      72             :   }
      73             : 
      74             :   void
      75             :   StreamNeeded(IPCBlobInputStream* aStream,
      76             :                nsIEventTarget* aEventTarget);
      77             : 
      78             :   mozilla::ipc::IPCResult
      79             :   RecvStreamReady(const OptionalIPCStream& aStream) override;
      80             : 
      81             :   void
      82             :   Shutdown();
      83             : 
      84             :   void
      85             :   Migrated();
      86             : 
      87             : private:
      88             :   ~IPCBlobInputStreamChild();
      89             : 
      90             :   // Raw pointers because these streams keep this actor alive. When the last
      91             :   // stream is unregister, the actor will be deleted. This list is protected by
      92             :   // mutex.
      93             :   nsTArray<IPCBlobInputStream*> mStreams;
      94             : 
      95             :   // This mutex protects mStreams because that can be touched in any thread.
      96             :   Mutex mMutex;
      97             : 
      98             :   const nsID mID;
      99             :   const uint64_t mSize;
     100             : 
     101             :   ActorState  mState;
     102             : 
     103             :   // This struct and the array are used for creating streams when needed.
     104           0 :   struct PendingOperation
     105             :   {
     106             :     RefPtr<IPCBlobInputStream> mStream;
     107             :     nsCOMPtr<nsIEventTarget> mEventTarget;
     108             :   };
     109             :   nsTArray<PendingOperation> mPendingOperations;
     110             : 
     111             :   nsCOMPtr<nsISerialEventTarget> mOwningEventTarget;
     112             : 
     113             :   UniquePtr<workers::WorkerHolder> mWorkerHolder;
     114             : };
     115             : 
     116             : } // namespace dom
     117             : } // namespace mozilla
     118             : 
     119             : #endif // mozilla_dom_ipc_IPCBlobInputStreamChild_h

Generated by: LCOV version 1.13