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

Unified 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, 2 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/sources/ThreadsSidebarPane.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sources/ThreadsSidebarPane.js b/third_party/WebKit/Source/devtools/front_end/sources/ThreadsSidebarPane.js
index 7008dbf052056ffe07953cb56175a55e0d1596d8..fbcc4e4e4a4f8f7a2fb7ed79bc0e9b9370a379e6 100644
--- a/third_party/WebKit/Source/devtools/front_end/sources/ThreadsSidebarPane.js
+++ b/third_party/WebKit/Source/devtools/front_end/sources/ThreadsSidebarPane.js
@@ -17,6 +17,8 @@ WebInspector.ThreadsSidebarPane = function()
this._listItemsToTargets = new Map();
/** @type {?WebInspector.UIList.Item} */
this._selectedListItem = null;
+ /** @type {!Map.<!WebInspector.TargetConnectionManager.Connection, !WebInspector.UIList.Item>} */
+ this._connectionToListItem = new Map();
this.threadList = new WebInspector.UIList();
this.threadList.show(this.element);
WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.DebuggerPaused, this._onDebuggerStateChanged, this);
@@ -25,6 +27,9 @@ WebInspector.ThreadsSidebarPane = function()
WebInspector.context.addFlavorChangeListener(WebInspector.Target, this._targetChanged, this);
WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Events.NameChanged, this._targetNameChanged, this);
WebInspector.targetManager.observeTargets(this);
+ WebInspector.targetConnectionManager.addEventListener(WebInspector.TargetConnectionManager.Events.ConnectionAdded, this._connectionAdded, this);
dgozman 2016/10/26 22:14:06 Why can't we talk directly to SubTargetsManager, w
+ WebInspector.targetConnectionManager.addEventListener(WebInspector.TargetConnectionManager.Events.ConnectionRemoved, this._connectionRemoved, this);
+ WebInspector.targetConnectionManager.connections().forEach(this._showConnection.bind(this));
};
WebInspector.ThreadsSidebarPane.prototype = {
@@ -38,15 +43,15 @@ WebInspector.ThreadsSidebarPane.prototype = {
if (!debuggerModel)
return;
- var listItem = new WebInspector.UIList.Item(this._titleForTarget(target), "");
- listItem.element.addEventListener("click", this._onListItemClick.bind(this, listItem), false);
+ var connection = WebInspector.TargetConnectionManager.Connection.fromTarget(target);
+ 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
+ this._setupTargetItem(listItem, target);
var currentTarget = WebInspector.context.flavor(WebInspector.Target);
if (currentTarget === target)
this._selectListItem(listItem);
this._debuggerModelToListItems.set(debuggerModel, listItem);
this._listItemsToTargets.set(listItem, target);
- this.threadList.addItem(listItem);
this._updateDebuggerState(debuggerModel);
},
@@ -60,8 +65,14 @@ WebInspector.ThreadsSidebarPane.prototype = {
if (!debuggerModel)
return;
var listItem = this._debuggerModelToListItems.remove(debuggerModel);
- if (listItem) {
- this._listItemsToTargets.remove(listItem);
+ this._listItemsToTargets.remove(listItem);
+ this._debuggerModelToListItems.remove(debuggerModel);
+ if (!listItem)
+ return;
+ var connection = WebInspector.TargetConnectionManager.Connection.fromTarget(target)
+ if (connection && this._connectionToListItem.get(connection) === listItem) {
+ this._setupConnectionItem(listItem, connection);
+ } else {
this.threadList.removeItem(listItem);
}
},
@@ -165,6 +176,77 @@ WebInspector.ThreadsSidebarPane.prototype = {
listItem.element.scrollIntoViewIfNeeded();
},
+ /**
+ * @param {!WebInspector.Event} event
+ */
+ _connectionAdded: function(event)
+ {
+ var connection =/** @type {!WebInspector.TargetConnectionManager.Connection} */ (event.data);
+ this._showConnection(connection);
+ },
+
+ /**
+ * @param {!WebInspector.Event} event
+ */
+ _connectionRemoved: function(event)
+ {
+ var connection = /** @type {!WebInspector.TargetConnectionManager.Connection} */ (event.data);
+ var listItem = this._connectionToListItem.get(connection);
+ this._connectionToListItem.delete(connection)
+ if (!listItem || this._listItemsToTargets.get(listItem))
+ return;
+ this.threadList.removeItem(listItem);
+ },
+
+ /**
+ * @return {!WebInspector.UIList.Item}
+ */
+ _createListItem: function()
+ {
+ var item = new WebInspector.UIList.Item("", "");
+ item.element.addEventListener("click", this._onListItemClick.bind(this, item), false);
+ this.threadList.addItem(item);
+ return item;
+ },
+
+ /**
+ * @param {!WebInspector.UIList.Item} item
+ * @param {!WebInspector.Target} target
+ */
+ _setupTargetItem: function(item, target)
+ {
+ item.setTitle(this._titleForTarget(target));
+ item.setSubtitle("");
+ item.setDimmed(false);
+ var connection = WebInspector.TargetConnectionManager.Connection.fromTarget(target);
+ if (connection)
+ item.setAction("Disconnect", () => connection.disconnect());
+ else
+ item.setAction(null, null);
+ },
+
+ /**
+ * @param {!WebInspector.UIList.Item} item
+ * @param {!WebInspector.TargetConnectionManager.Connection} connection
+ */
+ _setupConnectionItem: function(item, connection)
+ {
+ item.setTitle(connection.name());
+ item.setSubtitle("");
+ var clickFn = this._onListItemClick.bind(this, item);
+ item.setAction("Connect", (() => connection.connect().then(clickFn)));
+ item.setDimmed(true);
+ },
+
+ /**
+ * @param {!WebInspector.TargetConnectionManager.Connection} connection
+ */
+ _showConnection: function(connection)
+ {
+ var listItem = this._createListItem();
+ this._setupConnectionItem(listItem, connection);
+ this._connectionToListItem.set(connection, listItem);
+ },
__proto__: WebInspector.VBox.prototype
};

Powered by Google App Engine
This is Rietveld 408576698