OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 The Chromium Authors. All rights reserved. | 2 * Copyright 2014 The Chromium Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 SDK.TargetManager = class extends Common.Object { | 7 SDK.TargetManager = class extends Common.Object { |
8 constructor() { | 8 constructor() { |
9 super(); | 9 super(); |
10 /** @type {!Array.<!SDK.Target>} */ | 10 /** @type {!Array.<!SDK.Target>} */ |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 * @param {function()} webSocketConnectionLostCallback | 321 * @param {function()} webSocketConnectionLostCallback |
322 */ | 322 */ |
323 connectToMainTarget(webSocketConnectionLostCallback) { | 323 connectToMainTarget(webSocketConnectionLostCallback) { |
324 this._webSocketConnectionLostCallback = webSocketConnectionLostCallback; | 324 this._webSocketConnectionLostCallback = webSocketConnectionLostCallback; |
325 this._connectAndCreateMainTarget(); | 325 this._connectAndCreateMainTarget(); |
326 } | 326 } |
327 | 327 |
328 _connectAndCreateMainTarget() { | 328 _connectAndCreateMainTarget() { |
329 if (Runtime.queryParam('nodeFrontend')) { | 329 if (Runtime.queryParam('nodeFrontend')) { |
330 var target = new SDK.Target( | 330 var target = new SDK.Target( |
331 this, 'main', Common.UIString('Node'), SDK.Target.Capability.Target, t
his._createMainConnection.bind(this), | 331 this, 'main', Common.UIString('Node.js'), SDK.Target.Capability.Target
, this._createMainConnection.bind(this), |
332 null); | 332 null); |
333 target.setInspectedURL('Node'); | 333 target.setInspectedURL('Node.js'); |
334 this._childTargetManagers.set(target, new SDK.ChildTargetManager(this, tar
get)); | 334 this._childTargetManagers.set(target, new SDK.ChildTargetManager(this, tar
get)); |
335 Host.userMetrics.actionTaken(Host.UserMetrics.Action.ConnectToNodeJSFromFr
ontend); | 335 Host.userMetrics.actionTaken(Host.UserMetrics.Action.ConnectToNodeJSFromFr
ontend); |
336 return; | 336 return; |
337 } | 337 } |
338 | 338 |
339 var capabilities = SDK.Target.Capability.Browser | SDK.Target.Capability.DOM
| SDK.Target.Capability.JS | | 339 var capabilities = SDK.Target.Capability.Browser | SDK.Target.Capability.DOM
| SDK.Target.Capability.JS | |
340 SDK.Target.Capability.Log | SDK.Target.Capability.Network | SDK.Target.C
apability.Target | | 340 SDK.Target.Capability.Log | SDK.Target.Capability.Network | SDK.Target.C
apability.Target | |
341 SDK.Target.Capability.ScreenCapture | SDK.Target.Capability.Tracing | SD
K.Target.Capability.Emulation | | 341 SDK.Target.Capability.ScreenCapture | SDK.Target.Capability.Tracing | SD
K.Target.Capability.Emulation | |
342 SDK.Target.Capability.Security | SDK.Target.Capability.Input | SDK.Targe
t.Capability.Inspector | | 342 SDK.Target.Capability.Security | SDK.Target.Capability.Input | SDK.Targe
t.Capability.Inspector | |
343 SDK.Target.Capability.DeviceEmulation; | 343 SDK.Target.Capability.DeviceEmulation; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 this._targetAgent = parentTarget.targetAgent(); | 403 this._targetAgent = parentTarget.targetAgent(); |
404 | 404 |
405 /** @type {!Map<string, !SDK.ChildConnection>} */ | 405 /** @type {!Map<string, !SDK.ChildConnection>} */ |
406 this._childConnections = new Map(); | 406 this._childConnections = new Map(); |
407 | 407 |
408 parentTarget.registerTargetDispatcher(this); | 408 parentTarget.registerTargetDispatcher(this); |
409 this._targetAgent.invoke_setAutoAttach({autoAttach: true, waitForDebuggerOnS
tart: true}); | 409 this._targetAgent.invoke_setAutoAttach({autoAttach: true, waitForDebuggerOnS
tart: true}); |
410 if (Runtime.experiments.isEnabled('autoAttachToCrossProcessSubframes')) | 410 if (Runtime.experiments.isEnabled('autoAttachToCrossProcessSubframes')) |
411 this._targetAgent.setAttachToFrames(true); | 411 this._targetAgent.setAttachToFrames(true); |
412 | 412 |
413 if (!parentTarget.parentTarget()) | 413 if (!parentTarget.parentTarget()) { |
414 this._targetAgent.setDiscoverTargets(true); | 414 this._targetAgent.setDiscoverTargets(true); |
415 | 415 if (Runtime.queryParam('nodeFrontend')) { |
416 if (Runtime.queryParam('nodeFrontend') && !this._parentTarget.parentTarget()
) { | 416 InspectorFrontendHost.setDevicesUpdatesEnabled(true); |
417 InspectorFrontendHost.setDevicesUpdatesEnabled(true); | 417 InspectorFrontendHost.events.addEventListener( |
418 InspectorFrontendHost.events.addEventListener( | 418 InspectorFrontendHostAPI.Events.DevicesDiscoveryConfigChanged, this.
_devicesDiscoveryConfigChanged, this); |
419 InspectorFrontendHostAPI.Events.DevicesDiscoveryConfigChanged, this._d
evicesDiscoveryConfigChanged, this); | 419 } else { |
| 420 this._targetAgent.setRemoteLocations([{host: 'localhost', port: 9229}]); |
| 421 } |
420 } | 422 } |
421 } | 423 } |
422 | 424 |
423 /** | 425 /** |
424 * @param {!Common.Event} event | 426 * @param {!Common.Event} event |
425 */ | 427 */ |
426 _devicesDiscoveryConfigChanged(event) { | 428 _devicesDiscoveryConfigChanged(event) { |
427 var config = /** @type {!Adb.Config} */ (event.data); | 429 var config = /** @type {!Adb.Config} */ (event.data); |
428 var locations = []; | 430 var locations = []; |
429 for (var address of config.networkDiscoveryConfig) { | 431 for (var address of config.networkDiscoveryConfig) { |
430 var parts = address.split(':'); | 432 var parts = address.split(':'); |
431 var port = parseInt(parts[1], 10); | 433 var port = parseInt(parts[1], 10); |
432 locations.push({host: parts[0] || 'localhost', port: port || 9229}); | 434 if (parts[0] && port) |
| 435 locations.push({host: parts[0], port: port}); |
433 } | 436 } |
434 this._targetAgent.setRemoteLocations(locations); | 437 this._targetAgent.setRemoteLocations(locations); |
435 } | 438 } |
436 | 439 |
437 /** | 440 /** |
438 * @return {!Promise} | 441 * @return {!Promise} |
439 */ | 442 */ |
440 suspend() { | 443 suspend() { |
441 return this._targetAgent.invoke_setAutoAttach({autoAttach: true, waitForDebu
ggerOnStart: false}); | 444 return this._targetAgent.invoke_setAutoAttach({autoAttach: true, waitForDebu
ggerOnStart: false}); |
442 } | 445 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 } | 509 } |
507 | 510 |
508 /** | 511 /** |
509 * @override | 512 * @override |
510 * @param {!Protocol.Target.TargetInfo} targetInfo | 513 * @param {!Protocol.Target.TargetInfo} targetInfo |
511 * @param {boolean} waitingForDebugger | 514 * @param {boolean} waitingForDebugger |
512 */ | 515 */ |
513 attachedToTarget(targetInfo, waitingForDebugger) { | 516 attachedToTarget(targetInfo, waitingForDebugger) { |
514 var targetName = ''; | 517 var targetName = ''; |
515 if (targetInfo.type === 'node') { | 518 if (targetInfo.type === 'node') { |
516 targetName = Common.UIString('Node: %s', targetInfo.url); | 519 targetName = Common.UIString('Node.js: %s', targetInfo.url); |
517 } else if (targetInfo.type !== 'iframe') { | 520 } else if (targetInfo.type !== 'iframe') { |
518 var parsedURL = targetInfo.url.asParsedURL(); | 521 var parsedURL = targetInfo.url.asParsedURL(); |
519 targetName = | 522 targetName = |
520 parsedURL ? parsedURL.lastPathComponentWithFragment() : '#' + (++this.
_targetManager._lastAnonymousTargetId); | 523 parsedURL ? parsedURL.lastPathComponentWithFragment() : '#' + (++this.
_targetManager._lastAnonymousTargetId); |
521 } | 524 } |
522 var target = this._targetManager.createTarget( | 525 var target = this._targetManager.createTarget( |
523 targetInfo.targetId, targetName, this._capabilitiesForType(targetInfo.ty
pe), | 526 targetInfo.targetId, targetName, this._capabilitiesForType(targetInfo.ty
pe), |
524 this._createChildConnection.bind(this, this._targetAgent, targetInfo.tar
getId), this._parentTarget); | 527 this._createChildConnection.bind(this, this._targetAgent, targetInfo.tar
getId), this._parentTarget); |
525 target[SDK.TargetManager._isWorkerSymbol] = targetInfo.type === 'worker'; | 528 target[SDK.TargetManager._isWorkerSymbol] = targetInfo.type === 'worker'; |
526 | 529 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 /** | 647 /** |
645 * @param {!T} model | 648 * @param {!T} model |
646 */ | 649 */ |
647 modelRemoved(model) {}, | 650 modelRemoved(model) {}, |
648 }; | 651 }; |
649 | 652 |
650 /** | 653 /** |
651 * @type {!SDK.TargetManager} | 654 * @type {!SDK.TargetManager} |
652 */ | 655 */ |
653 SDK.targetManager = new SDK.TargetManager(); | 656 SDK.targetManager = new SDK.TargetManager(); |
OLD | NEW |