From b80261a3ec5f3ec9811450f9f1a969df901e7177 Mon Sep 17 00:00:00 2001 From: Edouard Oger Date: Tue, 2 May 2017 16:57:37 -0400 Subject: [PATCH] Bug 1358648 part 3 - Remove Async, Services and XPCOMUtils from util.js. r=markh MozReview-Commit-ID: 8na204K9cXp --HG-- extra : rebase_source : 96e7738aa6612cf67543d50053f50c2bccf1ab7e --- browser/base/content/aboutaccounts/aboutaccounts.js | 1 + services/sync/modules/addonsreconciler.js | 1 + services/sync/modules/bookmark_repair.js | 2 ++ services/sync/modules/browserid_identity.js | 7 ++++--- services/sync/modules/doctor.js | 1 + services/sync/modules/engines.js | 4 +++- services/sync/modules/engines/addons.js | 5 +++-- services/sync/modules/engines/bookmarks.js | 1 + services/sync/modules/engines/clients.js | 3 ++- services/sync/modules/engines/extension-storage.js | 1 + services/sync/modules/engines/passwords.js | 1 + services/sync/modules/engines/prefs.js | 4 +++- services/sync/modules/engines/tabs.js | 1 + services/sync/modules/policies.js | 2 ++ services/sync/modules/resource.js | 3 ++- services/sync/modules/service.js | 1 + services/sync/modules/stages/enginesync.js | 1 + services/sync/modules/telemetry.js | 5 +++-- services/sync/modules/util.js | 7 +++---- tools/lint/eslint/modules.json | 2 +- 20 files changed, 37 insertions(+), 16 deletions(-) diff --git a/browser/base/content/aboutaccounts/aboutaccounts.js b/browser/base/content/aboutaccounts/aboutaccounts.js index 05291067feb6..405c9f4e9a29 100644 --- a/browser/base/content/aboutaccounts/aboutaccounts.js +++ b/browser/base/content/aboutaccounts/aboutaccounts.js @@ -6,6 +6,7 @@ var {classes: Cc, interfaces: Ci, utils: Cu} = Components; +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/FxAccounts.jsm"); diff --git a/services/sync/modules/addonsreconciler.js b/services/sync/modules/addonsreconciler.js index fd0a97c58b92..470c03f340bf 100644 --- a/services/sync/modules/addonsreconciler.js +++ b/services/sync/modules/addonsreconciler.js @@ -20,6 +20,7 @@ var Cu = Components.utils; Cu.import("resource://gre/modules/Log.jsm"); +Cu.import("resource://services-common/async.js"); Cu.import("resource://services-sync/util.js"); Cu.import("resource://gre/modules/AddonManager.jsm"); diff --git a/services/sync/modules/bookmark_repair.js b/services/sync/modules/bookmark_repair.js index 0a5a25a54a55..68b496e2e0ab 100644 --- a/services/sync/modules/bookmark_repair.js +++ b/services/sync/modules/bookmark_repair.js @@ -8,6 +8,7 @@ const Cu = Components.utils; this.EXPORTED_SYMBOLS = ["BookmarkRepairRequestor", "BookmarkRepairResponder"]; +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/Preferences.jsm"); Cu.import("resource://gre/modules/Log.jsm"); @@ -17,6 +18,7 @@ Cu.import("resource://services-sync/constants.js"); Cu.import("resource://services-sync/resource.js"); Cu.import("resource://services-sync/doctor.js"); Cu.import("resource://services-sync/telemetry.js"); +Cu.import("resource://services-common/async.js"); Cu.import("resource://services-common/utils.js"); XPCOMUtils.defineLazyModuleGetter(this, "PlacesSyncUtils", diff --git a/services/sync/modules/browserid_identity.js b/services/sync/modules/browserid_identity.js index 4951e2185e4b..4f7dd0a95418 100644 --- a/services/sync/modules/browserid_identity.js +++ b/services/sync/modules/browserid_identity.js @@ -8,16 +8,17 @@ this.EXPORTED_SYMBOLS = ["BrowserIDManager", "AuthenticationError"]; var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); +Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/Log.jsm"); +Cu.import("resource://gre/modules/Promise.jsm"); +Cu.import("resource://gre/modules/FxAccounts.jsm"); Cu.import("resource://services-common/async.js"); Cu.import("resource://services-common/utils.js"); Cu.import("resource://services-common/tokenserverclient.js"); Cu.import("resource://services-crypto/utils.js"); Cu.import("resource://services-sync/util.js"); -Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://services-sync/constants.js"); -Cu.import("resource://gre/modules/Promise.jsm"); -Cu.import("resource://gre/modules/FxAccounts.jsm"); // Lazy imports to prevent unnecessary load on startup. XPCOMUtils.defineLazyModuleGetter(this, "Weave", diff --git a/services/sync/modules/doctor.js b/services/sync/modules/doctor.js index ffd1198e7158..70b246a18199 100644 --- a/services/sync/modules/doctor.js +++ b/services/sync/modules/doctor.js @@ -13,6 +13,7 @@ this.EXPORTED_SYMBOLS = ["Doctor"]; const Cu = Components.utils; +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/Log.jsm"); Cu.import("resource://services-common/async.js"); diff --git a/services/sync/modules/engines.js b/services/sync/modules/engines.js index 0304eca58e98..a735bfd52b68 100644 --- a/services/sync/modules/engines.js +++ b/services/sync/modules/engines.js @@ -13,9 +13,11 @@ this.EXPORTED_SYMBOLS = [ var {classes: Cc, interfaces: Ci, results: Cr, utils: Cu} = Components; -Cu.import("resource://services-common/async.js"); +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); +Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/JSONFile.jsm"); Cu.import("resource://gre/modules/Log.jsm"); +Cu.import("resource://services-common/async.js"); Cu.import("resource://services-common/observers.js"); Cu.import("resource://services-sync/constants.js"); Cu.import("resource://services-sync/record.js"); diff --git a/services/sync/modules/engines/addons.js b/services/sync/modules/engines/addons.js index 8dcad7bbd06a..259e390f2780 100644 --- a/services/sync/modules/engines/addons.js +++ b/services/sync/modules/engines/addons.js @@ -38,6 +38,9 @@ var {classes: Cc, interfaces: Ci, utils: Cu} = Components; +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); +Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/Preferences.jsm"); Cu.import("resource://services-sync/addonutils.js"); Cu.import("resource://services-sync/addonsreconciler.js"); Cu.import("resource://services-sync/engines.js"); @@ -47,8 +50,6 @@ Cu.import("resource://services-sync/constants.js"); Cu.import("resource://services-sync/collection_validator.js"); Cu.import("resource://services-common/async.js"); -Cu.import("resource://gre/modules/Preferences.jsm"); -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "AddonManager", "resource://gre/modules/AddonManager.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "AddonRepository", diff --git a/services/sync/modules/engines/bookmarks.js b/services/sync/modules/engines/bookmarks.js index 6b5c947c2aa9..21c6eee409c3 100644 --- a/services/sync/modules/engines/bookmarks.js +++ b/services/sync/modules/engines/bookmarks.js @@ -11,6 +11,7 @@ var Ci = Components.interfaces; var Cu = Components.utils; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); +Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://services-common/async.js"); Cu.import("resource://services-sync/constants.js"); Cu.import("resource://services-sync/engines.js"); diff --git a/services/sync/modules/engines/clients.js b/services/sync/modules/engines/clients.js index 8a661917a0fe..2581f980cf8d 100644 --- a/services/sync/modules/engines/clients.js +++ b/services/sync/modules/engines/clients.js @@ -27,13 +27,14 @@ this.EXPORTED_SYMBOLS = [ var {classes: Cc, interfaces: Ci, utils: Cu} = Components; +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); +Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://services-common/async.js"); Cu.import("resource://services-sync/constants.js"); Cu.import("resource://services-sync/engines.js"); Cu.import("resource://services-sync/record.js"); Cu.import("resource://services-sync/resource.js"); Cu.import("resource://services-sync/util.js"); -Cu.import("resource://gre/modules/Services.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "fxAccounts", "resource://gre/modules/FxAccounts.jsm"); diff --git a/services/sync/modules/engines/extension-storage.js b/services/sync/modules/engines/extension-storage.js index 44042fbb0e82..6d4b3703196c 100644 --- a/services/sync/modules/engines/extension-storage.js +++ b/services/sync/modules/engines/extension-storage.js @@ -8,6 +8,7 @@ this.EXPORTED_SYMBOLS = ["ExtensionStorageEngine"]; const {classes: Cc, interfaces: Ci, utils: Cu} = Components; +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://services-sync/constants.js"); Cu.import("resource://services-sync/engines.js"); Cu.import("resource://services-sync/util.js"); diff --git a/services/sync/modules/engines/passwords.js b/services/sync/modules/engines/passwords.js index e924c6da5aeb..95effe34b467 100644 --- a/services/sync/modules/engines/passwords.js +++ b/services/sync/modules/engines/passwords.js @@ -6,6 +6,7 @@ this.EXPORTED_SYMBOLS = ["PasswordEngine", "LoginRec", "PasswordValidator"]; var {classes: Cc, interfaces: Ci, utils: Cu} = Components; +Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://services-sync/record.js"); Cu.import("resource://services-sync/constants.js"); Cu.import("resource://services-sync/collection_validator.js"); diff --git a/services/sync/modules/engines/prefs.js b/services/sync/modules/engines/prefs.js index 401fb96010e3..f4ac7cc1dbd3 100644 --- a/services/sync/modules/engines/prefs.js +++ b/services/sync/modules/engines/prefs.js @@ -10,12 +10,14 @@ var Cu = Components.utils; const PREF_SYNC_PREFS_PREFIX = "services.sync.prefs.sync."; +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); +Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/Preferences.jsm"); Cu.import("resource://services-sync/engines.js"); Cu.import("resource://services-sync/record.js"); Cu.import("resource://services-sync/util.js"); Cu.import("resource://services-sync/constants.js"); Cu.import("resource://services-common/utils.js"); -Cu.import("resource://gre/modules/Preferences.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeManager", "resource://gre/modules/LightweightThemeManager.jsm"); diff --git a/services/sync/modules/engines/tabs.js b/services/sync/modules/engines/tabs.js index da660a806be5..08dbfd35b06e 100644 --- a/services/sync/modules/engines/tabs.js +++ b/services/sync/modules/engines/tabs.js @@ -10,6 +10,7 @@ const TABS_TTL = 1814400; // 21 days. const TAB_ENTRIES_LIMIT = 5; // How many URLs to include in tab history. Cu.import("resource://gre/modules/XPCOMUtils.jsm"); +Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://services-sync/engines.js"); Cu.import("resource://services-sync/record.js"); Cu.import("resource://services-sync/util.js"); diff --git a/services/sync/modules/policies.js b/services/sync/modules/policies.js index 4e6fa7915245..a932bae65f50 100644 --- a/services/sync/modules/policies.js +++ b/services/sync/modules/policies.js @@ -9,6 +9,8 @@ this.EXPORTED_SYMBOLS = [ var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); +Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/Log.jsm"); Cu.import("resource://services-sync/constants.js"); Cu.import("resource://services-sync/util.js"); diff --git a/services/sync/modules/resource.js b/services/sync/modules/resource.js index e728252adf97..2c6aff282b93 100644 --- a/services/sync/modules/resource.js +++ b/services/sync/modules/resource.js @@ -12,9 +12,10 @@ var Ci = Components.interfaces; var Cr = Components.results; var Cu = Components.utils; +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/NetUtil.jsm"); -Cu.import("resource://services-common/async.js"); Cu.import("resource://gre/modules/Log.jsm"); +Cu.import("resource://services-common/async.js"); Cu.import("resource://services-common/observers.js"); Cu.import("resource://services-common/utils.js"); Cu.import("resource://services-sync/constants.js"); diff --git a/services/sync/modules/service.js b/services/sync/modules/service.js index 8f49653c36f3..dc978e75e750 100644 --- a/services/sync/modules/service.js +++ b/services/sync/modules/service.js @@ -19,6 +19,7 @@ const CRYPTO_COLLECTION = "crypto"; const KEYS_WBO = "keys"; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); +Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/Log.jsm"); Cu.import("resource://services-common/async.js"); Cu.import("resource://services-sync/constants.js"); diff --git a/services/sync/modules/stages/enginesync.js b/services/sync/modules/stages/enginesync.js index e305c24904b6..793dd727b7e6 100644 --- a/services/sync/modules/stages/enginesync.js +++ b/services/sync/modules/stages/enginesync.js @@ -10,6 +10,7 @@ this.EXPORTED_SYMBOLS = ["EngineSynchronizer"]; var {utils: Cu} = Components; +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Log.jsm"); Cu.import("resource://services-sync/constants.js"); Cu.import("resource://services-sync/util.js"); diff --git a/services/sync/modules/telemetry.js b/services/sync/modules/telemetry.js index 9bcf3bf9636a..40fd840bd6b9 100644 --- a/services/sync/modules/telemetry.js +++ b/services/sync/modules/telemetry.js @@ -8,6 +8,9 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; this.EXPORTED_SYMBOLS = ["SyncTelemetry"]; +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); +Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/Log.jsm"); Cu.import("resource://services-sync/browserid_identity.js"); Cu.import("resource://services-sync/main.js"); Cu.import("resource://services-sync/status.js"); @@ -15,8 +18,6 @@ Cu.import("resource://services-sync/util.js"); Cu.import("resource://services-sync/resource.js"); Cu.import("resource://services-common/observers.js"); Cu.import("resource://services-common/async.js"); -Cu.import("resource://gre/modules/Log.jsm"); -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); let constants = {}; Cu.import("resource://services-sync/constants.js", constants); diff --git a/services/sync/modules/util.js b/services/sync/modules/util.js index d8b093da0149..ff73dcc76566 100644 --- a/services/sync/modules/util.js +++ b/services/sync/modules/util.js @@ -2,18 +2,17 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -this.EXPORTED_SYMBOLS = ["XPCOMUtils", "Services", "Utils", "Async", "Svc"]; +this.EXPORTED_SYMBOLS = ["Utils", "Svc"]; var {classes: Cc, interfaces: Ci, results: Cr, utils: Cu} = Components; Cu.import("resource://services-common/observers.js"); Cu.import("resource://services-common/utils.js"); -Cu.import("resource://services-common/async.js", this); Cu.import("resource://services-crypto/utils.js"); Cu.import("resource://services-sync/constants.js"); Cu.import("resource://gre/modules/Preferences.jsm"); -Cu.import("resource://gre/modules/Services.jsm", this); -Cu.import("resource://gre/modules/XPCOMUtils.jsm", this); +Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm"); diff --git a/tools/lint/eslint/modules.json b/tools/lint/eslint/modules.json index e7739eae1d9a..0414ef729876 100644 --- a/tools/lint/eslint/modules.json +++ b/tools/lint/eslint/modules.json @@ -224,7 +224,7 @@ "Translation.jsm": ["Translation", "TranslationTelemetry"], "Traversal.jsm": ["TraversalRules", "TraversalHelper"], "UpdateTelemetry.jsm": ["AUSTLMY"], - "util.js": ["getChromeWindow", "XPCOMUtils", "Services", "Utils", "Async", "Svc"], + "util.js": ["getChromeWindow", "Utils", "Svc"], "utils.js": ["applicationName", "assert", "Copy", "getBrowserObject", "getChromeWindow", "getWindows", "getWindowByTitle", "getWindowByType", "getWindowId", "getMethodInWindows", "getPreference", "saveDataURL", "setPreference", "sleep", "startTimer", "stopTimer", "takeScreenshot", "unwrapNode", "waitFor", "btoa", "encryptPayload", "makeIdentityConfig", "makeFxAccountsInternalMock", "configureFxAccountIdentity", "configureIdentity", "SyncTestingInfrastructure", "waitForZeroTimer", "Promise", "MockFxaStorageManager", "AccountState", "sumHistogram", "CommonUtils", "CryptoUtils", "TestingUtils", "promiseZeroTimer", "promiseNamedTimer"], "Utils.jsm": ["Utils", "Logger", "PivotContext", "PrefCache"], "VariablesView.jsm": ["VariablesView", "escapeHTML"],