netwerk/cache2/CacheFileInputStream.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/cache2/CacheFileInputStream.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 CacheFileInputStream__h__
     1.9 +#define CacheFileInputStream__h__
    1.10 +
    1.11 +#include "nsIAsyncInputStream.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 +
    1.23 +class CacheFileInputStream : public nsIAsyncInputStream
    1.24 +                           , public nsISeekableStream
    1.25 +                           , public CacheFileChunkListener
    1.26 +{
    1.27 +  NS_DECL_THREADSAFE_ISUPPORTS
    1.28 +  NS_DECL_NSIINPUTSTREAM
    1.29 +  NS_DECL_NSIASYNCINPUTSTREAM
    1.30 +  NS_DECL_NSISEEKABLESTREAM
    1.31 +
    1.32 +public:
    1.33 +  CacheFileInputStream(CacheFile *aFile);
    1.34 +
    1.35 +  NS_IMETHOD OnChunkRead(nsresult aResult, CacheFileChunk *aChunk);
    1.36 +  NS_IMETHOD OnChunkWritten(nsresult aResult, CacheFileChunk *aChunk);
    1.37 +  NS_IMETHOD OnChunkAvailable(nsresult aResult, uint32_t aChunkIdx,
    1.38 +                              CacheFileChunk *aChunk);
    1.39 +  NS_IMETHOD OnChunkUpdated(CacheFileChunk *aChunk);
    1.40 +
    1.41 +  // Memory reporting
    1.42 +  size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
    1.43 +
    1.44 +private:
    1.45 +  virtual ~CacheFileInputStream();
    1.46 +
    1.47 +  void ReleaseChunk();
    1.48 +  void EnsureCorrectChunk(bool aReleaseOnly);
    1.49 +  void CanRead(int64_t *aCanRead, const char **aBuf);
    1.50 +  void NotifyListener();
    1.51 +  void MaybeNotifyListener();
    1.52 +
    1.53 +  nsRefPtr<CacheFile>      mFile;
    1.54 +  nsRefPtr<CacheFileChunk> mChunk;
    1.55 +  int64_t                  mPos;
    1.56 +  bool                     mClosed;
    1.57 +  nsresult                 mStatus;
    1.58 +  bool                     mWaitingForUpdate;
    1.59 +  int64_t                  mListeningForChunk;
    1.60 +  bool                     mInReadSegments;
    1.61 +
    1.62 +  nsCOMPtr<nsIInputStreamCallback> 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

mercurial