Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
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 nsIURI;
8 interface nsICacheEntryOpenCallback;
9 interface nsICacheEntryDoomCallback;
10 interface nsICacheStorageVisitor;
12 /**
13 * Representation of a cache storage. There can be just-in-mem,
14 * in-mem+on-disk, in-mem+on-disk+app-cache or just a specific
15 * app-cache storage.
16 */
17 [scriptable, uuid(d983ba0c-433f-4017-abc1-93af737c82e4)]
18 interface nsICacheStorage : nsISupports
19 {
20 /**
21 * Placeholder for specifying "no special flags" during open.
22 */
23 const uint32_t OPEN_NORMALLY = 0;
25 /**
26 * Rewrite any existing data when opening a URL.
27 */
28 const uint32_t OPEN_TRUNCATE = 1 << 0;
30 /**
31 * Only open an existing entry. Don't create a new one.
32 */
33 const uint32_t OPEN_READONLY = 1 << 1;
35 /**
36 * Use for first-paint blocking loads.
37 */
38 const uint32_t OPEN_PRIORITY = 1 << 2;
40 /**
41 * Bypass the cache load when write is still in progress.
42 */
43 const uint32_t OPEN_BYPASS_IF_BUSY = 1 << 3;
45 /**
46 * Perform the cache entry check (onCacheEntryCheck invocation) on any thread
47 * for optimal perfomance optimization. If this flag is not specified it is
48 * ensured that onCacheEntryCheck is called on the same thread as respective
49 * asyncOpen has been called.
50 */
51 const uint32_t CHECK_MULTITHREADED = 1 << 4;
53 /**
54 * Asynchronously opens a cache entry for the specified URI.
55 * Result is fetched asynchronously via the callback.
56 *
57 * @param aURI
58 * The URI to search in cache or to open for writting.
59 * @param aIdExtension
60 * Any string that will extend (distinguish) the entry. Two entries
61 * with the same aURI but different aIdExtension will be comletely
62 * different entries. If you don't know what aIdExtension should be
63 * leave it empty.
64 * @param aFlags
65 * OPEN_NORMALLY - open cache entry normally for read and write
66 * OPEN_TRUNCATE - delete any existing entry before opening it
67 * OPEN_READONLY - don't create an entry if there is none
68 * OPEN_PRIORITY - give this request a priority over others
69 * OPEN_BYPASS_IF_BUSY - backward compatibility only, LOAD_BYPASS_LOCAL_CACHE_IF_BUSY
70 * CHECK_MULTITHREADED - onCacheEntryCheck may be called on any thread, consumer
71 * implementation is thread-safe
72 * @param aCallback
73 * The consumer that receives the result.
74 * IMPORTANT: The callback may be called sooner the method returns.
75 */
76 void asyncOpenURI(in nsIURI aURI, in ACString aIdExtension,
77 in uint32_t aFlags,
78 in nsICacheEntryOpenCallback aCallback);
80 /**
81 * Asynchronously removes an entry belonging to the URI from the cache.
82 */
83 void asyncDoomURI(in nsIURI aURI, in ACString aIdExtension,
84 in nsICacheEntryDoomCallback aCallback);
86 /**
87 * Asynchronously removes all cached entries under this storage.
88 * NOTE: Disk storage also evicts memory storage.
89 */
90 void asyncEvictStorage(in nsICacheEntryDoomCallback aCallback);
92 /**
93 * Visits the storage and its entries.
94 * NOTE: Disk storage also visits memory storage.
95 */
96 void asyncVisitStorage(in nsICacheStorageVisitor aVisitor,
97 in boolean aVisitEntries);
98 };