From a740be31b3c2c8312b62fa7ce2464783616e34ba Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Wed, 29 Aug 2012 14:43:40 -0700 Subject: [PATCH] Bug 785225 - Part 1: Don't rely on Engines singleton in AddonsReconciler; r=rnewman --- services/sync/modules/addonsreconciler.js | 6 +----- services/sync/modules/engines/addons.js | 9 +++++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/services/sync/modules/addonsreconciler.js b/services/sync/modules/addonsreconciler.js index 0b2a6b5c7658..f222540db092 100644 --- a/services/sync/modules/addonsreconciler.js +++ b/services/sync/modules/addonsreconciler.js @@ -20,7 +20,6 @@ const Cu = Components.utils; Cu.import("resource://services-common/log4moz.js"); -Cu.import("resource://services-sync/engines.js"); Cu.import("resource://services-sync/util.js"); Cu.import("resource://gre/modules/AddonManager.jsm"); @@ -119,8 +118,6 @@ function AddonsReconciler() { let level = Svc.Prefs.get("log.logger.addonsreconciler", "Debug"); this._log.level = Log4Moz.Level[level]; - Svc.Obs.add("weave:engine:start-tracking", this.startListening, this); - Svc.Obs.add("weave:engine:stop-tracking", this.stopListening, this); Svc.Obs.add("xpcom-shutdown", this.stopListening, this); }; AddonsReconciler.prototype = { @@ -301,8 +298,7 @@ AddonsReconciler.prototype = { * This is typically called automatically when Sync is loaded. */ startListening: function startListening() { - let engine = Engines.get("addons"); - if (!engine || !engine.enabled || this._listening) { + if (this._listening) { return; } diff --git a/services/sync/modules/engines/addons.js b/services/sync/modules/engines/addons.js index 0e80e3fffffa..976f2815527d 100644 --- a/services/sync/modules/engines/addons.js +++ b/services/sync/modules/engines/addons.js @@ -657,6 +657,10 @@ function AddonsTracker(name) { AddonsTracker.prototype = { __proto__: Tracker.prototype, + get engine() { + return Engines.get("addons"); + }, + get reconciler() { return Engines.get("addons")._reconciler; }, @@ -689,11 +693,16 @@ AddonsTracker.prototype = { observe: function(subject, topic, data) { switch (topic) { case "weave:engine:start-tracking": + if (this.engine.enabled) { + this.reconciler.startListening(); + } + this.reconciler.addChangeListener(this); break; case "weave:engine:stop-tracking": this.reconciler.removeChangeListener(this); + this.reconciler.stopListening(); break; } }