bug 1373728 - Count how many pinned tabs are restored in a session r=bsmedberg,Dexter
authorChris H-C <chutten@mozilla.com>
Wed, 28 Jun 2017 15:14:22 -0700
changeset 415471 e6b552124c9ce73ccfdf727596f37a55555469e6
parent 415470 4938ab2adfe92b50e92876f6e5698fe023172123
child 415472 26fd6d0a1254fbb364601102cfdc2ce3d7a22610
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg, Dexter
bugs1373728
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1373728 - Count how many pinned tabs are restored in a session r=bsmedberg,Dexter Pinned tabs, when restored, load. This can have startup impact. We should probably measure this. To avoid impacting startup ourselves, do this when idle or after 60s from session restore, whichever comes first. MozReview-Commit-ID: EQzqqcz4IdL
browser/components/sessionstore/nsSessionStartup.js
toolkit/components/telemetry/Scalars.yaml
--- a/browser/components/sessionstore/nsSessionStartup.js
+++ b/browser/components/sessionstore/nsSessionStartup.js
@@ -151,16 +151,26 @@ SessionStartup.prototype = {
     if (this._initialState == null) {
       // No valid session found.
       this._sessionType = Ci.nsISessionStartup.NO_SESSION;
       Services.obs.notifyObservers(null, "sessionstore-state-finalized");
       gOnceInitializedDeferred.resolve();
       return;
     }
 
+    let initialState = this._initialState;
+    Services.tm.idleDispatchToMainThread(() => {
+      let pinnedTabCount = initialState.windows.reduce((winAcc, win) => {
+        return winAcc + win.tabs.reduce((tabAcc, tab) => {
+          return tabAcc + (tab.pinned ? 1 : 0);
+        }, 0);
+      }, 0);
+      Services.telemetry.scalarSet("browser.engagement.restored_pinned_tabs_count", pinnedTabCount);
+    }, 60000);
+
     let shouldResumeSessionOnce = Services.prefs.getBoolPref("browser.sessionstore.resume_session_once");
     let shouldResumeSession = shouldResumeSessionOnce ||
           Services.prefs.getIntPref("browser.startup.page") == BROWSER_STARTUP_RESUME_SESSION;
 
     // If this is a normal restore then throw away any previous session
     if (!shouldResumeSessionOnce && this._initialState) {
       delete this._initialState.lastSessionState;
     }
--- a/toolkit/components/telemetry/Scalars.yaml
+++ b/toolkit/components/telemetry/Scalars.yaml
@@ -137,16 +137,29 @@ browser.engagement:
     expires: never
     kind: uint
     notification_emails:
       - rweiss@mozilla.com
     release_channel_collection: opt-out
     record_in_processes:
       - 'main'
 
+  restored_pinned_tabs_count:
+    bug_numbers:
+      - 1373728
+    description: >
+      The count of the number of pinned tabs that were restored.
+    expires: '62'
+    kind: uint
+    notification_emails:
+      - chutten@mozilla.com
+    release_channel_collection: opt-out
+    record_in_processes:
+      - 'main'
+
 # The following section contains the browser engagement scalars.
 browser.engagement.navigation:
   urlbar:
     bug_numbers:
       - 1271313
     description: >
       The count URI loads triggered in a subsession from the urlbar (awesomebar),
       broken down by the originating action.