diff --git a/browser/components/sessionstore/src/nsSessionStartup.js b/browser/components/sessionstore/src/nsSessionStartup.js index cbdc4cb0e13e..afe924288cc8 100644 --- a/browser/components/sessionstore/src/nsSessionStartup.js +++ b/browser/components/sessionstore/src/nsSessionStartup.js @@ -81,6 +81,8 @@ SessionStartup.prototype = { * Initialize the component */ init: function sss_init() { + Services.obs.notifyObservers(null, "sessionstore-init-started", null); + // do not need to initialize anything in auto-started private browsing sessions if (PrivateBrowsingUtils.permanentPrivateBrowsing) { this._initialized = true; diff --git a/browser/components/sessionstore/test/browser_telemetry.js b/browser/components/sessionstore/test/browser_telemetry.js index 7029c038e3cf..680e7c676ae4 100644 --- a/browser/components/sessionstore/test/browser_telemetry.js +++ b/browser/components/sessionstore/test/browser_telemetry.js @@ -242,6 +242,15 @@ add_task(function formdata() { } }); +add_task(function* test_sessionRestoreInit() { + let info = Cc["@mozilla.org/toolkit/app-startup;1"]. + getService(Ci.nsIAppStartup). + getStartupInfo(); + ok(info.sessionRestoreInit > info.process, "sessionRestoreInit is after process creation"); + ok(info.sessionRestoreInit < + Date.now() + 10000 /* Date.now() is non-monotonic, let's play it paranoid*/, + "sessionRestoreInit is before now"); +}); /** * Get the latest statistics. diff --git a/toolkit/components/startup/StartupTimeline.h b/toolkit/components/startup/StartupTimeline.h index f035dc0042a5..74aa7775a4ea 100644 --- a/toolkit/components/startup/StartupTimeline.h +++ b/toolkit/components/startup/StartupTimeline.h @@ -13,6 +13,7 @@ mozilla_StartupTimeline_Event(AFTER_PROFILE_LOCKED, "afterProfileLocked") mozilla_StartupTimeline_Event(STARTUP_CRASH_DETECTION_BEGIN, "startupCrashDetectionBegin") mozilla_StartupTimeline_Event(STARTUP_CRASH_DETECTION_END, "startupCrashDetectionEnd") mozilla_StartupTimeline_Event(FIRST_PAINT, "firstPaint") +mozilla_StartupTimeline_Event(SESSION_RESTORE_INIT, "sessionRestoreInit") mozilla_StartupTimeline_Event(SESSION_RESTORED, "sessionRestored") mozilla_StartupTimeline_Event(CREATE_TOP_LEVEL_WINDOW, "createTopLevelWindow") mozilla_StartupTimeline_Event(LINKER_INITIALIZED, "linkerInitialized") diff --git a/toolkit/components/startup/nsAppStartup.cpp b/toolkit/components/startup/nsAppStartup.cpp index a0bab7fb93a9..9e9ecb7bca01 100644 --- a/toolkit/components/startup/nsAppStartup.cpp +++ b/toolkit/components/startup/nsAppStartup.cpp @@ -161,6 +161,7 @@ nsAppStartup::Init() return NS_ERROR_FAILURE; os->AddObserver(this, "quit-application-forced", true); + os->AddObserver(this, "sessionstore-init-started", true); os->AddObserver(this, "sessionstore-windows-restored", true); os->AddObserver(this, "profile-change-teardown", true); os->AddObserver(this, "xul-window-registered", true); @@ -705,6 +706,8 @@ nsAppStartup::Observe(nsISupports *aSubject, mPlacesInitCompleteProbe->Trigger(); } #endif //defined(XP_WIN) + } else if (!strcmp(aTopic, "sessionstore-init-started")) { + StartupTimeline::Record(StartupTimeline::SESSION_RESTORE_INIT); } else if (!strcmp(aTopic, "xpcom-shutdown")) { Telemetry::EnteringShutdownStage(); #if defined(XP_WIN)