Chromium Code Reviews| 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 10 matching lines...) Expand all Loading... | |
| 21 /** @type {!Map<!SDK.Target, !SDK.ChildTargetManager>} */ | 21 /** @type {!Map<!SDK.Target, !SDK.ChildTargetManager>} */ |
| 22 this._childTargetManagers = new Map(); | 22 this._childTargetManagers = new Map(); |
| 23 /** @type {!Set<string>} */ | 23 /** @type {!Set<string>} */ |
| 24 this._nodeTargetIds = new Set(); | 24 this._nodeTargetIds = new Set(); |
| 25 /** @type {!Protocol.InspectorBackend.Connection} */ | 25 /** @type {!Protocol.InspectorBackend.Connection} */ |
| 26 this._mainConnection; | 26 this._mainConnection; |
| 27 /** @type {function()} */ | 27 /** @type {function()} */ |
| 28 this._webSocketConnectionLostCallback; | 28 this._webSocketConnectionLostCallback; |
| 29 } | 29 } |
| 30 | 30 |
| 31 /** | |
| 32 * @return {!Promise} | |
| 33 */ | |
| 31 suspendAllTargets() { | 34 suspendAllTargets() { |
| 32 if (this._isSuspended) | 35 if (this._isSuspended) |
| 33 return; | 36 throw new Error('Already suspended'); |
|
dgozman
2017/05/05 06:10:55
Not sure this won't ever happen. Let's just return
lushnikov
2017/05/05 20:58:26
Changed both here and in resumeAllTargets() to mak
| |
| 34 this._isSuspended = true; | 37 this._isSuspended = true; |
| 35 this.dispatchEventToListeners(SDK.TargetManager.Events.SuspendStateChanged); | 38 this.dispatchEventToListeners(SDK.TargetManager.Events.SuspendStateChanged); |
| 36 | 39 |
| 40 var promises = []; | |
| 37 for (var target of this._targets) { | 41 for (var target of this._targets) { |
| 38 var childTargetManager = this._childTargetManagers.get(target); | 42 var childTargetManager = this._childTargetManagers.get(target); |
| 39 if (childTargetManager) | 43 if (childTargetManager) |
| 40 childTargetManager.suspend(); | 44 promises.push(childTargetManager.suspend()); |
| 41 for (var model of target.models().values()) | 45 for (var model of target.models().values()) |
| 42 model.suspendModel(); | 46 promises.push(model.suspendModel()); |
| 43 } | 47 } |
| 48 return Promise.all(promises); | |
| 44 } | 49 } |
| 45 | 50 |
| 46 /** | 51 /** |
| 47 * @return {!Promise} | 52 * @return {!Promise} |
| 48 */ | 53 */ |
| 49 resumeAllTargets() { | 54 resumeAllTargets() { |
| 50 if (!this._isSuspended) | 55 if (!this._isSuspended) |
| 51 throw new Error('Not suspended'); | 56 throw new Error('Not suspended'); |
| 52 this._isSuspended = false; | 57 this._isSuspended = false; |
| 53 this.dispatchEventToListeners(SDK.TargetManager.Events.SuspendStateChanged); | 58 this.dispatchEventToListeners(SDK.TargetManager.Events.SuspendStateChanged); |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 404 this._targetAgent.invoke_setAutoAttach({autoAttach: true, waitForDebuggerOnS tart: true}); | 409 this._targetAgent.invoke_setAutoAttach({autoAttach: true, waitForDebuggerOnS tart: true}); |
| 405 if (Runtime.experiments.isEnabled('autoAttachToCrossProcessSubframes')) | 410 if (Runtime.experiments.isEnabled('autoAttachToCrossProcessSubframes')) |
| 406 this._targetAgent.setAttachToFrames(true); | 411 this._targetAgent.setAttachToFrames(true); |
| 407 | 412 |
| 408 if (!parentTarget.parentTarget()) { | 413 if (!parentTarget.parentTarget()) { |
| 409 this._targetAgent.setRemoteLocations([{host: 'localhost', port: 9229}]); | 414 this._targetAgent.setRemoteLocations([{host: 'localhost', port: 9229}]); |
| 410 this._targetAgent.setDiscoverTargets(true); | 415 this._targetAgent.setDiscoverTargets(true); |
| 411 } | 416 } |
| 412 } | 417 } |
| 413 | 418 |
| 419 /** | |
| 420 * @return {!Promise} | |
| 421 */ | |
| 414 suspend() { | 422 suspend() { |
| 415 this._targetAgent.invoke_setAutoAttach({autoAttach: true, waitForDebuggerOnS tart: false}); | 423 return this._targetAgent.invoke_setAutoAttach({autoAttach: true, waitForDebu ggerOnStart: false}); |
| 416 } | 424 } |
| 417 | 425 |
| 418 /** | 426 /** |
| 419 * @return {!Promise} | 427 * @return {!Promise} |
| 420 */ | 428 */ |
| 421 resume() { | 429 resume() { |
| 422 return this._targetAgent.invoke_setAutoAttach({autoAttach: true, waitForDebu ggerOnStart: true}); | 430 return this._targetAgent.invoke_setAutoAttach({autoAttach: true, waitForDebu ggerOnStart: true}); |
| 423 } | 431 } |
| 424 | 432 |
| 425 dispose() { | 433 dispose() { |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 610 /** | 618 /** |
| 611 * @param {!T} model | 619 * @param {!T} model |
| 612 */ | 620 */ |
| 613 modelRemoved(model) {}, | 621 modelRemoved(model) {}, |
| 614 }; | 622 }; |
| 615 | 623 |
| 616 /** | 624 /** |
| 617 * @type {!SDK.TargetManager} | 625 * @type {!SDK.TargetManager} |
| 618 */ | 626 */ |
| 619 SDK.targetManager = new SDK.TargetManager(); | 627 SDK.targetManager = new SDK.TargetManager(); |
| OLD | NEW |