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

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

Issue 2451363002: [DevTools] Move main target/connection to TargetManager. (Closed)
Patch Set: rebased 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 f2afa4f500777defa67dfee04da99e0fe2030151..ed342a458c8f316ecf5bc4e70465781d26d81763 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/TargetManager.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/TargetManager.js
@@ -234,23 +234,6 @@ WebInspector.TargetManager.prototype = {
},
/**
- * @param {function(function(string)):!Promise<!InspectorBackendClass.Connection>} interceptor
- */
- setMainConnectionInterceptor: function(interceptor)
- {
- this._mainConnectionInterceptor = interceptor;
- },
-
- /**
- * @param {function(string)} onMessage
- * @return {!Promise<!InspectorBackendClass.Connection>}
- */
- interceptMainConnection: function(onMessage)
- {
- return this._mainConnectionInterceptor.call(null, onMessage);
- },
-
- /**
* @param {!WebInspector.Target} target
* @return {!Array<!WebInspector.TargetManager.Observer>}
*/
@@ -380,6 +363,63 @@ WebInspector.TargetManager.prototype = {
setImmediate(resourceTreeModel.resumeReload.bind(resourceTreeModel));
},
+ /**
+ * @param {function()} webSocketConnectionLostCallback
+ */
+ connectToMainTarget: function(webSocketConnectionLostCallback)
+ {
+ this._webSocketConnectionLostCallback = webSocketConnectionLostCallback;
+ this._connectAndCreateMainTarget();
+ },
+
+ _connectAndCreateMainTarget: function()
+ {
+ var capabilities =
+ WebInspector.Target.Capability.Browser | WebInspector.Target.Capability.DOM |
+ WebInspector.Target.Capability.JS | WebInspector.Target.Capability.Log |
+ WebInspector.Target.Capability.Network | WebInspector.Target.Capability.Target;
+ if (Runtime.queryParam("isSharedWorker")) {
+ capabilities =
+ WebInspector.Target.Capability.Browser | WebInspector.Target.Capability.Log |
+ WebInspector.Target.Capability.Network | WebInspector.Target.Capability.Target;
+ } else if (Runtime.queryParam("v8only")) {
+ capabilities = WebInspector.Target.Capability.JS;
+ }
+
+ var target = this.createTarget(WebInspector.UIString("Main"), capabilities, this._createMainConnection.bind(this), null);
+ target.runtimeAgent().runIfWaitingForDebugger();
+ },
+
+ /**
+ * @param {!InspectorBackendClass.Connection.Params} params
+ * @return {!InspectorBackendClass.Connection}
+ */
+ _createMainConnection: function(params)
+ {
+ if (Runtime.queryParam("ws")) {
+ var ws = "ws://" + Runtime.queryParam("ws");
+ this._mainConnection = new WebInspector.WebSocketConnection(ws, this._webSocketConnectionLostCallback, params);
+ } else if (InspectorFrontendHost.isHostedMode()) {
+ this._mainConnection = new WebInspector.StubConnection(params);
+ } else {
+ this._mainConnection = new WebInspector.MainConnection(params);
+ }
+ return this._mainConnection;
+ },
+
+ /**
+ * @param {function(string)} onMessage
+ * @return {!Promise<!InspectorBackendClass.Connection>}
+ */
+ interceptMainConnection: function(onMessage)
+ {
+ var params = {
+ onMessage: onMessage,
+ onDisconnect: this._connectAndCreateMainTarget.bind(this)
+ };
+ return this._mainConnection.disconnect().then(this._createMainConnection.bind(this, params));
+ },
+
__proto__: WebInspector.Object.prototype
};

Powered by Google App Engine
This is Rietveld 408576698