netwerk/cache2/CacheStorage.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/cache2/CacheStorage.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,76 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef CacheStorage__h__
     1.9 +#define CacheStorage__h__
    1.10 +
    1.11 +#include "nsICacheStorage.h"
    1.12 +#include "CacheEntry.h"
    1.13 +#include "LoadContextInfo.h"
    1.14 +
    1.15 +#include "nsRefPtrHashtable.h"
    1.16 +#include "nsThreadUtils.h"
    1.17 +#include "nsCOMPtr.h"
    1.18 +#include "nsILoadContextInfo.h"
    1.19 +#include "nsIApplicationCache.h"
    1.20 +#include "nsICacheEntryDoomCallback.h"
    1.21 +
    1.22 +class nsIURI;
    1.23 +class nsIApplicationCache;
    1.24 +
    1.25 +namespace mozilla {
    1.26 +namespace net {
    1.27 +
    1.28 +// This dance is needed to make CacheEntryTable declarable-only in headers
    1.29 +// w/o exporting CacheEntry.h file to make nsNetModule.cpp compilable.
    1.30 +typedef nsRefPtrHashtable<nsCStringHashKey, CacheEntry> TCacheEntryTable;
    1.31 +class CacheEntryTable : public TCacheEntryTable
    1.32 +{
    1.33 +public:
    1.34 +  enum EType
    1.35 +  {
    1.36 +    MEMORY_ONLY,
    1.37 +    ALL_ENTRIES
    1.38 +  };
    1.39 +
    1.40 +  CacheEntryTable(EType aType) : mType(aType) { }
    1.41 +  EType Type() const
    1.42 +  {
    1.43 +    return mType;
    1.44 +  }
    1.45 +private:
    1.46 +  EType const mType;
    1.47 +  CacheEntryTable() MOZ_DELETE;
    1.48 +};
    1.49 +
    1.50 +class CacheStorage : public nsICacheStorage
    1.51 +{
    1.52 +  NS_DECL_THREADSAFE_ISUPPORTS
    1.53 +  NS_DECL_NSICACHESTORAGE
    1.54 +
    1.55 +public:
    1.56 +  CacheStorage(nsILoadContextInfo* aInfo,
    1.57 +               bool aAllowDisk,
    1.58 +               bool aLookupAppCache);
    1.59 +
    1.60 +protected:
    1.61 +  virtual ~CacheStorage();
    1.62 +
    1.63 +  nsresult ChooseApplicationCache(nsIURI* aURI, nsIApplicationCache** aCache);
    1.64 +
    1.65 +  nsRefPtr<LoadContextInfo> mLoadContextInfo;
    1.66 +  bool mWriteToDisk : 1;
    1.67 +  bool mLookupAppCache : 1;
    1.68 +
    1.69 +public:
    1.70 +  nsIApplicationCache* AppCache() const { return nullptr; }
    1.71 +  nsILoadContextInfo* LoadInfo() const { return mLoadContextInfo; }
    1.72 +  bool WriteToDisk() const { return mWriteToDisk && !mLoadContextInfo->IsPrivate(); }
    1.73 +  bool LookupAppCache() const { return mLookupAppCache; }
    1.74 +};
    1.75 +
    1.76 +} // net
    1.77 +} // mozilla
    1.78 +
    1.79 +#endif

mercurial