netwerk/cache2/OldWrappers.h

changeset 2
7e26c7da4463
equal deleted inserted replaced
-1:000000000000 0:09adadce84c7
1 // Stuff to link the old imp to the new api - will go away!
2
3 #ifndef OLDWRAPPERS__H__
4 #define OLDWRAPPERS__H__
5
6 #include "nsICacheEntry.h"
7 #include "nsICacheListener.h"
8 #include "nsICacheStorage.h"
9
10 #include "nsCOMPtr.h"
11 #include "nsICacheEntryOpenCallback.h"
12 #include "nsICacheEntryDescriptor.h"
13 #include "nsThreadUtils.h"
14 #include "mozilla/TimeStamp.h"
15
16 class nsIURI;
17 class nsICacheEntryOpenCallback;
18 class nsICacheStorageConsumptionObserver;
19 class nsIApplicationCache;
20 class nsILoadContextInfo;
21
22 namespace mozilla { namespace net {
23
24 class CacheStorage;
25
26 class _OldCacheEntryWrapper : public nsICacheEntry
27 {
28 public:
29 NS_DECL_THREADSAFE_ISUPPORTS
30 NS_FORWARD_SAFE_NSICACHEENTRYDESCRIPTOR(mOldDesc)
31 NS_FORWARD_NSICACHEENTRYINFO(mOldInfo->)
32
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);
43
44 _OldCacheEntryWrapper(nsICacheEntryDescriptor* desc);
45 _OldCacheEntryWrapper(nsICacheEntryInfo* info);
46
47 virtual ~_OldCacheEntryWrapper();
48
49 private:
50 _OldCacheEntryWrapper() MOZ_DELETE;
51 nsICacheEntryDescriptor* mOldDesc; // ref holded in mOldInfo
52 nsCOMPtr<nsICacheEntryInfo> mOldInfo;
53 };
54
55
56 class _OldCacheLoad : public nsRunnable
57 , public nsICacheListener
58 {
59 public:
60 NS_DECL_ISUPPORTS_INHERITED
61 NS_DECL_NSIRUNNABLE
62 NS_DECL_NSICACHELISTENER
63
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();
72
73 nsresult Start();
74
75 private:
76 void Check();
77
78 nsCOMPtr<nsIEventTarget> mCacheThread;
79
80 nsCString const mScheme;
81 nsCString const mCacheKey;
82 nsCOMPtr<nsICacheEntryOpenCallback> mCallback;
83 nsCOMPtr<nsILoadContextInfo> mLoadInfo;
84 uint32_t const mFlags;
85
86 bool const mWriteToDisk : 1;
87 bool mNew : 1;
88 bool mOpening : 1;
89 bool mSync : 1;
90
91 nsCOMPtr<nsICacheEntry> mCacheEntry;
92 nsresult mStatus;
93 uint32_t mRunCount;
94 nsCOMPtr<nsIApplicationCache> mAppCache;
95
96 mozilla::TimeStamp mLoadStart;
97 };
98
99
100 class _OldStorage : public nsICacheStorage
101 {
102 NS_DECL_THREADSAFE_ISUPPORTS
103 NS_DECL_NSICACHESTORAGE
104
105 public:
106 _OldStorage(nsILoadContextInfo* aInfo,
107 bool aAllowDisk,
108 bool aLookupAppCache,
109 bool aOfflineStorage,
110 nsIApplicationCache* aAppCache);
111
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);
117
118 nsCOMPtr<nsILoadContextInfo> mLoadInfo;
119 nsCOMPtr<nsIApplicationCache> mAppCache;
120 bool const mWriteToDisk : 1;
121 bool const mLookupAppCache : 1;
122 bool const mOfflineStorage : 1;
123 };
124
125 class _OldGetDiskConsumption : public nsRunnable,
126 public nsICacheVisitor
127 {
128 public:
129 static nsresult Get(nsICacheStorageConsumptionObserver* aCallback);
130
131 private:
132 _OldGetDiskConsumption(nsICacheStorageConsumptionObserver* aCallback);
133 virtual ~_OldGetDiskConsumption() {}
134 NS_DECL_ISUPPORTS_INHERITED
135 NS_DECL_NSICACHEVISITOR
136 NS_DECL_NSIRUNNABLE
137
138 nsCOMPtr<nsICacheStorageConsumptionObserver> mCallback;
139 int64_t mSize;
140 };
141
142 }}
143
144 #endif

mercurial