Use a UNIX domain socket for debugger server connections on Android (bug 916777). r=mfinkle
authorPanos Astithas <past@mozilla.com>
Fri, 20 Sep 2013 15:39:23 +0300
changeset 203249 42bdf2b7f26f2a460a5380a240753ad433b1918f
parent 203248 48b63c04b6645e8a78e5f3365e911d879d2d4c74
child 203250 39037aa7ded05cf5c92e40f6cc92102963f8a457
push id27424
push userryanvm@gmail.com
push dateWed, 03 Sep 2014 19:35:53 +0000
treeherdermozilla-central@bfef88becbba [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs916777
milestone35.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
Use a UNIX domain socket for debugger server connections on Android (bug 916777). r=mfinkle
mobile/android/app/mobile.js
mobile/android/app/moz.build
mobile/android/chrome/content/WebappRT.js
mobile/android/chrome/content/browser.js
--- a/mobile/android/app/mobile.js
+++ b/mobile/android/app/mobile.js
@@ -439,16 +439,19 @@ pref("javascript.options.mem.gc_max_empt
 pref("javascript.options.mem.high_water_mark", 32);
 #endif
 
 pref("dom.max_chrome_script_run_time", 0); // disable slow script dialog for chrome
 pref("dom.max_script_run_time", 20);
 
 // JS error console
 pref("devtools.errorconsole.enabled", false);
+// Absolute path to the devtools unix domain socket file used
+// to communicate with a usb cable via adb forward.
+pref("devtools.debugger.unix-domain-socket", "/data/data/@ANDROID_PACKAGE_NAME@/firefox-debugger-socket");
 
 pref("font.size.inflation.minTwips", 120);
 
 // When true, zooming will be enabled on all sites, even ones that declare user-scalable=no.
 pref("browser.ui.zoom.force-user-scalable", false);
 
 // Touch radius (area around the touch location to look for target elements),
 // in 1/240-inch pixels:
--- a/mobile/android/app/moz.build
+++ b/mobile/android/app/moz.build
@@ -2,13 +2,13 @@
 # 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/.
 
 for var in ('APP_NAME', 'APP_VERSION'):
     DEFINES[var] = CONFIG['MOZ_%s' % var]
 
-for var in ('MOZ_UPDATER', 'MOZ_APP_UA_NAME'):
+for var in ('MOZ_UPDATER', 'MOZ_APP_UA_NAME', 'ANDROID_PACKAGE_NAME'):
     DEFINES[var] = CONFIG[var]
 
 if CONFIG['MOZ_PKG_SPECIAL']:
     DEFINES['MOZ_PKG_SPECIAL'] = CONFIG['MOZ_PKG_SPECIAL']
--- a/mobile/android/chrome/content/WebappRT.js
+++ b/mobile/android/chrome/content/WebappRT.js
@@ -144,16 +144,19 @@ let WebappRT = {
     Services.prefs.setBoolPref("devtools.debugger.prompt-connection", false);
 
     // Automagically find a free port and configure the debugger to use it.
     let serv = Cc['@mozilla.org/network/server-socket;1'].createInstance(Ci.nsIServerSocket);
     serv.init(-1, true, -1);
     let port = serv.port;
     serv.close();
     Services.prefs.setIntPref("devtools.debugger.remote-port", port);
+    // Clear the UNIX domain socket path to ensure a TCP socket will be used
+    // instead.
+    Services.prefs.setCharPref("devtools.debugger.unix-domain-socket", "");
 
     Services.prefs.setBoolPref("devtools.debugger.remote-enabled", true);
 
     // Notify the user that we enabled the debugger and which port it's using
     // so they can use the DevTools Connect… dialog to connect the client to it.
     DOMApplicationRegistry.registryReady.then(() => {
       let name;
       let app = DOMApplicationRegistry.getAppByManifestURL(aUrl);
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -7280,31 +7280,36 @@ var RemoteDebugger = {
       case "devtools.debugger.remote-enabled":
         if (this._isEnabled())
           this._start();
         else
           this._stop();
         break;
 
       case "devtools.debugger.remote-port":
+      case "devtools.debugger.unix-domain-socket":
         if (this._isEnabled())
           this._restart();
         break;
     }
   },
 
   uninit: function rd_uninit() {
     Services.prefs.removeObserver("devtools.debugger.", this);
     this._stop();
   },
 
   _getPort: function _rd_getPort() {
     return Services.prefs.getIntPref("devtools.debugger.remote-port");
   },
 
+  _getPath: function _rd_getPath() {
+    return Services.prefs.getCharPref("devtools.debugger.unix-domain-socket");
+  },
+
   _isEnabled: function rd_isEnabled() {
     return Services.prefs.getBoolPref("devtools.debugger.remote-enabled");
   },
 
   /**
    * Prompt the user to accept or decline the incoming connection.
    * This is passed to DebuggerService.init as a callback.
    *
@@ -7356,19 +7361,21 @@ var RemoteDebugger = {
   _start: function rd_start() {
     try {
       if (!DebuggerServer.initialized) {
         DebuggerServer.init(this._showConnectionPrompt.bind(this));
         DebuggerServer.addBrowserActors();
         DebuggerServer.registerModule("resource://gre/modules/dbg-browser-actors.js");
       }
 
-      let port = this._getPort();
-      DebuggerServer.openListener(port);
-      dump("Remote debugger listening on port " + port);
+      let pathOrPort = this._getPath();
+      if (!pathOrPort)
+        pathOrPort = this._getPort();
+      DebuggerServer.openListener(pathOrPort);
+      dump("Remote debugger listening at path " + pathOrPort);
     } catch(e) {
       dump("Remote debugger didn't start: " + e);
     }
   },
 
   _stop: function rd_start() {
     DebuggerServer.closeAllListeners();
     dump("Remote debugger stopped");