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 #include
"nsISupports.idl"
7 interface nsICacheStorage
;
8 interface nsILoadContextInfo
;
9 interface nsIApplicationCache
;
10 interface nsIEventTarget
;
11 interface nsICacheStorageConsumptionObserver
;
12 interface nsICacheStorageVisitor
;
13 interface nsIPrincipal
;
16 * Provides access to particual cache storages of the network URI cache.
18 [scriptable
, uuid(ae29c44b
-fbc3
-4552-afaf
-0a157ce771e7
)]
19 interface nsICacheStorageService
: nsISupports
22 * Get storage where entries will only remain in memory, never written
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.
30 * @param aLoadContextInfo
31 * Information about the loading context, this focuses the storage JAR and
32 * respects separate storage for private browsing.
34 nsICacheStorage memoryCacheStorage
(in nsILoadContextInfo aLoadContextInfo
);
37 * Get storage where entries will be written to disk when not forbidden by
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.
44 nsICacheStorage diskCacheStorage
(in nsILoadContextInfo aLoadContextInfo
,
45 in bool aLookupAppCache
);
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()
52 nsICacheStorage pinningCacheStorage
(in nsILoadContextInfo aLoadContextInfo
);
55 * Get storage for a specified application cache obtained using some different
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.
64 nsICacheStorage appCacheStorage
(in nsILoadContextInfo aLoadContextInfo
,
65 in nsIApplicationCache aApplicationCache
);
68 * Get storage for synthesized cache entries that we currently use for ServiceWorker interception in non-e10s mode.
70 * This cache storage has no limits on file size to allow the ServiceWorker to intercept large files.
72 nsICacheStorage synthesizedCacheStorage
(in nsILoadContextInfo aLoadContextInfo
);
75 * Evict any cache entry having the same origin of aPrincipal.
78 * The principal to compare the entries with.
80 void clearOrigin
(in nsIPrincipal aPrincipal
);
83 * Evict any cache entry having the same originAttributes.
85 * @param aOriginAttributes
86 * The origin attributes in string format to compare the entries with.
88 void clearOriginAttributes
(in AString aOriginAttributes
);
91 * Evict the whole cache.
96 * Purge only data of disk backed entries. Metadata are left for
97 * performance purposes.
99 const uint32_t PURGE_DISK_DATA_ONLY
= 1;
101 * Purge whole disk backed entries from memory. Disk files will
102 * be left unattended.
104 const uint32_t PURGE_DISK_ALL
= 2;
106 * Purge all entries we keep in memory, including memory-storage
107 * entries. This may be dangerous to use.
109 const uint32_t PURGE_EVERYTHING
= 3;
111 * Purges data we keep warmed in memory. Use for tests and for
114 void purgeFromMemory
(in uint32_t aWhat
);
117 * I/O thread target to use for any operations on disk
119 readonly attribute nsIEventTarget ioTarget
;
122 * Asynchronously determine how many bytes of the disk space the cache takes.
123 * @see nsICacheStorageConsumptionObserver
125 * A mandatory (weak referred) observer. Documented at
126 * nsICacheStorageConsumptionObserver.
127 * NOTE: the observer MUST implement nsISupportsWeakReference.
129 void asyncGetDiskConsumption
(in nsICacheStorageConsumptionObserver aObserver
);
132 * Asynchronously visits all storages of the disk cache and memory cache.
133 * @see nsICacheStorageVisitor
135 * A visitor callback.
136 * @param aVisitEntries
137 * A boolean indicates whether visits entries.
139 void asyncVisitAllStorages
(in nsICacheStorageVisitor aVisitor
,
140 in boolean aVisitEntries
);
143 [scriptable
, uuid(7728ab5b
-4c01
-4483-a606
-32bf5b8136cb
)]
144 interface nsICacheStorageConsumptionObserver
: nsISupports
147 * Callback invoked to answer asyncGetDiskConsumption call. Always triggered
148 * on the main thread.
149 * NOTE: implementers must also implement nsISupportsWeakReference.
152 * The disk consumption in bytes.
154 void onNetworkCacheDiskConsumption
(in int64_t aDiskSize
);