Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[embedlite-components] Fix cache cleanup to work with cache v2. Fixes…
… MER#1611

nsICacheService is throws NS_ERROR_NOT_IMPLEMENTED when the cache
v2 is prefered. Thus, cleanup cache and image cache separately.
  • Loading branch information
rainemak committed Jul 1, 2016
1 parent 9beee6e commit d865ace
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions jscomps/PrivateDataManager.js
Expand Up @@ -27,8 +27,20 @@ PrivateDataManager.prototype = {
return Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
},

get cacheService() {
return Cc["@mozilla.org/network/cache-service;1"].getService(Ci.nsICacheService);
clearCaches: function() {
var cache = Cc["@mozilla.org/netwerk/cache-storage-service;1"].getService(Ci.nsICacheStorageService);
try {
cache.clear();
} catch(e) {
debug("error in clearing storage cache: " + e);
}

var imageCache = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools).getImgCacheForDocument(null);
try {
imageCache.clearCache(false); // true=chrome, false=content
} catch(e) {
debug("error in clearing image cache: " + e);
}
},

clearPrivateData: function (aData) {
Expand All @@ -44,9 +56,7 @@ PrivateDataManager.prototype = {
break;
}
case "cache": {
try {
this.cacheService.evictEntries(Ci.nsICache.STORE_ANYWHERE);
} catch (ex) {debug(ex)}
this.clearCaches()
debug("Cache cleaned");
break;
}
Expand Down

0 comments on commit d865ace

Please sign in to comment.