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 "nsILoadContextInfo.h"
19 // This dance is needed to make CacheEntryTable declarable-only in headers
20 // w/o exporting CacheEntry.h file to make nsNetModule.cpp compilable.
21 using TCacheEntryTable
= nsRefPtrHashtable
<nsCStringHashKey
, CacheEntry
>;
22 class CacheEntryTable
: public TCacheEntryTable
{
24 enum EType
{ MEMORY_ONLY
, ALL_ENTRIES
};
26 explicit CacheEntryTable(EType aType
) : mType(aType
) {}
27 EType
Type() const { return mType
; }
31 CacheEntryTable() = delete;
34 class CacheStorage
: public nsICacheStorage
{
35 NS_DECL_THREADSAFE_ISUPPORTS
36 NS_DECL_NSICACHESTORAGE
39 CacheStorage(nsILoadContextInfo
* aInfo
, bool aAllowDisk
, bool aSkipSizeCheck
,
43 virtual ~CacheStorage() = default;
45 RefPtr
<LoadContextInfo
> mLoadContextInfo
;
46 bool mWriteToDisk
: 1;
47 bool mSkipSizeCheck
: 1;
51 nsILoadContextInfo
* LoadInfo() const { return mLoadContextInfo
; }
52 bool WriteToDisk() const {
53 return mWriteToDisk
&&
54 (!mLoadContextInfo
|| !mLoadContextInfo
->IsPrivate());
56 bool SkipSizeCheck() const { return mSkipSizeCheck
; }
57 bool Pinning() const { return mPinning
; }
61 } // namespace mozilla