Bug 497578: delay update resuming to avoid it being interrupted by the private browsing necko reset when private browsing autostart is enabled, r=mconnor
--- 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);
}