netwerk/cache2/CacheFileInputStream.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 CacheFileInputStream__h__
michael@0 6 #define CacheFileInputStream__h__
michael@0 7
michael@0 8 #include "nsIAsyncInputStream.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
michael@0 20 class CacheFileInputStream : public nsIAsyncInputStream
michael@0 21 , public nsISeekableStream
michael@0 22 , public CacheFileChunkListener
michael@0 23 {
michael@0 24 NS_DECL_THREADSAFE_ISUPPORTS
michael@0 25 NS_DECL_NSIINPUTSTREAM
michael@0 26 NS_DECL_NSIASYNCINPUTSTREAM
michael@0 27 NS_DECL_NSISEEKABLESTREAM
michael@0 28
michael@0 29 public:
michael@0 30 CacheFileInputStream(CacheFile *aFile);
michael@0 31
michael@0 32 NS_IMETHOD OnChunkRead(nsresult aResult, CacheFileChunk *aChunk);
michael@0 33 NS_IMETHOD OnChunkWritten(nsresult aResult, CacheFileChunk *aChunk);
michael@0 34 NS_IMETHOD OnChunkAvailable(nsresult aResult, uint32_t aChunkIdx,
michael@0 35 CacheFileChunk *aChunk);
michael@0 36 NS_IMETHOD OnChunkUpdated(CacheFileChunk *aChunk);
michael@0 37
michael@0 38 // Memory reporting
michael@0 39 size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
michael@0 40
michael@0 41 private:
michael@0 42 virtual ~CacheFileInputStream();
michael@0 43
michael@0 44 void ReleaseChunk();
michael@0 45 void EnsureCorrectChunk(bool aReleaseOnly);
michael@0 46 void CanRead(int64_t *aCanRead, const char **aBuf);
michael@0 47 void NotifyListener();
michael@0 48 void MaybeNotifyListener();
michael@0 49
michael@0 50 nsRefPtr<CacheFile> mFile;
michael@0 51 nsRefPtr<CacheFileChunk> mChunk;
michael@0 52 int64_t mPos;
michael@0 53 bool mClosed;
michael@0 54 nsresult mStatus;
michael@0 55 bool mWaitingForUpdate;
michael@0 56 int64_t mListeningForChunk;
michael@0 57 bool mInReadSegments;
michael@0 58
michael@0 59 nsCOMPtr<nsIInputStreamCallback> 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

mercurial