Bumping manifests a=b2g-bump
[gecko.git] / netwerk / cache2 / CacheStorage.h
blob617af805d468f03fd4b06e42a6c3095fb8e5d9a9
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/. */
5 #ifndef CacheStorage__h__
6 #define CacheStorage__h__
8 #include "nsICacheStorage.h"
9 #include "CacheEntry.h"
10 #include "LoadContextInfo.h"
12 #include "nsRefPtrHashtable.h"
13 #include "nsThreadUtils.h"
14 #include "nsCOMPtr.h"
15 #include "nsILoadContextInfo.h"
16 #include "nsIApplicationCache.h"
17 #include "nsICacheEntryDoomCallback.h"
19 class nsIURI;
20 class nsIApplicationCache;
22 namespace mozilla {
23 namespace net {
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
30 public:
31 enum EType
33 MEMORY_ONLY,
34 ALL_ENTRIES
37 explicit CacheEntryTable(EType aType) : mType(aType) { }
38 EType Type() const
40 return mType;
42 private:
43 EType const mType;
44 CacheEntryTable() MOZ_DELETE;
47 class CacheStorage : public nsICacheStorage
49 NS_DECL_THREADSAFE_ISUPPORTS
50 NS_DECL_NSICACHESTORAGE
52 public:
53 CacheStorage(nsILoadContextInfo* aInfo,
54 bool aAllowDisk,
55 bool aLookupAppCache);
57 protected:
58 virtual ~CacheStorage();
60 nsresult ChooseApplicationCache(nsIURI* aURI, nsIApplicationCache** aCache);
62 nsRefPtr<LoadContextInfo> mLoadContextInfo;
63 bool mWriteToDisk : 1;
64 bool mLookupAppCache : 1;
66 public:
67 nsILoadContextInfo* LoadInfo() const { return mLoadContextInfo; }
68 bool WriteToDisk() const { return mWriteToDisk && !mLoadContextInfo->IsPrivate(); }
69 bool LookupAppCache() const { return mLookupAppCache; }
72 } // net
73 } // mozilla
75 #endif