netwerk/cache2/CacheFileOutputStream.h

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     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/. */
     5 #ifndef CacheFileOutputStream__h__
     6 #define CacheFileOutputStream__h__
     8 #include "nsIAsyncOutputStream.h"
     9 #include "nsISeekableStream.h"
    10 #include "nsCOMPtr.h"
    11 #include "nsAutoPtr.h"
    12 #include "CacheFileChunk.h"
    15 namespace mozilla {
    16 namespace net {
    18 class CacheFile;
    19 class CacheOutputCloseListener;
    21 class CacheFileOutputStream : public nsIAsyncOutputStream
    22                             , public nsISeekableStream
    23                             , public CacheFileChunkListener
    24 {
    25   NS_DECL_THREADSAFE_ISUPPORTS
    26   NS_DECL_NSIOUTPUTSTREAM
    27   NS_DECL_NSIASYNCOUTPUTSTREAM
    28   NS_DECL_NSISEEKABLESTREAM
    30 public:
    31   CacheFileOutputStream(CacheFile *aFile, CacheOutputCloseListener *aCloseListener);
    33   NS_IMETHOD OnChunkRead(nsresult aResult, CacheFileChunk *aChunk);
    34   NS_IMETHOD OnChunkWritten(nsresult aResult, CacheFileChunk *aChunk);
    35   NS_IMETHOD OnChunkAvailable(nsresult aResult, uint32_t aChunkIdx,
    36                               CacheFileChunk *aChunk);
    37   NS_IMETHOD OnChunkUpdated(CacheFileChunk *aChunk);
    39   void NotifyCloseListener();
    41   // Memory reporting
    42   size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
    44 private:
    45   virtual ~CacheFileOutputStream();
    47   void ReleaseChunk();
    48   void EnsureCorrectChunk(bool aReleaseOnly);
    49   void FillHole();
    50   void NotifyListener();
    52   nsRefPtr<CacheFile>      mFile;
    53   nsRefPtr<CacheFileChunk> mChunk;
    54   nsRefPtr<CacheOutputCloseListener> mCloseListener;
    55   int64_t                  mPos;
    56   bool                     mClosed;
    57   nsresult                 mStatus;
    59   nsCOMPtr<nsIOutputStreamCallback> mCallback;
    60   uint32_t                          mCallbackFlags;
    61   nsCOMPtr<nsIEventTarget>          mCallbackTarget;
    62 };
    65 } // net
    66 } // mozilla
    68 #endif

mercurial