Bug 497578: delay update resuming to avoid it being interrupted by the private browsing necko reset when private browsing autostart is enabled, r=mconnor
authorRobert Strong <robert.bugzilla@gmail.com>
Fri, 12 Jun 2009 01:04:49 -0400
changeset 29120 f9a4e14e1678626005f937e900241a9d2e0abf59
parent 29119 6c95fd93471f4ae3a52d4c4d523b9456b686de79
child 29121 6a4b79ff31e6e02db86ca295df48468ffe6977ba
push id7427
push usergsharp@mozilla.com
push dateFri, 12 Jun 2009 05:05:41 +0000
treeherderautoland@f9a4e14e1678 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconnor
bugs497578
milestone1.9.2a1pre
Bug 497578: delay update resuming to avoid it being interrupted by the private browsing necko reset when private browsing autostart is enabled, r=mconnor
toolkit/mozapps/update/src/nsUpdateService.js.in
toolkit/mozapps/update/test/unit/head_update.js
--- a/toolkit/mozapps/update/src/nsUpdateService.js.in
+++ b/toolkit/mozapps/update/src/nsUpdateService.js.in
@@ -1113,18 +1113,23 @@ UpdateService.prototype = {
    *          Additional data
    */
   observe: function AUS_observe(subject, topic, data) {
     var os = getObserverService();
 
     switch (topic) {
     case "profile-after-change":
       os.removeObserver(this, "profile-after-change");
+      os.addObserver(this, "final-ui-startup", false);
       this._start();
       break;
+    case "final-ui-startup":
+      os.removeObserver(this, "final-ui-startup");
+      this._final_ui_start();
+      break;
     case "xpcom-shutdown":
       os.removeObserver(this, "xpcom-shutdown");
 
       // Prevent leaking the downloader (bug 454964)
       this._downloader = null;
 
       // Release Services
       gApp      = null;
@@ -1136,24 +1141,33 @@ UpdateService.prototype = {
 
   /**
    * Start the Update Service
    */
   _start: function AUS__start() {
     // Start logging
     this._initLoggingPrefs();
 
-    // Clean up any extant updates
-    this._postUpdateProcessing();
-
     // Register a background update check timer
     var tm = Cc["@mozilla.org/updates/timer-manager;1"].
              getService(Ci.nsIUpdateTimerManager);
     var interval = getPref("getIntPref", PREF_APP_UPDATE_INTERVAL, 86400);
     tm.registerTimer("background-update-timer", this, interval);
+  },
+
+  /**
+   * The following needs to be performed after final-ui-startup (bug 497578)
+   * 1. post update processing
+   * 2. resume of a download that was in progress during a previous session
+   * 3. start of a complete update download after the failure to apply a partial
+   *    update
+   */
+  _final_ui_start: function AUS__delayed_start() {
+    // Clean up any extant updates
+    this._postUpdateProcessing();
 
     // Resume fetching...
     var um = Cc["@mozilla.org/updates/update-manager;1"].
              getService(Ci.nsIUpdateManager);
     var activeUpdate = um.activeUpdate;
     if (activeUpdate && activeUpdate.state != STATE_SUCCEEDED) {
       var status = this.downloadUpdate(activeUpdate, true);
       if (status == STATE_NONE)
--- a/toolkit/mozapps/update/test/unit/head_update.js
+++ b/toolkit/mozapps/update/test/unit/head_update.js
@@ -151,16 +151,17 @@ function startAUS() {
   pb.setBoolPref("browser.search.update", false);
   pb.setBoolPref("browser.microsummary.updateGenerators", false);
 
   gAUS = AUS_Cc["@mozilla.org/updates/update-service;1"].
          getService(AUS_Ci.nsIApplicationUpdateService);
   var os = AUS_Cc["@mozilla.org/observer-service;1"].
            getService(AUS_Ci.nsIObserverService);
   os.notifyObservers(null, "profile-after-change", null);
+  os.notifyObservers(null, "final-ui-startup", null);
 }
 
 /* Initializes nsIUpdateChecker */
 function startUpdateChecker() {
   gUpdateChecker = AUS_Cc["@mozilla.org/updates/update-checker;1"].
                    createInstance(AUS_Ci.nsIUpdateChecker);
 }