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

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

Issue 2431223003: [DevTools]: Require explicit connection (Closed)
Patch Set: Reworked - again 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..0d9e816e8a772d8bcfd0be729c4dff1bee6cc909 100644
--- a/third_party/WebKit/Source/devtools/front_end/sources/ThreadsSidebarPane.js
+++ b/third_party/WebKit/Source/devtools/front_end/sources/ThreadsSidebarPane.js
@@ -11,12 +11,16 @@ WebInspector.ThreadsSidebarPane = function()
{
WebInspector.VBox.call(this);
- /** @type {!Map.<!WebInspector.DebuggerModel, !WebInspector.UIList.Item>} */
+ /** @type {!Map<!WebInspector.DebuggerModel, !WebInspector.UIList.Item>} */
this._debuggerModelToListItems = new Map();
- /** @type {!Map.<!WebInspector.UIList.Item, !WebInspector.Target>} */
+ /** @type {!Map<!WebInspector.UIList.Item, !WebInspector.Target>} */
this._listItemsToTargets = new Map();
/** @type {?WebInspector.UIList.Item} */
this._selectedListItem = null;
+ /** @type {!Map<!WebInspector.PendingConnection, !WebInspector.UIList.Item>} */
+ this._connectionToListItem = new Map();
+ /** @type {!Map<!WebInspector.Target, ?WebInspector.PendingConnection>} */
+ this._targetToConnection = new Map();
this.threadList = new WebInspector.UIList();
this.threadList.show(this.element);
WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.DebuggerPaused, this._onDebuggerStateChanged, this);
@@ -24,7 +28,13 @@ WebInspector.ThreadsSidebarPane = function()
WebInspector.targetManager.addModelListener(WebInspector.RuntimeModel, WebInspector.RuntimeModel.Events.ExecutionContextChanged, this._onExecutionContextChanged, this);
WebInspector.context.addFlavorChangeListener(WebInspector.Target, this._targetChanged, this);
WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Events.NameChanged, this._targetNameChanged, this);
+ WebInspector.targetManager.addModelListener(WebInspector.SubTargetsManager, WebInspector.SubTargetsManager.Events.SubTargetConnectionCreated, this._connectionAdded, this);
+ WebInspector.targetManager.addModelListener(WebInspector.SubTargetsManager, WebInspector.SubTargetsManager.Events.SubTargetConnectionDestroyed, this._connectionRemoved, this);
WebInspector.targetManager.observeTargets(this);
+
+ for (var target of WebInspector.targetManager.targets(WebInspector.Target.Capability.Target))
dgozman 2016/10/28 18:31:36 {} around body
eostroukhov 2016/11/01 20:28:15 Done.
+ for (var connection of WebInspector.SubTargetsManager.fromTarget(target).targetConnections())
+ this._showConnection(connection);
};
WebInspector.ThreadsSidebarPane.prototype = {
@@ -38,15 +48,24 @@ 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 = null;
+ for (var conn of this._connectionToListItem.keys()) {
dgozman 2016/10/28 18:31:36 no abbreviations
eostroukhov 2016/11/01 20:28:15 Done.
+ if (conn.target() !== target)
+ continue
dgozman 2016/10/28 18:31:36 missing semicolon
eostroukhov 2016/11/01 20:28:15 Done.
+ connection = conn;
+ break;
+ }
+ this._targetToConnection.set(target, connection);
+ var listItem = connection ? this._connectionToListItem.get(connection) : null;
+ if (!listItem)
+ listItem = this._createListItem();
+ this._setupTargetItem(listItem, target, connection);
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 +79,15 @@ 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 = this._targetToConnection.get(target);
+ this._targetToConnection.delete(target);
+ if (connection && this._connectionToListItem.get(connection) === listItem) {
+ this._setupConnectionItem(listItem, connection);
+ } else {
this.threadList.removeItem(listItem);
}
},
@@ -165,6 +191,76 @@ WebInspector.ThreadsSidebarPane.prototype = {
listItem.element.scrollIntoViewIfNeeded();
},
+ /**
+ * @param {!WebInspector.Event} event
+ */
+ _connectionAdded: function(event)
+ {
+ var connection =/** @type {!WebInspector.PendingConnection} */ (event.data);
+ this._showConnection(connection);
+ },
+
+ /**
+ * @param {!WebInspector.Event} event
+ */
+ _connectionRemoved: function(event)
+ {
+ var connection = /** @type {!WebInspector.PendingConnection} */ (event.data);
+ var listItem = this._connectionToListItem.get(connection);
+ this._connectionToListItem.delete(connection)
dgozman 2016/10/28 18:31:36 missing semicolon...
eostroukhov 2016/11/01 20:28:15 Done.
+ 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
+ * @param {?WebInspector.PendingConnection} connection
+ */
+ _setupTargetItem: function(item, target, connection)
+ {
+ item.setTitle(this._titleForTarget(target));
+ item.setSubtitle("");
+ item.setDimmed(false);
+ if (connection)
+ item.setAction("Disconnect", () => connection.disconnect());
+ else
+ item.setAction(null, null);
+ },
+
+ /**
+ * @param {!WebInspector.UIList.Item} item
+ * @param {!WebInspector.PendingConnection} connection
+ */
+ _setupConnectionItem: function(item, connection)
+ {
+ item.setTitle(connection.name());
+ item.setSubtitle("");
+ item.setAction("Connect", (() => connection.connect().then(() => this._onListItemClick(item))));
+ item.setDimmed(true);
+ },
+
+ /**
+ * @param {!WebInspector.PendingConnection} 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