Bug 1321303 - Part 2: Implement browsingData.removeCache, r=aswan
MozReview-Commit-ID: 3mBgpkoFaYJ
This commit is contained in:
@@ -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});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user