Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/netwerk/cache2/CacheStorage.h
Line
Count
Source (jump to first uncovered line)
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/. */
4
5
#ifndef CacheStorage__h__
6
#define CacheStorage__h__
7
8
#include "nsICacheStorage.h"
9
#include "CacheEntry.h"
10
#include "LoadContextInfo.h"
11
12
#include "nsRefPtrHashtable.h"
13
#include "nsThreadUtils.h"
14
#include "nsCOMPtr.h"
15
#include "nsILoadContextInfo.h"
16
#include "nsIApplicationCache.h"
17
#include "nsICacheEntryDoomCallback.h"
18
19
class nsIURI;
20
class nsIApplicationCache;
21
22
namespace mozilla {
23
namespace net {
24
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
  };
36
37
0
  explicit CacheEntryTable(EType aType) : mType(aType) { }
38
  EType Type() const
39
0
  {
40
0
    return mType;
41
0
  }
42
private:
43
  EType const mType;
44
  CacheEntryTable() = delete;
45
};
46
47
class CacheStorage : public nsICacheStorage
48
{
49
  NS_DECL_THREADSAFE_ISUPPORTS
50
  NS_DECL_NSICACHESTORAGE
51
52
public:
53
  CacheStorage(nsILoadContextInfo* aInfo,
54
               bool aAllowDisk,
55
               bool aLookupAppCache,
56
               bool aSkipSizeCheck,
57
               bool aPinning);
58
59
protected:
60
0
  virtual ~CacheStorage() = default;
61
62
  nsresult ChooseApplicationCache(nsIURI* aURI, nsIApplicationCache** aCache);
63
64
  RefPtr<LoadContextInfo> mLoadContextInfo;
65
  bool mWriteToDisk : 1;
66
  bool mLookupAppCache : 1;
67
  bool mSkipSizeCheck: 1;
68
  bool mPinning : 1;
69
70
public:
71
0
  nsILoadContextInfo* LoadInfo() const { return mLoadContextInfo; }
72
0
  bool WriteToDisk() const { return mWriteToDisk && !mLoadContextInfo->IsPrivate(); }
73
0
  bool LookupAppCache() const { return mLookupAppCache; }
74
0
  bool SkipSizeCheck() const { return mSkipSizeCheck; }
75
0
  bool Pinning() const { return mPinning; }
76
};
77
78
} // namespace net
79
} // namespace mozilla
80
81
#endif