| 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 699286ccf95613febd9ce5a0e3aa9a9d034a38ba..763c77fcea43cede7fe4ca56c72c8a371cdef5d7 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/sdk/TargetManager.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/sdk/TargetManager.js
|
| @@ -14,7 +14,7 @@ SDK.TargetManager = class extends Common.Object {
|
| this._observerCapabiliesMaskSymbol = Symbol('observerCapabilitiesMask');
|
| /** @type {!Map<symbol, !Array<{modelClass: !Function, thisObject: (!Object|undefined), listener: function(!Common.Event)}>>} */
|
| this._modelListeners = new Map();
|
| - /** @type {!Map<function(new:SDK.SDKModel, !SDK.Target), !Array<!SDK.SDKModelObserver>>} */
|
| + /** @type {!Map<function(new:SDK.SDKModel, !SDK.Target, !Protocol.Dispatcher), !Array<!SDK.SDKModelObserver>>} */
|
| this._modelObservers = new Map();
|
| this._isSuspended = false;
|
| this._lastAnonymousTargetId = 0;
|
| @@ -71,7 +71,7 @@ SDK.TargetManager = class extends Common.Object {
|
| }
|
|
|
| /**
|
| - * @param {function(new:T,!SDK.Target)} modelClass
|
| + * @param {function(new:T, !SDK.Target, !Protocol.Dispatcher)} modelClass
|
| * @return {!Array<!T>}
|
| * @template T
|
| */
|
| @@ -93,7 +93,7 @@ SDK.TargetManager = class extends Common.Object {
|
| }
|
|
|
| /**
|
| - * @param {function(new:T,!SDK.Target)} modelClass
|
| + * @param {function(new:T, !SDK.Target, !Protocol.Dispatcher)} modelClass
|
| * @param {!SDK.SDKModelObserver<T>} observer
|
| * @template T
|
| */
|
| @@ -106,7 +106,7 @@ SDK.TargetManager = class extends Common.Object {
|
| }
|
|
|
| /**
|
| - * @param {function(new:T,!SDK.Target)} modelClass
|
| + * @param {function(new:T, !SDK.Target, !Protocol.Dispatcher)} modelClass
|
| * @param {!SDK.SDKModelObserver<T>} observer
|
| * @template T
|
| */
|
| @@ -121,7 +121,7 @@ SDK.TargetManager = class extends Common.Object {
|
|
|
| /**
|
| * @param {!SDK.Target} target
|
| - * @param {function(new:SDK.SDKModel,!SDK.Target)} modelClass
|
| + * @param {function(new:SDK.SDKModel,!SDK.Target, !Protocol.Dispatcher)} modelClass
|
| * @param {!SDK.SDKModel} model
|
| */
|
| modelAdded(target, modelClass, model) {
|
| @@ -133,7 +133,7 @@ SDK.TargetManager = class extends Common.Object {
|
|
|
| /**
|
| * @param {!SDK.Target} target
|
| - * @param {function(new:SDK.SDKModel,!SDK.Target)} modelClass
|
| + * @param {function(new:SDK.SDKModel, !SDK.Target, !Protocol.Dispatcher)} modelClass
|
| * @param {!SDK.SDKModel} model
|
| */
|
| _modelRemoved(target, modelClass, model) {
|
| @@ -210,15 +210,15 @@ SDK.TargetManager = class extends Common.Object {
|
| * @param {string} id
|
| * @param {string} name
|
| * @param {number} capabilitiesMask
|
| - * @param {!Protocol.InspectorBackend.Connection.Factory} connectionFactory
|
| + * @param {!Protocol.Dispatcher} dispatcher
|
| * @param {?SDK.Target} parentTarget
|
| * @return {!SDK.Target}
|
| */
|
| - createTarget(id, name, capabilitiesMask, connectionFactory, parentTarget) {
|
| - var target = new SDK.Target(this, id, name, capabilitiesMask, connectionFactory, parentTarget);
|
| + createTarget(id, name, capabilitiesMask, dispatcher, parentTarget) {
|
| + var target = new SDK.Target(this, id, name, capabilitiesMask, dispatcher, parentTarget);
|
| target.createModels(new Set(this._modelObservers.keys()));
|
| if (target.hasTargetCapability())
|
| - this._childTargetManagers.set(target, new SDK.ChildTargetManager(this, target));
|
| + this._childTargetManagers.set(target, new SDK.ChildTargetManager(this, target, dispatcher));
|
| this._targets.push(target);
|
|
|
| var copy = this._observersForTarget(target);
|
| @@ -322,11 +322,11 @@ SDK.TargetManager = class extends Common.Object {
|
|
|
| _connectAndCreateMainTarget() {
|
| if (Runtime.queryParam('nodeFrontend')) {
|
| - var target = new SDK.Target(
|
| - this, 'main', Common.UIString('Node'), SDK.Target.Capability.Target, this._createMainConnection.bind(this),
|
| - null);
|
| + var dispatcher = new Protocol.Dispatcher(this._createMainConnection.bind(this));
|
| + var target =
|
| + new SDK.Target(this, 'main', Common.UIString('Node'), SDK.Target.Capability.Target, dispatcher, null);
|
| target.setInspectedURL('Node');
|
| - this._childTargetManagers.set(target, new SDK.ChildTargetManager(this, target));
|
| + this._childTargetManagers.set(target, new SDK.ChildTargetManager(this, target, dispatcher));
|
| Host.userMetrics.actionTaken(Host.UserMetrics.Action.ConnectToNodeJSFromFrontend);
|
| return;
|
| }
|
| @@ -344,9 +344,9 @@ SDK.TargetManager = class extends Common.Object {
|
| Host.userMetrics.actionTaken(Host.UserMetrics.Action.ConnectToNodeJSDirectly);
|
| }
|
|
|
| - var target =
|
| - this.createTarget('main', Common.UIString('Main'), capabilities, this._createMainConnection.bind(this), null);
|
| - target.runtimeAgent().runIfWaitingForDebugger();
|
| + var dispatcher = new Protocol.Dispatcher(this._createMainConnection.bind(this));
|
| + var target = this.createTarget('main', Common.UIString('Main'), capabilities, dispatcher, null);
|
| + dispatcher.runtimeAgent().runIfWaitingForDebugger();
|
| }
|
|
|
| /**
|
| @@ -391,16 +391,17 @@ SDK.ChildTargetManager = class {
|
| /**
|
| * @param {!SDK.TargetManager} targetManager
|
| * @param {!SDK.Target} parentTarget
|
| + * @param {!Protocol.Dispatcher} dispatcher
|
| */
|
| - constructor(targetManager, parentTarget) {
|
| + constructor(targetManager, parentTarget, dispatcher) {
|
| this._targetManager = targetManager;
|
| this._parentTarget = parentTarget;
|
| - this._targetAgent = parentTarget.targetAgent();
|
| + this._targetAgent = dispatcher.targetAgent();
|
|
|
| /** @type {!Map<string, !SDK.ChildConnection>} */
|
| this._childConnections = new Map();
|
|
|
| - parentTarget.registerTargetDispatcher(this);
|
| + dispatcher.registerTargetDispatcher(this);
|
| this._targetAgent.invoke_setAutoAttach({autoAttach: true, waitForDebuggerOnStart: true});
|
| if (Runtime.experiments.isEnabled('autoAttachToCrossProcessSubframes'))
|
| this._targetAgent.setAttachToFrames(true);
|
| @@ -488,9 +489,10 @@ SDK.ChildTargetManager = class {
|
| targetName =
|
| parsedURL ? parsedURL.lastPathComponentWithFragment() : '#' + (++this._targetManager._lastAnonymousTargetId);
|
| }
|
| + var dispatcher =
|
| + new Protocol.Dispatcher(this._createChildConnection.bind(this, this._targetAgent, targetInfo.targetId));
|
| var target = this._targetManager.createTarget(
|
| - targetInfo.targetId, targetName, this._capabilitiesForType(targetInfo.type),
|
| - this._createChildConnection.bind(this, this._targetAgent, targetInfo.targetId), this._parentTarget);
|
| + targetInfo.targetId, targetName, this._capabilitiesForType(targetInfo.type), dispatcher, this._parentTarget);
|
| target[SDK.TargetManager._isWorkerSymbol] = targetInfo.type === 'worker';
|
|
|
| // Only pause the new worker if debugging SW - we are going through the pause on start checkbox.
|
| @@ -499,7 +501,7 @@ SDK.ChildTargetManager = class {
|
| if (debuggerModel)
|
| debuggerModel.pause();
|
| }
|
| - target.runtimeAgent().runIfWaitingForDebugger();
|
| + dispatcher.runtimeAgent().runIfWaitingForDebugger();
|
| }
|
|
|
| /**
|
|
|