Bug 965017 - Remove session restore shutdown handling. r=mfinkle
authorBrian Nicholson <bnicholson@mozilla.com>
Tue, 28 Jan 2014 15:21:47 -0800
changeset 165635 d3150d5a665d6b82b3e5344d77013ed78ced06e6
parent 165634 733028be599d1fbe4402f4e79f925f9c923bc353
child 165636 95c958fa3cf2ca71696d0c5a8ee830b5c3922316
push id4627
push userbnicholson@mozilla.com
push dateTue, 28 Jan 2014 23:21:57 +0000
treeherderfx-team@d3150d5a665d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs965017
milestone29.0a1
Bug 965017 - Remove session restore shutdown handling. r=mfinkle
mobile/android/components/SessionStore.js
--- a/mobile/android/components/SessionStore.js
+++ b/mobile/android/components/SessionStore.js
@@ -23,17 +23,16 @@ function dump(a) {
 }
 
 // -----------------------------------------------------------------------
 // Session Store
 // -----------------------------------------------------------------------
 
 const STATE_STOPPED = 0;
 const STATE_RUNNING = 1;
-const STATE_QUITTING = -1;
 
 function SessionStore() { }
 
 SessionStore.prototype = {
   classID: Components.ID("{8c1f07d6-cba3-4226-a315-8bd43d67d032}"),
 
   QueryInterface: XPCOMUtils.generateQI([Ci.nsISessionStore,
                                          Ci.nsIDOMEventListener,
@@ -71,21 +70,17 @@ SessionStore.prototype = {
   observe: function ss_observe(aSubject, aTopic, aData) {
     let self = this;
     let observerService = Services.obs;
     switch (aTopic) {
       case "app-startup":
         observerService.addObserver(this, "final-ui-startup", true);
         observerService.addObserver(this, "domwindowopened", true);
         observerService.addObserver(this, "domwindowclosed", true);
-        observerService.addObserver(this, "browser-lastwindow-close-granted", true);
         observerService.addObserver(this, "browser:purge-session-history", true);
-        observerService.addObserver(this, "quit-application-requested", true);
-        observerService.addObserver(this, "quit-application-granted", true);
-        observerService.addObserver(this, "quit-application", true);
         observerService.addObserver(this, "Session:Restore", true);
         break;
       case "final-ui-startup":
         observerService.removeObserver(this, "final-ui-startup");
         this.init();
         break;
       case "domwindowopened": {
         let window = aSubject;
@@ -93,70 +88,19 @@ SessionStore.prototype = {
           self.onWindowOpen(window);
           window.removeEventListener("load", arguments.callee, false);
         }, false);
         break;
       }
       case "domwindowclosed": // catch closed windows
         this.onWindowClose(aSubject);
         break;
-      case "browser-lastwindow-close-granted":
-        // If a save has been queued, kill the timer and save state now
-        if (this._saveTimer) {
-          this._saveTimer.cancel();
-          this._saveTimer = null;
-          this.saveState();
-        }
-
-        // Freeze the data at what we've got (ignoring closing windows)
-        this._loadState = STATE_QUITTING;
-        break;
-      case "quit-application-requested":
-        // Get a current snapshot of all windows
-        this._forEachBrowserWindow(function(aWindow) {
-          self._collectWindowData(aWindow);
-        });
-        break;
-      case "quit-application-granted":
-        // Get a current snapshot of all windows
-        this._forEachBrowserWindow(function(aWindow) {
-          self._collectWindowData(aWindow);
-        });
-
-        // Freeze the data at what we've got (ignoring closing windows)
-        this._loadState = STATE_QUITTING;
-        break;
-      case "quit-application":
-        // Freeze the data at what we've got (ignoring closing windows)
-        this._loadState = STATE_QUITTING;
-
-        observerService.removeObserver(this, "domwindowopened");
-        observerService.removeObserver(this, "domwindowclosed");
-        observerService.removeObserver(this, "browser-lastwindow-close-granted");
-        observerService.removeObserver(this, "quit-application-requested");
-        observerService.removeObserver(this, "quit-application-granted");
-        observerService.removeObserver(this, "quit-application");
-        observerService.removeObserver(this, "Session:Restore");
-
-        // If a save has been queued, kill the timer and save state now
-        if (this._saveTimer) {
-          this._saveTimer.cancel();
-          this._saveTimer = null;
-          this.saveState();
-        }
-        break;
       case "browser:purge-session-history": // catch sanitization 
         this._clearDisk();
 
-        // If the browser is shutting down, simply return after clearing the
-        // session data on disk as this notification fires after the
-        // quit-application notification so the browser is about to exit.
-        if (this._loadState == STATE_QUITTING)
-          return;
-
         // Clear all data about closed tabs
         for (let [ssid, win] in Iterator(this._windows))
           win.closedTabs = [];
 
         if (this._loadState == STATE_RUNNING) {
           // Save the purged state immediately
           this.saveStateNow();
         }
@@ -232,17 +176,17 @@ SessionStore.prototype = {
   },
 
   onWindowOpen: function ss_onWindowOpen(aWindow) {
     // Return if window has already been initialized
     if (aWindow && aWindow.__SSID && this._windows[aWindow.__SSID])
       return;
 
     // Ignore non-browser windows and windows opened while shutting down
-    if (aWindow.document.documentElement.getAttribute("windowtype") != "navigator:browser" || this._loadState == STATE_QUITTING)
+    if (aWindow.document.documentElement.getAttribute("windowtype") != "navigator:browser")
       return;
 
     // Assign it a unique identifier (timestamp) and create its data object
     aWindow.__SSID = "window" + Date.now();
     this._windows[aWindow.__SSID] = { tabs: [], selected: 0, closedTabs: [] };
 
     // Perform additional initialization when the first window is loading
     if (this._loadState == STATE_STOPPED) {