netwerk/cache2/CacheStorage.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:e78c6f65563d
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 #ifndef CacheStorage__h__
6 #define CacheStorage__h__
7
8 #include "nsICacheStorage.h"
9 #include "CacheEntry.h"
10 #include "LoadContextInfo.h"
11
12 #include "nsRefPtrHashtable.h"
13 #include "nsThreadUtils.h"
14 #include "nsCOMPtr.h"
15 #include "nsILoadContextInfo.h"
16 #include "nsIApplicationCache.h"
17 #include "nsICacheEntryDoomCallback.h"
18
19 class nsIURI;
20 class nsIApplicationCache;
21
22 namespace mozilla {
23 namespace net {
24
25 // This dance is needed to make CacheEntryTable declarable-only in headers
26 // w/o exporting CacheEntry.h file to make nsNetModule.cpp compilable.
27 typedef nsRefPtrHashtable<nsCStringHashKey, CacheEntry> TCacheEntryTable;
28 class CacheEntryTable : public TCacheEntryTable
29 {
30 public:
31 enum EType
32 {
33 MEMORY_ONLY,
34 ALL_ENTRIES
35 };
36
37 CacheEntryTable(EType aType) : mType(aType) { }
38 EType Type() const
39 {
40 return mType;
41 }
42 private:
43 EType const mType;
44 CacheEntryTable() MOZ_DELETE;
45 };
46
47 class CacheStorage : public nsICacheStorage
48 {
49 NS_DECL_THREADSAFE_ISUPPORTS
50 NS_DECL_NSICACHESTORAGE
51
52 public:
53 CacheStorage(nsILoadContextInfo* aInfo,
54 bool aAllowDisk,
55 bool aLookupAppCache);
56
57 protected:
58 virtual ~CacheStorage();
59
60 nsresult ChooseApplicationCache(nsIURI* aURI, nsIApplicationCache** aCache);
61
62 nsRefPtr<LoadContextInfo> mLoadContextInfo;
63 bool mWriteToDisk : 1;
64 bool mLookupAppCache : 1;
65
66 public:
67 nsIApplicationCache* AppCache() const { return nullptr; }
68 nsILoadContextInfo* LoadInfo() const { return mLoadContextInfo; }
69 bool WriteToDisk() const { return mWriteToDisk && !mLoadContextInfo->IsPrivate(); }
70 bool LookupAppCache() const { return mLookupAppCache; }
71 };
72
73 } // net
74 } // mozilla
75
76 #endif

mercurial