| Index: Source/devtools/front_end/sdk/WorkerTargetManager.js
|
| diff --git a/Source/devtools/front_end/sdk/WorkerTargetManager.js b/Source/devtools/front_end/sdk/WorkerTargetManager.js
|
| index 9215cb608709d194b33868790b87dea6b912a008..c2f6a0b3cfb96d78154cd172e4c97c3a77494552 100644
|
| --- a/Source/devtools/front_end/sdk/WorkerTargetManager.js
|
| +++ b/Source/devtools/front_end/sdk/WorkerTargetManager.js
|
| @@ -12,7 +12,9 @@ WebInspector.WorkerTargetManager = function(mainTarget, targetManager)
|
| {
|
| this._mainTarget = mainTarget;
|
| this._targetManager = targetManager;
|
| + this._targetsByWorkerId = new Map();
|
| mainTarget.workerManager.addEventListener(WebInspector.WorkerManager.Events.WorkerAdded, this._onWorkerAdded, this);
|
| + mainTarget.workerManager.addEventListener(WebInspector.WorkerManager.Events.WorkerRemoved, this._onWorkerRemoved, this);
|
| mainTarget.workerManager.addEventListener(WebInspector.WorkerManager.Events.WorkersCleared, this._onWorkersCleared, this);
|
| WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Events.SuspendStateChanged, this._onSuspendStateChanged, this);
|
| this._onSuspendStateChanged();
|
| @@ -35,27 +37,31 @@ WebInspector.WorkerTargetManager.prototype = {
|
| _onWorkerAdded: function(event)
|
| {
|
| var data = /** @type {{workerId: number, url: string, inspectorConnected: boolean}} */ (event.data);
|
| - new WebInspector.WorkerConnection(this._mainTarget, data.workerId, data.inspectorConnected, onConnectionReady.bind(this));
|
| + new WebInspector.WorkerConnection(this._mainTarget, data.workerId, data.inspectorConnected, onConnectionReady.bind(this, data.workerId));
|
|
|
| /**
|
| * @this {WebInspector.WorkerTargetManager}
|
| + * @param {number} workerId
|
| * @param {!InspectorBackendClass.Connection} connection
|
| */
|
| - function onConnectionReady(connection)
|
| + function onConnectionReady(workerId, connection)
|
| {
|
| var parsedURL = data.url.asParsedURL();
|
| - var workerId = parsedURL ? parsedURL.lastPathComponent : "#" + (++this._lastAnonymousTargetId);
|
| - this._targetManager.createTarget(WebInspector.UIString("Worker %s", workerId), connection, targetCreated.bind(this));
|
| + var workerName = parsedURL ? parsedURL.lastPathComponent : "#" + (++this._lastAnonymousTargetId);
|
| + this._targetManager.createTarget(WebInspector.UIString("Worker %s", workerName), connection, targetCreated.bind(this, workerId));
|
| }
|
|
|
| /**
|
| * @this {WebInspector.WorkerTargetManager}
|
| + * @param {number} workerId
|
| * @param {?WebInspector.Target} target
|
| */
|
| - function targetCreated(target)
|
| + function targetCreated(workerId, target)
|
| {
|
| if (!target)
|
| return;
|
| + if (workerId)
|
| + this._targetsByWorkerId.set(workerId, target);
|
| if (data.inspectorConnected) {
|
| if (this._shouldPauseWorkerOnStart)
|
| target.debuggerAgent().pause();
|
| @@ -105,6 +111,25 @@ WebInspector.WorkerTargetManager.prototype = {
|
| _onWorkersCleared: function()
|
| {
|
| this._lastAnonymousTargetId = 0;
|
| + this._targetsByWorkerId.clear();
|
| + },
|
| +
|
| + /**
|
| + * @param {!WebInspector.Event} event
|
| + */
|
| + _onWorkerRemoved: function(event)
|
| + {
|
| + var workerId = /** @type {number} */ (event.data);
|
| + this._targetsByWorkerId.delete(workerId);
|
| + },
|
| +
|
| + /**
|
| + * @param {number} workerId
|
| + * @return {?WebInspector.Target}
|
| + */
|
| + targetByWorkerId: function(workerId)
|
| + {
|
| + return this._targetsByWorkerId.get(workerId) || null;
|
| }
|
| }
|
|
|
| @@ -173,3 +198,8 @@ WebInspector.WorkerConnection.prototype = {
|
|
|
| __proto__: InspectorBackendClass.Connection.prototype
|
| }
|
| +
|
| +/**
|
| + * @type {?WebInspector.WorkerTargetManager}
|
| + */
|
| +WebInspector.workerTargetManager;
|
|
|