netwerk/cache2/CacheStorage.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #ifndef CacheStorage__h__
michael@0 6 #define CacheStorage__h__
michael@0 7
michael@0 8 #include "nsICacheStorage.h"
michael@0 9 #include "CacheEntry.h"
michael@0 10 #include "LoadContextInfo.h"
michael@0 11
michael@0 12 #include "nsRefPtrHashtable.h"
michael@0 13 #include "nsThreadUtils.h"
michael@0 14 #include "nsCOMPtr.h"
michael@0 15 #include "nsILoadContextInfo.h"
michael@0 16 #include "nsIApplicationCache.h"
michael@0 17 #include "nsICacheEntryDoomCallback.h"
michael@0 18
michael@0 19 class nsIURI;
michael@0 20 class nsIApplicationCache;
michael@0 21
michael@0 22 namespace mozilla {
michael@0 23 namespace net {
michael@0 24
michael@0 25 // This dance is needed to make CacheEntryTable declarable-only in headers
michael@0 26 // w/o exporting CacheEntry.h file to make nsNetModule.cpp compilable.
michael@0 27 typedef nsRefPtrHashtable<nsCStringHashKey, CacheEntry> TCacheEntryTable;
michael@0 28 class CacheEntryTable : public TCacheEntryTable
michael@0 29 {
michael@0 30 public:
michael@0 31 enum EType
michael@0 32 {
michael@0 33 MEMORY_ONLY,
michael@0 34 ALL_ENTRIES
michael@0 35 };
michael@0 36
michael@0 37 CacheEntryTable(EType aType) : mType(aType) { }
michael@0 38 EType Type() const
michael@0 39 {
michael@0 40 return mType;
michael@0 41 }
michael@0 42 private:
michael@0 43 EType const mType;
michael@0 44 CacheEntryTable() MOZ_DELETE;
michael@0 45 };
michael@0 46
michael@0 47 class CacheStorage : public nsICacheStorage
michael@0 48 {
michael@0 49 NS_DECL_THREADSAFE_ISUPPORTS
michael@0 50 NS_DECL_NSICACHESTORAGE
michael@0 51
michael@0 52 public:
michael@0 53 CacheStorage(nsILoadContextInfo* aInfo,
michael@0 54 bool aAllowDisk,
michael@0 55 bool aLookupAppCache);
michael@0 56
michael@0 57 protected:
michael@0 58 virtual ~CacheStorage();
michael@0 59
michael@0 60 nsresult ChooseApplicationCache(nsIURI* aURI, nsIApplicationCache** aCache);
michael@0 61
michael@0 62 nsRefPtr<LoadContextInfo> mLoadContextInfo;
michael@0 63 bool mWriteToDisk : 1;
michael@0 64 bool mLookupAppCache : 1;
michael@0 65
michael@0 66 public:
michael@0 67 nsIApplicationCache* AppCache() const { return nullptr; }
michael@0 68 nsILoadContextInfo* LoadInfo() const { return mLoadContextInfo; }
michael@0 69 bool WriteToDisk() const { return mWriteToDisk && !mLoadContextInfo->IsPrivate(); }
michael@0 70 bool LookupAppCache() const { return mLookupAppCache; }
michael@0 71 };
michael@0 72
michael@0 73 } // net
michael@0 74 } // mozilla
michael@0 75
michael@0 76 #endif

mercurial