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

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

Issue 2421913003: DevTools: allow reattaching main target live. (Closed)
Patch Set: link fixed 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/sdk/TargetManager.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/TargetManager.js b/third_party/WebKit/Source/devtools/front_end/sdk/TargetManager.js
index a98d55b9dd904ae763c68a6781aa28842efe23b0..1ff7ec90df08bf3e3f6f6dc38d0b96f67a5f0809 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/TargetManager.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/TargetManager.js
@@ -236,6 +236,38 @@ WebInspector.TargetManager.prototype = {
},
/**
+ * @param {function()} factory
+ */
+ setMainTargetFactory: function(factory)
+ {
+ this._mainTargetFactory = factory;
+ },
+
+ /**
+ * @param {function(string)} dispatch
+ * @return {!Promise<!WebInspector.RawProtocolConnection>}
+ */
+ interceptMainConnection: function(dispatch)
+ {
+ var target = WebInspector.targetManager.mainTarget();
+ if (target)
+ target.connection().close();
+
+ var fulfill;
+ var result = new Promise(resolve => fulfill = resolve);
+ InspectorFrontendHost.reattach(() => fulfill(new WebInspector.RawProtocolConnection(dispatch, yieldCallback.bind(this))));
+ return result;
+
+ /**
+ * @this {WebInspector.TargetManager}
+ */
+ function yieldCallback()
+ {
+ InspectorFrontendHost.reattach(this._mainTargetFactory());
+ }
+ },
+
+ /**
* @param {!WebInspector.Target} target
* @return {!Array<!WebInspector.TargetManager.Observer>}
*/
@@ -289,6 +321,8 @@ WebInspector.TargetManager.prototype = {
*/
removeTarget: function(target)
{
+ if (!this._targets.includes(target))
+ return;
this._targets.remove(target);
var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(target);
var treeModelListeners = resourceTreeModel && resourceTreeModel[WebInspector.TargetManager._listenersSymbol];
@@ -309,14 +343,6 @@ WebInspector.TargetManager.prototype = {
}
},
- removeAllTargets: function()
- {
- var targets = this._targets.slice();
- for (var i = targets.length - 1; i >=0 ; --i)
- this.removeTarget(targets[i]);
- this._targets = [];
- },
-
/**
* @param {number=} capabilitiesMask
* @return {!Array.<!WebInspector.Target>}

Powered by Google App Engine
This is Rietveld 408576698