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.

     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"
    16 #include "nsIApplicationCache.h"
    17 #include "nsICacheEntryDoomCallback.h"
    19 class nsIURI;
    20 class nsIApplicationCache;
    22 namespace mozilla {
    23 namespace net {
    25 // This dance is needed to make CacheEntryTable declarable-only in headers
    26 // w/o exporting CacheEntry.h file to make nsNetModule.cpp compilable.
    27 typedef nsRefPtrHashtable<nsCStringHashKey, CacheEntry> TCacheEntryTable;
    28 class CacheEntryTable : public TCacheEntryTable
    29 {
    30 public:
    31   enum EType
    32   {
    33     MEMORY_ONLY,
    34     ALL_ENTRIES
    35   };
    37   CacheEntryTable(EType aType) : mType(aType) { }
    38   EType Type() const
    39   {
    40     return mType;
    41   }
    42 private:
    43   EType const mType;
    44   CacheEntryTable() MOZ_DELETE;
    45 };
    47 class CacheStorage : public nsICacheStorage
    48 {
    49   NS_DECL_THREADSAFE_ISUPPORTS
    50   NS_DECL_NSICACHESTORAGE
    52 public:
    53   CacheStorage(nsILoadContextInfo* aInfo,
    54                bool aAllowDisk,
    55                bool aLookupAppCache);
    57 protected:
    58   virtual ~CacheStorage();
    60   nsresult ChooseApplicationCache(nsIURI* aURI, nsIApplicationCache** aCache);
    62   nsRefPtr<LoadContextInfo> mLoadContextInfo;
    63   bool mWriteToDisk : 1;
    64   bool mLookupAppCache : 1;
    66 public:
    67   nsIApplicationCache* AppCache() const { return nullptr; }
    68   nsILoadContextInfo* LoadInfo() const { return mLoadContextInfo; }
    69   bool WriteToDisk() const { return mWriteToDisk && !mLoadContextInfo->IsPrivate(); }
    70   bool LookupAppCache() const { return mLookupAppCache; }
    71 };
    73 } // net
    74 } // mozilla
    76 #endif

mercurial