Bug 701523 - add initTransport for consumers that don't need the jsdebugger, r=dcamp
authorJonathan Griffin <jgriffin@mozilla.com>
Mon, 14 Nov 2011 21:32:18 -0800
changeset 79649 c0498cb305de
parent 79648 8f6d95ca4d28
child 79650 2a652fe9b4bd
push id76
push userjgriffin@mozilla.com
push dateWed, 16 Nov 2011 00:45:16 +0000
reviewersdcamp
bugs701523
milestone10.0a1
Bug 701523 - add initTransport for consumers that don't need the jsdebugger, r=dcamp
toolkit/devtools/debugger/server/dbg-server.js
--- a/toolkit/devtools/debugger/server/dbg-server.js
+++ b/toolkit/devtools/debugger/server/dbg-server.js
@@ -65,33 +65,45 @@ const ServerSocket = CC("@mozilla.org/ne
                         "nsIServerSocket",
                         "init");
 
 /***
  * Public API
  */
 var DebuggerServer = {
   _listener: null,
-
+  _transportInitialized: false,
   xpcInspector: null,
 
   /**
    * Initialize the debugger server.
    */
   init: function DH_init() {
     if (this.initialized) {
       return;
     }
 
     Cu.import("resource://gre/modules/jsdebugger.jsm");
     this.xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector);
+    this.initTransport();
+    this.addActors("resource:///modules/dbg-script-actors.js");
+  },
+
+  /**
+   * Initialize the debugger server's transport variables.  This can be
+   * in place of init() for cases where the jsdebugger isn't needed.
+   */
+  initTransport: function DH_initTransport() {
+    if (this._transportInitialized) {
+        return;
+    }
+
     this._connections = {};
     this._nextConnID = 0;
-
-    this.addActors("resource:///modules/dbg-script-actors.js");
+    this._transportInitialized = true;
   },
 
   get initialized() { return !!this.xpcInspector; },
 
   /**
    * Load a subscript into the debugging global.
    *
    * @param aURL string A url that will be loaded as a subscript into the
@@ -192,17 +204,17 @@ var DebuggerServer = {
   },
 
   onStopListening: function DH_onStopListening() { },
 
   /**
    * Raises an exception if the server has not been properly initialized.
    */
   _checkInit: function DH_checkInit() {
-    if (!this.xpcInspector) {
+    if (!this._transportInitialized) {
       throw "DebuggerServer has not been initialized.";
     }
 
     if (!this.createRootActor) {
       throw "Use DebuggerServer.addActors() to add a root actor implementation.";
     }
   },