Bug 1321303 - Part 2: Implement browsingData.removeCache, r=aswan

MozReview-Commit-ID: 3mBgpkoFaYJ
This commit is contained in:
Bob Silverberg
2016-12-01 14:01:08 -05:00
parent 8fa4d6fdf2
commit ae3ccfbb6f
6 changed files with 186 additions and 74 deletions

View File

@@ -31,6 +31,11 @@ XPCOMUtils.defineLazyGetter(this, "sanitizer", () => {
return sanitizer;
});
function clearCache() {
// Clearing the cache does not support timestamps.
return sanitizer.items.cache.clear();
}
let clearCookies = Task.async(function* (options) {
// This code has been borrowed from sanitize.js.
let yieldCounter = 0;
@@ -69,6 +74,9 @@ function doRemoval(options, dataToRemove, extension) {
for (let dataType in dataToRemove) {
if (dataToRemove[dataType]) {
switch (dataType) {
case "cache":
removalPromises.push(clearCache());
break;
case "cookies":
removalPromises.push(clearCookies(options));
break;
@@ -117,6 +125,9 @@ extensions.registerSchemaAPI("browsingData", "addon_parent", context => {
remove(options, dataToRemove) {
return doRemoval(options, dataToRemove, extension);
},
removeCache(options) {
return doRemoval(options, {cache: true});
},
removeCookies(options) {
return doRemoval(options, {cookies: true});
},