Bug 1059001 - Part 1b: Update openListener callsites. r=past
authorJ. Ryan Stinnett <jryans@gmail.com>
Wed, 10 Dec 2014 20:55:51 -0600
changeset 219130 b16c58046543597ba9b4b6632cbaacf2a32f2814
parent 219129 0a424f45dc2320193ab078a983db4dd3a06f0d01
child 219131 20a3c5ad55c69e9c2f6de60066a3e3951ce15832
push id27956
push userkwierso@gmail.com
push dateFri, 12 Dec 2014 00:47:19 +0000
treeherdermozilla-central@32a2c5bd2f68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspast
bugs1059001
milestone37.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 1059001 - Part 1b: Update openListener callsites. r=past
b2g/chrome/content/desktop.js
b2g/chrome/content/devtools/debugger.js
browser/devtools/debugger/test/browser_dbg_chrome-create.js
browser/devtools/framework/ToolboxProcess.jsm
browser/metro/base/content/browser-ui.js
mobile/android/chrome/content/browser.js
testing/xpcshell/head.js
toolkit/devtools/gcli/commands/listen.js
toolkit/devtools/server/tests/unit/test_dbgglobal.js
toolkit/devtools/transport/tests/unit/head_dbg.js
toolkit/devtools/transport/tests/unit/test_dbgsocket.js
toolkit/devtools/transport/tests/unit/test_dbgsocket_connection_drop.js
webapprt/RemoteDebugger.jsm
--- a/b2g/chrome/content/desktop.js
+++ b/b2g/chrome/content/desktop.js
@@ -51,18 +51,18 @@ function setupButtons() {
     GlobalSimulatorScreen.flipScreen();
     rotateButton.classList.remove('active');
   });
 }
 
 function checkDebuggerPort() {
   // XXX: To be removed once bug 942756 lands.
   // We are hacking 'unix-domain-socket' pref by setting a tcp port (number).
-  // DebuggerServer.openListener detects that it isn't a file path (string),
-  // and starts listening on the tcp port given here as command line argument.
+  // SocketListener.open detects that it isn't a file path (string), and starts
+  // listening on the tcp port given here as command line argument.
 
   // Get the command line arguments that were passed to the b2g client
   let args;
   try {
     let service = Cc["@mozilla.org/commandlinehandler/general-startup;1?type=b2gcmds"].getService(Ci.nsISupports);
     args = service.wrappedJSObject.cmdLine;
   } catch(e) {}
 
--- a/b2g/chrome/content/devtools/debugger.js
+++ b/b2g/chrome/content/devtools/debugger.js
@@ -140,18 +140,20 @@ let USBRemoteDebugger = {
     RemoteDebugger.initServer();
 
     let portOrPath =
       Services.prefs.getCharPref("devtools.debugger.unix-domain-socket") ||
       "/data/local/debugger-socket";
 
     try {
       debug("Starting USB debugger on " + portOrPath);
-      this._listener = DebuggerServer.openListener(portOrPath);
+      this._listener = DebuggerServer.createListener();
+      this._listener.portOrPath = portOrPath;
       this._listener.allowConnection = RemoteDebugger.prompt;
+      this._listener.open();
       // Temporary event, until bug 942756 lands and offers a way to know
       // when the server is up and running.
       Services.obs.notifyObservers(null, "debugger-server-started", null);
     } catch (e) {
       debug("Unable to start USB debugger server: " + e);
     }
   },
 
@@ -176,18 +178,20 @@ let WiFiRemoteDebugger = {
     if (this._listener) {
       return;
     }
 
     RemoteDebugger.initServer();
 
     try {
       debug("Starting WiFi debugger");
-      this._listener = DebuggerServer.openListener(-1);
+      this._listener = DebuggerServer.createListener();
+      this._listener.portOrPath = -1 /* any available port */;
       this._listener.allowConnection = RemoteDebugger.prompt;
+      this._listener.open();
       let port = this._listener.port;
       debug("Started WiFi debugger on " + port);
       discovery.addService("devtools", { port: port });
     } catch (e) {
       debug("Unable to start WiFi debugger server: " + e);
     }
   },
 
--- a/browser/devtools/debugger/test/browser_dbg_chrome-create.js
+++ b/browser/devtools/debugger/test/browser_dbg_chrome-create.js
@@ -5,16 +5,17 @@
  * Tests that a chrome debugger can be created in a new process.
  */
 
 let gProcess;
 
 function test() {
   // Windows XP and 8.1 test slaves are terribly slow at this test.
   requestLongerTimeout(5);
+  Services.prefs.setBoolPref("devtools.debugger.remote-enabled", true);
 
   initChromeDebugger(aOnClose).then(aProcess => {
     gProcess = aProcess;
 
     info("Starting test...");
     performTest();
   });
 }
@@ -51,10 +52,11 @@ function aOnClose() {
   info("process exit value: " + gProcess._dbgProcess.exitValue);
 
   info("profile path: " + gProcess._dbgProfilePath);
 
   finish();
 }
 
 registerCleanupFunction(function() {
+  Services.prefs.clearUserPref("devtools.debugger.remote-enabled");
   gProcess = null;
 });
--- a/browser/devtools/framework/ToolboxProcess.jsm
+++ b/browser/devtools/framework/ToolboxProcess.jsm
@@ -137,17 +137,19 @@ BrowserToolboxProcess.prototype = {
     if (!this.debuggerServer.initialized) {
       this.debuggerServer.init();
       this.debuggerServer.addBrowserActors();
       dumpn("initialized and added the browser actors for the DebuggerServer.");
     }
 
     let chromeDebuggingPort =
       Services.prefs.getIntPref("devtools.debugger.chrome-debugging-port");
-    this.debuggerServer.openListener(chromeDebuggingPort);
+    let listener = this.debuggerServer.createListener();
+    listener.portOrPath = chromeDebuggingPort;
+    listener.open();
 
     dumpn("Finished initializing the chrome toolbox server.");
     dumpn("Started listening on port: " + chromeDebuggingPort);
   },
 
   /**
    * Initializes a profile for the remote debugger process.
    */
--- a/browser/metro/base/content/browser-ui.js
+++ b/browser/metro/base/content/browser-ui.js
@@ -231,17 +231,19 @@ var BrowserUI = {
    */
   runDebugServer: function runDebugServer(aPort) {
     let port = aPort || Services.prefs.getIntPref(debugServerPortChanged);
     if (!DebuggerServer.initialized) {
       DebuggerServer.init();
       DebuggerServer.addBrowserActors();
       DebuggerServer.addActors('chrome://browser/content/dbg-metro-actors.js');
     }
-    DebuggerServer.openListener(port);
+    let listener = DebuggerServer.createListener();
+    listener.portOrPath = port;
+    listener.open();
   },
 
   stopDebugServer: function stopDebugServer() {
     if (DebuggerServer.initialized) {
       DebuggerServer.destroy();
     }
   },
 
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -7350,18 +7350,20 @@ var RemoteDebugger = {
         DebuggerServer.init();
         DebuggerServer.addBrowserActors();
         DebuggerServer.registerModule("resource://gre/modules/dbg-browser-actors.js");
       }
 
       let pathOrPort = this._getPath();
       if (!pathOrPort)
         pathOrPort = this._getPort();
-      let listener = DebuggerServer.openListener(pathOrPort);
+      let listener = DebuggerServer.createListener();
+      listener.portOrPath = pathOrPort;
       listener.allowConnection = this._showConnectionPrompt.bind(this);
+      listener.open();
       dump("Remote debugger listening at path " + pathOrPort);
     } catch(e) {
       dump("Remote debugger didn't start: " + e);
     }
   },
 
   _stop: function rd_start() {
     DebuggerServer.closeAllListeners();
--- a/testing/xpcshell/head.js
+++ b/testing/xpcshell/head.js
@@ -401,18 +401,20 @@ function _initDebugging(port) {
   do_print("*******************************************************************");
   do_print("Waiting for the debugger to connect on port " + port)
   do_print("")
   do_print("To connect the debugger, open a Firefox instance, select 'Connect'");
   do_print("from the Developer menu and specify the port as " + port);
   do_print("*******************************************************************");
   do_print("")
 
-  let listener = DebuggerServer.openListener(port);
+  let listener = DebuggerServer.createListener();
+  listener.portOrPath = port;
   listener.allowConnection = () => true;
+  listener.open();
 
   // spin an event loop until the debugger connects.
   let thr = Components.classes["@mozilla.org/thread-manager;1"]
               .getService().currentThread;
   while (!initialized) {
     do_print("Still waiting for debugger to connect...");
     thr.processNextEvent(true);
   }
--- a/toolkit/devtools/gcli/commands/listen.js
+++ b/toolkit/devtools/gcli/commands/listen.js
@@ -43,21 +43,24 @@ exports.items = [
         type: "number",
         get defaultValue() {
           return Services.prefs.getIntPref("devtools.debugger.chrome-debugging-port");
         },
         description: gcli.lookup("listenPortDesc"),
       }
     ],
     exec: function(args, context) {
-      var reply = debuggerServer.openListener(args.port);
-      if (!reply) {
+      var listener = debuggerServer.createListener();
+      if (!listener) {
         throw new Error(gcli.lookup("listenDisabledOutput"));
       }
 
+      listener.portOrPath = args.port;
+      listener.open();
+
       if (debuggerServer.initialized) {
         return gcli.lookupFormat("listenInitOutput", [ "" + args.port ]);
       }
 
       return gcli.lookup("listenNoInitOutput");
     },
   }
 ];
