netwerk/cache2/OldWrappers.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 // Stuff to link the old imp to the new api - will go away!
     3 #ifndef OLDWRAPPERS__H__
     4 #define OLDWRAPPERS__H__
     6 #include "nsICacheEntry.h"
     7 #include "nsICacheListener.h"
     8 #include "nsICacheStorage.h"
    10 #include "nsCOMPtr.h"
    11 #include "nsICacheEntryOpenCallback.h"
    12 #include "nsICacheEntryDescriptor.h"
    13 #include "nsThreadUtils.h"
    14 #include "mozilla/TimeStamp.h"
    16 class nsIURI;
    17 class nsICacheEntryOpenCallback;
    18 class nsICacheStorageConsumptionObserver;
    19 class nsIApplicationCache;
    20 class nsILoadContextInfo;
    22 namespace mozilla { namespace net {
    24 class CacheStorage;
    26 class _OldCacheEntryWrapper : public nsICacheEntry
    27 {
    28 public:
    29   NS_DECL_THREADSAFE_ISUPPORTS
    30   NS_FORWARD_SAFE_NSICACHEENTRYDESCRIPTOR(mOldDesc)
    31   NS_FORWARD_NSICACHEENTRYINFO(mOldInfo->)
    33   NS_IMETHOD AsyncDoom(nsICacheEntryDoomCallback* listener);
    34   NS_IMETHOD GetPersistent(bool *aPersistToDisk);
    35   NS_IMETHOD SetValid() { return NS_OK; }
    36   NS_IMETHOD MetaDataReady() { return NS_OK; }
    37   NS_IMETHOD Recreate(bool, nsICacheEntry**);
    38   NS_IMETHOD GetDataSize(int64_t *size);
    39   NS_IMETHOD OpenInputStream(int64_t offset, nsIInputStream * *_retval);
    40   NS_IMETHOD OpenOutputStream(int64_t offset, nsIOutputStream * *_retval);
    41   NS_IMETHOD MaybeMarkValid();
    42   NS_IMETHOD HasWriteAccess(bool aWriteOnly, bool *aWriteAccess);
    44   _OldCacheEntryWrapper(nsICacheEntryDescriptor* desc);
    45   _OldCacheEntryWrapper(nsICacheEntryInfo* info);
    47   virtual ~_OldCacheEntryWrapper();
    49 private:
    50   _OldCacheEntryWrapper() MOZ_DELETE;
    51   nsICacheEntryDescriptor* mOldDesc; // ref holded in mOldInfo
    52   nsCOMPtr<nsICacheEntryInfo> mOldInfo;
    53 };
    56 class _OldCacheLoad : public nsRunnable
    57                     , public nsICacheListener
    58 {
    59 public:
    60   NS_DECL_ISUPPORTS_INHERITED
    61   NS_DECL_NSIRUNNABLE
    62   NS_DECL_NSICACHELISTENER
    64   _OldCacheLoad(nsCSubstring const& aScheme,
    65                 nsCSubstring const& aCacheKey,
    66                 nsICacheEntryOpenCallback* aCallback,
    67                 nsIApplicationCache* aAppCache,
    68                 nsILoadContextInfo* aLoadInfo,
    69                 bool aWriteToDisk,
    70                 uint32_t aFlags);
    71   virtual ~_OldCacheLoad();
    73   nsresult Start();
    75 private:
    76   void Check();
    78   nsCOMPtr<nsIEventTarget> mCacheThread;
    80   nsCString const mScheme;
    81   nsCString const mCacheKey;
    82   nsCOMPtr<nsICacheEntryOpenCallback> mCallback;
    83   nsCOMPtr<nsILoadContextInfo> mLoadInfo;
    84   uint32_t const mFlags;
    86   bool const mWriteToDisk : 1;
    87   bool mNew : 1;
    88   bool mOpening : 1;
    89   bool mSync : 1;
    91   nsCOMPtr<nsICacheEntry> mCacheEntry;
    92   nsresult mStatus;
    93   uint32_t mRunCount;
    94   nsCOMPtr<nsIApplicationCache> mAppCache;
    96   mozilla::TimeStamp mLoadStart;
    97 };
   100 class _OldStorage : public nsICacheStorage
   101 {
   102   NS_DECL_THREADSAFE_ISUPPORTS
   103   NS_DECL_NSICACHESTORAGE
   105 public:
   106   _OldStorage(nsILoadContextInfo* aInfo,
   107               bool aAllowDisk,
   108               bool aLookupAppCache,
   109               bool aOfflineStorage,
   110               nsIApplicationCache* aAppCache);
   112 private:
   113   virtual ~_OldStorage();
   114   nsresult AssembleCacheKey(nsIURI *aURI, nsACString const & aIdExtension,
   115                             nsACString & aCacheKey, nsACString & aScheme);
   116   nsresult ChooseApplicationCache(nsCSubstring const &cacheKey, nsIApplicationCache** aCache);
   118   nsCOMPtr<nsILoadContextInfo> mLoadInfo;
   119   nsCOMPtr<nsIApplicationCache> mAppCache;
   120   bool const mWriteToDisk : 1;
   121   bool const mLookupAppCache : 1;
   122   bool const mOfflineStorage : 1;
   123 };
   125 class _OldGetDiskConsumption : public nsRunnable,
   126                                public nsICacheVisitor
   127 {
   128 public:
   129   static nsresult Get(nsICacheStorageConsumptionObserver* aCallback);
   131 private:
   132   _OldGetDiskConsumption(nsICacheStorageConsumptionObserver* aCallback);
   133   virtual ~_OldGetDiskConsumption() {}
   134   NS_DECL_ISUPPORTS_INHERITED
   135   NS_DECL_NSICACHEVISITOR
   136   NS_DECL_NSIRUNNABLE
   138   nsCOMPtr<nsICacheStorageConsumptionObserver> mCallback;
   139   int64_t mSize;
   140 };
   142 }}
   144 #endif

mercurial