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

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

Issue 2421913003: DevTools: allow reattaching main target live. (Closed)
Patch Set: review comments addressed. 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 39c039703e2b9a2a135a39253a766bcf76e65f74..78fa6c6852c36da670fcb185e3e348309670b64d 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/TargetManager.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/TargetManager.js
@@ -235,6 +235,37 @@ 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();
dgozman 2016/10/17 17:21:16 For hosted mode: if (target) target.connection()
+ 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>}
*/
@@ -288,6 +319,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];
@@ -308,14 +341,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