--- a/toolkit/devtools/server/tests/unit/test_dbgglobal.js
+++ b/toolkit/devtools/server/tests/unit/test_dbgglobal.js
@@ -4,36 +4,36 @@
 Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
 Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
 
 function run_test()
 {
   // Should get an exception if we try to interact with DebuggerServer
   // before we initialize it...
   check_except(function() {
-    DebuggerServer.openListener(-1);
+    DebuggerServer.createListener();
   });
   check_except(DebuggerServer.closeAllListeners);
   check_except(DebuggerServer.connectPipe);
 
   // Allow incoming connections.
   DebuggerServer.init();
 
   // These should still fail because we haven't added a createRootActor
   // implementation yet.
   check_except(function() {
-    DebuggerServer.openListener(-1);
+    DebuggerServer.createListener();
   });
   check_except(DebuggerServer.closeAllListeners);
   check_except(DebuggerServer.connectPipe);
 
   DebuggerServer.registerModule("xpcshell-test/testactors");
 
   // Now they should work.
-  DebuggerServer.openListener(-1);
+  DebuggerServer.createListener();
   DebuggerServer.closeAllListeners();
 
   // Make sure we got the test's root actor all set up.
   let client1 = DebuggerServer.connectPipe();
   client1.hooks = {
     onPacket: function(aPacket1) {
       do_check_eq(aPacket1.from, "root");
       do_check_eq(aPacket1.applicationType, "xpcshell-tests");
--- a/toolkit/devtools/transport/tests/unit/head_dbg.js
+++ b/toolkit/devtools/transport/tests/unit/head_dbg.js
@@ -255,18 +255,20 @@ function writeTestTempFile(aFileName, aC
     stream.close();
   }
 }
 
 /*** Transport Factories ***/
 
 function socket_transport() {
   if (!DebuggerServer.listeningSockets) {
-    let listener = DebuggerServer.openListener(-1);
+    let listener = DebuggerServer.createListener();
+    listener.portOrPath = -1 /* any available port */;
     listener.allowConnection = () => true;
+    listener.open();
   }
   let port = DebuggerServer._listeners[0].port;
   do_print("Debugger server port is " + port);
   return DebuggerClient.socketConnect("127.0.0.1", port);
 }
 
 function local_transport() {
   return DebuggerServer.connectPipe();
--- a/toolkit/devtools/transport/tests/unit/test_dbgsocket.js
+++ b/toolkit/devtools/transport/tests/unit/test_dbgsocket.js
@@ -17,25 +17,29 @@ function run_test()
   add_test(test_pipe_conn);
 
   run_next_test();
 }
 
 function test_socket_conn()
 {
   do_check_eq(DebuggerServer.listeningSockets, 0);
-  let listener = DebuggerServer.openListener(-1);
+  let listener = DebuggerServer.createListener();
+  do_check_true(listener);
+  listener.portOrPath = -1 /* any available port */;
   listener.allowConnection = () => true;
-  do_check_true(listener);
+  listener.open();
   do_check_eq(DebuggerServer.listeningSockets, 1);
   gPort = DebuggerServer._listeners[0].port;
   do_print("Debugger server port is " + gPort);
   // Open a second, separate listener
-  gExtraListener = DebuggerServer.openListener(-1);
+  gExtraListener = DebuggerServer.createListener();
+  gExtraListener.portOrPath = -1;
   gExtraListener.allowConnection = () => true;
+  gExtraListener.open();
   do_check_eq(DebuggerServer.listeningSockets, 2);
 
   do_print("Starting long and unicode tests at " + new Date().toTimeString());
   let unicodeString = "(╯°□°)╯︵ ┻━┻";
   let transport = DebuggerClient.socketConnect("127.0.0.1", gPort);
   transport.hooks = {
     onPacket: function(aPacket) {
       this.onPacket = function(aPacket) {
--- a/toolkit/devtools/transport/tests/unit/test_dbgsocket_connection_drop.js
+++ b/toolkit/devtools/transport/tests/unit/test_dbgsocket_connection_drop.js
@@ -42,18 +42,20 @@ function test_socket_conn_drops_after_to
   let rawPacket = '4305724038957487634549823475894325';
   for (let i = 0; i < 8; i++) {
     rawPacket += rawPacket;
   }
   return test_helper(rawPacket + ':');
 }
 
 function test_helper(payload) {
-  let listener = DebuggerServer.openListener(-1);
+  let listener = DebuggerServer.createListener();
+  listener.portOrPath = -1;
   listener.allowConnection = () => true;
+  listener.open();
 
   let transport = DebuggerClient.socketConnect("127.0.0.1", listener.port);
   transport.hooks = {
     onPacket: function(aPacket) {
       this.onPacket = function(aPacket) {
         do_throw(new Error("This connection should be dropped."));
         transport.close();
       };
--- a/webapprt/RemoteDebugger.jsm
+++ b/webapprt/RemoteDebugger.jsm
@@ -16,11 +16,13 @@ Cu.import('resource://gre/modules/devtoo
 
 this.RemoteDebugger = {
   init: function(port) {
     if (!DebuggerServer.initialized) {
       DebuggerServer.init();
       DebuggerServer.addBrowserActors("webapprt:webapp");
       DebuggerServer.addActors("chrome://webapprt/content/dbg-webapp-actors.js");
     }
-    DebuggerServer.openListener(port);
+    let listener = DebuggerServer.createListener();
+    listener.portOrPath = port;
+    listener.open();
   }
 }