OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 /** | 6 /** |
7 * @constructor | 7 * @constructor |
8 * @param {!WebInspector.Target} mainTarget | 8 * @param {!WebInspector.Target} mainTarget |
9 * @param {!WebInspector.TargetManager} targetManager | 9 * @param {!WebInspector.TargetManager} targetManager |
10 */ | 10 */ |
11 WebInspector.WorkerTargetManager = function(mainTarget, targetManager) | 11 WebInspector.WorkerTargetManager = function(mainTarget, targetManager) |
12 { | 12 { |
13 this._mainTarget = mainTarget; | 13 this._mainTarget = mainTarget; |
14 this._targetManager = targetManager; | 14 this._targetManager = targetManager; |
15 mainTarget.workerManager.addEventListener(WebInspector.WorkerManager.Events.
WorkerAdded, this._onWorkerAdded, this); | 15 mainTarget.workerManager.addEventListener(WebInspector.WorkerManager.Events.
WorkerAdded, this._onWorkerAdded, this); |
16 mainTarget.workerManager.addEventListener(WebInspector.WorkerManager.Events.
WorkersCleared, this._onWorkersCleared, this); | 16 mainTarget.workerManager.addEventListener(WebInspector.WorkerManager.Events.
WorkersCleared, this._onWorkersCleared, this); |
17 WebInspector.profilingLock().addEventListener(WebInspector.Lock.Events.State
Changed, this._onProfilingStateChanged, this); | 17 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event
s.SuspendStateChanged, this._onSuspendStateChanged, this); |
18 this._onProfilingStateChanged(); | 18 this._onSuspendStateChanged(); |
19 this._lastAnonymousTargetId = 0; | 19 this._lastAnonymousTargetId = 0; |
20 this._shouldPauseWorkerOnStart = WebInspector.isWorkerFrontend(); | 20 this._shouldPauseWorkerOnStart = WebInspector.isWorkerFrontend(); |
21 } | 21 } |
22 | 22 |
23 WebInspector.WorkerTargetManager.prototype = { | 23 WebInspector.WorkerTargetManager.prototype = { |
24 _onProfilingStateChanged: function() | 24 _onSuspendStateChanged: function() |
25 { | 25 { |
26 var acquired = WebInspector.profilingLock().isAcquired(); | 26 // FIXME: the logic needs to be extended and cover the case when a worke
r was started after disabling autoconnect |
27 this._mainTarget.workerAgent().setAutoconnectToWorkers(!acquired); | 27 // and still alive after enabling autoconnect. |
| 28 var suspended = WebInspector.targetManager.allTargetsSuspended(); |
| 29 this._mainTarget.workerAgent().setAutoconnectToWorkers(!suspended); |
28 }, | 30 }, |
29 | 31 |
30 /** | 32 /** |
31 * @param {!WebInspector.Event} event | 33 * @param {!WebInspector.Event} event |
32 */ | 34 */ |
33 _onWorkerAdded: function(event) | 35 _onWorkerAdded: function(event) |
34 { | 36 { |
35 var data = /** @type {{workerId: number, url: string, inspectorConnected
: boolean}} */ (event.data); | 37 var data = /** @type {{workerId: number, url: string, inspectorConnected
: boolean}} */ (event.data); |
36 new WebInspector.WorkerConnection(this._mainTarget, data.workerId, data.
inspectorConnected, onConnectionReady.bind(this)); | 38 new WebInspector.WorkerConnection(this._mainTarget, data.workerId, data.
inspectorConnected, onConnectionReady.bind(this)); |
37 | 39 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 _close: function() | 166 _close: function() |
165 { | 167 { |
166 this._target.workerManager.removeEventListener(WebInspector.WorkerManage
r.Events.MessageFromWorker, this._dispatchMessageFromWorker, this); | 168 this._target.workerManager.removeEventListener(WebInspector.WorkerManage
r.Events.MessageFromWorker, this._dispatchMessageFromWorker, this); |
167 this._target.workerManager.removeEventListener(WebInspector.WorkerManage
r.Events.WorkerRemoved, this._onWorkerRemoved, this); | 169 this._target.workerManager.removeEventListener(WebInspector.WorkerManage
r.Events.WorkerRemoved, this._onWorkerRemoved, this); |
168 this._target.workerManager.removeEventListener(WebInspector.WorkerManage
r.Events.WorkersCleared, this._close, this); | 170 this._target.workerManager.removeEventListener(WebInspector.WorkerManage
r.Events.WorkersCleared, this._close, this); |
169 this.connectionClosed("worker_terminated"); | 171 this.connectionClosed("worker_terminated"); |
170 }, | 172 }, |
171 | 173 |
172 __proto__: InspectorBackendClass.Connection.prototype | 174 __proto__: InspectorBackendClass.Connection.prototype |
173 } | 175 } |
OLD | NEW |