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"
8 interface nsICacheEntry
;
9 interface nsICacheEntryOpenCallback
;
10 interface nsICacheEntryDoomCallback
;
11 interface nsICacheStorageVisitor
;
14 * Representation of a cache storage. There can be just-in-mem,
15 * in-mem+on-disk, in-mem+on-disk+app-cache or just a specific
18 [scriptable
, uuid(35d104a6
-d252
-4fd4
-8a56
-3c14657cad3b
)]
19 interface nsICacheStorage
: nsISupports
22 * Placeholder for specifying "no special flags" during open.
24 const uint32_t OPEN_NORMALLY
= 0;
27 * Rewrite any existing data when opening a URL.
29 const uint32_t OPEN_TRUNCATE
= 1 << 0;
32 * Only open an existing entry. Don't create a new one.
34 const uint32_t OPEN_READONLY
= 1 << 1;
37 * Use for first-paint blocking loads.
39 const uint32_t OPEN_PRIORITY
= 1 << 2;
42 * Bypass the cache load when write is still in progress.
44 const uint32_t OPEN_BYPASS_IF_BUSY
= 1 << 3;
47 * Perform the cache entry check (onCacheEntryCheck invocation) on any thread
48 * for optimal perfomance optimization. If this flag is not specified it is
49 * ensured that onCacheEntryCheck is called on the same thread as respective
50 * asyncOpen has been called.
52 const uint32_t CHECK_MULTITHREADED
= 1 << 4;
55 * Don't automatically update any 'last used' metadata of the entry.
57 const uint32_t OPEN_SECRETLY
= 1 << 5;
60 * Entry is being opened as part of a service worker interception. Do not
61 * allow the cache to be disabled in this case.
63 const uint32_t OPEN_INTERCEPTED
= 1 << 6;
66 * Asynchronously opens a cache entry for the specified URI.
67 * Result is fetched asynchronously via the callback.
70 * The URI to search in cache or to open for writting.
72 * Any string that will extend (distinguish) the entry. Two entries
73 * with the same aURI but different aIdExtension will be comletely
74 * different entries. If you don't know what aIdExtension should be
77 * OPEN_NORMALLY - open cache entry normally for read and write
78 * OPEN_TRUNCATE - delete any existing entry before opening it
79 * OPEN_READONLY - don't create an entry if there is none
80 * OPEN_PRIORITY - give this request a priority over others
81 * OPEN_BYPASS_IF_BUSY - backward compatibility only, LOAD_BYPASS_LOCAL_CACHE_IF_BUSY
82 * CHECK_MULTITHREADED - onCacheEntryCheck may be called on any thread, consumer
83 * implementation is thread-safe
85 * The consumer that receives the result.
86 * IMPORTANT: The callback may be called sooner the method returns.
88 void asyncOpenURI
(in nsIURI aURI
, in ACString aIdExtension
,
90 in nsICacheEntryOpenCallback aCallback
);
93 * Immediately opens a new and empty cache entry in the storage, any existing
94 * entries are immediately doomed. This is similar to the recreate() method
97 * Storage may not implement this method and throw NS_ERROR_NOT_IMPLEMENTED.
98 * In that case consumer must use asyncOpen with OPEN_TRUNCATE flag and get
99 * the new entry via a callback.
101 * @param aURI @see asyncOpenURI
102 * @param aIdExtension @see asyncOpenURI
104 nsICacheEntry openTruncate
(in nsIURI aURI
,
105 in ACString aIdExtension
);
108 * Synchronously check on existance of an entry. In case of disk entries
109 * this uses information from the cache index. When the index data are not
110 * up to date or index is still building, NS_ERROR_NOT_AVAILABLE is thrown.
111 * The same error may throw any storage implementation that cannot determine
112 * entry state without blocking the caller.
114 boolean exists
(in nsIURI aURI
, in ACString aIdExtension
);
117 * Synchronously check on existance of alternative data and size of the
118 * content. When the index data are not up to date or index is still building,
119 * NS_ERROR_NOT_AVAILABLE is thrown. The same error may throw any storage
120 * implementation that cannot determine entry state without blocking the caller.
122 void getCacheIndexEntryAttrs
(in nsIURI aURI
,
123 in ACString aIdExtension
,
124 out bool aHasAltData
,
125 out uint32_t aSizeInKB
);
127 * Asynchronously removes an entry belonging to the URI from the cache.
129 void asyncDoomURI
(in nsIURI aURI
, in ACString aIdExtension
,
130 in nsICacheEntryDoomCallback aCallback
);
133 * Asynchronously removes all cached entries under this storage.
134 * NOTE: Disk storage also evicts memory storage.
136 void asyncEvictStorage
(in nsICacheEntryDoomCallback aCallback
);
139 * Visits the storage and its entries.
140 * NOTE: Disk storage also visits memory storage.
142 void asyncVisitStorage
(in nsICacheStorageVisitor aVisitor
,
143 in boolean aVisitEntries
);