Bug 1515612 - Update Network runtimes after receiving closed event on Debugger client;r=ladybenko,Ola
☠☠ backed out by 5d5c62405e28 ☠ ☠
authorJulian Descottes <jdescottes@mozilla.com>
Wed, 09 Jan 2019 17:14:08 +0000
changeset 510217 97b28c1b8a8595a7e47dc671432ef3d7b3ea8770
parent 510216 eee3227176bb9078ad72a8009fd8e6ec181d273c
child 510218 552427e973d5556a4666f86974f4793af42c97d8
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersladybenko, Ola
bugs1515612
milestone66.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 1515612 - Update Network runtimes after receiving closed event on Debugger client;r=ladybenko,Ola Depends on D15414 Differential Revision: https://phabricator.services.mozilla.com/D15415
devtools/client/aboutdebugging-new/src/actions/runtimes.js
--- a/devtools/client/aboutdebugging-new/src/actions/runtimes.js
+++ b/devtools/client/aboutdebugging-new/src/actions/runtimes.js
@@ -57,21 +57,19 @@ async function getRuntimeInfo(runtime, c
     icon,
     isMultiE10s,
     name,
     type,
     version,
   };
 }
 
-function onUSBDebuggerClientClosed() {
-  // After scanUSBRuntimes action, updateUSBRuntimes action is called.
-  // The closed runtime will be unwatched and disconnected explicitly in the action
-  // if needed.
-  window.AboutDebugging.store.dispatch(Actions.scanUSBRuntimes());
+function onRemoteDebuggerClientClosed() {
+  window.AboutDebugging.onNetworkLocationsUpdated();
+  window.AboutDebugging.onUSBRuntimesUpdated();
 }
 
 function onMultiE10sUpdated() {
   window.AboutDebugging.store.dispatch(updateMultiE10s());
 }
 
 function connectRuntime(id) {
   return async (dispatch, getState) => {
@@ -94,20 +92,20 @@ function connectRuntime(id) {
 
       clientWrapper.addListener("closed", onUSBDebuggerClientClosed);
 
       const deviceFront = await clientWrapper.getFront("device");
       if (deviceFront) {
         deviceFront.on("multi-e10s-updated", onMultiE10sUpdated);
       }
 
-      if (runtime.type === RUNTIMES.USB) {
+      if (runtime.type !== RUNTIMES.THIS_FIREFOX) {
         // `closed` event will be emitted when disabling remote debugging
-        // on the connected USB runtime.
-        clientWrapper.addOneTimeListener("closed", onUSBDebuggerClientClosed);
+        // on the connected remote runtime.
+        clientWrapper.addOneTimeListener("closed", onRemoteDebuggerClientClosed);
       }
 
       dispatch({
         type: CONNECT_RUNTIME_SUCCESS,
         runtime: {
           id,
           runtimeDetails,
           type: runtime.type,
@@ -126,18 +124,18 @@ function disconnectRuntime(id) {
       const runtime = findRuntimeById(id, getState().runtimes);
       const { clientWrapper } = runtime.runtimeDetails;
 
       const deviceFront = await clientWrapper.getFront("device");
       if (deviceFront) {
         deviceFront.off("multi-e10s-updated", onMultiE10sUpdated);
       }
 
-      if (runtime.type === RUNTIMES.USB) {
-        clientWrapper.removeListener("closed", onUSBDebuggerClientClosed);
+      if (runtime.type !== RUNTIMES.THIS_FIREFOX) {
+        clientWrapper.removeListener("closed", onRemoteDebuggerClientClosed);
       }
 
       await clientWrapper.close();
 
       dispatch({
         type: DISCONNECT_RUNTIME_SUCCESS,
         runtime: {
           id,
@@ -329,21 +327,22 @@ function updateRemoteRuntimes(runtimes, 
 
 /**
  * Remove all the listeners added on client objects. Since those objects are persisted
  * regardless of the about:debugging lifecycle, all the added events should be removed
  * before leaving about:debugging.
  */
 function removeRuntimeListeners() {
   return (dispatch, getState) => {
-    const { usbRuntimes } = getState().runtimes;
-    for (const runtime of usbRuntimes) {
+    const allRuntimes = getAllRuntimes(getState().runtimes);
+    const remoteRuntimes = allRuntimes.filter(r => r.type !== RUNTIMES.THIS_FIREFOX);
+    for (const runtime of remoteRuntimes) {
       if (runtime.runtimeDetails) {
         const { clientWrapper } = runtime.runtimeDetails;
-        clientWrapper.removeListener("closed", onUSBDebuggerClientClosed);
+        clientWrapper.removeListener("closed", onRemoteDebuggerClientClosed);
       }
     }
   };
 }
 
 module.exports = {
   connectRuntime,
   disconnectRuntime,