Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Side by Side Diff: Source/devtools/front_end/sdk/WorkerTargetManager.js

Issue 471413002: DevTools: Avoid exception when inspecting blob-based workers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 WebInspector.profilingLock().addEventListener(WebInspector.Lock.Events.State Changed, this._onProfilingStateChanged, this); 17 WebInspector.profilingLock().addEventListener(WebInspector.Lock.Events.State Changed, this._onProfilingStateChanged, this);
17 this._onProfilingStateChanged(); 18 this._onProfilingStateChanged();
19 this._lastAnonymousTargetId = 0;
18 } 20 }
19 21
20 WebInspector.WorkerTargetManager.prototype = { 22 WebInspector.WorkerTargetManager.prototype = {
21 _onProfilingStateChanged: function() 23 _onProfilingStateChanged: function()
22 { 24 {
23 var acquired = WebInspector.profilingLock().isAcquired(); 25 var acquired = WebInspector.profilingLock().isAcquired();
24 this._mainTarget.workerAgent().setAutoconnectToWorkers(!acquired); 26 this._mainTarget.workerAgent().setAutoconnectToWorkers(!acquired);
25 }, 27 },
26 28
27 /** 29 /**
28 * @param {!WebInspector.Event} event 30 * @param {!WebInspector.Event} event
29 */ 31 */
30 _onWorkerAdded: function(event) 32 _onWorkerAdded: function(event)
31 { 33 {
32 var data = /** @type {{workerId: number, url: string, inspectorConnected : boolean}} */ (event.data); 34 var data = /** @type {{workerId: number, url: string, inspectorConnected : boolean}} */ (event.data);
33 new WebInspector.WorkerConnection(this._mainTarget, data.workerId, data. inspectorConnected, onConnectionReady.bind(this)); 35 new WebInspector.WorkerConnection(this._mainTarget, data.workerId, data. inspectorConnected, onConnectionReady.bind(this));
34 36
35 /** 37 /**
36 * @this {WebInspector.WorkerTargetManager} 38 * @this {WebInspector.WorkerTargetManager}
37 * @param {!InspectorBackendClass.Connection} connection 39 * @param {!InspectorBackendClass.Connection} connection
38 */ 40 */
39 function onConnectionReady(connection) 41 function onConnectionReady(connection)
40 { 42 {
41 this._targetManager.createTarget(WebInspector.UIString("Worker %s", data.url.asParsedURL().lastPathComponent), connection, targetCreated) 43 var parsedURL = data.url.asParsedURL();
44 var workerId = parsedURL ? parsedURL.lastPathComponent : "#" + (++th is._lastAnonymousTargetId);
45 this._targetManager.createTarget(WebInspector.UIString("Worker %s", workerId), connection, targetCreated);
42 } 46 }
43 47
44 /** 48 /**
45 * @param {!WebInspector.Target} target 49 * @param {!WebInspector.Target} target
46 */ 50 */
47 function targetCreated(target) 51 function targetCreated(target)
48 { 52 {
49 if (data.inspectorConnected) 53 if (data.inspectorConnected)
50 target.runtimeAgent().run(); 54 target.runtimeAgent().run();
51 } 55 }
56 },
57
58 _onWorkersCleared: function()
59 {
60 this._lastAnonymousTargetId = 0;
52 } 61 }
53 } 62 }
54 63
55 /** 64 /**
56 * @constructor 65 * @constructor
57 * @extends {InspectorBackendClass.Connection} 66 * @extends {InspectorBackendClass.Connection}
58 * @param {!WebInspector.Target} target 67 * @param {!WebInspector.Target} target
59 * @param {number} workerId 68 * @param {number} workerId
60 * @param {boolean} inspectorConnected 69 * @param {boolean} inspectorConnected
61 * @param {!function(!InspectorBackendClass.Connection)} onConnectionReady 70 * @param {!function(!InspectorBackendClass.Connection)} onConnectionReady
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 _close: function() 119 _close: function()
111 { 120 {
112 this._target.workerManager.removeEventListener(WebInspector.WorkerManage r.Events.MessageFromWorker, this._dispatchMessageFromWorker, this); 121 this._target.workerManager.removeEventListener(WebInspector.WorkerManage r.Events.MessageFromWorker, this._dispatchMessageFromWorker, this);
113 this._target.workerManager.removeEventListener(WebInspector.WorkerManage r.Events.WorkerRemoved, this._onWorkerRemoved, this); 122 this._target.workerManager.removeEventListener(WebInspector.WorkerManage r.Events.WorkerRemoved, this._onWorkerRemoved, this);
114 this._target.workerManager.removeEventListener(WebInspector.WorkerManage r.Events.WorkersCleared, this._close, this); 123 this._target.workerManager.removeEventListener(WebInspector.WorkerManage r.Events.WorkersCleared, this._close, this);
115 this.connectionClosed("worker_terminated"); 124 this.connectionClosed("worker_terminated");
116 }, 125 },
117 126
118 __proto__: InspectorBackendClass.Connection.prototype 127 __proto__: InspectorBackendClass.Connection.prototype
119 } 128 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698