Bug 1930378: Ensure nsIClearDataService.cleanupAfterDeletionAtShutdown is always called after sanitization.r=dom-storage-reviewers,janv,asuth,emz
We ensure that nsIClearDataService.cleanupAfterDeletionAtShutdown always get called at the end of sanitization process. For optimization reasons, this was only performed conditionally where it used to check if sanitization was performed or not and skips cleanup if it was not. Now, the condition is more general and relaxed where we check the existence of 'to-be-removed' directory and check its' contents to decide if cleanup is required. It was harder to ensure that cleanup was done correctly for all cases with prior approach. Differential Revision: https://phabricator.services.mozilla.com/D231268
This commit is contained in:
@@ -234,6 +234,7 @@ export var Sanitizer = {
|
||||
);
|
||||
}
|
||||
}
|
||||
await cleanupAfterSanitization(Ci.nsIClearDataService.CLEAR_ALL);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -1161,9 +1162,18 @@ async function sanitizeOnShutdown(progress) {
|
||||
);
|
||||
progress.sanitizationPrefs.session_permission_exceptions = exceptions;
|
||||
}
|
||||
|
||||
await cleanupAfterSanitization(Ci.nsIClearDataService.CLEAR_ALL);
|
||||
|
||||
progress.advancement = "done";
|
||||
}
|
||||
|
||||
async function cleanupAfterSanitization(flags) {
|
||||
await new Promise(resolve =>
|
||||
Services.clearData.cleanupAfterDeletionAtShutdown(flags, resolve)
|
||||
);
|
||||
}
|
||||
|
||||
// Extracts the principals matching matchUri as root domain.
|
||||
function extractMatchingPrincipals(principals, matchHost) {
|
||||
return principals.filter(principal => {
|
||||
@@ -1203,9 +1213,6 @@ async function maybeSanitizeSessionPrincipals(progress, principals, flags) {
|
||||
progress.step = "promises:" + promises.length;
|
||||
if (promises.length) {
|
||||
await Promise.all(promises);
|
||||
await new Promise(resolve =>
|
||||
Services.clearData.cleanupAfterDeletionAtShutdown(flags, resolve)
|
||||
);
|
||||
}
|
||||
progress.step = "promises resolved";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user