Bug 1446222 - Move DevTools worker startup to new dir. r=jdescottes draft
authorJ. Ryan Stinnett <jryans@gmail.com>
Mon, 19 Mar 2018 22:14:08 -0500
changeset 770150 c8a6f9b9172598016637f49d450d37d728286393
parent 770149 ac798c62f0813110a1d0d21ab99dc96b7c4bbf99
push id103347
push userbmo:jryans@gmail.com
push dateTue, 20 Mar 2018 20:50:57 +0000
reviewersjdescottes
bugs1446222
milestone61.0a1
Bug 1446222 - Move DevTools worker startup to new dir. r=jdescottes Move and rename the server's worker debugger script that starts DevTools for a worker from `worker.js` to `startup/worker.js`. These code paths will likely change more as Site Isolation work continues, but for now, we have this light cleanup to gather startup-related paths together. MozReview-Commit-ID: EvzDSGnG1vU
devtools/server/main.js
devtools/server/moz.build
devtools/server/startup/moz.build
devtools/server/startup/worker.js
devtools/server/worker.js
--- a/devtools/server/main.js
+++ b/devtools/server/main.js
@@ -774,21 +774,25 @@ var DebuggerServer = {
       });
       Services.obs.addObserver(onMessageManagerClose,
                                "message-manager-close");
 
       EventEmitter.on(connection, "closed", onClose);
     });
   },
 
+  /**
+   * Start a DevTools server in a worker and add it as a child server for an active
+   * connection.
+   */
   connectToWorker(connection, dbg, id, options) {
     return new Promise((resolve, reject) => {
       // Step 1: Ensure the worker debugger is initialized.
       if (!dbg.isInitialized) {
-        dbg.initialize("resource://devtools/server/worker.js");
+        dbg.initialize("resource://devtools/server/startup/worker.js");
 
         // Create a listener for rpc requests from the worker debugger. Only do
         // this once, when the worker debugger is first initialized, rather than
         // for each connection.
         let listener = {
           onClose: () => {
             dbg.removeListener(listener);
           },
--- a/devtools/server/moz.build
+++ b/devtools/server/moz.build
@@ -14,13 +14,12 @@ DIRS += [
 ]
 
 BROWSER_CHROME_MANIFESTS += ['tests/browser/browser.ini']
 MOCHITEST_CHROME_MANIFESTS += ['tests/mochitest/chrome.ini']
 XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini']
 
 DevToolsModules(
     'main.js',
-    'worker.js'
 )
 
 with Files('**'):
     BUG_COMPONENT = ('Firefox', 'Developer Tools')
--- a/devtools/server/startup/moz.build
+++ b/devtools/server/startup/moz.build
@@ -3,9 +3,10 @@
 # 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/.
 
 DevToolsModules(
     'content-process.js',
     'content-process.jsm',
     'frame.js',
+    'worker.js',
 )
rename from devtools/server/worker.js
rename to devtools/server/startup/worker.js
--- a/devtools/server/worker.js
+++ b/devtools/server/startup/worker.js
@@ -2,16 +2,22 @@
  * 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";
 
 /* eslint-env mozilla/chrome-worker */
 /* global worker, loadSubScript, global */
 
+/*
+ * Worker debugger script that listens for requests to start a `DebuggerServer` for a
+ * worker in a process.  Loaded into a specific worker during
+ * `DebuggerServer.connectToWorker` which is called from the same process as the worker.
+ */
+
 // This function is used to do remote procedure calls from the worker to the
 // main thread. It is exposed as a built-in global to every module by the
 // worker loader. To make sure the worker loader can access it, it needs to be
 // defined before loading the worker loader script below.
 this.rpc = function(method, ...params) {
   let id = nextId++;
 
   postMessage(JSON.stringify({