Bug 942937 - Move onProfileShutdown logic to quit-application-granted phase. r=IanN a=IanN
authorFrank-Rainer Grahl <frgrahl@gmx.net>
Mon, 07 May 2018 12:41:29 +0200
changeset 31466 85fef84f3604
parent 31465 faa0beaa7193
child 31467 e7ec4d4f2a40
push id383
push userclokep@gmail.com
push date2018-05-07 21:52 +0000
reviewersIanN, IanN
bugs942937, 967839
Bug 942937 - Move onProfileShutdown logic to quit-application-granted phase. r=IanN a=IanN Port Bug 967839 [onProfileShutdown work in BrowserGlue doesn't really have to happen at profile shutdown].
suite/common/src/nsSuiteGlue.js
--- a/suite/common/src/nsSuiteGlue.js
+++ b/suite/common/src/nsSuiteGlue.js
@@ -217,17 +217,20 @@ SuiteGlue.prototype = {
             // Wifi visibility has changed, we need to restart the debugger
             // server.
             if (this.dbgIsEnabled && !Services.prefs.getBoolPref(DEBUGGER_FORCE_LOCAL))
               this.dbgRestart();
             break;
         }
         break;
       case "profile-before-change":
-        this._onProfileShutdown();
+         // Any component depending on Places should be finalized in
+         // _onPlacesShutdown.  Any component that doesn't need to act after
+         // the UI has gone should be finalized in _onQuitApplicationGranted.
+        this._dispose();
         break;
       case "profile-after-change":
         this._onProfileAfterChange();
         break;
       case "final-ui-startup":
         this._onProfileStartup();
         this._promptForMasterPassword();
         this._checkForNewAddons();
@@ -268,22 +271,17 @@ SuiteGlue.prototype = {
         // reset the console service's error buffer
         Services.console.logStringMessage(null); // clear the console (in case it's open)
         Services.console.reset();
         break;
       case "quit-application-requested":
         this._onQuitRequest(subject, data);
         break;
       case "quit-application-granted":
-        AutoCompletePopup.uninit();
-
-        if (this._saveSession) {
-          this._setPrefToSaveSession();
-        }
-        Sanitizer.checkSettings();
+        this._onQuitApplicationGranted();
         break;
       case "browser-lastwindow-close-requested":
         // The application is not actually quitting, but the last full browser
         // window is about to be closed.
         this._onQuitRequest(subject, "lastwindow");
         break;
       case "browser-lastwindow-close-granted":
         if (this._saveSession)
@@ -423,16 +421,20 @@ SuiteGlue.prototype = {
     Services.obs.addObserver(this, "notifications-open-settings", true);
     Services.prefs.addObserver("devtools.debugger.", this, true);
     Services.obs.addObserver(this, "handle-xul-text-link", true);
     Cc['@mozilla.org/docloaderservice;1']
       .getService(Ci.nsIWebProgress)
       .addProgressListener(this, Ci.nsIWebProgress.NOTIFY_LOCATION);
   },
 
+  // cleanup (called on application shutdown)
+  _dispose: function BG__dispose() {
+  },
+
   // profile is available
   _onProfileAfterChange: function()
   {
     // check if we're in safe mode
     if (Services.appinfo.inSafeMode) {
       Services.ww.openWindow(null, "chrome://communicator/content/safeMode.xul",
                              "_blank", "chrome,centerscreen,modal,resizable=no", null);
     }
@@ -655,22 +657,29 @@ SuiteGlue.prototype = {
     // Detect if updates are off and warn for outdated builds.
     if (this._shouldShowUpdateWarning())
       notifyBox.showUpdateWarning();
 
     this._checkForDefaultClient(aWindow);
   },
 
   /**
-   * Profile shutdown handler (contains profile cleanup routines).
-   * All components depending on Places should be shut down in
-   * _onPlacesShutdown() and not here.
+   * Application shutdown handler.
    */
-  _onProfileShutdown: function()
+  _onQuitApplicationGranted: function()
   {
+    if (this._saveSession) {
+      this._setPrefToSaveSession();
+    }
+    Sanitizer.checkSettings();
+    AutoCompletePopup.uninit();
+
+    if (!Sanitizer.doPendingSanitize()) {
+      Services.prefs.setBoolPref("privacy.sanitize.didShutdownSanitize", true);
+    }
   },
 
   _promptForMasterPassword: function()
   {
     if (!Services.prefs.getBoolPref("signon.startup.prompt"))
       return;
 
     // Try to avoid the multiple master password prompts on startup scenario
@@ -1135,19 +1144,16 @@ SuiteGlue.prototype = {
           }
         );
         var thread = Services.tm.currentThread;
         while (!shutdownComplete) {
           thread.processNextEvent(true);
         }
       }
     } catch(ex) { /* Don't export */ }
-
-    if (!Sanitizer.doPendingSanitize())
-      Services.prefs.setBoolPref("privacy.sanitize.didShutdownSanitize", true);
   },
 
   /**
    * Backup bookmarks if needed.
    */
   _backupBookmarks: function() {
     let lastBackupFile = PlacesBackups.getMostRecent();