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 23387 053ebdb6a88c3417b17a8d3c4ee8ae32e28cc205
parent 23386 3153bca51559d1ce6a67e5610e3f55fac8da0fda
child 23388 e35d7575410873cf15a376b03255c3f5c1a3cd1c
push id4513
push userdietrich@mozilla.com
push dateTue, 06 Jan 2009 20:41:59 +0000
treeherdermozilla-central@053ebdb6a88c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdietrich, gavin
bugs470348
milestone1.9.2a1pre
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;