michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef CacheStorage__h__ michael@0: #define CacheStorage__h__ michael@0: michael@0: #include "nsICacheStorage.h" michael@0: #include "CacheEntry.h" michael@0: #include "LoadContextInfo.h" michael@0: michael@0: #include "nsRefPtrHashtable.h" michael@0: #include "nsThreadUtils.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsILoadContextInfo.h" michael@0: #include "nsIApplicationCache.h" michael@0: #include "nsICacheEntryDoomCallback.h" michael@0: michael@0: class nsIURI; michael@0: class nsIApplicationCache; michael@0: michael@0: namespace mozilla { michael@0: namespace net { michael@0: michael@0: // This dance is needed to make CacheEntryTable declarable-only in headers michael@0: // w/o exporting CacheEntry.h file to make nsNetModule.cpp compilable. michael@0: typedef nsRefPtrHashtable TCacheEntryTable; michael@0: class CacheEntryTable : public TCacheEntryTable michael@0: { michael@0: public: michael@0: enum EType michael@0: { michael@0: MEMORY_ONLY, michael@0: ALL_ENTRIES michael@0: }; michael@0: michael@0: CacheEntryTable(EType aType) : mType(aType) { } michael@0: EType Type() const michael@0: { michael@0: return mType; michael@0: } michael@0: private: michael@0: EType const mType; michael@0: CacheEntryTable() MOZ_DELETE; michael@0: }; michael@0: michael@0: class CacheStorage : public nsICacheStorage michael@0: { michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_NSICACHESTORAGE michael@0: michael@0: public: michael@0: CacheStorage(nsILoadContextInfo* aInfo, michael@0: bool aAllowDisk, michael@0: bool aLookupAppCache); michael@0: michael@0: protected: michael@0: virtual ~CacheStorage(); michael@0: michael@0: nsresult ChooseApplicationCache(nsIURI* aURI, nsIApplicationCache** aCache); michael@0: michael@0: nsRefPtr mLoadContextInfo; michael@0: bool mWriteToDisk : 1; michael@0: bool mLookupAppCache : 1; michael@0: michael@0: public: michael@0: nsIApplicationCache* AppCache() const { return nullptr; } michael@0: nsILoadContextInfo* LoadInfo() const { return mLoadContextInfo; } michael@0: bool WriteToDisk() const { return mWriteToDisk && !mLoadContextInfo->IsPrivate(); } michael@0: bool LookupAppCache() const { return mLookupAppCache; } michael@0: }; michael@0: michael@0: } // net michael@0: } // mozilla michael@0: michael@0: #endif