Bug 1866777 - Disable test_race_cache_with_network.js on windows opt for frequent...
[gecko.git] / netwerk / cache2 / CacheStorage.h
blobf4db3e2a961cd70112e1184b2b46658313f76c91
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"
14 class nsIURI;
16 namespace mozilla {
17 namespace net {
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 {
23 public:
24 enum EType { MEMORY_ONLY, ALL_ENTRIES };
26 explicit CacheEntryTable(EType aType) : mType(aType) {}
27 EType Type() const { return mType; }
29 private:
30 EType const mType;
31 CacheEntryTable() = delete;
34 class CacheStorage : public nsICacheStorage {
35 NS_DECL_THREADSAFE_ISUPPORTS
36 NS_DECL_NSICACHESTORAGE
38 public:
39 CacheStorage(nsILoadContextInfo* aInfo, bool aAllowDisk, bool aSkipSizeCheck,
40 bool aPinning);
42 protected:
43 virtual ~CacheStorage() = default;
45 RefPtr<LoadContextInfo> mLoadContextInfo;
46 bool mWriteToDisk : 1;
47 bool mSkipSizeCheck : 1;
48 bool mPinning : 1;
50 public:
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; }
60 } // namespace net
61 } // namespace mozilla
63 #endif