Bug 1266794 - Fix lazy load of blocklist collections preferences
MozReview-Commit-ID: Eg6CoI95YPH
--- a/services/common/KintoBlocklist.js
+++ b/services/common/KintoBlocklist.js
@@ -56,33 +56,34 @@ function kintoClient() {
};
return new Kinto(config);
}
class BlocklistClient {
- constructor(collectionName, lastCheckTimePref, processCallback) {
- this.collectionName = collectionName;
+ constructor(collectionNamePref, lastCheckTimePref, processCallback) {
+ this.collectionNamePref = collectionNamePref;
this.lastCheckTimePref = lastCheckTimePref;
this.processCallback = processCallback;
}
/**
* Synchronize from Kinto server, if necessary.
*
* @param {int} lastModified the lastModified date (on the server) for
the remote collection.
* @param {Date} serverTime the current date return by the server.
* @return {Promise} which rejects on sync or process failure.
*/
maybeSync(lastModified, serverTime) {
let db = kintoClient();
- let collection = db.collection(this.collectionName);
+ const collectionName = Services.prefs.getCharPref(this.collectionNamePref);
+ let collection = db.collection(collectionName);
return Task.spawn((function* syncCollection() {
try {
yield collection.db.open();
let collectionLastModified = yield collection.db.getLastModified();
// If the data is up to date, there's no need to sync. We still need
// to record the fact that a check happened.
@@ -156,30 +157,30 @@ function* updateJSONBlocklist(filename,
Services.cpmm.sendAsyncMessage("Blocklist:reload-from-disk", eventData);
} catch(e) {
Cu.reportError(e);
}
}
this.OneCRLBlocklistClient = new BlocklistClient(
- Services.prefs.getCharPref(PREF_KINTO_ONECRL_COLLECTION),
+ PREF_KINTO_ONECRL_COLLECTION,
PREF_KINTO_ONECRL_CHECKED_SECONDS,
updateCertBlocklist
);
this.AddonBlocklistClient = new BlocklistClient(
- Services.prefs.getCharPref(PREF_KINTO_ADDONS_COLLECTION),
+ PREF_KINTO_ADDONS_COLLECTION,
PREF_KINTO_ADDONS_CHECKED_SECONDS,
updateJSONBlocklist.bind(undefined, FILENAME_ADDONS_JSON)
);
this.GfxBlocklistClient = new BlocklistClient(
- Services.prefs.getCharPref(PREF_KINTO_GFX_COLLECTION),
+ PREF_KINTO_GFX_COLLECTION,
PREF_KINTO_GFX_CHECKED_SECONDS,
updateJSONBlocklist.bind(undefined, FILENAME_GFX_JSON)
);
this.PluginBlocklistClient = new BlocklistClient(
- Services.prefs.getCharPref(PREF_KINTO_PLUGINS_COLLECTION),
+ PREF_KINTO_PLUGINS_COLLECTION,
PREF_KINTO_PLUGINS_CHECKED_SECONDS,
updateJSONBlocklist.bind(undefined, FILENAME_PLUGINS_JSON)
);