LCOV - code coverage report
Current view: top level - netwerk/cache2 - CacheFileInputStream.h (source / functions) Hit Total Coverage
Test: output.info Lines: 2 3 66.7 %
Date: 2017-07-14 16:53:18 Functions: 2 3 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* This Source Code Form is subject to the terms of the Mozilla Public
       2             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       3             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       4             : 
       5             : #ifndef CacheFileInputStream__h__
       6             : #define CacheFileInputStream__h__
       7             : 
       8             : #include "nsIAsyncInputStream.h"
       9             : #include "nsISeekableStream.h"
      10             : #include "nsCOMPtr.h"
      11             : #include "nsAutoPtr.h"
      12             : #include "CacheFileChunk.h"
      13             : 
      14             : namespace mozilla {
      15             : namespace net {
      16             : 
      17             : class CacheFile;
      18             : 
      19             : class CacheFileInputStream : public nsIAsyncInputStream
      20             :                            , public nsISeekableStream
      21             :                            , public CacheFileChunkListener
      22             : {
      23             :   NS_DECL_THREADSAFE_ISUPPORTS
      24             :   NS_DECL_NSIINPUTSTREAM
      25             :   NS_DECL_NSIASYNCINPUTSTREAM
      26             :   NS_DECL_NSISEEKABLESTREAM
      27             : 
      28             : public:
      29             :   explicit CacheFileInputStream(CacheFile *aFile, nsISupports *aEntry,
      30             :                                 bool aAlternativeData);
      31             : 
      32             :   NS_IMETHOD OnChunkRead(nsresult aResult, CacheFileChunk *aChunk) override;
      33             :   NS_IMETHOD OnChunkWritten(nsresult aResult, CacheFileChunk *aChunk) override;
      34             :   NS_IMETHOD OnChunkAvailable(nsresult aResult, uint32_t aChunkIdx,
      35             :                               CacheFileChunk *aChunk) override;
      36             :   NS_IMETHOD OnChunkUpdated(CacheFileChunk *aChunk) override;
      37             : 
      38             :   // Memory reporting
      39             :   size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
      40             : 
      41           4 :   uint32_t GetPosition() const { return mPos; };
      42           1 :   bool IsAlternativeData() const { return mAlternativeData; };
      43           0 :   int64_t GetChunkIdx() const { return mChunk ? static_cast<int64_t>(mChunk->Index()) : -1; };
      44             : 
      45             : private:
      46             :   virtual ~CacheFileInputStream();
      47             : 
      48             :   nsresult CloseWithStatusLocked(nsresult aStatus);
      49             :   void CleanUp();
      50             :   void ReleaseChunk();
      51             :   void EnsureCorrectChunk(bool aReleaseOnly);
      52             : 
      53             :   // CanRead returns negative value when output stream truncates the data before
      54             :   // the input stream's mPos.
      55             :   int64_t CanRead(CacheFileChunkReadHandle *aHandle);
      56             :   void NotifyListener();
      57             :   void MaybeNotifyListener();
      58             : 
      59             :   RefPtr<CacheFile>      mFile;
      60             :   RefPtr<CacheFileChunk> mChunk;
      61             :   int64_t                mPos;
      62             :   nsresult               mStatus;
      63             :   bool                   mClosed : 1;
      64             :   bool                   mInReadSegments : 1;
      65             :   bool                   mWaitingForUpdate : 1;
      66             :   bool const             mAlternativeData : 1;
      67             :   int64_t                mListeningForChunk;
      68             : 
      69             :   nsCOMPtr<nsIInputStreamCallback> mCallback;
      70             :   uint32_t                         mCallbackFlags;
      71             :   nsCOMPtr<nsIEventTarget>         mCallbackTarget;
      72             :   // Held purely for referencing purposes
      73             :   RefPtr<nsISupports>              mCacheEntryHandle;
      74             : };
      75             : 
      76             : 
      77             : } // namespace net
      78             : } // namespace mozilla
      79             : 
      80             : #endif

Generated by: LCOV version 1.13