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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sources/ThreadsSidebarPane.js

Issue 2431223003: [DevTools]: Require explicit connection (Closed)
Patch Set: Fixed Node.JS connection title Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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.VBox} 7 * @extends {WebInspector.VBox}
8 * @implements {WebInspector.TargetManager.Observer} 8 * @implements {WebInspector.TargetManager.Observer}
9 */ 9 */
10 WebInspector.ThreadsSidebarPane = function() 10 WebInspector.ThreadsSidebarPane = function()
11 { 11 {
12 WebInspector.VBox.call(this); 12 WebInspector.VBox.call(this);
13 13
14 /** @type {!Map.<!WebInspector.DebuggerModel, !WebInspector.UIList.Item>} */ 14 /** @type {!Map.<!WebInspector.DebuggerModel, !WebInspector.UIList.Item>} */
15 this._debuggerModelToListItems = new Map(); 15 this._debuggerModelToListItems = new Map();
16 /** @type {!Map.<!WebInspector.UIList.Item, !WebInspector.Target>} */ 16 /** @type {!Map.<!WebInspector.UIList.Item, !WebInspector.Target>} */
17 this._listItemsToTargets = new Map(); 17 this._listItemsToTargets = new Map();
18 /** @type {?WebInspector.UIList.Item} */ 18 /** @type {?WebInspector.UIList.Item} */
19 this._selectedListItem = null; 19 this._selectedListItem = null;
20 /** @type {!Map.<!WebInspector.TargetConnectionManager.Connection, !WebInspe ctor.UIList.Item>} */
21 this._connectionToListItem = new Map();
20 this.threadList = new WebInspector.UIList(); 22 this.threadList = new WebInspector.UIList();
21 this.threadList.show(this.element); 23 this.threadList.show(this.element);
22 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI nspector.DebuggerModel.Events.DebuggerPaused, this._onDebuggerStateChanged, this ); 24 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI nspector.DebuggerModel.Events.DebuggerPaused, this._onDebuggerStateChanged, this );
23 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI nspector.DebuggerModel.Events.DebuggerResumed, this._onDebuggerStateChanged, thi s); 25 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI nspector.DebuggerModel.Events.DebuggerResumed, this._onDebuggerStateChanged, thi s);
24 WebInspector.targetManager.addModelListener(WebInspector.RuntimeModel, WebIn spector.RuntimeModel.Events.ExecutionContextChanged, this._onExecutionContextCha nged, this); 26 WebInspector.targetManager.addModelListener(WebInspector.RuntimeModel, WebIn spector.RuntimeModel.Events.ExecutionContextChanged, this._onExecutionContextCha nged, this);
25 WebInspector.context.addFlavorChangeListener(WebInspector.Target, this._targ etChanged, this); 27 WebInspector.context.addFlavorChangeListener(WebInspector.Target, this._targ etChanged, this);
26 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event s.NameChanged, this._targetNameChanged, this); 28 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event s.NameChanged, this._targetNameChanged, this);
27 WebInspector.targetManager.observeTargets(this); 29 WebInspector.targetManager.observeTargets(this);
30 WebInspector.targetConnectionManager.addEventListener(WebInspector.TargetCon nectionManager.Events.ConnectionAdded, this._connectionAdded, this);
dgozman 2016/10/26 22:14:06 Why can't we talk directly to SubTargetsManager, w
31 WebInspector.targetConnectionManager.addEventListener(WebInspector.TargetCon nectionManager.Events.ConnectionRemoved, this._connectionRemoved, this);
32 WebInspector.targetConnectionManager.connections().forEach(this._showConnect ion.bind(this));
28 }; 33 };
29 34
30 WebInspector.ThreadsSidebarPane.prototype = { 35 WebInspector.ThreadsSidebarPane.prototype = {
31 /** 36 /**
32 * @override 37 * @override
33 * @param {!WebInspector.Target} target 38 * @param {!WebInspector.Target} target
34 */ 39 */
35 targetAdded: function(target) 40 targetAdded: function(target)
36 { 41 {
37 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); 42 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target);
38 if (!debuggerModel) 43 if (!debuggerModel)
39 return; 44 return;
40 45
41 var listItem = new WebInspector.UIList.Item(this._titleForTarget(target) , ""); 46 var connection = WebInspector.TargetConnectionManager.Connection.fromTar get(target);
42 listItem.element.addEventListener("click", this._onListItemClick.bind(th is, listItem), false); 47 var listItem = (connection && this._connectionToListItem.get(connection) ) || this._createListItem();
dgozman 2016/10/26 22:14:06 I'd suggest to remove connections from the collect
eostroukhov 2016/10/27 23:42:25 Then target will need "disconnect" and "isDisconne
48 this._setupTargetItem(listItem, target);
43 var currentTarget = WebInspector.context.flavor(WebInspector.Target); 49 var currentTarget = WebInspector.context.flavor(WebInspector.Target);
44 if (currentTarget === target) 50 if (currentTarget === target)
45 this._selectListItem(listItem); 51 this._selectListItem(listItem);
46 52
47 this._debuggerModelToListItems.set(debuggerModel, listItem); 53 this._debuggerModelToListItems.set(debuggerModel, listItem);
48 this._listItemsToTargets.set(listItem, target); 54 this._listItemsToTargets.set(listItem, target);
49 this.threadList.addItem(listItem);
50 this._updateDebuggerState(debuggerModel); 55 this._updateDebuggerState(debuggerModel);
51 }, 56 },
52 57
53 /** 58 /**
54 * @override 59 * @override
55 * @param {!WebInspector.Target} target 60 * @param {!WebInspector.Target} target
56 */ 61 */
57 targetRemoved: function(target) 62 targetRemoved: function(target)
58 { 63 {
59 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); 64 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target);
60 if (!debuggerModel) 65 if (!debuggerModel)
61 return; 66 return;
62 var listItem = this._debuggerModelToListItems.remove(debuggerModel); 67 var listItem = this._debuggerModelToListItems.remove(debuggerModel);
63 if (listItem) { 68 this._listItemsToTargets.remove(listItem);
64 this._listItemsToTargets.remove(listItem); 69 this._debuggerModelToListItems.remove(debuggerModel);
70 if (!listItem)
71 return;
72 var connection = WebInspector.TargetConnectionManager.Connection.fromTar get(target)
73 if (connection && this._connectionToListItem.get(connection) === listIte m) {
74 this._setupConnectionItem(listItem, connection);
75 } else {
65 this.threadList.removeItem(listItem); 76 this.threadList.removeItem(listItem);
66 } 77 }
67 }, 78 },
68 79
69 /** 80 /**
70 * @param {!WebInspector.Event} event 81 * @param {!WebInspector.Event} event
71 */ 82 */
72 _targetNameChanged: function(event) 83 _targetNameChanged: function(event)
73 { 84 {
74 var target = /** @type {!WebInspector.Target} */ (event.data); 85 var target = /** @type {!WebInspector.Target} */ (event.data);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 169
159 /** 170 /**
160 * @param {!WebInspector.UIList.Item} listItem 171 * @param {!WebInspector.UIList.Item} listItem
161 */ 172 */
162 _onListItemClick: function(listItem) 173 _onListItemClick: function(listItem)
163 { 174 {
164 WebInspector.context.setFlavor(WebInspector.Target, this._listItemsToTar gets.get(listItem)); 175 WebInspector.context.setFlavor(WebInspector.Target, this._listItemsToTar gets.get(listItem));
165 listItem.element.scrollIntoViewIfNeeded(); 176 listItem.element.scrollIntoViewIfNeeded();
166 }, 177 },
167 178
179 /**
180 * @param {!WebInspector.Event} event
181 */
182 _connectionAdded: function(event)
183 {
184 var connection =/** @type {!WebInspector.TargetConnectionManager.Connect ion} */ (event.data);
185 this._showConnection(connection);
186 },
187
188 /**
189 * @param {!WebInspector.Event} event
190 */
191 _connectionRemoved: function(event)
192 {
193 var connection = /** @type {!WebInspector.TargetConnectionManager.Connec tion} */ (event.data);
194 var listItem = this._connectionToListItem.get(connection);
195 this._connectionToListItem.delete(connection)
196 if (!listItem || this._listItemsToTargets.get(listItem))
197 return;
198 this.threadList.removeItem(listItem);
199 },
200
201 /**
202 * @return {!WebInspector.UIList.Item}
203 */
204 _createListItem: function()
205 {
206 var item = new WebInspector.UIList.Item("", "");
207 item.element.addEventListener("click", this._onListItemClick.bind(this, item), false);
208 this.threadList.addItem(item);
209 return item;
210 },
211
212 /**
213 * @param {!WebInspector.UIList.Item} item
214 * @param {!WebInspector.Target} target
215 */
216 _setupTargetItem: function(item, target)
217 {
218 item.setTitle(this._titleForTarget(target));
219 item.setSubtitle("");
220 item.setDimmed(false);
221 var connection = WebInspector.TargetConnectionManager.Connection.fromTar get(target);
222 if (connection)
223 item.setAction("Disconnect", () => connection.disconnect());
224 else
225 item.setAction(null, null);
226 },
227
228 /**
229 * @param {!WebInspector.UIList.Item} item
230 * @param {!WebInspector.TargetConnectionManager.Connection} connection
231 */
232 _setupConnectionItem: function(item, connection)
233 {
234 item.setTitle(connection.name());
235 item.setSubtitle("");
236 var clickFn = this._onListItemClick.bind(this, item);
237 item.setAction("Connect", (() => connection.connect().then(clickFn)));
238 item.setDimmed(true);
239 },
240
241 /**
242 * @param {!WebInspector.TargetConnectionManager.Connection} connection
243 */
244 _showConnection: function(connection)
245 {
246 var listItem = this._createListItem();
247 this._setupConnectionItem(listItem, connection);
248 this._connectionToListItem.set(connection, listItem);
249 },
168 250
169 __proto__: WebInspector.VBox.prototype 251 __proto__: WebInspector.VBox.prototype
170 }; 252 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698