Bug 1708422: part 8) Move `mozInlineSpellChecker::CheckWordsAndAddRangesForMisspellin...
[gecko.git] / netwerk / cache2 / CacheStorage.h
blob80f7568d0d45ba7e49c26064033d5b9b89319b4f
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"
17 class nsIURI;
19 namespace mozilla {
20 namespace net {
22 // This dance is needed to make CacheEntryTable declarable-only in headers
23 // w/o exporting CacheEntry.h file to make nsNetModule.cpp compilable.
24 typedef nsRefPtrHashtable<nsCStringHashKey, CacheEntry> TCacheEntryTable;
25 class CacheEntryTable : public TCacheEntryTable {
26 public:
27 enum EType { MEMORY_ONLY, ALL_ENTRIES };
29 explicit CacheEntryTable(EType aType) : mType(aType) {}
30 EType Type() const { return mType; }
32 private:
33 EType const mType;
34 CacheEntryTable() = delete;
37 class CacheStorage : public nsICacheStorage {
38 NS_DECL_THREADSAFE_ISUPPORTS
39 NS_DECL_NSICACHESTORAGE
41 public:
42 CacheStorage(nsILoadContextInfo* aInfo, bool aAllowDisk, bool aSkipSizeCheck,
43 bool aPinning);
45 protected:
46 virtual ~CacheStorage() = default;
48 RefPtr<LoadContextInfo> mLoadContextInfo;
49 bool mWriteToDisk : 1;
50 bool mSkipSizeCheck : 1;
51 bool mPinning : 1;
53 public:
54 nsILoadContextInfo* LoadInfo() const { return mLoadContextInfo; }
55 bool WriteToDisk() const {
56 return mWriteToDisk &&
57 (!mLoadContextInfo || !mLoadContextInfo->IsPrivate());
59 bool SkipSizeCheck() const { return mSkipSizeCheck; }
60 bool Pinning() const { return mPinning; }
63 } // namespace net
64 } // namespace mozilla
66 #endif