Bug 1473513 - reduce number of poolFor calls; r=ochameau
authoryulia <ystartsev@mozilla.com>
Wed, 26 Sep 2018 10:08:10 +0200
changeset 486835 479aed56444800862b7d74b08c290be2031f0e84
parent 486834 04e64ca2ad0f3f4042d657d67f485c5a5c480061
child 486836 ee1f0957ef4d1782f26d5f5a018addcaa70ff5f2
push id246
push userfmarier@mozilla.com
push dateSat, 13 Oct 2018 00:15:40 +0000
reviewersochameau
bugs1473513
milestone64.0a1
Bug 1473513 - reduce number of poolFor calls; r=ochameau Summary: MozReview-Commit-ID: 9VqKPauAP9j Depends on D6475 Reviewers: ochameau Reviewed By: ochameau Bug #: 1473513 Differential Revision: https://phabricator.services.mozilla.com/D6476
devtools/shared/protocol.js
--- a/devtools/shared/protocol.js
+++ b/devtools/shared/protocol.js
@@ -854,26 +854,28 @@ Pool.prototype = extend(EventEmitter.pro
   },
 
   /**
    * Add an actor as a child of this pool.
    */
   manage: function(actor) {
     if (!actor.actorID) {
       actor.actorID = this.conn.allocID(actor.actorPrefix || actor.typeName);
-    }
+    } else {
+      // If the actor is already registerd in a pool, remove it without destroying it.
+      // This happens for example when an addon is reloaded. To see this behavior, take a
+      // look at devtools/server/tests/unit/test_addon_reload.js
 
-    // If the actor is already in a pool, remove it without destroying it.
-    // TODO: not all actors have been moved to protocol.js, so they do not all have
-    // a parent field. Remove the check for the parent once the conversion is finished
-    const parent = this.poolFor(actor.actorID);
-    if (parent) {
-      parent.unmanage(actor);
+      // TODO: not all actors have been moved to protocol.js, so they do not all have
+      // a parent field. Remove the check for the parent once the conversion is finished
+      const parent = this.poolFor(actor.actorID);
+      if (parent) {
+        parent.unmanage(actor);
+      }
     }
-
     this._poolMap.set(actor.actorID, actor);
     return actor;
   },
 
   /**
    * Remove an actor as a child of this pool.
    */
   unmanage: function(actor) {