diff --git a/services/settings/RemoteSettingsClient.jsm b/services/settings/RemoteSettingsClient.jsm index e042c71a6cff..5d60027d9ead 100644 --- a/services/settings/RemoteSettingsClient.jsm +++ b/services/settings/RemoteSettingsClient.jsm @@ -60,6 +60,11 @@ const DB_NAME = "remote-settings"; const TELEMETRY_COMPONENT = "remotesettings"; XPCOMUtils.defineLazyGetter(this, "console", () => Utils.log); +XPCOMUtils.defineLazyPreferenceGetter( + this, + "gServerURL", + "services.settings.server" +); /** * cacheProxy returns an object Proxy that will memoize properties of the target. @@ -272,7 +277,7 @@ class RemoteSettingsClient extends EventEmitter { } httpClient() { - const api = new KintoHttpClient(Utils.SERVER_URL); + const api = new KintoHttpClient(gServerURL); return api.bucket(this.bucketName).collection(this.collectionName); } @@ -393,7 +398,7 @@ class RemoteSettingsClient extends EventEmitter { async sync(options) { // We want to know which timestamp we are expected to obtain in order to leverage // cache busting. We don't provide ETag because we don't want a 304. - const { changes } = await Utils.fetchLatestChanges(Utils.SERVER_URL, { + const { changes } = await Utils.fetchLatestChanges(gServerURL, { filters: { collection: this.collectionName, bucket: this.bucketName, @@ -542,7 +547,7 @@ class RemoteSettingsClient extends EventEmitter { // Fetch changes from server, and make sure we overwrite local data. const strategy = Kinto.syncStrategy.PULL_ONLY; syncResult = await kintoCollection.sync({ - remote: Utils.SERVER_URL, + remote: gServerURL, strategy, expectedTimestamp, }); diff --git a/services/settings/Utils.jsm b/services/settings/Utils.jsm index 36da62856100..e42bca38b2a3 100644 --- a/services/settings/Utils.jsm +++ b/services/settings/Utils.jsm @@ -8,11 +8,6 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); const { XPCOMUtils } = ChromeUtils.import( "resource://gre/modules/XPCOMUtils.jsm" ); -ChromeUtils.defineModuleGetter( - this, - "AppConstants", - "resource://gre/modules/AppConstants.jsm" -); XPCOMUtils.defineLazyGlobalGetters(this, ["fetch"]); @@ -30,23 +25,7 @@ XPCOMUtils.defineLazyGetter(this, "log", () => { }); }); -XPCOMUtils.defineLazyPreferenceGetter( - this, - "gServerURL", - "services.settings.server" -); - var Utils = { - get SERVER_URL() { - const env = Cc["@mozilla.org/process/environment;1"].getService( - Ci.nsIEnvironment - ); - const isXpcshell = env.exists("XPCSHELL_TEST_PROFILE_DIR"); - return AppConstants.RELEASE_OR_BETA && !Cu.isInAutomation && !isXpcshell - ? "https://firefox.settings.services.mozilla.com/v1" - : gServerURL; - }, - CHANGES_PATH: "/buckets/monitor/collections/changes/records", /** diff --git a/services/settings/remote-settings.js b/services/settings/remote-settings.js index 9e35627ef2ac..4327600946d3 100644 --- a/services/settings/remote-settings.js +++ b/services/settings/remote-settings.js @@ -47,6 +47,7 @@ XPCOMUtils.defineLazyGlobalGetters(this, ["fetch"]); const PREF_SETTINGS_DEFAULT_BUCKET = "services.settings.default_bucket"; const PREF_SETTINGS_BRANCH = "services.settings."; +const PREF_SETTINGS_SERVER = "server"; const PREF_SETTINGS_DEFAULT_SIGNER = "default_signer"; const PREF_SETTINGS_SERVER_BACKOFF = "server.backoff"; const PREF_SETTINGS_LAST_UPDATE = "last_update_seconds"; @@ -69,6 +70,11 @@ XPCOMUtils.defineLazyGetter(this, "gPrefs", () => { return Services.prefs.getBranch(PREF_SETTINGS_BRANCH); }); XPCOMUtils.defineLazyGetter(this, "console", () => Utils.log); +XPCOMUtils.defineLazyPreferenceGetter( + this, + "gServerURL", + PREF_SETTINGS_BRANCH + PREF_SETTINGS_SERVER +); /** * Default entry filtering function, in charge of excluding remote settings entries @@ -222,7 +228,7 @@ function remoteSettingsFunction() { let pollResult; try { - pollResult = await Utils.fetchLatestChanges(Utils.SERVER_URL, { + pollResult = await Utils.fetchLatestChanges(gServerURL, { expectedTimestamp, lastEtag, }); @@ -369,7 +375,7 @@ function remoteSettingsFunction() { const { changes, currentEtag: serverTimestamp, - } = await Utils.fetchLatestChanges(Utils.SERVER_URL); + } = await Utils.fetchLatestChanges(gServerURL); const collections = await Promise.all( changes.map(async change => { @@ -396,8 +402,8 @@ function remoteSettingsFunction() { ); return { - serverURL: Utils.SERVER_URL, - pollingEndpoint: Utils.SERVER_URL + Utils.CHANGES_PATH, + serverURL: gServerURL, + pollingEndpoint: gServerURL + Utils.CHANGES_PATH, serverTimestamp, localTimestamp: gPrefs.getCharPref(PREF_SETTINGS_LAST_ETAG, null), lastCheck: gPrefs.getIntPref(PREF_SETTINGS_LAST_UPDATE, 0),