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 * Asynchronously opens a cache entry for the specified URI.
61 * Result is fetched asynchronously via the callback.
64 * The URI to search in cache or to open for writting.
66 * Any string that will extend (distinguish) the entry. Two entries
67 * with the same aURI but different aIdExtension will be comletely
68 * different entries. If you don't know what aIdExtension should be
71 * OPEN_NORMALLY - open cache entry normally for read and write
72 * OPEN_TRUNCATE - delete any existing entry before opening it
73 * OPEN_READONLY - don't create an entry if there is none
74 * OPEN_PRIORITY - give this request a priority over others
75 * OPEN_BYPASS_IF_BUSY - backward compatibility only, LOAD_BYPASS_LOCAL_CACHE_IF_BUSY
76 * CHECK_MULTITHREADED - onCacheEntryCheck may be called on any thread, consumer
77 * implementation is thread-safe
79 * The consumer that receives the result.
80 * IMPORTANT: The callback may be called sooner the method returns.
82 void asyncOpenURI
(in nsIURI aURI
, in ACString aIdExtension
,
84 in nsICacheEntryOpenCallback aCallback
);
87 * Immediately opens a new and empty cache entry in the storage, any existing
88 * entries are immediately doomed. This is similar to the recreate() method
91 * Storage may not implement this method and throw NS_ERROR_NOT_IMPLEMENTED.
92 * In that case consumer must use asyncOpen with OPEN_TRUNCATE flag and get
93 * the new entry via a callback.
95 * @param aURI @see asyncOpenURI
96 * @param aIdExtension @see asyncOpenURI
98 nsICacheEntry openTruncate
(in nsIURI aURI
,
99 in ACString aIdExtension
);
102 * Synchronously check on existance of an entry. In case of disk entries
103 * this uses information from the cache index. When the index data are not
104 * up to date or index is still building, NS_ERROR_NOT_AVAILABLE is thrown.
105 * The same error may throw any storage implementation that cannot determine
106 * entry state without blocking the caller.
108 boolean exists
(in nsIURI aURI
, in ACString aIdExtension
);
111 * Asynchronously removes an entry belonging to the URI from the cache.
113 void asyncDoomURI
(in nsIURI aURI
, in ACString aIdExtension
,
114 in nsICacheEntryDoomCallback aCallback
);
117 * Asynchronously removes all cached entries under this storage.
118 * NOTE: Disk storage also evicts memory storage.
120 void asyncEvictStorage
(in nsICacheEntryDoomCallback aCallback
);
123 * Visits the storage and its entries.
124 * NOTE: Disk storage also visits memory storage.
126 void asyncVisitStorage
(in nsICacheStorageVisitor aVisitor
,
127 in boolean aVisitEntries
);