Bug 797639 - Part -1: Change forwarding prefix to slash. r=jimb
authorJ. Ryan Stinnett <jryans@gmail.com>
Wed, 14 May 2014 14:30:01 -0500
changeset 183115 f20466641641cd77d850580b860ff85921801082
parent 183114 ccabfe66be68bc7ac43075c1440ff122a1543523
child 183116 463401983c4c95ebe92c63b70de035ae50632d32
push id6799
push userjryans@gmail.com
push dateWed, 14 May 2014 19:31:26 +0000
treeherderfx-team@1f71b3099720 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimb
bugs797639
milestone32.0a1
Bug 797639 - Part -1: Change forwarding prefix to slash. r=jimb
toolkit/devtools/server/main.js
toolkit/devtools/server/tests/unit/test_forwardingprefix.js
--- a/toolkit/devtools/server/main.js
+++ b/toolkit/devtools/server/main.js
@@ -496,17 +496,17 @@ var DebuggerServer = {
 
   /**
    * Creates a new connection to the local debugger speaking over a fake
    * transport. This connection results in straightforward calls to the onPacket
    * handlers of each side.
    *
    * @param aPrefix string [optional]
    *    If given, all actors in this connection will have names starting
-   *    with |aPrefix + ':'|.
+   *    with |aPrefix + '/'|.
    * @returns a client-side DebuggerTransport for communicating with
    *    the newly-created connection.
    */
   connectPipe: function DS_connectPipe(aPrefix) {
     this._checkInit();
 
     let serverTransport = new LocalDebuggerTransport;
     let clientTransport = new LocalDebuggerTransport(serverTransport);
@@ -536,17 +536,17 @@ var DebuggerServer = {
   /**
    * In a content child process, create a new connection that exchanges
    * nsIMessageSender messages with our parent process.
    *
    * @param aPrefix
    *    The prefix we should use in our nsIMessageSender message names and
    *    actor names. This connection will use messages named
    *    "debug:<prefix>:packet", and all its actors will have names
-   *    beginning with "<prefix>:".
+   *    beginning with "<prefix>/".
    */
   connectToParent: function(aPrefix, aMessageManager) {
     this._checkInit();
 
     let transport = new ChildDebuggerTransport(aMessageManager, aPrefix);
     return this._onConnection(transport, aPrefix, true);
   },
 
@@ -686,34 +686,34 @@ var DebuggerServer = {
 
   /**
    * Create a new debugger connection for the given transport. Called after
    * connectPipe(), from connectToParent, or from an incoming socket
    * connection handler.
    *
    * If present, |aForwardingPrefix| is a forwarding prefix that a parent
    * server is using to recognizes messages intended for this server. Ensure
-   * that all our actors have names beginning with |aForwardingPrefix + ':'|.
-   * In particular, the root actor's name will be |aForwardingPrefix + ':root'|.
+   * that all our actors have names beginning with |aForwardingPrefix + '/'|.
+   * In particular, the root actor's name will be |aForwardingPrefix + '/root'|.
    */
   _onConnection: function DS_onConnection(aTransport, aForwardingPrefix, aNoRootActor = false) {
     let connID;
     if (aForwardingPrefix) {
-      connID = aForwardingPrefix + ":";
+      connID = aForwardingPrefix + "/";
     } else {
       connID = "conn" + this._nextConnID++ + '.';
     }
     let conn = new DebuggerServerConnection(connID, aTransport);
     this._connections[connID] = conn;
 
     // Create a root actor for the connection and send the hello packet.
     if (!aNoRootActor) {
       conn.rootActor = this.createRootActor(conn);
       if (aForwardingPrefix)
-        conn.rootActor.actorID = aForwardingPrefix + ":root";
+        conn.rootActor.actorID = aForwardingPrefix + "/root";
       else
         conn.rootActor.actorID = "root";
       conn.addActor(conn.rootActor);
       aTransport.send(conn.rootActor.sayHello());
     }
     aTransport.ready();
 
     this.emit("connectionchange", "opened", conn);
@@ -868,17 +868,17 @@ function DebuggerServerConnection(aPrefi
   // This map stores the latest request promise in the chain, keyed
   // by an actor ID string.
   this._actorResponses = new Map;
 
   /*
    * We can forward packets to other servers, if the actors on that server
    * all use a distinct prefix on their names. This is a map from prefixes
    * to transports: it maps a prefix P to a transport T if T conveys
-   * packets to the server whose actors' names all begin with P + ":".
+   * packets to the server whose actors' names all begin with P + "/".
    */
   this._forwardingPrefixes = new Map;
 }
 
 DebuggerServerConnection.prototype = {
   _prefix: null,
   get prefix() { return this._prefix },
 
@@ -1014,33 +1014,33 @@ DebuggerServerConnection.prototype = {
 
   /* Forwarding packets to other transports based on actor name prefixes. */
 
   /*
    * Arrange to forward packets to another server. This is how we
    * forward debugging connections to child processes.
    *
    * If we receive a packet for an actor whose name begins with |aPrefix|
-   * followed by ':', then we will forward that packet to |aTransport|.
+   * followed by '/', then we will forward that packet to |aTransport|.
    *
    * This overrides any prior forwarding for |aPrefix|.
    *
    * @param aPrefix string
-   *    The actor name prefix, not including the ':'.
+   *    The actor name prefix, not including the '/'.
    * @param aTransport object
    *    A packet transport to which we should forward packets to actors
-   *    whose names begin with |(aPrefix + ':').|
+   *    whose names begin with |(aPrefix + '/').|
    */
   setForwarding: function(aPrefix, aTransport) {
     this._forwardingPrefixes.set(aPrefix, aTransport);
   },
 
   /*
    * Stop forwarding messages to actors whose names begin with
-   * |aPrefix+':'|. Such messages will now elicit 'noSuchActor' errors.
+   * |aPrefix+'/'|. Such messages will now elicit 'noSuchActor' errors.
    */
   cancelForwarding: function(aPrefix) {
     this._forwardingPrefixes.delete(aPrefix);
   },
 
   // Transport hooks.
 
   /**
@@ -1052,19 +1052,19 @@ DebuggerServerConnection.prototype = {
   onPacket: function DSC_onPacket(aPacket) {
     // If the actor's name begins with a prefix we've been asked to
     // forward, do so.
     //
     // Note that the presence of a prefix alone doesn't indicate that
     // forwarding is needed: in DebuggerServerConnection instances in child
     // processes, every actor has a prefixed name.
     if (this._forwardingPrefixes.size > 0) {
-      let colon = aPacket.to.indexOf(':');
-      if (colon >= 0) {
-        let forwardTo = this._forwardingPrefixes.get(aPacket.to.substring(0, colon));
+      let separator = aPacket.to.indexOf('/');
+      if (separator >= 0) {
+        let forwardTo = this._forwardingPrefixes.get(aPacket.to.substring(0, separator));
         if (forwardTo) {
           forwardTo.send(aPacket);
           return;
         }
       }
     }
 
     let actor = this.getActor(aPacket.to);
--- a/toolkit/devtools/server/tests/unit/test_forwardingprefix.js
+++ b/toolkit/devtools/server/tests/unit/test_forwardingprefix.js
@@ -24,17 +24,17 @@ function run_test()
 
 /*
  * Create a pipe connection, and return an object |{ conn, transport }|,
  * where |conn| is the new DebuggerServerConnection instance, and
  * |transport| is the client side of the transport on which it communicates
  * (that is, packets sent on |transport| go to the new connection, and
  * |transport|'s hooks receive replies).
  *
- * |aPrefix| is optional; if present, it's the prefix (minus the ':') for
+ * |aPrefix| is optional; if present, it's the prefix (minus the '/') for
  * actors in the new connection.
  */
 function newConnection(aPrefix)
 {
   var conn;
   DebuggerServer.createRootActor = function (aConn) {
     conn = aConn;
     return new RootActor(aConn, {});
@@ -51,34 +51,34 @@ function createMainConnection()
   ({ conn: gMainConnection, transport: gMainTransport }) = newConnection();
   gClient = new DebuggerClient(gMainTransport);
   gClient.connect((aType, aTraits) => run_next_test());
 }
 
 /*
  * Exchange 'echo' messages with five actors:
  * - root
- * - prefix1:root
- * - prefix1:actor
- * - prefix2:root
- * - prefix2:actor
+ * - prefix1/root
+ * - prefix1/actor
+ * - prefix2/root
+ * - prefix2/actor
  *
  * Expect proper echos from those named in |aReachables|, and 'noSuchActor'
  * errors from the others. When we've gotten all our replies (errors or
  * otherwise), call |aCompleted|.
  *
  * To avoid deep stacks, we call aCompleted from the next tick.
  */
 function tryActors(aReachables, aCompleted) {
   let count = 0;
 
   let outerActor;
   for (outerActor of [ 'root',
-                       'prefix1:root', 'prefix1:actor',
-                       'prefix2:root', 'prefix2:actor' ]) {
+                       'prefix1/root', 'prefix1/actor',
+                       'prefix2/root', 'prefix2/actor' ]) {
     /*
      * Let each callback capture its own iteration's value; outerActor is
      * local to the whole loop, not to a single iteration.
      */
     let actor = outerActor;
 
     count++;
 
@@ -103,17 +103,17 @@ function tryActors(aReachables, aComplet
 function TestNoForwardingYet()
 {
   tryActors(Set(['root']), run_next_test);
 }
 
 /*
  * Create a new pipe connection which forwards its reply packets to
  * gMainConnection's client, and to which gMainConnection forwards packets
- * directed to actors whose names begin with |aPrefix + ':'|, and.
+ * directed to actors whose names begin with |aPrefix + '/'|, and.
  *
  * Return an object { conn, transport }, as for newConnection.
  */
 function newSubconnection(aPrefix)
 {
   let { conn, transport } = newConnection(aPrefix);
   transport.hooks = {
     onPacket: (aPacket) => gMainConnection.send(aPacket),
@@ -125,37 +125,37 @@ function newSubconnection(aPrefix)
 }
 
 /* Create a second root actor, to which we can forward things. */
 function createSubconnection1()
 {
   let { conn, transport } = newSubconnection('prefix1');
   gSubconnection1 = conn;
   transport.ready();
-  gClient.expectReply('prefix1:root', (aReply) => run_next_test());
+  gClient.expectReply('prefix1/root', (aReply) => run_next_test());
 }
 
 // Establish forwarding, but don't put any actors in that server.
 function TestForwardPrefix1OnlyRoot()
 {
-  tryActors(Set(['root', 'prefix1:root']), run_next_test);
+  tryActors(Set(['root', 'prefix1/root']), run_next_test);
 }
 
 /* Create a third root actor, to which we can forward things. */
 function createSubconnection2()
 {
   let { conn, transport } = newSubconnection('prefix2');
   gSubconnection2 = conn;
   transport.ready();
-  gClient.expectReply('prefix2:root', (aReply) => run_next_test());
+  gClient.expectReply('prefix2/root', (aReply) => run_next_test());
 }
 
 function TestForwardPrefix12OnlyRoot()
 {
-  tryActors(Set(['root', 'prefix1:root', 'prefix2:root']), run_next_test);
+  tryActors(Set(['root', 'prefix1/root', 'prefix2/root']), run_next_test);
 }
 
 // A dumb actor that implements 'echo'.
 //
 // It's okay that both subconnections' actors behave identically, because
 // the reply-sending code attaches the replying actor's name to the packet,
 // so simply matching the 'from' field in the reply ensures that we heard
 // from the right actor.
@@ -173,22 +173,22 @@ EchoActor.prototype.onEcho = function (a
 };
 EchoActor.prototype.requestTypes = {
   "echo": EchoActor.prototype.onEcho
 };
 
 function TestForwardPrefix12WithActor1()
 {
   let actor = new EchoActor(gSubconnection1)
-  actor.actorID = 'prefix1:actor';
+  actor.actorID = 'prefix1/actor';
   gSubconnection1.addActor(actor);
 
-  tryActors(Set(['root', 'prefix1:root', 'prefix1:actor', 'prefix2:root']), run_next_test);
+  tryActors(Set(['root', 'prefix1/root', 'prefix1/actor', 'prefix2/root']), run_next_test);
 }
 
 function TestForwardPrefix12WithActor12()
 {
   let actor = new EchoActor(gSubconnection2)
-  actor.actorID = 'prefix2:actor';
+  actor.actorID = 'prefix2/actor';
   gSubconnection2.addActor(actor);
 
-  tryActors(Set(['root', 'prefix1:root', 'prefix1:actor', 'prefix2:root', 'prefix2:actor']), run_next_test);
+  tryActors(Set(['root', 'prefix1/root', 'prefix1/actor', 'prefix2/root', 'prefix2/actor']), run_next_test);
 }