зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1415342 - Part 2 - Copy offlineApps sanitizing code from desktop implementation. r=esawin
This is a straight copy-and-paste of the non-range-based desktop code in Sanitizer.jsm. MozReview-Commit-ID: 71r8LO4xzYF --HG-- extra : rebase_source : 276cb7d1043016f3df04727bd8437e9e014a558e
This commit is contained in:
Родитель
404003707f
Коммит
4e291000d0
|
@ -15,10 +15,16 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
FormHistory: "resource://gre/modules/FormHistory.jsm",
|
||||
OfflineAppCacheHelper: "resource://gre/modules/offlineAppCache.jsm",
|
||||
OS: "resource://gre/modules/osfile.jsm",
|
||||
ServiceWorkerCleanUp: "resource://gre/modules/ServiceWorkerCleanUp.jsm",
|
||||
Task: "resource://gre/modules/Task.jsm",
|
||||
TelemetryStopwatch: "resource://gre/modules/TelemetryStopwatch.jsm",
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetters(this, {
|
||||
quotaManagerService: ["@mozilla.org/dom/quota-manager-service;1", "nsIQuotaManagerService"],
|
||||
});
|
||||
|
||||
|
||||
var EXPORTED_SYMBOLS = ["Sanitizer"];
|
||||
|
||||
function Sanitizer() {}
|
||||
|
@ -146,14 +152,43 @@ Sanitizer.prototype = {
|
|||
},
|
||||
|
||||
offlineApps: {
|
||||
clear: function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
// AppCache
|
||||
// This doesn't wait for the cleanup to be complete.
|
||||
OfflineAppCacheHelper.clear();
|
||||
async clear() {
|
||||
// AppCache
|
||||
// This doesn't wait for the cleanup to be complete.
|
||||
OfflineAppCacheHelper.clear();
|
||||
|
||||
resolve();
|
||||
// LocalStorage
|
||||
Services.obs.notifyObservers(null, "extension:purge-localStorage");
|
||||
|
||||
// ServiceWorkers
|
||||
await ServiceWorkerCleanUp.removeAll();
|
||||
|
||||
// QuotaManager
|
||||
let promises = [];
|
||||
await new Promise(resolve => {
|
||||
quotaManagerService.getUsage(request => {
|
||||
if (request.resultCode != Cr.NS_OK) {
|
||||
// We are probably shutting down. We don't want to propagate the
|
||||
// error, rejecting the promise.
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
for (let item of request.result) {
|
||||
let principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(item.origin);
|
||||
let uri = principal.URI;
|
||||
if (uri.scheme == "http" || uri.scheme == "https" || uri.scheme == "file") {
|
||||
promises.push(new Promise(r => {
|
||||
let req = quotaManagerService.clearStoragesForPrincipal(principal, null, false);
|
||||
req.callback = () => { r(); };
|
||||
}));
|
||||
}
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
return Promise.all(promises);
|
||||
},
|
||||
|
||||
get canClear() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче