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"
15 #include "nsILoadContextInfo.h"
16 #include "nsIApplicationCache.h"
17 #include "nsICacheEntryDoomCallback.h"
20 class nsIApplicationCache
;
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
37 explicit CacheEntryTable(EType aType
) : mType(aType
) { }
44 CacheEntryTable() = delete;
47 class CacheStorage
: public nsICacheStorage
49 NS_DECL_THREADSAFE_ISUPPORTS
50 NS_DECL_NSICACHESTORAGE
53 CacheStorage(nsILoadContextInfo
* aInfo
,
55 bool aLookupAppCache
);
58 virtual ~CacheStorage();
60 nsresult
ChooseApplicationCache(nsIURI
* aURI
, nsIApplicationCache
** aCache
);
62 nsRefPtr
<LoadContextInfo
> mLoadContextInfo
;
63 bool mWriteToDisk
: 1;
64 bool mLookupAppCache
: 1;
67 nsILoadContextInfo
* LoadInfo() const { return mLoadContextInfo
; }
68 bool WriteToDisk() const { return mWriteToDisk
&& !mLoadContextInfo
->IsPrivate(); }
69 bool LookupAppCache() const { return mLookupAppCache
; }