LCOV - code coverage report
Current view: top level - dom/cache - StreamControl.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 1 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 1 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_cache_StreamControl_h
       8             : #define mozilla_dom_cache_StreamControl_h
       9             : 
      10             : #include "mozilla/dom/cache/ReadStream.h"
      11             : #include "mozilla/RefPtr.h"
      12             : #include "nsTObserverArray.h"
      13             : 
      14             : struct nsID;
      15             : 
      16             : namespace mozilla {
      17             : namespace ipc {
      18             : class AutoIPCStream;
      19             : } // namespace ipc
      20             : namespace dom {
      21             : namespace cache {
      22             : 
      23             : class CacheReadStream;
      24             : 
      25             : // Abstract class to help implement the stream control Child and Parent actors.
      26             : // This provides an interface to partly help with serialization of IPC types,
      27             : // but also an implementation for tracking ReadStream objects.
      28           0 : class StreamControl
      29             : {
      30             : public:
      31             :   // abstract interface that must be implemented by child class
      32             :   virtual void
      33             :   SerializeControl(CacheReadStream* aReadStreamOut) = 0;
      34             : 
      35             :   virtual void
      36             :   SerializeStream(CacheReadStream* aReadStreamOut, nsIInputStream* aStream,
      37             :                   nsTArray<UniquePtr<mozilla::ipc::AutoIPCStream>>& aStreamCleanupList) = 0;
      38             : 
      39             :   // inherited implementation of the ReadStream::Controllable list
      40             : 
      41             :   // Begin controlling the given ReadStream.  This causes a strong ref to
      42             :   // be held by the control.  The ReadStream must call NoteClosed() or
      43             :   // ForgetReadStream() to release this ref.
      44             :   void
      45             :   AddReadStream(ReadStream::Controllable* aReadStream);
      46             : 
      47             :   // Forget the ReadStream without notifying the actor.
      48             :   void
      49             :   ForgetReadStream(ReadStream::Controllable* aReadStream);
      50             : 
      51             :   // Forget the ReadStream and then notify the actor the stream is closed.
      52             :   void
      53             :   NoteClosed(ReadStream::Controllable* aReadStream, const nsID& aId);
      54             : 
      55             : protected:
      56             :   ~StreamControl();
      57             : 
      58             :   void
      59             :   CloseReadStreams(const nsID& aId);
      60             : 
      61             :   void
      62             :   CloseAllReadStreams();
      63             : 
      64             :   void
      65             :   CloseAllReadStreamsWithoutReporting();
      66             : 
      67             :   bool
      68             :   HasEverBeenRead() const;
      69             : 
      70             :   // protected parts of the abstract interface
      71             :   virtual void
      72             :   NoteClosedAfterForget(const nsID& aId) = 0;
      73             : 
      74             : #ifdef DEBUG
      75             :   virtual void
      76             :   AssertOwningThread() = 0;
      77             : #else
      78             :   void AssertOwningThread() { }
      79             : #endif
      80             : 
      81             : private:
      82             :   // Hold strong references to ReadStream object.  When the stream is closed
      83             :   // it should call NoteClosed() or ForgetReadStream() to release this ref.
      84             :   typedef nsTObserverArray<RefPtr<ReadStream::Controllable>> ReadStreamList;
      85             :   ReadStreamList mReadStreamList;
      86             : };
      87             : 
      88             : } // namespace cache
      89             : } // namespace dom
      90             : } // namespace mozilla
      91             : 
      92             : #endif // mozilla_dom_cache_StreamControl_h

Generated by: LCOV version 1.13