Bug 1524688: Part 4 - Convert UpdateService to static registration r=mhowell
☠☠ backed out by 3b1b94e39795 ☠ ☠
authorKris Maglione <maglione.k@gmail.com>
Tue, 29 Jan 2019 17:46:17 -0800
changeset 458977 6b3684e7d8f9
parent 458976 ee28258a5724
child 458978 56607c5a301a
push id111909
push usermaglione.k@gmail.com
push dateThu, 14 Feb 2019 02:30:40 +0000
treeherdermozilla-inbound@81dc12cc9257 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhowell
bugs1524688
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1524688: Part 4 - Convert UpdateService to static registration r=mhowell
browser/components/preferences/in-content/tests/browser_advanced_update.js
browser/installer/package-manifest.in
mobile/android/installer/package-manifest.in
toolkit/mozapps/update/UpdateService.jsm
toolkit/mozapps/update/UpdateServiceStub.jsm
toolkit/mozapps/update/components.conf
toolkit/mozapps/update/moz.build
toolkit/mozapps/update/nsUpdateService.js
toolkit/mozapps/update/nsUpdateService.manifest
toolkit/mozapps/update/nsUpdateServiceStub.js
--- a/browser/components/preferences/in-content/tests/browser_advanced_update.js
+++ b/browser/components/preferences/in-content/tests/browser_advanced_update.js
@@ -9,41 +9,37 @@ const uuidGenerator = Cc["@mozilla.org/u
 
 const mockUpdateManager = {
   contractId: "@mozilla.org/updates/update-manager;1",
 
   _mockClassId: uuidGenerator.generateUUID(),
 
   _originalClassId: "",
 
-  _originalFactory: null,
-
   QueryInterface: ChromeUtils.generateQI([Ci.nsIUpdateManager]),
 
   createInstance(outer, iiD) {
     if (outer) {
       throw Cr.NS_ERROR_NO_AGGREGATION;
     }
     return this.QueryInterface(iiD);
   },
 
   register() {
     let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
     if (!registrar.isCIDRegistered(this._mockClassId)) {
       this._originalClassId = registrar.contractIDToCID(this.contractId);
-      this._originalFactory = Cm.getClassObject(Cc[this.contractId], Ci.nsIFactory);
-      registrar.unregisterFactory(this._originalClassId, this._originalFactory);
       registrar.registerFactory(this._mockClassId, "Unregister after testing", this.contractId, this);
     }
   },
 
   unregister() {
     let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
     registrar.unregisterFactory(this._mockClassId, this);
-    registrar.registerFactory(this._originalClassId, "", this.contractId, this._originalFactory);
+    registrar.registerFactory(this._originalClassId, "", this.contractId, null);
   },
 
   get updateCount() {
     return this._updates.length;
   },
 
   getUpdateAt(index) {
     return this._updates[index];
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -220,18 +220,16 @@
 @RESPATH@/components/NetworkGeolocationProvider.js
 @RESPATH@/components/extensions.manifest
 @RESPATH@/components/addonManager.js
 @RESPATH@/components/amContentHandler.js
 @RESPATH@/components/amInstallTrigger.js
 @RESPATH@/components/amWebAPI.js
 #ifdef MOZ_UPDATER
 @RESPATH@/components/nsUpdateService.manifest
-@RESPATH@/components/nsUpdateService.js
-@RESPATH@/components/nsUpdateServiceStub.js
 #endif
 @RESPATH@/components/nsUpdateTimerManager.manifest
 @RESPATH@/components/nsUpdateTimerManager.js
 @RESPATH@/components/utils.manifest
 @RESPATH@/components/simpleServices.js
 @RESPATH@/components/ProcessSingleton.manifest
 @RESPATH@/components/MainProcessSingleton.js
 @RESPATH@/components/ContentProcessSingleton.js
--- a/mobile/android/installer/package-manifest.in
+++ b/mobile/android/installer/package-manifest.in
@@ -151,18 +151,16 @@
 #endif
 
 @BINPATH@/components/WebVTT.manifest
 @BINPATH@/components/WebVTTParserWrapper.js
 
 #ifndef MOZ_GECKOVIEW_JAR
 #ifdef MOZ_UPDATER
 @BINPATH@/components/nsUpdateService.manifest
-@BINPATH@/components/nsUpdateService.js
-@BINPATH@/components/nsUpdateServiceStub.js
 #endif
 #endif
 
 @BINPATH@/components/ClearDataService.manifest
 @BINPATH@/components/ClearDataService.js
 
 @BINPATH@/components/nsUpdateTimerManager.manifest
 @BINPATH@/components/nsUpdateTimerManager.js
rename from toolkit/mozapps/update/nsUpdateService.js
rename to toolkit/mozapps/update/UpdateService.jsm
--- a/toolkit/mozapps/update/nsUpdateService.js
+++ b/toolkit/mozapps/update/UpdateService.jsm
@@ -4362,10 +4362,9 @@ UpdatePrompt.prototype = {
   },
 
   classDescription: "Update Prompt",
   contractID: "@mozilla.org/updates/update-prompt;1",
   classID: Components.ID("{27ABA825-35B5-4018-9FDD-F99250A0E722}"),
   QueryInterface: ChromeUtils.generateQI([Ci.nsIUpdatePrompt]),
 };
 
-var components = [UpdateService, Checker, UpdatePrompt, UpdateManager];
-this.NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
+var EXPORTED_SYMBOLS = ["UpdateService", "Checker", "UpdatePrompt", "UpdateManager"];
rename from toolkit/mozapps/update/nsUpdateServiceStub.js
rename to toolkit/mozapps/update/UpdateServiceStub.jsm
--- a/toolkit/mozapps/update/nsUpdateServiceStub.js
+++ b/toolkit/mozapps/update/UpdateServiceStub.jsm
@@ -56,17 +56,17 @@ function UpdateServiceStub() {
   }
 }
 UpdateServiceStub.prototype = {
   observe() {},
   classID: Components.ID("{e43b0010-04ba-4da6-b523-1f92580bc150}"),
   QueryInterface: ChromeUtils.generateQI([Ci.nsIObserver]),
 };
 
-this.NSGetFactory = XPCOMUtils.generateNSGetFactory([UpdateServiceStub]);
+var EXPORTED_SYMBOLS = ["UpdateServiceStub"];
 
 /**
  * This function should be called when there are files in the old update
  * directory that may need to be migrated to the new update directory.
  */
 function migrateUpdateDirectory() {
   let sourceRootDir = FileUtils.getDir(KEY_OLD_UPDROOT, [], false);
   let destRootDir = FileUtils.getDir(KEY_UPDROOT, [], false);
new file mode 100644
--- /dev/null
+++ b/toolkit/mozapps/update/components.conf
@@ -0,0 +1,40 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# 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/.
+
+Classes = [
+    {
+        'cid': '{B3C290A6-3943-4B89-8BBE-C01EB7B3B311}',
+        'contract_ids': ['@mozilla.org/updates/update-service;1'],
+        'jsm': 'resource://gre/modules/UpdateService.jsm',
+        'constructor': 'UpdateService',
+    },
+    {
+        'cid': '{093C2356-4843-4C65-8709-D7DBCBBE7DFB}',
+        'contract_ids': ['@mozilla.org/updates/update-manager;1'],
+        'jsm': 'resource://gre/modules/UpdateService.jsm',
+        'constructor': 'UpdateManager',
+    },
+    {
+        'cid': '{898CDC9B-E43F-422F-9CC4-2F6291B415A3}',
+        'contract_ids': ['@mozilla.org/updates/update-checker;1'],
+        'jsm': 'resource://gre/modules/UpdateService.jsm',
+        'constructor': 'Checker',
+    },
+    {
+        'cid': '{27ABA825-35B5-4018-9FDD-F99250A0E722}',
+        'contract_ids': ['@mozilla.org/updates/update-prompt;1'],
+        'jsm': 'resource://gre/modules/UpdateService.jsm',
+        'constructor': 'UpdatePrompt',
+    },
+
+    {
+        'cid': '{e43b0010-04ba-4da6-b523-1f92580bc150}',
+        'contract_ids': ['@mozilla.org/updates/update-service-stub;1'],
+        'jsm': 'resource://gre/modules/UpdateServiceStub.jsm',
+        'constructor': 'UpdateServiceStub',
+        'categories': {'profile-after-change': 'nsUpdateServiceStub'},
+    },
+]
--- a/toolkit/mozapps/update/moz.build
+++ b/toolkit/mozapps/update/moz.build
@@ -12,22 +12,26 @@ DIRS += [
 
 XPIDL_SOURCES += [
     'nsIUpdateService.idl',
 ]
 
 TEST_DIRS += ['tests']
 
 EXTRA_COMPONENTS += [
-    'nsUpdateService.js',
     'nsUpdateService.manifest',
-    'nsUpdateServiceStub.js',
 ]
 
 EXTRA_JS_MODULES += [
     'UpdateListener.jsm',
+    'UpdateService.jsm',
+    'UpdateServiceStub.jsm',
     'UpdateTelemetry.jsm',
 ]
 
+XPCOM_MANIFESTS += [
+    'components.conf',
+]
+
 JAR_MANIFESTS += ['jar.mn']
 
 with Files('**'):
     BUG_COMPONENT = ('Toolkit', 'Application Update')
--- a/toolkit/mozapps/update/nsUpdateService.manifest
+++ b/toolkit/mozapps/update/nsUpdateService.manifest
@@ -1,12 +1,1 @@
-component {B3C290A6-3943-4B89-8BBE-C01EB7B3B311} nsUpdateService.js
-contract @mozilla.org/updates/update-service;1 {B3C290A6-3943-4B89-8BBE-C01EB7B3B311}
 category update-timer nsUpdateService @mozilla.org/updates/update-service;1,getService,background-update-timer,app.update.interval,43200,86400
-component {093C2356-4843-4C65-8709-D7DBCBBE7DFB} nsUpdateService.js
-contract @mozilla.org/updates/update-manager;1 {093C2356-4843-4C65-8709-D7DBCBBE7DFB}
-component {898CDC9B-E43F-422F-9CC4-2F6291B415A3} nsUpdateService.js
-contract @mozilla.org/updates/update-checker;1 {898CDC9B-E43F-422F-9CC4-2F6291B415A3}
-component {27ABA825-35B5-4018-9FDD-F99250A0E722} nsUpdateService.js
-contract @mozilla.org/updates/update-prompt;1 {27ABA825-35B5-4018-9FDD-F99250A0E722}
-component {e43b0010-04ba-4da6-b523-1f92580bc150} nsUpdateServiceStub.js
-contract @mozilla.org/updates/update-service-stub;1 {e43b0010-04ba-4da6-b523-1f92580bc150}
-category profile-after-change nsUpdateServiceStub @mozilla.org/updates/update-service-stub;1