1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/cache2/OldWrappers.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,144 @@ 1.4 +// Stuff to link the old imp to the new api - will go away! 1.5 + 1.6 +#ifndef OLDWRAPPERS__H__ 1.7 +#define OLDWRAPPERS__H__ 1.8 + 1.9 +#include "nsICacheEntry.h" 1.10 +#include "nsICacheListener.h" 1.11 +#include "nsICacheStorage.h" 1.12 + 1.13 +#include "nsCOMPtr.h" 1.14 +#include "nsICacheEntryOpenCallback.h" 1.15 +#include "nsICacheEntryDescriptor.h" 1.16 +#include "nsThreadUtils.h" 1.17 +#include "mozilla/TimeStamp.h" 1.18 + 1.19 +class nsIURI; 1.20 +class nsICacheEntryOpenCallback; 1.21 +class nsICacheStorageConsumptionObserver; 1.22 +class nsIApplicationCache; 1.23 +class nsILoadContextInfo; 1.24 + 1.25 +namespace mozilla { namespace net { 1.26 + 1.27 +class CacheStorage; 1.28 + 1.29 +class _OldCacheEntryWrapper : public nsICacheEntry 1.30 +{ 1.31 +public: 1.32 + NS_DECL_THREADSAFE_ISUPPORTS 1.33 + NS_FORWARD_SAFE_NSICACHEENTRYDESCRIPTOR(mOldDesc) 1.34 + NS_FORWARD_NSICACHEENTRYINFO(mOldInfo->) 1.35 + 1.36 + NS_IMETHOD AsyncDoom(nsICacheEntryDoomCallback* listener); 1.37 + NS_IMETHOD GetPersistent(bool *aPersistToDisk); 1.38 + NS_IMETHOD SetValid() { return NS_OK; } 1.39 + NS_IMETHOD MetaDataReady() { return NS_OK; } 1.40 + NS_IMETHOD Recreate(bool, nsICacheEntry**); 1.41 + NS_IMETHOD GetDataSize(int64_t *size); 1.42 + NS_IMETHOD OpenInputStream(int64_t offset, nsIInputStream * *_retval); 1.43 + NS_IMETHOD OpenOutputStream(int64_t offset, nsIOutputStream * *_retval); 1.44 + NS_IMETHOD MaybeMarkValid(); 1.45 + NS_IMETHOD HasWriteAccess(bool aWriteOnly, bool *aWriteAccess); 1.46 + 1.47 + _OldCacheEntryWrapper(nsICacheEntryDescriptor* desc); 1.48 + _OldCacheEntryWrapper(nsICacheEntryInfo* info); 1.49 + 1.50 + virtual ~_OldCacheEntryWrapper(); 1.51 + 1.52 +private: 1.53 + _OldCacheEntryWrapper() MOZ_DELETE; 1.54 + nsICacheEntryDescriptor* mOldDesc; // ref holded in mOldInfo 1.55 + nsCOMPtr<nsICacheEntryInfo> mOldInfo; 1.56 +}; 1.57 + 1.58 + 1.59 +class _OldCacheLoad : public nsRunnable 1.60 + , public nsICacheListener 1.61 +{ 1.62 +public: 1.63 + NS_DECL_ISUPPORTS_INHERITED 1.64 + NS_DECL_NSIRUNNABLE 1.65 + NS_DECL_NSICACHELISTENER 1.66 + 1.67 + _OldCacheLoad(nsCSubstring const& aScheme, 1.68 + nsCSubstring const& aCacheKey, 1.69 + nsICacheEntryOpenCallback* aCallback, 1.70 + nsIApplicationCache* aAppCache, 1.71 + nsILoadContextInfo* aLoadInfo, 1.72 + bool aWriteToDisk, 1.73 + uint32_t aFlags); 1.74 + virtual ~_OldCacheLoad(); 1.75 + 1.76 + nsresult Start(); 1.77 + 1.78 +private: 1.79 + void Check(); 1.80 + 1.81 + nsCOMPtr<nsIEventTarget> mCacheThread; 1.82 + 1.83 + nsCString const mScheme; 1.84 + nsCString const mCacheKey; 1.85 + nsCOMPtr<nsICacheEntryOpenCallback> mCallback; 1.86 + nsCOMPtr<nsILoadContextInfo> mLoadInfo; 1.87 + uint32_t const mFlags; 1.88 + 1.89 + bool const mWriteToDisk : 1; 1.90 + bool mNew : 1; 1.91 + bool mOpening : 1; 1.92 + bool mSync : 1; 1.93 + 1.94 + nsCOMPtr<nsICacheEntry> mCacheEntry; 1.95 + nsresult mStatus; 1.96 + uint32_t mRunCount; 1.97 + nsCOMPtr<nsIApplicationCache> mAppCache; 1.98 + 1.99 + mozilla::TimeStamp mLoadStart; 1.100 +}; 1.101 + 1.102 + 1.103 +class _OldStorage : public nsICacheStorage 1.104 +{ 1.105 + NS_DECL_THREADSAFE_ISUPPORTS 1.106 + NS_DECL_NSICACHESTORAGE 1.107 + 1.108 +public: 1.109 + _OldStorage(nsILoadContextInfo* aInfo, 1.110 + bool aAllowDisk, 1.111 + bool aLookupAppCache, 1.112 + bool aOfflineStorage, 1.113 + nsIApplicationCache* aAppCache); 1.114 + 1.115 +private: 1.116 + virtual ~_OldStorage(); 1.117 + nsresult AssembleCacheKey(nsIURI *aURI, nsACString const & aIdExtension, 1.118 + nsACString & aCacheKey, nsACString & aScheme); 1.119 + nsresult ChooseApplicationCache(nsCSubstring const &cacheKey, nsIApplicationCache** aCache); 1.120 + 1.121 + nsCOMPtr<nsILoadContextInfo> mLoadInfo; 1.122 + nsCOMPtr<nsIApplicationCache> mAppCache; 1.123 + bool const mWriteToDisk : 1; 1.124 + bool const mLookupAppCache : 1; 1.125 + bool const mOfflineStorage : 1; 1.126 +}; 1.127 + 1.128 +class _OldGetDiskConsumption : public nsRunnable, 1.129 + public nsICacheVisitor 1.130 +{ 1.131 +public: 1.132 + static nsresult Get(nsICacheStorageConsumptionObserver* aCallback); 1.133 + 1.134 +private: 1.135 + _OldGetDiskConsumption(nsICacheStorageConsumptionObserver* aCallback); 1.136 + virtual ~_OldGetDiskConsumption() {} 1.137 + NS_DECL_ISUPPORTS_INHERITED 1.138 + NS_DECL_NSICACHEVISITOR 1.139 + NS_DECL_NSIRUNNABLE 1.140 + 1.141 + nsCOMPtr<nsICacheStorageConsumptionObserver> mCallback; 1.142 + int64_t mSize; 1.143 +}; 1.144 + 1.145 +}} 1.146 + 1.147 +#endif