Index: third_party/WebKit/Source/devtools/front_end/sdk/TargetManager.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/TargetManager.js b/third_party/WebKit/Source/devtools/front_end/sdk/TargetManager.js |
index 2275b7510298cf99521c8868deb7d08444726a3f..e4b313d5702daa35d17984f9f4ef61266a903abb 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/sdk/TargetManager.js |
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/TargetManager.js |
@@ -457,10 +457,8 @@ SDK.ChildTargetManager = class { |
InspectorFrontendHostAPI.Events.DevicesDiscoveryConfigChanged, this._devicesDiscoveryConfigChanged, this); |
} |
- // TODO(dgozman): this is O(n^2) when removing main target. |
- var childTargets = this._targetManager._targets.filter(child => child.parentTarget() === this._parentTarget); |
- for (var child of childTargets) |
- this.detachedFromTarget(child.id()); |
+ for (var sessionId of Array.from(this._childConnections.keys())) |
caseq
2017/06/27 18:29:30
drop Array.from()
|
+ this.detachedFromTarget(sessionId); |
} |
/** |
@@ -510,10 +508,11 @@ SDK.ChildTargetManager = class { |
/** |
* @override |
+ * @param {string} sessionId |
* @param {!Protocol.Target.TargetInfo} targetInfo |
* @param {boolean} waitingForDebugger |
*/ |
- attachedToTarget(targetInfo, waitingForDebugger) { |
+ attachedToTarget(sessionId, targetInfo, waitingForDebugger) { |
var targetName = ''; |
if (targetInfo.type === 'node') { |
targetName = Common.UIString('Node.js: %s', targetInfo.url); |
@@ -524,7 +523,7 @@ SDK.ChildTargetManager = class { |
} |
var target = this._targetManager.createTarget( |
targetInfo.targetId, targetName, this._capabilitiesForType(targetInfo.type), |
- this._createChildConnection.bind(this, this._targetAgent, targetInfo.targetId), this._parentTarget); |
+ this._createChildConnection.bind(this, this._targetAgent, sessionId), this._parentTarget); |
// Only pause the new worker if debugging SW - we are going through the pause on start checkbox. |
if (!this._parentTarget.parentTarget() && Runtime.queryParam('isSharedWorker') && waitingForDebugger) { |
@@ -540,33 +539,33 @@ SDK.ChildTargetManager = class { |
/** |
* @override |
- * @param {string} childTargetId |
+ * @param {string} sessionId |
*/ |
- detachedFromTarget(childTargetId) { |
- this._childConnections.get(childTargetId)._onDisconnect.call(null, 'target terminated'); |
- this._childConnections.delete(childTargetId); |
+ detachedFromTarget(sessionId) { |
+ this._childConnections.get(sessionId)._onDisconnect.call(null, 'target terminated'); |
+ this._childConnections.delete(sessionId); |
} |
/** |
* @override |
- * @param {string} childTargetId |
+ * @param {string} sessionId |
* @param {string} message |
*/ |
- receivedMessageFromTarget(childTargetId, message) { |
- var connection = this._childConnections.get(childTargetId); |
+ receivedMessageFromTarget(sessionId, message) { |
+ var connection = this._childConnections.get(sessionId); |
if (connection) |
connection._onMessage.call(null, message); |
} |
/** |
* @param {!Protocol.TargetAgent} agent |
- * @param {string} childTargetId |
+ * @param {string} sessionId |
* @param {!Protocol.InspectorBackend.Connection.Params} params |
* @return {!Protocol.InspectorBackend.Connection} |
*/ |
- _createChildConnection(agent, childTargetId, params) { |
- var connection = new SDK.ChildConnection(agent, childTargetId, params); |
- this._childConnections.set(childTargetId, connection); |
+ _createChildConnection(agent, sessionId, params) { |
+ var connection = new SDK.ChildConnection(agent, sessionId, params); |
+ this._childConnections.set(sessionId, connection); |
return connection; |
} |
}; |
@@ -577,12 +576,12 @@ SDK.ChildTargetManager = class { |
SDK.ChildConnection = class { |
/** |
* @param {!Protocol.TargetAgent} agent |
- * @param {string} targetId |
+ * @param {string} sessionId |
* @param {!Protocol.InspectorBackend.Connection.Params} params |
*/ |
- constructor(agent, targetId, params) { |
+ constructor(agent, sessionId, params) { |
this._agent = agent; |
- this._targetId = targetId; |
+ this._sessionId = sessionId; |
this._onMessage = params.onMessage; |
this._onDisconnect = params.onDisconnect; |
} |
@@ -592,7 +591,7 @@ SDK.ChildConnection = class { |
* @param {string} message |
*/ |
sendMessage(message) { |
- this._agent.sendMessageToTarget(this._targetId, message); |
+ this._agent.sendMessageToTarget(this._sessionId, message); |
} |
/** |