Bug 1388145 - Move startup crashes tracking to nsBrowserGlue as it should only run once, and not per-window. r=florian
MozReview-Commit-ID: KR1bv1TJGVf
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1670,25 +1670,16 @@ var gBrowserInit = {
});
window.addEventListener("mousemove", MousePosTracker);
window.addEventListener("dragover", MousePosTracker);
gNavToolbox.addEventListener("customizationstarting", CustomizationHandler);
gNavToolbox.addEventListener("customizationending", CustomizationHandler);
- // End startup crash tracking after a delay to catch crashes while restoring
- // tabs and to postpone saving the pref to disk.
- try {
- const startupCrashEndDelay = 30 * 1000;
- setTimeout(Services.startup.trackStartupCrashEnd, startupCrashEndDelay);
- } catch (ex) {
- Cu.reportError("Could not end startup crash tracking: " + ex);
- }
-
SessionStore.promiseInitialized.then(() => {
// Bail out if the window has been closed in the meantime.
if (window.closed) {
return;
}
// Enable the Restore Last Session command if needed
RestoreLastSessionObserver.init();
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -231,16 +231,18 @@ const BOOKMARKS_BACKUP_IDLE_TIME_SEC = 8
// Minimum interval between backups. We try to not create more than one backup
// per interval.
const BOOKMARKS_BACKUP_MIN_INTERVAL_DAYS = 1;
// Maximum interval between backups. If the last backup is older than these
// days we will try to create a new one more aggressively.
const BOOKMARKS_BACKUP_MAX_INTERVAL_DAYS = 3;
// Seconds of idle time before the late idle tasks will be scheduled.
const LATE_TASKS_IDLE_TIME_SEC = 20;
+// Time after we stop tracking startup crashes.
+const STARTUP_CRASHES_END_DELAY_MS = 30 * 1000;
// Factory object
const BrowserGlueServiceFactory = {
_instance: null,
createInstance: function BGSF_createInstance(outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
return this._instance == null ?
@@ -1159,16 +1161,23 @@ BrowserGlue.prototype = {
Services.tm.idleDispatchToMainThread(() => {
this._createExtraDefaultProfile();
});
}
Services.tm.idleDispatchToMainThread(() => {
this._checkForDefaultBrowser();
});
+
+ Services.tm.idleDispatchToMainThread(() => {
+ let {setTimeout} = Cu.import("resource://gre/modules/Timer.jsm", {});
+ setTimeout(function() {
+ Services.tm.idleDispatchToMainThread(Services.startup.trackStartupCrashEnd);
+ }, STARTUP_CRASHES_END_DELAY_MS);
+ });
},
/**
* Use this function as an entry point to schedule tasks that need
* to run once per session, at any arbitrary point in time.
* This function will be called from an idle observer. Check the value of
* LATE_TASKS_IDLE_TIME_SEC to see the current value for this idle
* observer.