OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 * @constructor | 6 * @constructor |
7 * @extends {WebInspector.SDKModel} | 7 * @extends {WebInspector.SDKModel} |
8 * @param {!WebInspector.Target} target | 8 * @param {!WebInspector.Target} target |
9 */ | 9 */ |
10 WebInspector.SubTargetsManager = function(target) | 10 WebInspector.SubTargetsManager = function(target) |
11 { | 11 { |
12 WebInspector.SDKModel.call(this, WebInspector.SubTargetsManager, target); | 12 WebInspector.SDKModel.call(this, WebInspector.SubTargetsManager, target); |
13 target.registerTargetDispatcher(new WebInspector.SubTargetsDispatcher(this))
; | 13 target.registerTargetDispatcher(new WebInspector.SubTargetsDispatcher(this))
; |
14 this._lastAnonymousTargetId = 0; | 14 this._lastAnonymousTargetId = 0; |
15 this._agent = target.targetAgent(); | 15 this._agent = target.targetAgent(); |
16 | 16 |
17 /** @type {!Map<string, !WebInspector.Target>} */ | 17 /** @type {!Map<string, !WebInspector.Target>} */ |
18 this._attachedTargets = new Map(); | 18 this._attachedTargets = new Map(); |
19 /** @type {!Map<string, !WebInspector.SubTargetConnection>} */ | 19 /** @type {!Map<string, !WebInspector.SubTargetConnection>} */ |
20 this._connections = new Map(); | 20 this._connections = new Map(); |
21 | 21 |
22 this._agent.setAutoAttach(true /* autoAttach */, true /* waitForDebuggerOnSt
art */); | 22 this._agent.setAutoAttach(true /* autoAttach */, true /* waitForDebuggerOnSt
art */); |
23 this._agent.setAttachToFrames(Runtime.experiments.isEnabled("autoAttachToCro
ssProcessSubframes")); | 23 this._agent.setAttachToFrames(Runtime.experiments.isEnabled("autoAttachToCro
ssProcessSubframes")); |
| 24 |
| 25 if (Runtime.experiments.isEnabled("nodeDebugging") && !target.parentTarget()
) { |
| 26 var defaultLocations = [{host: "localhost", port: 9229}]; |
| 27 this._agent.setRemoteLocations(defaultLocations); |
| 28 this._agent.setDiscoverTargets(true); |
| 29 } |
24 } | 30 } |
25 | 31 |
26 /** @enum {symbol} */ | 32 /** @enum {symbol} */ |
27 WebInspector.SubTargetsManager.Events = { | 33 WebInspector.SubTargetsManager.Events = { |
28 SubTargetAdded: Symbol("SubTargetAdded"), | 34 SubTargetAdded: Symbol("SubTargetAdded"), |
29 SubTargetRemoved: Symbol("SubTargetRemoved"), | 35 SubTargetRemoved: Symbol("SubTargetRemoved"), |
30 } | 36 } |
31 | 37 |
32 WebInspector.SubTargetsManager._InfoSymbol = Symbol("SubTargetInfo"); | 38 WebInspector.SubTargetsManager._InfoSymbol = Symbol("SubTargetInfo"); |
33 | 39 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 _capabilitiesForType: function(type) | 131 _capabilitiesForType: function(type) |
126 { | 132 { |
127 if (type === "worker") | 133 if (type === "worker") |
128 return WebInspector.Target.Capability.JS | WebInspector.Target.Capab
ility.Log; | 134 return WebInspector.Target.Capability.JS | WebInspector.Target.Capab
ility.Log; |
129 if (type === "service_worker") | 135 if (type === "service_worker") |
130 return WebInspector.Target.Capability.Log | WebInspector.Target.Capa
bility.Network | WebInspector.Target.Capability.Worker; | 136 return WebInspector.Target.Capability.Log | WebInspector.Target.Capa
bility.Network | WebInspector.Target.Capability.Worker; |
131 if (type === "iframe") | 137 if (type === "iframe") |
132 return WebInspector.Target.Capability.Browser | WebInspector.Target.
Capability.DOM | | 138 return WebInspector.Target.Capability.Browser | WebInspector.Target.
Capability.DOM | |
133 WebInspector.Target.Capability.JS | WebInspector.Target.Capabili
ty.Log | | 139 WebInspector.Target.Capability.JS | WebInspector.Target.Capabili
ty.Log | |
134 WebInspector.Target.Capability.Network | WebInspector.Target.Cap
ability.Worker; | 140 WebInspector.Target.Capability.Network | WebInspector.Target.Cap
ability.Worker; |
| 141 if (type === "node") |
| 142 return WebInspector.Target.Capability.JS; |
135 return 0; | 143 return 0; |
136 }, | 144 }, |
137 | 145 |
138 /** | 146 /** |
139 * @param {!WebInspector.TargetInfo} targetInfo | 147 * @param {!WebInspector.TargetInfo} targetInfo |
140 * @param {boolean} waitingForDebugger | 148 * @param {boolean} waitingForDebugger |
141 */ | 149 */ |
142 _attachedToTarget: function(targetInfo, waitingForDebugger) | 150 _attachedToTarget: function(targetInfo, waitingForDebugger) |
143 { | 151 { |
144 var connection = new WebInspector.SubTargetConnection(this._agent, targe
tInfo.id); | 152 var connection = new WebInspector.SubTargetConnection(this._agent, targe
tInfo.id); |
145 this._connections.set(targetInfo.id, connection); | 153 this._connections.set(targetInfo.id, connection); |
146 | 154 |
147 var targetName = ""; | 155 var targetName = ""; |
148 if (targetInfo.type !== "iframe") { | 156 if (targetInfo.type === "node") { |
| 157 targetName = targetInfo.title; |
| 158 } else if (targetInfo.type !== "iframe") { |
149 var parsedURL = targetInfo.url.asParsedURL(); | 159 var parsedURL = targetInfo.url.asParsedURL(); |
150 targetName = parsedURL ? parsedURL.lastPathComponentWithFragment() :
"#" + (++this._lastAnonymousTargetId); | 160 targetName = parsedURL ? parsedURL.lastPathComponentWithFragment() :
"#" + (++this._lastAnonymousTargetId); |
151 } | 161 } |
152 var target = WebInspector.targetManager.createTarget(targetName, this._c
apabilitiesForType(targetInfo.type), connection, this.target()); | 162 var target = WebInspector.targetManager.createTarget(targetName, this._c
apabilitiesForType(targetInfo.type), connection, this.target()); |
153 target[WebInspector.SubTargetsManager._InfoSymbol] = targetInfo; | 163 target[WebInspector.SubTargetsManager._InfoSymbol] = targetInfo; |
154 this._attachedTargets.set(targetInfo.id, target); | 164 this._attachedTargets.set(targetInfo.id, target); |
155 | 165 |
156 // Only pause new worker if debugging SW - we are going through the paus
e on start checkbox. | 166 // Only pause new worker if debugging SW - we are going through the paus
e on start checkbox. |
157 var mainIsServiceWorker = !this.target().parentTarget() && this.target()
.hasWorkerCapability() && !this.target().hasBrowserCapability(); | 167 var mainIsServiceWorker = !this.target().parentTarget() && this.target()
.hasWorkerCapability() && !this.target().hasBrowserCapability(); |
158 if (mainIsServiceWorker && waitingForDebugger) | 168 if (mainIsServiceWorker && waitingForDebugger) |
(...skipping 21 matching lines...) Expand all Loading... |
180 * @param {string} targetId | 190 * @param {string} targetId |
181 * @param {string} message | 191 * @param {string} message |
182 */ | 192 */ |
183 _receivedMessageFromTarget: function(targetId, message) | 193 _receivedMessageFromTarget: function(targetId, message) |
184 { | 194 { |
185 var connection = this._connections.get(targetId); | 195 var connection = this._connections.get(targetId); |
186 if (connection) | 196 if (connection) |
187 connection.dispatch(message); | 197 connection.dispatch(message); |
188 }, | 198 }, |
189 | 199 |
| 200 /** |
| 201 * @param {!WebInspector.TargetInfo} targetInfo |
| 202 */ |
| 203 _targetCreated: function(targetInfo) |
| 204 { |
| 205 if (targetInfo.type !== "node") |
| 206 return; |
| 207 this._agent.attachToTarget(targetInfo.id); |
| 208 }, |
| 209 |
| 210 /** |
| 211 * @param {string} targetId |
| 212 */ |
| 213 _targetDestroyed: function(targetId) |
| 214 { |
| 215 // All the work is done in _detachedFromTarget. |
| 216 }, |
| 217 |
190 __proto__: WebInspector.SDKModel.prototype | 218 __proto__: WebInspector.SDKModel.prototype |
191 } | 219 } |
192 | 220 |
193 /** | 221 /** |
194 * @constructor | 222 * @constructor |
195 * @implements {TargetAgent.Dispatcher} | 223 * @implements {TargetAgent.Dispatcher} |
196 * @param {!WebInspector.SubTargetsManager} manager | 224 * @param {!WebInspector.SubTargetsManager} manager |
197 */ | 225 */ |
198 WebInspector.SubTargetsDispatcher = function(manager) | 226 WebInspector.SubTargetsDispatcher = function(manager) |
199 { | 227 { |
200 this._manager = manager; | 228 this._manager = manager; |
201 } | 229 } |
202 | 230 |
203 WebInspector.SubTargetsDispatcher.prototype = { | 231 WebInspector.SubTargetsDispatcher.prototype = { |
204 /** | 232 /** |
205 * @override | 233 * @override |
206 * @param {!TargetAgent.TargetInfo} targetInfo | 234 * @param {!TargetAgent.TargetInfo} targetInfo |
207 */ | 235 */ |
208 targetCreated: function(targetInfo) | 236 targetCreated: function(targetInfo) |
209 { | 237 { |
210 // Ignored. | 238 this._manager._targetCreated(new WebInspector.TargetInfo(targetInfo)); |
211 }, | 239 }, |
212 | 240 |
213 /** | 241 /** |
214 * @override | 242 * @override |
215 * @param {string} targetId | 243 * @param {string} targetId |
216 */ | 244 */ |
217 targetDestroyed: function(targetId) | 245 targetDestroyed: function(targetId) |
218 { | 246 { |
219 // Ignored. | 247 this._manager._targetDestroyed(targetId); |
220 }, | 248 }, |
221 | 249 |
222 /** | 250 /** |
223 * @override | 251 * @override |
224 * @param {!TargetAgent.TargetInfo} targetInfo | 252 * @param {!TargetAgent.TargetInfo} targetInfo |
225 * @param {boolean} waitingForDebugger | 253 * @param {boolean} waitingForDebugger |
226 */ | 254 */ |
227 attachedToTarget: function(targetInfo, waitingForDebugger) | 255 attachedToTarget: function(targetInfo, waitingForDebugger) |
228 { | 256 { |
229 this._manager._attachedToTarget(new WebInspector.TargetInfo(targetInfo),
waitingForDebugger); | 257 this._manager._attachedToTarget(new WebInspector.TargetInfo(targetInfo),
waitingForDebugger); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 this.url = payload.url; | 326 this.url = payload.url; |
299 this.type = payload.type; | 327 this.type = payload.type; |
300 if (this.type !== "page" && this.type !== "iframe") { | 328 if (this.type !== "page" && this.type !== "iframe") { |
301 this.title = WebInspector.UIString("Worker: %s", this.url); | 329 this.title = WebInspector.UIString("Worker: %s", this.url); |
302 this.canActivate = false; | 330 this.canActivate = false; |
303 } else { | 331 } else { |
304 this.title = payload.title; | 332 this.title = payload.title; |
305 this.canActivate = true; | 333 this.canActivate = true; |
306 } | 334 } |
307 } | 335 } |
OLD | NEW |