mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
6735dbcad7
--HG-- extra : rebase_source : 626a90178480b47f24956a86914fdc3e76cbd20b
47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
var _CSvc;
|
|
function get_cache_service() {
|
|
if (_CSvc)
|
|
return _CSvc;
|
|
|
|
return _CSvc = Components.classes["@mozilla.org/network/cache-service;1"]
|
|
.getService(Components.interfaces.nsICacheService);
|
|
}
|
|
|
|
function evict_cache_entries(where)
|
|
{
|
|
if (where == null)
|
|
where = Components.interfaces.nsICache.STORE_ANYWHERE;
|
|
|
|
get_cache_service().evictEntries(where);
|
|
}
|
|
|
|
function asyncOpenCacheEntry(key, sessionName, storagePolicy, access, callback)
|
|
{
|
|
function CacheListener() { }
|
|
CacheListener.prototype = {
|
|
QueryInterface: function (iid) {
|
|
if (iid.equals(Components.interfaces.nsICacheListener) ||
|
|
iid.equals(Components.interfaces.nsISupports))
|
|
return this;
|
|
throw Components.results.NS_ERROR_NO_INTERFACE;
|
|
},
|
|
|
|
onCacheEntryAvailable: function (entry, access, status) {
|
|
callback(status, entry);
|
|
},
|
|
|
|
run: function () {
|
|
var cache = get_cache_service();
|
|
var session = cache.createSession(
|
|
sessionName,
|
|
storagePolicy,
|
|
Components.interfaces.nsICache.STREAM_BASED);
|
|
var cacheEntry = session.asyncOpenCacheEntry(key, access, this);
|
|
}
|
|
};
|
|
|
|
(new CacheListener()).run();
|
|
}
|
|
|
|
|