Bug 1225492 - Listen to events on the ThreadClient instead of re-emitting them on the target; r=jdescottes
authoryulia <ystartsev@mozilla.com>
Wed, 15 May 2019 08:26:08 +0000
changeset 474042 e55213bb470a88e0bd26a75b91497235fd3e9d97
parent 474041 1e82c40506077c6d5864a658b3585b0b2f2d8631
child 474043 7811523177894d6658e481200b644686126d7fd1
push id36022
push userncsoregi@mozilla.com
push dateThu, 16 May 2019 21:55:16 +0000
treeherdermozilla-central@96802be91766 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1225492
milestone68.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 1225492 - Listen to events on the ThreadClient instead of re-emitting them on the target; r=jdescottes As per the bug description, this removes some old code that relied on the target re-emitting threadClient events. Now we simply listen to the threadClient events directly. Differential Revision: https://phabricator.services.mozilla.com/D29162
devtools/client/framework/attach-thread.js
devtools/client/framework/toolbox-process-window.js
--- a/devtools/client/framework/attach-thread.js
+++ b/devtools/client/framework/attach-thread.js
@@ -10,21 +10,16 @@ const L10N = new LocalizationHelper("dev
 
 function handleThreadState(toolbox, event, packet) {
   // Suppress interrupted events by default because the thread is
   // paused/resumed a lot for various actions.
   if (event === "paused" && packet.why.type === "interrupted") {
     return;
   }
 
-  // TODO: Bug 1225492, we continue emitting events on the target
-  // like we used to, but we should emit these only on the
-  // threadClient now.
-  toolbox.target.emit("thread-" + event);
-
   if (event === "paused") {
     toolbox.highlightTool("jsdebugger");
 
     if (packet.why.type === "debuggerStatement" ||
        packet.why.type === "breakpoint" ||
        packet.why.type === "exception") {
       toolbox.raise();
       toolbox.selectTool("jsdebugger", packet.why.type);
--- a/devtools/client/framework/toolbox-process-window.js
+++ b/devtools/client/framework/toolbox-process-window.js
@@ -195,24 +195,30 @@ async function bindToolboxHandlers() {
     const panel = await gToolbox.getPanelWhenReady("jsdebugger");
     setupThreadListeners(panel);
   }
 }
 
 function setupThreadListeners(panel) {
   updateBadgeText(panel.isPaused());
 
-  const onPaused = updateBadgeText.bind(null, true);
+  const onPaused = packet => {
+    if (packet.why.type === "interrupted") {
+      return;
+    }
+    updateBadgeText(true);
+  };
   const onResumed = updateBadgeText.bind(null, false);
-  gToolbox.target.on("thread-paused", onPaused);
-  gToolbox.target.on("thread-resumed", onResumed);
+  const threadClient = gToolbox.target.threadClient;
+  threadClient.addListener("paused", onPaused);
+  threadClient.addListener("resumed", onResumed);
 
   panel.once("destroyed", () => {
-    gToolbox.target.off("thread-paused", onPaused);
-    gToolbox.target.off("thread-resumed", onResumed);
+    threadClient.removeListener("paused", onPaused);
+    threadClient.removeListener("resumed", onResumed);
   });
 }
 
 function updateBadgeText(paused) {
   const dockSupport = Cc["@mozilla.org/widget/macdocksupport;1"]
     .getService(Ci.nsIMacDockSupport);
   dockSupport.badgeText = paused ? "▐▐ " : " ▶";
 }