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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/TargetManager.js

Issue 2832943002: DevTools: properly handle target suspension/resuming in NetworkProject (Closed)
Patch Set: address comments Created 3 years, 7 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
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/sdk/DebuggerModel.js ('k') | 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 /* 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
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 return Promise.resolve();
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 return Promise.resolve();
52 this._isSuspended = false; 57 this._isSuspended = false;
53 this.dispatchEventToListeners(SDK.TargetManager.Events.SuspendStateChanged); 58 this.dispatchEventToListeners(SDK.TargetManager.Events.SuspendStateChanged);
54 59
55 var promises = []; 60 var promises = [];
56 for (var target of this._targets) { 61 for (var target of this._targets) {
57 var childTargetManager = this._childTargetManagers.get(target); 62 var childTargetManager = this._childTargetManagers.get(target);
58 if (childTargetManager) 63 if (childTargetManager)
59 promises.push(childTargetManager.resume()); 64 promises.push(childTargetManager.resume());
60 for (var model of target.models().values()) 65 for (var model of target.models().values())
61 promises.push(model.resumeModel()); 66 promises.push(model.resumeModel());
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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();
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/sdk/DebuggerModel.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698