Source code

Revision control

Other Tools

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
#include "nsISupports.idl"
6
7
interface nsICacheStorage;
8
interface nsILoadContextInfo;
9
interface nsIApplicationCache;
10
interface nsIEventTarget;
11
interface nsICacheStorageConsumptionObserver;
12
interface nsICacheStorageVisitor;
13
interface nsIPrincipal;
14
15
/**
16
* Provides access to particual cache storages of the network URI cache.
17
*/
18
[scriptable, uuid(ae29c44b-fbc3-4552-afaf-0a157ce771e7)]
19
interface nsICacheStorageService : nsISupports
20
{
21
/**
22
* Get storage where entries will only remain in memory, never written
23
* to the disk.
24
*
25
* NOTE: Any existing disk entry for [URL|id-extension] will be doomed
26
* prior opening an entry using this memory-only storage. Result of
27
* AsyncOpenURI will be a new and empty memory-only entry. Using
28
* OPEN_READONLY open flag has no effect on this behavior.
29
*
30
* @param aLoadContextInfo
31
* Information about the loading context, this focuses the storage JAR and
32
* respects separate storage for private browsing.
33
*/
34
nsICacheStorage memoryCacheStorage(in nsILoadContextInfo aLoadContextInfo);
35
36
/**
37
* Get storage where entries will be written to disk when not forbidden by
38
* response headers.
39
*
40
* @param aLookupAppCache
41
* When set true (for top level document loading channels) app cache will
42
* be first to check on to find entries in.
43
*/
44
nsICacheStorage diskCacheStorage(in nsILoadContextInfo aLoadContextInfo,
45
in bool aLookupAppCache);
46
47
/**
48
* Get storage where entries will be written to disk and marked as pinned.
49
* These pinned entries are immune to over limit eviction and call of clear()
50
* on this service.
51
*/
52
nsICacheStorage pinningCacheStorage(in nsILoadContextInfo aLoadContextInfo);
53
54
/**
55
* Get storage for a specified application cache obtained using some different
56
* mechanism.
57
*
58
* @param aLoadContextInfo
59
* Mandatory reference to a load context information.
60
* @param aApplicationCache
61
* Optional reference to an existing appcache. When left null, this will
62
* work with offline cache as a whole.
63
*/
64
nsICacheStorage appCacheStorage(in nsILoadContextInfo aLoadContextInfo,
65
in nsIApplicationCache aApplicationCache);
66
67
/**
68
* Get storage for synthesized cache entries that we currently use for ServiceWorker interception in non-e10s mode.
69
*
70
* This cache storage has no limits on file size to allow the ServiceWorker to intercept large files.
71
*/
72
nsICacheStorage synthesizedCacheStorage(in nsILoadContextInfo aLoadContextInfo);
73
74
/**
75
* Evict any cache entry having the same origin of aPrincipal.
76
*
77
* @param aPrincipal
78
* The principal to compare the entries with.
79
*/
80
void clearOrigin(in nsIPrincipal aPrincipal);
81
82
/**
83
* Evict the whole cache.
84
*/
85
void clear();
86
87
/**
88
* Purge only data of disk backed entries. Metadata are left for
89
* performance purposes.
90
*/
91
const uint32_t PURGE_DISK_DATA_ONLY = 1;
92
/**
93
* Purge whole disk backed entries from memory. Disk files will
94
* be left unattended.
95
*/
96
const uint32_t PURGE_DISK_ALL = 2;
97
/**
98
* Purge all entries we keep in memory, including memory-storage
99
* entries. This may be dangerous to use.
100
*/
101
const uint32_t PURGE_EVERYTHING = 3;
102
/**
103
* Purges data we keep warmed in memory. Use for tests and for
104
* saving memory.
105
*/
106
void purgeFromMemory(in uint32_t aWhat);
107
108
/**
109
* I/O thread target to use for any operations on disk
110
*/
111
readonly attribute nsIEventTarget ioTarget;
112
113
/**
114
* Asynchronously determine how many bytes of the disk space the cache takes.
115
* @see nsICacheStorageConsumptionObserver
116
* @param aObserver
117
* A mandatory (weak referred) observer. Documented at
118
* nsICacheStorageConsumptionObserver.
119
* NOTE: the observer MUST implement nsISupportsWeakReference.
120
*/
121
void asyncGetDiskConsumption(in nsICacheStorageConsumptionObserver aObserver);
122
123
/**
124
* Asynchronously visits all storages of the disk cache and memory cache.
125
* @see nsICacheStorageVisitor
126
* @param aVisitor
127
* A visitor callback.
128
* @param aVisitEntries
129
* A boolean indicates whether visits entries.
130
*/
131
void asyncVisitAllStorages(in nsICacheStorageVisitor aVisitor,
132
in boolean aVisitEntries);
133
};
134
135
[scriptable, uuid(7728ab5b-4c01-4483-a606-32bf5b8136cb)]
136
interface nsICacheStorageConsumptionObserver : nsISupports
137
{
138
/**
139
* Callback invoked to answer asyncGetDiskConsumption call. Always triggered
140
* on the main thread.
141
* NOTE: implementers must also implement nsISupportsWeakReference.
142
*
143
* @param aDiskSize
144
* The disk consumption in bytes.
145
*/
146
void onNetworkCacheDiskConsumption(in int64_t aDiskSize);
147
};