Bug 960669 - Close Browser Toolbox on browser shutdown. r=past
authorJ. Ryan Stinnett <jryans@gmail.com>
Fri, 24 Jan 2014 11:29:33 -0600
changeset 165393 13da989bc869632a341b80464d6f7df3126041f8
parent 165392 6dc4806fa8a2669d8d80d10d6bda30fb293097e7
child 165394 a8ef73c97aa6273404bfa5f43a3ce83c56957950
push id26089
push userryanvm@gmail.com
push dateMon, 27 Jan 2014 20:23:17 +0000
treeherdermozilla-central@ba31f271fbd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspast
bugs960669
milestone29.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 960669 - Close Browser Toolbox on browser shutdown. r=past
browser/devtools/framework/ToolboxProcess.jsm
--- a/browser/devtools/framework/ToolboxProcess.jsm
+++ b/browser/devtools/framework/ToolboxProcess.jsm
@@ -27,16 +27,18 @@ this.EXPORTED_SYMBOLS = ["BrowserToolbox
  * @param function aOnRun [optional]
  *        A function called when the process starts running.
  */
 this.BrowserToolboxProcess = function BrowserToolboxProcess(aOnClose, aOnRun) {
   this._closeCallback = aOnClose;
   this._runCallback = aOnRun;
   this._telemetry = new Telemetry();
 
+  this.close = this.close.bind(this);
+  Services.obs.addObserver(this.close, "quit-application", false);
   this._initServer();
   this._initProfile();
   this._create();
 };
 
 /**
  * Initializes and starts a chrome toolbox process.
  * @return object
@@ -149,29 +151,37 @@ BrowserToolboxProcess.prototype = {
 
     dumpn("Chrome toolbox is now running...");
     if (typeof this._runCallback == "function") {
       this._runCallback.call({}, this);
     }
   },
 
   /**
-   * Closes the remote debugger, removing the profile and killing the process.
+   * Closes the remote debugging server and kills the toolbox process.
    */
   close: function() {
+    if (this.closed) {
+      return;
+    }
+
     dumpn("Cleaning up the chrome debugging process.");
+    Services.obs.removeObserver(this.close, "quit-application");
 
     if (this._dbgProcess.isRunning) {
       this._dbgProcess.kill();
     }
 
     this._telemetry.toolClosed("jsbrowserdebugger");
-    this.debuggerServer.destroy();
+    if (this.debuggerServer) {
+      this.debuggerServer.destroy();
+    }
 
     dumpn("Chrome toolbox is now closed...");
+    this.closed = true;
     if (typeof this._closeCallback == "function") {
       this._closeCallback.call({}, this);
     }
   }
 };
 
 /**
  * Shortcuts for accessing various debugger preferences.