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.js'), SDK.Target.Capability.Target
, this._createMainConnection.bind(this), | 331 this, 'main', Common.UIString('Node'), SDK.Target.Capability.Target, t
his._createMainConnection.bind(this), |
332 null); | 332 null); |
333 target.setInspectedURL('Node.js'); | 333 target.setInspectedURL('Node'); |
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 if (Runtime.queryParam('nodeFrontend')) { | 415 |
416 InspectorFrontendHost.setDevicesUpdatesEnabled(true); | 416 if (Runtime.queryParam('nodeFrontend') && !this._parentTarget.parentTarget()
) { |
417 InspectorFrontendHost.events.addEventListener( | 417 InspectorFrontendHost.setDevicesUpdatesEnabled(true); |
418 InspectorFrontendHostAPI.Events.DevicesDiscoveryConfigChanged, this.
_devicesDiscoveryConfigChanged, this); | 418 InspectorFrontendHost.events.addEventListener( |
419 } else { | 419 InspectorFrontendHostAPI.Events.DevicesDiscoveryConfigChanged, this._d
evicesDiscoveryConfigChanged, this); |
420 this._targetAgent.setRemoteLocations([{host: 'localhost', port: 9229}]); | |
421 } | |
422 } | 420 } |
423 } | 421 } |
424 | 422 |
425 /** | 423 /** |
426 * @param {!Common.Event} event | 424 * @param {!Common.Event} event |
427 */ | 425 */ |
428 _devicesDiscoveryConfigChanged(event) { | 426 _devicesDiscoveryConfigChanged(event) { |
429 var config = /** @type {!Adb.Config} */ (event.data); | 427 var config = /** @type {!Adb.Config} */ (event.data); |
430 var locations = []; | 428 var locations = []; |
431 for (var address of config.networkDiscoveryConfig) { | 429 for (var address of config.networkDiscoveryConfig) { |
432 var parts = address.split(':'); | 430 var parts = address.split(':'); |
433 var port = parseInt(parts[1], 10); | 431 var port = parseInt(parts[1], 10); |
434 if (parts[0] && port) | 432 locations.push({host: parts[0] || 'localhost', port: port || 9229}); |
435 locations.push({host: parts[0], port: port}); | |
436 } | 433 } |
437 this._targetAgent.setRemoteLocations(locations); | 434 this._targetAgent.setRemoteLocations(locations); |
438 } | 435 } |
439 | 436 |
440 /** | 437 /** |
441 * @return {!Promise} | 438 * @return {!Promise} |
442 */ | 439 */ |
443 suspend() { | 440 suspend() { |
444 return this._targetAgent.invoke_setAutoAttach({autoAttach: true, waitForDebu
ggerOnStart: false}); | 441 return this._targetAgent.invoke_setAutoAttach({autoAttach: true, waitForDebu
ggerOnStart: false}); |
445 } | 442 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 } | 506 } |
510 | 507 |
511 /** | 508 /** |
512 * @override | 509 * @override |
513 * @param {!Protocol.Target.TargetInfo} targetInfo | 510 * @param {!Protocol.Target.TargetInfo} targetInfo |
514 * @param {boolean} waitingForDebugger | 511 * @param {boolean} waitingForDebugger |
515 */ | 512 */ |
516 attachedToTarget(targetInfo, waitingForDebugger) { | 513 attachedToTarget(targetInfo, waitingForDebugger) { |
517 var targetName = ''; | 514 var targetName = ''; |
518 if (targetInfo.type === 'node') { | 515 if (targetInfo.type === 'node') { |
519 targetName = Common.UIString('Node.js: %s', targetInfo.url); | 516 targetName = Common.UIString('Node: %s', targetInfo.url); |
520 } else if (targetInfo.type !== 'iframe') { | 517 } else if (targetInfo.type !== 'iframe') { |
521 var parsedURL = targetInfo.url.asParsedURL(); | 518 var parsedURL = targetInfo.url.asParsedURL(); |
522 targetName = | 519 targetName = |
523 parsedURL ? parsedURL.lastPathComponentWithFragment() : '#' + (++this.
_targetManager._lastAnonymousTargetId); | 520 parsedURL ? parsedURL.lastPathComponentWithFragment() : '#' + (++this.
_targetManager._lastAnonymousTargetId); |
524 } | 521 } |
525 var target = this._targetManager.createTarget( | 522 var target = this._targetManager.createTarget( |
526 targetInfo.targetId, targetName, this._capabilitiesForType(targetInfo.ty
pe), | 523 targetInfo.targetId, targetName, this._capabilitiesForType(targetInfo.ty
pe), |
527 this._createChildConnection.bind(this, this._targetAgent, targetInfo.tar
getId), this._parentTarget); | 524 this._createChildConnection.bind(this, this._targetAgent, targetInfo.tar
getId), this._parentTarget); |
528 target[SDK.TargetManager._isWorkerSymbol] = targetInfo.type === 'worker'; | 525 target[SDK.TargetManager._isWorkerSymbol] = targetInfo.type === 'worker'; |
529 | 526 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 /** | 644 /** |
648 * @param {!T} model | 645 * @param {!T} model |
649 */ | 646 */ |
650 modelRemoved(model) {}, | 647 modelRemoved(model) {}, |
651 }; | 648 }; |
652 | 649 |
653 /** | 650 /** |
654 * @type {!SDK.TargetManager} | 651 * @type {!SDK.TargetManager} |
655 */ | 652 */ |
656 SDK.targetManager = new SDK.TargetManager(); | 653 SDK.targetManager = new SDK.TargetManager(); |
OLD | NEW |