Bug 1438055 - Switch Fluent Localization class to use weak observers. r=mossop

MozReview-Commit-ID: 4R8OyziLRUo

--HG--
extra : rebase_source : 8a26c97c30e46af0a5f77060066046cd91ccb64c
This commit is contained in:
Zibi Braniecki 2018-02-13 16:25:41 -08:00
Родитель b5f314390e
Коммит 168adb6f0b
1 изменённых файлов: 8 добавлений и 3 удалений

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

@ -21,6 +21,7 @@
/* eslint no-console: ["error", { allow: ["warn", "error"] }] */ /* eslint no-console: ["error", { allow: ["warn", "error"] }] */
/* global console */ /* global console */
const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm", {});
const { L10nRegistry } = ChromeUtils.import("resource://gre/modules/L10nRegistry.jsm", {}); const { L10nRegistry } = ChromeUtils.import("resource://gre/modules/L10nRegistry.jsm", {});
const LocaleService = Cc["@mozilla.org/intl/localeservice;1"].getService(Ci.mozILocaleService); const LocaleService = Cc["@mozilla.org/intl/localeservice;1"].getService(Ci.mozILocaleService);
const ObserverService = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService); const ObserverService = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
@ -254,11 +255,11 @@ class Localization {
} }
/** /**
* Register observers on events that will trigger cache invalidation * Register weak observers on events that will trigger cache invalidation
*/ */
registerObservers() { registerObservers() {
ObserverService.addObserver(this, 'l10n:available-locales-changed', false); ObserverService.addObserver(this, 'l10n:available-locales-changed', true);
ObserverService.addObserver(this, 'intl:requested-locales-changed', false); ObserverService.addObserver(this, 'intl:requested-locales-changed', true);
} }
/** /**
@ -296,6 +297,10 @@ class Localization {
} }
} }
Localization.prototype.QueryInterface = XPCOMUtils.generateQI([
Ci.nsISupportsWeakReference
]);
/** /**
* Format the value of a message into a string. * Format the value of a message into a string.
* *