Bug 865328: Close console clients by building a chain of continuations. r=msucan
authorJim Blandy <jimb@mozilla.com>
Tue, 30 Apr 2013 15:18:05 -0700
changeset 130405 de9d4e1505a9322a4ec739fa58dc62f35bdc114f
parent 130404 6f094b0083d34e8d650921fe01bff4ace607534f
child 130406 40437cd7395bf12bab86634513e6e245c6030911
push id27349
push userjblandy@mozilla.com
push dateTue, 30 Apr 2013 22:18:31 +0000
treeherdermozilla-inbound@de9d4e1505a9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmsucan
bugs865328
milestone23.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 865328: Close console clients by building a chain of continuations. r=msucan
toolkit/devtools/debugger/dbg-client.jsm
--- a/toolkit/devtools/debugger/dbg-client.jsm
+++ b/toolkit/devtools/debugger/dbg-client.jsm
@@ -345,36 +345,27 @@ DebuggerClient.prototype = {
     if (aOnClosed) {
       this.addOneTimeListener('closed', function(aEvent) {
         aOnClosed();
       });
     }
 
     let self = this;
 
-    let consolesClosed = 0;
-    let consolesToClose = 0;
-
-    for each (let client in this._consoleClients) {
-      consolesToClose++;
-      client.close(onConsoleClose);
-    }
-
-    if (!consolesToClose) {
+    let continuation = function () {
+      self._consoleClients = {};
       detachThread();
     }
 
-    function onConsoleClose() {
-      consolesClosed++;
-      if (consolesClosed >= consolesToClose) {
-        self._consoleClients = {};
-        detachThread();
-      }
+    for each (let client in this._consoleClients) {
+      continuation = client.close.bind(client, continuation);
     }
 
+    continuation();
+
     function detachThread() {
       if (self.activeThread) {
         self.activeThread.detach(detachTab);
       } else {
         detachTab();
       }
     }