Bug 1515612 - Update Network runtimes after receiving closed event on Debugger client;r=ladybenko,Ola
authorJulian Descottes <jdescottes@mozilla.com>
Thu, 10 Jan 2019 16:53:57 +0000
changeset 510400 9fc243c2626cc267a90912261c4fa09a1f032c90
parent 510399 958fb1212e11be66cd0f12b2fa6689dfdf34af68
child 510401 d19483d0f4110c7f831e26cb195dbe8f2b2e706b
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) => {
@@ -92,20 +90,20 @@ function connectRuntime(id) {
         isMultiE10s,
       };
 
       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,
@@ -124,18 +122,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,
@@ -327,21 +325,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,