Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #ifndef CacheFileOutputStream__h__ |
michael@0 | 6 | #define CacheFileOutputStream__h__ |
michael@0 | 7 | |
michael@0 | 8 | #include "nsIAsyncOutputStream.h" |
michael@0 | 9 | #include "nsISeekableStream.h" |
michael@0 | 10 | #include "nsCOMPtr.h" |
michael@0 | 11 | #include "nsAutoPtr.h" |
michael@0 | 12 | #include "CacheFileChunk.h" |
michael@0 | 13 | |
michael@0 | 14 | |
michael@0 | 15 | namespace mozilla { |
michael@0 | 16 | namespace net { |
michael@0 | 17 | |
michael@0 | 18 | class CacheFile; |
michael@0 | 19 | class CacheOutputCloseListener; |
michael@0 | 20 | |
michael@0 | 21 | class CacheFileOutputStream : public nsIAsyncOutputStream |
michael@0 | 22 | , public nsISeekableStream |
michael@0 | 23 | , public CacheFileChunkListener |
michael@0 | 24 | { |
michael@0 | 25 | NS_DECL_THREADSAFE_ISUPPORTS |
michael@0 | 26 | NS_DECL_NSIOUTPUTSTREAM |
michael@0 | 27 | NS_DECL_NSIASYNCOUTPUTSTREAM |
michael@0 | 28 | NS_DECL_NSISEEKABLESTREAM |
michael@0 | 29 | |
michael@0 | 30 | public: |
michael@0 | 31 | CacheFileOutputStream(CacheFile *aFile, CacheOutputCloseListener *aCloseListener); |
michael@0 | 32 | |
michael@0 | 33 | NS_IMETHOD OnChunkRead(nsresult aResult, CacheFileChunk *aChunk); |
michael@0 | 34 | NS_IMETHOD OnChunkWritten(nsresult aResult, CacheFileChunk *aChunk); |
michael@0 | 35 | NS_IMETHOD OnChunkAvailable(nsresult aResult, uint32_t aChunkIdx, |
michael@0 | 36 | CacheFileChunk *aChunk); |
michael@0 | 37 | NS_IMETHOD OnChunkUpdated(CacheFileChunk *aChunk); |
michael@0 | 38 | |
michael@0 | 39 | void NotifyCloseListener(); |
michael@0 | 40 | |
michael@0 | 41 | // Memory reporting |
michael@0 | 42 | size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const; |
michael@0 | 43 | |
michael@0 | 44 | private: |
michael@0 | 45 | virtual ~CacheFileOutputStream(); |
michael@0 | 46 | |
michael@0 | 47 | void ReleaseChunk(); |
michael@0 | 48 | void EnsureCorrectChunk(bool aReleaseOnly); |
michael@0 | 49 | void FillHole(); |
michael@0 | 50 | void NotifyListener(); |
michael@0 | 51 | |
michael@0 | 52 | nsRefPtr<CacheFile> mFile; |
michael@0 | 53 | nsRefPtr<CacheFileChunk> mChunk; |
michael@0 | 54 | nsRefPtr<CacheOutputCloseListener> mCloseListener; |
michael@0 | 55 | int64_t mPos; |
michael@0 | 56 | bool mClosed; |
michael@0 | 57 | nsresult mStatus; |
michael@0 | 58 | |
michael@0 | 59 | nsCOMPtr<nsIOutputStreamCallback> mCallback; |
michael@0 | 60 | uint32_t mCallbackFlags; |
michael@0 | 61 | nsCOMPtr<nsIEventTarget> mCallbackTarget; |
michael@0 | 62 | }; |
michael@0 | 63 | |
michael@0 | 64 | |
michael@0 | 65 | } // net |
michael@0 | 66 | } // mozilla |
michael@0 | 67 | |
michael@0 | 68 | #endif |