Bug 887394 - Don't collect state right after startup when restoring the initial session; r=yoric
authorTim Taubert <ttaubert@mozilla.com>
Thu, 27 Jun 2013 10:32:04 -0400
changeset 136662 086465524970f931602facfa5cbe2b327e67ac9e
parent 136661 52f605debfd4134f3a862878622bd6381c22a637
child 136663 5f285200124bbf80fde8da120a176b96aa0e7587
push id1808
push userttaubert@mozilla.com
push dateThu, 27 Jun 2013 14:32:20 +0000
treeherderfx-team@086465524970 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyoric
bugs887394
milestone25.0a1
Bug 887394 - Don't collect state right after startup when restoring the initial session; r=yoric
browser/components/sessionstore/src/SessionStore.jsm
--- a/browser/components/sessionstore/src/SessionStore.jsm
+++ b/browser/components/sessionstore/src/SessionStore.jsm
@@ -246,16 +246,19 @@ let SessionStoreInternal = {
     Ci.nsIDOMEventListener,
     Ci.nsIObserver,
     Ci.nsISupportsWeakReference
   ]),
 
   // set default load state
   _loadState: STATE_STOPPED,
 
+  // initial state to restore after startup
+  _initialState: null,
+
   // During the initial restore and setBrowserState calls tracks the number of
   // windows yet to be restored
   _restoreCount: -1,
 
   // whether a setBrowserState call is in progress
   _browserSetState: false,
 
   // time in milliseconds (Date.now()) when the session was last written to file
@@ -695,32 +698,33 @@ let SessionStoreInternal = {
 
       // restore a crashed session resp. resume the last session if requested
       if (this._initialState) {
         if (isPrivateWindow) {
           // We're starting with a single private window. Save the state we
           // actually wanted to restore so that we can do it later in case
           // the user opens another, non-private window.
           this._deferredInitialState = this._initialState;
-          delete this._initialState;
+          this._initialState = null;
 
           // Nothing to restore now, notify observers things are complete.
           Services.obs.notifyObservers(null, NOTIFY_WINDOWS_RESTORED, "");
         } else {
           TelemetryTimestamps.add("sessionRestoreRestoring");
           // make sure that the restored tabs are first in the window
           this._initialState._firstTabs = true;
           this._restoreCount = this._initialState.windows ? this._initialState.windows.length : 0;
           this.restoreWindow(aWindow, this._initialState,
                              this._isCmdLineEmpty(aWindow, this._initialState));
-          delete this._initialState;
 
           // _loadState changed from "stopped" to "running"
           // force a save operation so that crashes happening during startup are correctly counted
-          this.saveState(true);
+          this._initialState.session.state = STATE_RUNNING_STR;
+          this._saveStateObject(this._initialState);
+          this._initialState = null;
         }
       }
       else {
         // Nothing to restore, notify observers things are complete.
         Services.obs.notifyObservers(null, NOTIFY_WINDOWS_RESTORED, "");
 
         // the next delayed save request should execute immediately
         this._lastSaveTime -= this._interval;