1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/cache2/nsICacheStorage.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,98 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#include "nsISupports.idl" 1.9 + 1.10 +interface nsIURI; 1.11 +interface nsICacheEntryOpenCallback; 1.12 +interface nsICacheEntryDoomCallback; 1.13 +interface nsICacheStorageVisitor; 1.14 + 1.15 +/** 1.16 + * Representation of a cache storage. There can be just-in-mem, 1.17 + * in-mem+on-disk, in-mem+on-disk+app-cache or just a specific 1.18 + * app-cache storage. 1.19 + */ 1.20 +[scriptable, uuid(d983ba0c-433f-4017-abc1-93af737c82e4)] 1.21 +interface nsICacheStorage : nsISupports 1.22 +{ 1.23 + /** 1.24 + * Placeholder for specifying "no special flags" during open. 1.25 + */ 1.26 + const uint32_t OPEN_NORMALLY = 0; 1.27 + 1.28 + /** 1.29 + * Rewrite any existing data when opening a URL. 1.30 + */ 1.31 + const uint32_t OPEN_TRUNCATE = 1 << 0; 1.32 + 1.33 + /** 1.34 + * Only open an existing entry. Don't create a new one. 1.35 + */ 1.36 + const uint32_t OPEN_READONLY = 1 << 1; 1.37 + 1.38 + /** 1.39 + * Use for first-paint blocking loads. 1.40 + */ 1.41 + const uint32_t OPEN_PRIORITY = 1 << 2; 1.42 + 1.43 + /** 1.44 + * Bypass the cache load when write is still in progress. 1.45 + */ 1.46 + const uint32_t OPEN_BYPASS_IF_BUSY = 1 << 3; 1.47 + 1.48 + /** 1.49 + * Perform the cache entry check (onCacheEntryCheck invocation) on any thread 1.50 + * for optimal perfomance optimization. If this flag is not specified it is 1.51 + * ensured that onCacheEntryCheck is called on the same thread as respective 1.52 + * asyncOpen has been called. 1.53 + */ 1.54 + const uint32_t CHECK_MULTITHREADED = 1 << 4; 1.55 + 1.56 + /** 1.57 + * Asynchronously opens a cache entry for the specified URI. 1.58 + * Result is fetched asynchronously via the callback. 1.59 + * 1.60 + * @param aURI 1.61 + * The URI to search in cache or to open for writting. 1.62 + * @param aIdExtension 1.63 + * Any string that will extend (distinguish) the entry. Two entries 1.64 + * with the same aURI but different aIdExtension will be comletely 1.65 + * different entries. If you don't know what aIdExtension should be 1.66 + * leave it empty. 1.67 + * @param aFlags 1.68 + * OPEN_NORMALLY - open cache entry normally for read and write 1.69 + * OPEN_TRUNCATE - delete any existing entry before opening it 1.70 + * OPEN_READONLY - don't create an entry if there is none 1.71 + * OPEN_PRIORITY - give this request a priority over others 1.72 + * OPEN_BYPASS_IF_BUSY - backward compatibility only, LOAD_BYPASS_LOCAL_CACHE_IF_BUSY 1.73 + * CHECK_MULTITHREADED - onCacheEntryCheck may be called on any thread, consumer 1.74 + * implementation is thread-safe 1.75 + * @param aCallback 1.76 + * The consumer that receives the result. 1.77 + * IMPORTANT: The callback may be called sooner the method returns. 1.78 + */ 1.79 + void asyncOpenURI(in nsIURI aURI, in ACString aIdExtension, 1.80 + in uint32_t aFlags, 1.81 + in nsICacheEntryOpenCallback aCallback); 1.82 + 1.83 + /** 1.84 + * Asynchronously removes an entry belonging to the URI from the cache. 1.85 + */ 1.86 + void asyncDoomURI(in nsIURI aURI, in ACString aIdExtension, 1.87 + in nsICacheEntryDoomCallback aCallback); 1.88 + 1.89 + /** 1.90 + * Asynchronously removes all cached entries under this storage. 1.91 + * NOTE: Disk storage also evicts memory storage. 1.92 + */ 1.93 + void asyncEvictStorage(in nsICacheEntryDoomCallback aCallback); 1.94 + 1.95 + /** 1.96 + * Visits the storage and its entries. 1.97 + * NOTE: Disk storage also visits memory storage. 1.98 + */ 1.99 + void asyncVisitStorage(in nsICacheStorageVisitor aVisitor, 1.100 + in boolean aVisitEntries); 1.101 +};