Bug 1174666 - Remove unneeded SessionSaver.clearLastSaveTime() r=Yoric
authorTim Taubert <ttaubert@mozilla.com>
Mon, 15 Jun 2015 11:54:47 +0200
changeset 250178 8d99fb177495bb0224002941d30db435031f3ec9
parent 250177 5e6f90f35f9bde7cedf3a003773faeba644440ac
child 250179 56b6a6eca59ac61cc863099f7407de007c23823d
push id61471
push usercbook@mozilla.com
push dateThu, 25 Jun 2015 09:33:34 +0000
treeherdermozilla-inbound@5b38df79819f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersYoric
bugs1174666
milestone41.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 1174666 - Remove unneeded SessionSaver.clearLastSaveTime() r=Yoric
browser/components/sessionstore/SessionSaver.jsm
browser/components/sessionstore/SessionStore.jsm
--- a/browser/components/sessionstore/SessionSaver.jsm
+++ b/browser/components/sessionstore/SessionSaver.jsm
@@ -87,24 +87,16 @@ this.SessionSaver = Object.freeze({
    * Sets the last save time to the current time. This will cause us to wait for
    * at least the configured interval when runDelayed() is called next.
    */
   updateLastSaveTime: function () {
     SessionSaverInternal.updateLastSaveTime();
   },
 
   /**
-   * Sets the last save time to zero. This will cause us to
-   * immediately save the next time runDelayed() is called.
-   */
-  clearLastSaveTime: function () {
-    SessionSaverInternal.clearLastSaveTime();
-  },
-
-  /**
    * Cancels all pending session saves.
    */
   cancel: function () {
     SessionSaverInternal.cancel();
   }
 });
 
 /**
@@ -157,24 +149,16 @@ let SessionSaverInternal = {
    * Sets the last save time to the current time. This will cause us to wait for
    * at least the configured interval when runDelayed() is called next.
    */
   updateLastSaveTime: function () {
     this._lastSaveTime = Date.now();
   },
 
   /**
-   * Sets the last save time to zero. This will cause us to
-   * immediately save the next time runDelayed() is called.
-   */
-  clearLastSaveTime: function () {
-    this._lastSaveTime = 0;
-  },
-
-  /**
    * Cancels all pending session saves.
    */
   cancel: function () {
     clearTimeout(this._timeoutID);
     this._timeoutID = null;
   },
 
   /**
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -904,20 +904,23 @@ let SessionStoreInternal = {
    *        The initial state to be loaded after startup (optional)
    */
   initializeWindow(aWindow, aInitialState = null) {
     let isPrivateWindow = PrivateBrowsingUtils.isWindowPrivate(aWindow);
 
     // perform additional initialization when the first window is loading
     if (RunState.isStopped) {
       RunState.setRunning();
-      SessionSaver.updateLastSaveTime();
 
       // restore a crashed session resp. resume the last session if requested
       if (aInitialState) {
+        // Don't write to disk right after startup. Set the last time we wrote
+        // to disk to NOW() to enforce a full interval before the next write.
+        SessionSaver.updateLastSaveTime();
+
         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 = gSessionStartup.state;
 
           // Nothing to restore now, notify observers things are complete.
           Services.obs.notifyObservers(null, NOTIFY_WINDOWS_RESTORED, "");
@@ -932,19 +935,16 @@ let SessionStoreInternal = {
           let overwrite = this._isCmdLineEmpty(aWindow, aInitialState);
           let options = {firstWindow: true, overwriteTabs: overwrite};
           this.restoreWindows(aWindow, aInitialState, options);
         }
       }
       else {
         // Nothing to restore, notify observers things are complete.
         Services.obs.notifyObservers(null, NOTIFY_WINDOWS_RESTORED, "");
-
-        // The next delayed save request should execute immediately.
-        SessionSaver.clearLastSaveTime();
       }
     }
     // this window was opened by _openWindowWithState
     else if (!this._isWindowLoaded(aWindow)) {
       let state = this._statesToRestore[aWindow.__SS_restoreID];
       let options = {overwriteTabs: true, isFollowUp: state.windows.length == 1};
       this.restoreWindow(aWindow, state.windows[0], options);
     }