Bug 815522 - Start and stop the remote debugger without restarting b2g itself [r=past]
authorFabrice Desré <fabrice@mozilla.com>
Wed, 28 Nov 2012 02:48:10 -0800
changeset 114353 4dd422e2f0c926cf6fc2e1f37052d34bad6a1a23
parent 114352 50dd9b85d1b1741117a4d737a9d6e24b7986b721
child 114355 6b229b34c04639941c5dd7d141fea9edfddc438d
push id18713
push userfdesre@mozilla.com
push dateWed, 28 Nov 2012 10:48:21 +0000
treeherdermozilla-inbound@4dd422e2f0c9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspast
bugs815522
milestone20.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 815522 - Start and stop the remote debugger without restarting b2g itself [r=past]
b2g/chrome/content/settings.js
b2g/chrome/content/shell.js
--- a/b2g/chrome/content/settings.js
+++ b/b2g/chrome/content/settings.js
@@ -197,28 +197,17 @@ Components.utils.import('resource://gre/
   lock.set('deviceinfo.hardware', hardware_version, null, null);
 })();
 
 // =================== Debugger ====================
 SettingsListener.observe('devtools.debugger.remote-enabled', false, function(value) {
   Services.prefs.setBoolPref('devtools.debugger.remote-enabled', value);
   // This preference is consulted during startup
   Services.prefs.savePrefFile(null);
-});
-
-SettingsListener.observe('devtools.debugger.log', false, function(value) {
-  Services.prefs.setBoolPref('devtools.debugger.log', value);
-});
-
-SettingsListener.observe('devtools.debugger.remote-port', 6000, function(value) {
-  Services.prefs.setIntPref('devtools.debugger.remote-port', value);
-});
-
-SettingsListener.observe('devtools.debugger.force-local', true, function(value) {
-  Services.prefs.setBoolPref('devtools.debugger.force-local', value);
+  value ? startDebugger() : stopDebugger();
 });
 
 SettingsListener.observe('debug.log-animations.enabled', false, function(value) {
   Services.prefs.setBoolPref('layers.offmainthreadcomposition.log-animations', value);
 });
 
 SettingsListener.observe('debug.dev-mode', false, function(value) {
   Services.prefs.setBoolPref('dom.mozApps.dev_mode', value);
--- a/b2g/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -725,21 +725,27 @@ function startDebugger() {
   let port = Services.prefs.getIntPref('devtools.debugger.remote-port') || 6000;
   try {
     DebuggerServer.openListener(port);
   } catch (e) {
     dump('Unable to start debugger server: ' + e + '\n');
   }
 }
 
-window.addEventListener('ContentStart', function(evt) {
-  if (Services.prefs.getBoolPref('devtools.debugger.remote-enabled')) {
-    startDebugger();
+function stopDebugger() {
+  if (!DebuggerServer.initialized) {
+    return;
   }
-});
+
+  try {
+    DebuggerServer.closeListener();
+  } catch (e) {
+    dump('Unable to stop debugger server: ' + e + '\n');
+  }
+}
 
 // This is the backend for Gaia's screenshot feature.  Gaia requests a
 // screenshot by sending a mozContentEvent with detail.type set to
 // 'take-screenshot'.  Then we take a screenshot and send a
 // mozChromeEvent with detail.type set to 'take-screenshot-success'
 // and detail.file set to the an image/png blob
 window.addEventListener('ContentStart', function ss_onContentStart() {
   let content = shell.contentBrowser.contentWindow;