1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/cache2/CacheFileOutputStream.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,68 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#ifndef CacheFileOutputStream__h__ 1.9 +#define CacheFileOutputStream__h__ 1.10 + 1.11 +#include "nsIAsyncOutputStream.h" 1.12 +#include "nsISeekableStream.h" 1.13 +#include "nsCOMPtr.h" 1.14 +#include "nsAutoPtr.h" 1.15 +#include "CacheFileChunk.h" 1.16 + 1.17 + 1.18 +namespace mozilla { 1.19 +namespace net { 1.20 + 1.21 +class CacheFile; 1.22 +class CacheOutputCloseListener; 1.23 + 1.24 +class CacheFileOutputStream : public nsIAsyncOutputStream 1.25 + , public nsISeekableStream 1.26 + , public CacheFileChunkListener 1.27 +{ 1.28 + NS_DECL_THREADSAFE_ISUPPORTS 1.29 + NS_DECL_NSIOUTPUTSTREAM 1.30 + NS_DECL_NSIASYNCOUTPUTSTREAM 1.31 + NS_DECL_NSISEEKABLESTREAM 1.32 + 1.33 +public: 1.34 + CacheFileOutputStream(CacheFile *aFile, CacheOutputCloseListener *aCloseListener); 1.35 + 1.36 + NS_IMETHOD OnChunkRead(nsresult aResult, CacheFileChunk *aChunk); 1.37 + NS_IMETHOD OnChunkWritten(nsresult aResult, CacheFileChunk *aChunk); 1.38 + NS_IMETHOD OnChunkAvailable(nsresult aResult, uint32_t aChunkIdx, 1.39 + CacheFileChunk *aChunk); 1.40 + NS_IMETHOD OnChunkUpdated(CacheFileChunk *aChunk); 1.41 + 1.42 + void NotifyCloseListener(); 1.43 + 1.44 + // Memory reporting 1.45 + size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const; 1.46 + 1.47 +private: 1.48 + virtual ~CacheFileOutputStream(); 1.49 + 1.50 + void ReleaseChunk(); 1.51 + void EnsureCorrectChunk(bool aReleaseOnly); 1.52 + void FillHole(); 1.53 + void NotifyListener(); 1.54 + 1.55 + nsRefPtr<CacheFile> mFile; 1.56 + nsRefPtr<CacheFileChunk> mChunk; 1.57 + nsRefPtr<CacheOutputCloseListener> mCloseListener; 1.58 + int64_t mPos; 1.59 + bool mClosed; 1.60 + nsresult mStatus; 1.61 + 1.62 + nsCOMPtr<nsIOutputStreamCallback> mCallback; 1.63 + uint32_t mCallbackFlags; 1.64 + nsCOMPtr<nsIEventTarget> mCallbackTarget; 1.65 +}; 1.66 + 1.67 + 1.68 +} // net 1.69 +} // mozilla 1.70 + 1.71 +#endif