#581: M1047098 M1355576
This commit is contained in:
parent
8bd4c09a76
commit
ec8e681026
|
@ -17,8 +17,15 @@ XPCOMUtils.defineLazyModuleGetter(this, "Task",
|
||||||
"resource://gre/modules/Task.jsm");
|
"resource://gre/modules/Task.jsm");
|
||||||
XPCOMUtils.defineLazyModuleGetter(this, "DownloadsCommon",
|
XPCOMUtils.defineLazyModuleGetter(this, "DownloadsCommon",
|
||||||
"resource:///modules/DownloadsCommon.jsm");
|
"resource:///modules/DownloadsCommon.jsm");
|
||||||
XPCOMUtils.defineLazyModuleGetter(this, "TelemetryStopwatch",
|
//XPCOMUtils.defineLazyModuleGetter(this, "//TelemetryStopwatch",
|
||||||
"resource://gre/modules/TelemetryStopwatch.jsm");
|
// "resource://gre/modules///TelemetryStopwatch.jsm");
|
||||||
|
XPCOMUtils.defineLazyServiceGetter(this, "serviceWorkerManager",
|
||||||
|
"@mozilla.org/serviceworkers/manager;1",
|
||||||
|
"nsIServiceWorkerManager");
|
||||||
|
XPCOMUtils.defineLazyServiceGetter(this, "quotaManagerService",
|
||||||
|
"@mozilla.org/dom/quota-manager-service;1",
|
||||||
|
"nsIQuotaManagerService");
|
||||||
|
|
||||||
|
|
||||||
function Sanitizer() {}
|
function Sanitizer() {}
|
||||||
Sanitizer.prototype = {
|
Sanitizer.prototype = {
|
||||||
|
@ -128,7 +135,7 @@ Sanitizer.prototype = {
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
TelemetryStopwatch.start("FX_SANITIZE_TOTAL");
|
//TelemetryStopwatch.start("FX_SANITIZE_TOTAL");
|
||||||
|
|
||||||
// Cache the range of times to clear
|
// Cache the range of times to clear
|
||||||
if (this.ignoreTimespan)
|
if (this.ignoreTimespan)
|
||||||
|
@ -139,7 +146,7 @@ Sanitizer.prototype = {
|
||||||
let itemCount = Object.keys(itemsToClear).length;
|
let itemCount = Object.keys(itemsToClear).length;
|
||||||
let onItemComplete = function() {
|
let onItemComplete = function() {
|
||||||
if (!--itemCount) {
|
if (!--itemCount) {
|
||||||
TelemetryStopwatch.finish("FX_SANITIZE_TOTAL");
|
//TelemetryStopwatch.finish("FX_SANITIZE_TOTAL");
|
||||||
seenError ? deferred.reject() : deferred.resolve();
|
seenError ? deferred.reject() : deferred.resolve();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -185,7 +192,7 @@ Sanitizer.prototype = {
|
||||||
cache: {
|
cache: {
|
||||||
clear: function ()
|
clear: function ()
|
||||||
{
|
{
|
||||||
TelemetryStopwatch.start("FX_SANITIZE_CACHE");
|
//TelemetryStopwatch.start("FX_SANITIZE_CACHE");
|
||||||
|
|
||||||
var cache = Cc["@mozilla.org/netwerk/cache-storage-service;1"].
|
var cache = Cc["@mozilla.org/netwerk/cache-storage-service;1"].
|
||||||
getService(Ci.nsICacheStorageService);
|
getService(Ci.nsICacheStorageService);
|
||||||
|
@ -201,7 +208,7 @@ Sanitizer.prototype = {
|
||||||
imageCache.clearCache(false); // true=chrome, false=content
|
imageCache.clearCache(false); // true=chrome, false=content
|
||||||
} catch(er) {}
|
} catch(er) {}
|
||||||
|
|
||||||
TelemetryStopwatch.finish("FX_SANITIZE_CACHE");
|
//TelemetryStopwatch.finish("FX_SANITIZE_CACHE");
|
||||||
},
|
},
|
||||||
|
|
||||||
get canClear()
|
get canClear()
|
||||||
|
@ -213,8 +220,8 @@ Sanitizer.prototype = {
|
||||||
cookies: {
|
cookies: {
|
||||||
clear: function (aCallback)
|
clear: function (aCallback)
|
||||||
{
|
{
|
||||||
TelemetryStopwatch.start("FX_SANITIZE_COOKIES");
|
//TelemetryStopwatch.start("FX_SANITIZE_COOKIES");
|
||||||
TelemetryStopwatch.start("FX_SANITIZE_COOKIES_2");
|
//TelemetryStopwatch.start("FX_SANITIZE_COOKIES_2");
|
||||||
|
|
||||||
var cookieMgr = Components.classes["@mozilla.org/cookiemanager;1"]
|
var cookieMgr = Components.classes["@mozilla.org/cookiemanager;1"]
|
||||||
.getService(Ci.nsICookieManager);
|
.getService(Ci.nsICookieManager);
|
||||||
|
@ -234,7 +241,7 @@ Sanitizer.prototype = {
|
||||||
cookieMgr.removeAll();
|
cookieMgr.removeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
TelemetryStopwatch.finish("FX_SANITIZE_COOKIES_2");
|
//TelemetryStopwatch.finish("FX_SANITIZE_COOKIES_2");
|
||||||
|
|
||||||
// Clear deviceIds. Done asynchronously (returns before complete).
|
// Clear deviceIds. Done asynchronously (returns before complete).
|
||||||
let mediaMgr = Components.classes["@mozilla.org/mediaManagerService;1"]
|
let mediaMgr = Components.classes["@mozilla.org/mediaManagerService;1"]
|
||||||
|
@ -242,11 +249,11 @@ Sanitizer.prototype = {
|
||||||
mediaMgr.sanitizeDeviceIds(this.range && this.range[0]);
|
mediaMgr.sanitizeDeviceIds(this.range && this.range[0]);
|
||||||
|
|
||||||
// Clear plugin data.
|
// Clear plugin data.
|
||||||
TelemetryStopwatch.start("FX_SANITIZE_PLUGINS");
|
//TelemetryStopwatch.start("FX_SANITIZE_PLUGINS");
|
||||||
this.clearPluginCookies().then(
|
this.clearPluginCookies().then(
|
||||||
function() {
|
function() {
|
||||||
TelemetryStopwatch.finish("FX_SANITIZE_PLUGINS");
|
//TelemetryStopwatch.finish("FX_SANITIZE_PLUGINS");
|
||||||
TelemetryStopwatch.finish("FX_SANITIZE_COOKIES");
|
//TelemetryStopwatch.finish("FX_SANITIZE_COOKIES");
|
||||||
aCallback();
|
aCallback();
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
|
@ -301,10 +308,30 @@ Sanitizer.prototype = {
|
||||||
offlineApps: {
|
offlineApps: {
|
||||||
clear: function ()
|
clear: function ()
|
||||||
{
|
{
|
||||||
TelemetryStopwatch.start("FX_SANITIZE_OFFLINEAPPS");
|
// AppCache
|
||||||
|
//TelemetryStopwatch.start("FX_SANITIZE_OFFLINEAPPS");
|
||||||
Components.utils.import("resource:///modules/offlineAppCache.jsm");
|
Components.utils.import("resource:///modules/offlineAppCache.jsm");
|
||||||
OfflineAppCacheHelper.clear();
|
OfflineAppCacheHelper.clear();
|
||||||
TelemetryStopwatch.finish("FX_SANITIZE_OFFLINEAPPS");
|
//TelemetryStopwatch.finish("FX_SANITIZE_OFFLINEAPPS");
|
||||||
|
|
||||||
|
// LocalStorage
|
||||||
|
Services.obs.notifyObservers(null, "extension:purge-localStorage", null);
|
||||||
|
|
||||||
|
// ServiceWorkers
|
||||||
|
// NYI because service workers are disabled
|
||||||
|
// See bug 1047098
|
||||||
|
/*
|
||||||
|
let serviceWorkers = serviceWorkerManager.getAllRegistrations();
|
||||||
|
for (let i = 0; i < serviceWorkers.length; i++) {
|
||||||
|
let sw = serviceWorkers.queryElementAt(i, Ci.nsIServiceWorkerRegistrationInfo);
|
||||||
|
let host = sw.principal.URI.host;
|
||||||
|
serviceWorkerManager.removeAndPropagate(host);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// QuotaManager
|
||||||
|
// NYI due to missing getUsage() in quotaManagerService
|
||||||
|
// See bug 1047098 and bug 1348660 (esp. part 5, but unsure if useable)
|
||||||
},
|
},
|
||||||
|
|
||||||
get canClear()
|
get canClear()
|
||||||
|
@ -316,7 +343,7 @@ Sanitizer.prototype = {
|
||||||
history: {
|
history: {
|
||||||
clear: function ()
|
clear: function ()
|
||||||
{
|
{
|
||||||
TelemetryStopwatch.start("FX_SANITIZE_HISTORY");
|
//TelemetryStopwatch.start("FX_SANITIZE_HISTORY");
|
||||||
|
|
||||||
if (this.range)
|
if (this.range)
|
||||||
PlacesUtils.history.removeVisitsByTimeframe(this.range[0], this.range[1]);
|
PlacesUtils.history.removeVisitsByTimeframe(this.range[0], this.range[1]);
|
||||||
|
@ -337,7 +364,7 @@ Sanitizer.prototype = {
|
||||||
predictor.reset();
|
predictor.reset();
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
|
|
||||||
TelemetryStopwatch.finish("FX_SANITIZE_HISTORY");
|
//TelemetryStopwatch.finish("FX_SANITIZE_HISTORY");
|
||||||
},
|
},
|
||||||
|
|
||||||
get canClear()
|
get canClear()
|
||||||
|
@ -351,7 +378,7 @@ Sanitizer.prototype = {
|
||||||
formdata: {
|
formdata: {
|
||||||
clear: function ()
|
clear: function ()
|
||||||
{
|
{
|
||||||
TelemetryStopwatch.start("FX_SANITIZE_FORMDATA");
|
//TelemetryStopwatch.start("FX_SANITIZE_FORMDATA");
|
||||||
|
|
||||||
// Clear undo history of all searchBars
|
// Clear undo history of all searchBars
|
||||||
var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1']
|
var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1']
|
||||||
|
@ -378,7 +405,7 @@ Sanitizer.prototype = {
|
||||||
}
|
}
|
||||||
FormHistory.update(change);
|
FormHistory.update(change);
|
||||||
|
|
||||||
TelemetryStopwatch.finish("FX_SANITIZE_FORMDATA");
|
//TelemetryStopwatch.finish("FX_SANITIZE_FORMDATA");
|
||||||
},
|
},
|
||||||
|
|
||||||
canClear : function(aCallback, aArg)
|
canClear : function(aCallback, aArg)
|
||||||
|
@ -425,7 +452,7 @@ Sanitizer.prototype = {
|
||||||
downloads: {
|
downloads: {
|
||||||
clear: function ()
|
clear: function ()
|
||||||
{
|
{
|
||||||
TelemetryStopwatch.start("FX_SANITIZE_DOWNLOADS");
|
//TelemetryStopwatch.start("FX_SANITIZE_DOWNLOADS");
|
||||||
Task.spawn(function*() {
|
Task.spawn(function*() {
|
||||||
let filterByTime = null;
|
let filterByTime = null;
|
||||||
if (this.range) {
|
if (this.range) {
|
||||||
|
@ -439,9 +466,9 @@ Sanitizer.prototype = {
|
||||||
// Clear all completed/cancelled downloads
|
// Clear all completed/cancelled downloads
|
||||||
let list = yield Downloads.getList(Downloads.ALL);
|
let list = yield Downloads.getList(Downloads.ALL);
|
||||||
list.removeFinished(filterByTime);
|
list.removeFinished(filterByTime);
|
||||||
TelemetryStopwatch.finish("FX_SANITIZE_DOWNLOADS");
|
//TelemetryStopwatch.finish("FX_SANITIZE_DOWNLOADS");
|
||||||
}.bind(this)).then(null, error => {
|
}.bind(this)).then(null, error => {
|
||||||
TelemetryStopwatch.finish("FX_SANITIZE_DOWNLOADS");
|
//TelemetryStopwatch.finish("FX_SANITIZE_DOWNLOADS");
|
||||||
Components.utils.reportError(error);
|
Components.utils.reportError(error);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -456,7 +483,7 @@ Sanitizer.prototype = {
|
||||||
sessions: {
|
sessions: {
|
||||||
clear: function ()
|
clear: function ()
|
||||||
{
|
{
|
||||||
TelemetryStopwatch.start("FX_SANITIZE_SESSIONS");
|
//TelemetryStopwatch.start("FX_SANITIZE_SESSIONS");
|
||||||
|
|
||||||
// clear all auth tokens
|
// clear all auth tokens
|
||||||
var sdr = Components.classes["@mozilla.org/security/sdr;1"]
|
var sdr = Components.classes["@mozilla.org/security/sdr;1"]
|
||||||
|
@ -468,7 +495,7 @@ Sanitizer.prototype = {
|
||||||
.getService(Components.interfaces.nsIObserverService);
|
.getService(Components.interfaces.nsIObserverService);
|
||||||
os.notifyObservers(null, "net:clear-active-logins", null);
|
os.notifyObservers(null, "net:clear-active-logins", null);
|
||||||
|
|
||||||
TelemetryStopwatch.finish("FX_SANITIZE_SESSIONS");
|
//TelemetryStopwatch.finish("FX_SANITIZE_SESSIONS");
|
||||||
},
|
},
|
||||||
|
|
||||||
get canClear()
|
get canClear()
|
||||||
|
@ -480,7 +507,7 @@ Sanitizer.prototype = {
|
||||||
siteSettings: {
|
siteSettings: {
|
||||||
clear: function ()
|
clear: function ()
|
||||||
{
|
{
|
||||||
TelemetryStopwatch.start("FX_SANITIZE_SITESETTINGS");
|
//TelemetryStopwatch.start("FX_SANITIZE_SITESETTINGS");
|
||||||
|
|
||||||
// Clear site-specific permissions like "Allow this site to open popups"
|
// Clear site-specific permissions like "Allow this site to open popups"
|
||||||
// we ignore the "end" range and hope it is now() - none of the
|
// we ignore the "end" range and hope it is now() - none of the
|
||||||
|
@ -530,7 +557,7 @@ Sanitizer.prototype = {
|
||||||
dump("Web Push may not be available.\n");
|
dump("Web Push may not be available.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TelemetryStopwatch.finish("FX_SANITIZE_SITESETTINGS");
|
//TelemetryStopwatch.finish("FX_SANITIZE_SITESETTINGS");
|
||||||
},
|
},
|
||||||
|
|
||||||
get canClear()
|
get canClear()
|
||||||
|
@ -592,7 +619,7 @@ Sanitizer.prototype = {
|
||||||
|
|
||||||
// If/once we get here, we should actually be able to close all windows.
|
// If/once we get here, we should actually be able to close all windows.
|
||||||
|
|
||||||
TelemetryStopwatch.start("FX_SANITIZE_OPENWINDOWS");
|
//TelemetryStopwatch.start("FX_SANITIZE_OPENWINDOWS");
|
||||||
|
|
||||||
// First create a new window. We do this first so that on non-mac, we don't
|
// First create a new window. We do this first so that on non-mac, we don't
|
||||||
// accidentally close the app by closing all the windows.
|
// accidentally close the app by closing all the windows.
|
||||||
|
@ -617,7 +644,7 @@ Sanitizer.prototype = {
|
||||||
newWindowOpened = true;
|
newWindowOpened = true;
|
||||||
// If we're the last thing to happen, invoke callback.
|
// If we're the last thing to happen, invoke callback.
|
||||||
if (numWindowsClosing == 0) {
|
if (numWindowsClosing == 0) {
|
||||||
TelemetryStopwatch.finish("FX_SANITIZE_OPENWINDOWS");
|
//TelemetryStopwatch.finish("FX_SANITIZE_OPENWINDOWS");
|
||||||
aCallback();
|
aCallback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -629,7 +656,7 @@ Sanitizer.prototype = {
|
||||||
Services.obs.removeObserver(onWindowClosed, "xul-window-destroyed");
|
Services.obs.removeObserver(onWindowClosed, "xul-window-destroyed");
|
||||||
// If we're the last thing to happen, invoke callback.
|
// If we're the last thing to happen, invoke callback.
|
||||||
if (newWindowOpened) {
|
if (newWindowOpened) {
|
||||||
TelemetryStopwatch.finish("FX_SANITIZE_OPENWINDOWS");
|
//TelemetryStopwatch.finish("FX_SANITIZE_OPENWINDOWS");
|
||||||
aCallback();
|
aCallback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -490,7 +490,8 @@ nsresult
|
||||||
DOMStorageManager::Observe(const char* aTopic, const nsACString& aScopePrefix)
|
DOMStorageManager::Observe(const char* aTopic, const nsACString& aScopePrefix)
|
||||||
{
|
{
|
||||||
// Clear everything, caches + database
|
// Clear everything, caches + database
|
||||||
if (!strcmp(aTopic, "cookie-cleared")) {
|
if (!strcmp(aTopic, "cookie-cleared") ||
|
||||||
|
!strcmp(aTopic, "extension:purge-localStorage-caches")) {
|
||||||
ClearCaches(DOMStorageCache::kUnloadComplete, EmptyCString());
|
ClearCaches(DOMStorageCache::kUnloadComplete, EmptyCString());
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ DOMStorageObserver::Init()
|
||||||
obs->AddObserver(sSelf, "browser:purge-domain-data", true);
|
obs->AddObserver(sSelf, "browser:purge-domain-data", true);
|
||||||
obs->AddObserver(sSelf, "last-pb-context-exited", true);
|
obs->AddObserver(sSelf, "last-pb-context-exited", true);
|
||||||
obs->AddObserver(sSelf, "webapps-clear-data", true);
|
obs->AddObserver(sSelf, "webapps-clear-data", true);
|
||||||
|
obs->AddObserver(sSelf, "extension:purge-localStorage", true);
|
||||||
|
|
||||||
// Shutdown
|
// Shutdown
|
||||||
obs->AddObserver(sSelf, "profile-after-change", true);
|
obs->AddObserver(sSelf, "profile-after-change", true);
|
||||||
|
@ -223,6 +224,17 @@ DOMStorageObserver::Observe(nsISupports* aSubject,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!strcmp(aTopic, "extension:purge-localStorage")) {
|
||||||
|
DOMStorageDBBridge* db = DOMStorageCache::StartDatabase();
|
||||||
|
NS_ENSURE_TRUE(db, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
db->AsyncClearAll();
|
||||||
|
|
||||||
|
Notify("extension:purge-localStorage-caches");
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
// Clear everything (including so and pb data) from caches and database
|
// Clear everything (including so and pb data) from caches and database
|
||||||
// for the gived domain and subdomains.
|
// for the gived domain and subdomains.
|
||||||
if (!strcmp(aTopic, "browser:purge-domain-data")) {
|
if (!strcmp(aTopic, "browser:purge-domain-data")) {
|
||||||
|
|
|
@ -634,14 +634,44 @@ ServiceWorkerRegistrar::ProfileStopped()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PBackgroundChild* child = BackgroundChild::GetForCurrentThread();
|
// We must set the pointer before potentially entering the fast-path shutdown
|
||||||
if (!child) {
|
// below.
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool completed = false;
|
bool completed = false;
|
||||||
mShutdownCompleteFlag = &completed;
|
mShutdownCompleteFlag = &completed;
|
||||||
|
|
||||||
|
PBackgroundChild* child = BackgroundChild::GetForCurrentThread();
|
||||||
|
if (!child) {
|
||||||
|
// Mutations to the ServiceWorkerRegistrar happen on the PBackground thread,
|
||||||
|
// issued by the ServiceWorkerManagerService, so the appropriate place to
|
||||||
|
// trigger shutdown is on that thread.
|
||||||
|
//
|
||||||
|
// However, it's quite possible that the PBackground thread was not brought
|
||||||
|
// into existence for xpcshell tests. We don't cause it to be created
|
||||||
|
// ourselves for any reason, for example.
|
||||||
|
//
|
||||||
|
// In this scenario, we know that:
|
||||||
|
// - We will receive exactly one call to ourself from BlockShutdown() and
|
||||||
|
// BlockShutdown() will be called (at most) once.
|
||||||
|
// - The only way our Shutdown() method gets called is via
|
||||||
|
// BackgroundParentImpl::RecvShutdownServiceWorkerRegistrar() being
|
||||||
|
// invoked, which only happens if we get to that send below here that we
|
||||||
|
// can't get to.
|
||||||
|
// - All Shutdown() does is set mShuttingDown=true (essential for
|
||||||
|
// invariants) and invoke MaybeScheduleShutdownCompleted().
|
||||||
|
// - Since there is no PBackground thread, mRunnableCounter must be 0
|
||||||
|
// because only ScheduleSaveData() increments it and it only runs on the
|
||||||
|
// background thread, so it cannot have run. And so we would expect
|
||||||
|
// MaybeScheduleShutdownCompleted() to schedule an invocation of
|
||||||
|
// ShutdownCompleted on the main thread.
|
||||||
|
//
|
||||||
|
// So it's appropriate for us to set mShuttingDown=true (as Shutdown would
|
||||||
|
// do) and directly invoke ShutdownCompleted() (as Shutdown would indirectly
|
||||||
|
// do via MaybeScheduleShutdownCompleted).
|
||||||
|
mShuttingDown = true;
|
||||||
|
ShutdownCompleted();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
child->SendShutdownServiceWorkerRegistrar();
|
child->SendShutdownServiceWorkerRegistrar();
|
||||||
|
|
||||||
nsCOMPtr<nsIThread> thread(do_GetCurrentThread());
|
nsCOMPtr<nsIThread> thread(do_GetCurrentThread());
|
||||||
|
@ -682,6 +712,12 @@ ServiceWorkerRegistrar::Observe(nsISupports* aSubject, const char* aTopic,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(aTopic, "profile-before-change")) {
|
if (!strcmp(aTopic, "profile-before-change")) {
|
||||||
|
// Hygiene; gServiceWorkerRegistrar should still be keeping a reference
|
||||||
|
// alive well past this phase of shutdown, but it's bad form to drop your
|
||||||
|
// last potentially owning reference and then make a call that requires you
|
||||||
|
// to still be alive, especially when you spin a nested event loop.
|
||||||
|
RefPtr<ServiceWorkerRegistrar> kungFuDeathGrip(this);
|
||||||
|
|
||||||
nsCOMPtr<nsIObserverService> observerService =
|
nsCOMPtr<nsIObserverService> observerService =
|
||||||
services::GetObserverService();
|
services::GetObserverService();
|
||||||
observerService->RemoveObserver(this, "profile-before-change");
|
observerService->RemoveObserver(this, "profile-before-change");
|
||||||
|
|
Loading…
Reference in New Issue