Bug 452975 - don't reset browser.sessionstore.resume_session_once until the first browser window opened. r=dietrich
authorSimon Bünzli <zeniko@gmail.com>
Fri, 05 Sep 2008 12:05:34 +0200
changeset 18841 c9c71158c35ac60263ca87f7d2b9a52247f3daf3
parent 18840 659569177517cbbbcfdaf9884fd91809043f38fd
child 18842 8a3537e9a08f4828ef4d10cac7ad4a6fcd0bfebd
push id1758
push userdgottwald@mozilla.com
push dateFri, 05 Sep 2008 10:05:51 +0000
treeherderautoland@c9c71158c35a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdietrich
bugs452975
milestone1.9.1b1pre
Bug 452975 - don't reset browser.sessionstore.resume_session_once until the first browser window opened. r=dietrich
browser/components/sessionstore/src/nsSessionStartup.js
browser/components/sessionstore/src/nsSessionStore.js
--- a/browser/components/sessionstore/src/nsSessionStartup.js
+++ b/browser/components/sessionstore/src/nsSessionStartup.js
@@ -130,20 +130,16 @@ SessionStartup.prototype = {
       if (this._lastSessionCrashed && this._doRecoverSession())
         this._sessionType = Ci.nsISessionStartup.RECOVER_SESSION;
       else if (!this._lastSessionCrashed && this._doResumeSession())
         this._sessionType = Ci.nsISessionStartup.RESUME_SESSION;
       else
         this._iniString = null; // reset the state string
     }
 
-    if (this._prefBranch.getBoolPref("sessionstore.resume_session_once")) {
-      this._prefBranch.setBoolPref("sessionstore.resume_session_once", false);
-    }
-    
     if (this._sessionType != Ci.nsISessionStartup.NO_SESSION) {
       // wait for the first browser window to open
       var observerService = Cc["@mozilla.org/observer-service;1"].
                             getService(Ci.nsIObserverService);
       observerService.addObserver(this, "domwindowopened", true);
     }
   },
 
@@ -160,18 +156,17 @@ SessionStartup.prototype = {
       observerService.addObserver(this, "quit-application", true);
       break;
     case "final-ui-startup": 
       observerService.removeObserver(this, "final-ui-startup");
       observerService.removeObserver(this, "quit-application");
       this.init();
       break;
     case "quit-application":
-      // make sure that we don't init at this point, as that might
-      // unwantedly discard the session (cf. bug 409115)
+      // no reason for initializing at this point (cf. bug 409115)
       observerService.removeObserver(this, "final-ui-startup");
       observerService.removeObserver(this, "quit-application");
       break;
     case "domwindowopened":
       var window = aSubject;
       var self = this;
       window.addEventListener("load", function() {
         self._onWindowOpened(window);
--- a/browser/components/sessionstore/src/nsSessionStore.js
+++ b/browser/components/sessionstore/src/nsSessionStore.js
@@ -229,16 +229,22 @@ SessionStoreService.prototype = {
       }
       catch (ex) { } // nothing else we can do here
     }
 
     // remove the session data files if crash recovery is disabled
     if (!this._resume_from_crash)
       this._clearDisk();
     
+    // at this point, we've as good as resumed the session, so we can
+    // clear the resume_session_once flag, if it's set
+    if (this._loadState != STATE_QUITTING &&
+        this._prefBranch.getBoolPref("sessionstore.resume_session_once"))
+      this._prefBranch.setBoolPref("sessionstore.resume_session_once", false);
+    
     // As this is called at delayedStartup, restoration must be initiated here
     this.onLoad(aWindow);
   },
 
   /**
    * Called on application shutdown, after notifications:
    * quit-application-granted, quit-application
    */