Bug 470348 - clear private data on shutdown does not delete history if "ask me before..." is enabled (r=dietrich, gavin)
authormak77@bonardo.net
Tue, 06 Jan 2009 12:41:08 -0800
changeset 22734 00a4e7bf722b25347d1d4233390699f96a09aaaa
parent 22733 06f8f373eb7a6210c2692ed8d4344b3d43f46e4d
child 22735 1f72b977ac0e2f874d79c0fda4af10c55d8d7ccd
push id385
push usersdwilsh@shawnwilsher.com
push dateWed, 07 Jan 2009 20:25:09 +0000
reviewersdietrich, gavin
bugs470348
milestone1.9.1b3pre
Bug 470348 - clear private data on shutdown does not delete history if "ask me before..." is enabled (r=dietrich, gavin)
browser/components/nsBrowserGlue.js
toolkit/components/places/public/nsINavHistoryService.idl
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -110,19 +110,16 @@ BrowserGlue.prototype = {
 
   // nsIObserver implementation 
   observe: function(subject, topic, data) 
   {
     switch(topic) {
       case "xpcom-shutdown":
         this._dispose();
         break;
-      case "quit-application": 
-        this._onProfileShutdown();
-        break;
       case "prefservice:after-app-defaults":
         this._onAppDefaults();
         break;
       case "final-ui-startup":
         this._onProfileStartup();
         break;
       case "sessionstore-windows-restored":
         this._onBrowserStartup();
@@ -136,16 +133,20 @@ BrowserGlue.prototype = {
         break;
       case "quit-application-requested":
         this._onQuitRequest(subject, data);
         break;
       case "quit-application-granted":
         if (this._saveSession) {
           this._setPrefToSaveSession();
         }
+        // Everything that uses Places during shutdown should be here, since
+        // on quit-application Places database connection will be closed
+        // and history synchronization could fail.
+        this._onProfileShutdown();
         break;
       case "session-save":
         this._setPrefToSaveSession();
         subject.QueryInterface(Ci.nsISupportsPRBool);
         subject.data = true;
         break;
       case "places-init-complete":
         this._initPlaces();
@@ -168,17 +169,16 @@ BrowserGlue.prototype = {
     }
   }, 
 
   // initialization (called on application startup) 
   _init: function() 
   {
     // observer registration
     const osvr = this._observerService;
-    osvr.addObserver(this, "quit-application", false);
     osvr.addObserver(this, "xpcom-shutdown", false);
     osvr.addObserver(this, "prefservice:after-app-defaults", false);
     osvr.addObserver(this, "final-ui-startup", false);
     osvr.addObserver(this, "sessionstore-windows-restored", false);
     osvr.addObserver(this, "browser:purge-session-history", false);
     osvr.addObserver(this, "quit-application-requested", false);
     osvr.addObserver(this, "quit-application-granted", false);
     osvr.addObserver(this, "session-save", false);
@@ -186,17 +186,16 @@ BrowserGlue.prototype = {
     osvr.addObserver(this, "places-database-locked", false);
   },
 
   // cleanup (called on application shutdown)
   _dispose: function() 
   {
     // observer removal 
     const osvr = this._observerService;
-    osvr.removeObserver(this, "quit-application");
     osvr.removeObserver(this, "xpcom-shutdown");
     osvr.removeObserver(this, "prefservice:after-app-defaults");
     osvr.removeObserver(this, "final-ui-startup");
     osvr.removeObserver(this, "sessionstore-windows-restored");
     osvr.removeObserver(this, "browser:purge-session-history");
     osvr.removeObserver(this, "quit-application-requested");
     osvr.removeObserver(this, "quit-application-granted");
     osvr.removeObserver(this, "session-save");
--- a/toolkit/components/places/public/nsINavHistoryService.idl
+++ b/toolkit/components/places/public/nsINavHistoryService.idl
@@ -31,16 +31,22 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
+/**
+ * Using Places services on quit-application or later is not reliable, so make
+ * sure to do shutdown work on quit-application-granted, or history
+ * synchronization could fail, losing latest changes.
+ */
+ 
 #include "nsISupports.idl"
 #include "nsIArray.idl"
 #include "nsIURI.idl"
 
 interface nsIFile;
 interface nsINavHistoryContainerResultNode;
 interface nsINavHistoryQueryResultNode;
 interface nsINavHistoryQuery;