Bug 785225 - Part 1: Don't rely on Engines singleton in AddonsReconciler; r=rnewman

This commit is contained in:
Gregory Szorc 2012-08-29 14:43:40 -07:00
Родитель 04c46a9077
Коммит a740be31b3
2 изменённых файлов: 10 добавлений и 5 удалений

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;
}
}