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