Bug 1536862 - Register RemoteAgent JS XPCOM by using new registration method. r=ato
authorAlexandre Poirot <poirot.alex@gmail.com>
Wed, 26 Jun 2019 20:25:43 +0000
changeset 480359 d891eef5e1f471c71c99f9d7450d7f019cf8e148
parent 480358 89d1a2584683d3159cf1ed79a73e83bc04263775
child 480360 ef2895162f2f01e78483f511386166c6cf03b086
push id88640
push userapoirot@mozilla.com
push dateThu, 27 Jun 2019 12:35:41 +0000
treeherderautoland@d891eef5e1f4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato
bugs1536862
milestone69.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 1536862 - Register RemoteAgent JS XPCOM by using new registration method. r=ato Differential Revision: https://phabricator.services.mozilla.com/D24228
browser/installer/package-manifest.in
remote/RemoteAgent.conf
remote/RemoteAgent.jsm
remote/RemoteAgent.manifest
remote/command-line-handler.js
remote/moz.build
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -191,18 +191,16 @@
 
 @RESPATH@/components/l10n-registry.manifest
 @RESPATH@/browser/components/l10n-registry.manifest
 
 ; CDP remote agent
 #ifdef ENABLE_REMOTE_AGENT
 @RESPATH@/chrome/remote@JAREXT@
 @RESPATH@/chrome/remote.manifest
-@RESPATH@/components/command-line-handler.js
-@RESPATH@/components/RemoteAgent.manifest
 @RESPATH@/defaults/pref/remote.js
 #endif
 
 ; Marionette remote control protocol
 #ifdef ENABLE_MARIONETTE
 @RESPATH@/chrome/marionette@JAREXT@
 @RESPATH@/chrome/marionette.manifest
 @RESPATH@/components/marionette.manifest
new file mode 100644
--- /dev/null
+++ b/remote/RemoteAgent.conf
@@ -0,0 +1,15 @@
+# -*- 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': '{8f685a9d-8181-46d6-a71d-869289099c6d}',
+        'contract_ids': ['@mozilla.org/remote/agent'],
+        'jsm': 'chrome://remote/content/RemoteAgent.jsm',
+        'constructor': 'RemoteAgentFactory',
+        'categories': {'command-line-handler': 'm-remote'},
+    },
+]
--- a/remote/RemoteAgent.jsm
+++ b/remote/RemoteAgent.jsm
@@ -1,15 +1,15 @@
 /* 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/. */
 
 "use strict";
 
-var EXPORTED_SYMBOLS = ["RemoteAgent"];
+var EXPORTED_SYMBOLS = ["RemoteAgent", "RemoteAgentFactory"];
 
 const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetters(this, {
   FatalError: "chrome://remote/content/Error.jsm",
   HttpServer: "chrome://remote/content/server/HTTPD.jsm",
   JSONHandler: "chrome://remote/content/JSONHandler.jsm",
@@ -214,8 +214,13 @@ class RemoteAgentClass {
   // XPCOM
 
   get QueryInterface() {
     return ChromeUtils.generateQI([Ci.nsICommandLineHandler]);
   }
 }
 
 var RemoteAgent = new RemoteAgentClass();
+
+// This is used by the XPCOM codepath which expects a constructor
+var RemoteAgentFactory = function() {
+  return RemoteAgent;
+};
deleted file mode 100644
--- a/remote/RemoteAgent.manifest
+++ /dev/null
@@ -1,3 +0,0 @@
-component {8f685a9d-8181-46d6-a71d-869289099c6d} command-line-handler.js
-contract @mozilla.org/remote/agent {8f685a9d-8181-46d6-a71d-869289099c6d}
-category command-line-handler m-remote @mozilla.org/remote/agent
deleted file mode 100644
--- a/remote/command-line-handler.js
+++ /dev/null
@@ -1,38 +0,0 @@
-/* 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/. */
-
-"use strict";
-
-// Stopgap module until we can land bug 1536862 and remove this temporary file
-
-const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
-const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-
-ChromeUtils.defineModuleGetter(this, "RemoteAgent",
-    "chrome://remote/content/RemoteAgent.jsm");
-
-const RemoteAgentFactory = {
-  createInstance(outer, iid) {
-    if (outer) {
-      throw Cr.NS_ERROR_NO_AGGREGATION;
-    }
-    // we can't use Preferences.jsm before first paint
-    if (!Services.prefs.getBoolPref("remote.enabled")) {
-      return {};
-    }
-
-    return RemoteAgent.QueryInterface(iid);
-  },
-};
-
-function RemoteAgentComponent() {}
-
-RemoteAgentComponent.prototype = {
-    classDescription: "Remote Agent",
-    classID: Components.ID("{8f685a9d-8181-46d6-a71d-869289099c6d}"),
-    contractID: "@mozilla.org/remote/agent",
-    _xpcom_factory: RemoteAgentFactory,  /* eslint-disable-line */
-};
-
-this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RemoteAgentComponent]);
--- a/remote/moz.build
+++ b/remote/moz.build
@@ -2,19 +2,18 @@
 # 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/.
 
 DIRS += [
   "pref",
   "test",
 ]
 
-EXTRA_COMPONENTS += [
-    "command-line-handler.js",
-    "RemoteAgent.manifest",
+XPCOM_MANIFESTS += [
+  "RemoteAgent.conf",
 ]
 
 JAR_MANIFESTS += ["jar.mn"]
 
 with Files("**"):
     BUG_COMPONENT = ("Remote Protocol", "Agent")
 with Files("domains/**/Emulation.jsm"):
     BUG_COMPONENT = ("Remote Protocol", "Emulation")