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

Unified Diff: third_party/WebKit/Source/devtools/front_end/main/Main.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
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/sdk/Connections.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/main/Main.js
diff --git a/third_party/WebKit/Source/devtools/front_end/main/Main.js b/third_party/WebKit/Source/devtools/front_end/main/Main.js
index c45b38f0ae489c0c0987e2a570e55d56c05ee5a0..63c929dc42a5d71e0987049992f3c8e248a06bc6 100644
--- a/third_party/WebKit/Source/devtools/front_end/main/Main.js
+++ b/third_party/WebKit/Source/devtools/front_end/main/Main.js
@@ -207,6 +207,7 @@ WebInspector.Main.prototype = {
WebInspector.ShortcutsScreen.registerShortcuts();
this._registerForwardedShortcuts();
this._registerMessageSinkListener();
+ new WebInspector.Main.InspectorDomainObserver();
self.runtime.extension(WebInspector.AppProvider).instance().then(this._showAppUI.bind(this));
console.timeEnd("Main._createAppUI");
@@ -266,77 +267,18 @@ WebInspector.Main.prototype = {
_initializeTarget: function()
{
- this._connectAndCreateTarget();
+ console.time("Main._initializeTarget");
+ WebInspector.targetManager.connectToMainTarget(webSocketConnectionLost);
+
InspectorFrontendHost.readyForTest();
- WebInspector.targetManager.setMainConnectionInterceptor(this._interceptMainConnection.bind(this));
// Asynchronously run the extensions.
setTimeout(this._lateInitialization.bind(this), 100);
- },
-
- _connectAndCreateTarget: function()
- {
- console.time("Main._connectAndCreateTarget");
-
- 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 = WebInspector.targetManager.createTarget(WebInspector.UIString("Main"), capabilities, this._createMainConnection.bind(this), null);
- target.registerInspectorDispatcher(new WebInspector.Main.InspectorDomainDispatcher(target));
- target.runtimeAgent().runIfWaitingForDebugger();
- if (target.hasBrowserCapability())
- target.inspectorAgent().enable();
-
- console.timeEnd("Main._connectAndCreateTarget");
- },
-
- /**
- * @param {function(string)} onMessage
- * @return {!Promise<!InspectorBackendClass.Connection>}
- */
- _interceptMainConnection: function(onMessage)
- {
- var params = {
- onMessage: onMessage,
- onDisconnect: this._connectAndCreateTarget.bind(this)
- };
- return this._connection.disconnect().then(this._createMainConnection.bind(this, params));
- },
-
- /**
- * @param {!InspectorBackendClass.Connection.Params} params
- * @return {!InspectorBackendClass.Connection}
- */
- _createMainConnection: function(params)
- {
- if (Runtime.queryParam("ws")) {
- var ws = "ws://" + Runtime.queryParam("ws");
- params.onDisconnect = onDisconnect.bind(null, params.onDisconnect);
- this._connection = new WebInspector.WebSocketConnection(ws, params);
- } else if (InspectorFrontendHost.isHostedMode()) {
- this._connection = new WebInspector.StubConnection(params);
- } else {
- this._connection = new WebInspector.MainConnection(params);
- }
- return this._connection;
+ console.timeEnd("Main._initializeTarget");
- /**
- * @param {function(string)} callback
- * @param {string} reason
- */
- function onDisconnect(callback, reason)
+ function webSocketConnectionLost()
{
if (!WebInspector._disconnectedScreenWithReasonWasShown)
- WebInspector.RemoteDebuggingTerminatedScreen.show(reason);
- callback(reason);
+ WebInspector.RemoteDebuggingTerminatedScreen.show("WebSocket disconnected");
}
},
@@ -555,6 +497,35 @@ WebInspector.Main.prototype = {
/**
* @constructor
+ * @implements {WebInspector.TargetManager.Observer}
+ */
+WebInspector.Main.InspectorDomainObserver = function()
+{
+ WebInspector.targetManager.observeTargets(this, WebInspector.Target.Capability.Browser);
+};
+
+WebInspector.Main.InspectorDomainObserver.prototype = {
+ /**
+ * @override
+ * @param {!WebInspector.Target} target
+ */
+ targetAdded: function(target)
+ {
+ target.registerInspectorDispatcher(new WebInspector.Main.InspectorDomainDispatcher(target));
+ target.inspectorAgent().enable();
+ },
+
+ /**
+ * @override
+ * @param {!WebInspector.Target} target
+ */
+ targetRemoved: function(target)
+ {
+ },
+};
+
+/**
+ * @constructor
* @implements {InspectorAgent.Dispatcher}
* @param {!WebInspector.Target} target
*/
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/sdk/Connections.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698