Chromium Code Reviews| 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 ede8832fc657744ca5342a5599140bb716192894..2c5eeda09b838315d900a8a606bef13f515e57da 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/main/Main.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/main/Main.js |
| @@ -30,6 +30,7 @@ |
| /** |
| * @constructor |
| + * @implements {WebInspector.TargetManager.MainChannelInterceptor} |
| * @suppressGlobalPropertiesCheck |
| */ |
| WebInspector.Main = function() |
| @@ -267,41 +268,57 @@ WebInspector.Main.prototype = { |
| _connectAndCreateTarget: function() |
| { |
| console.time("Main._connectAndCreateTarget"); |
| - this._createConnection().then(connection => { |
| - this._createMainTarget(connection); |
| + this._createChannel().then(channel => { |
| + this._mainChannel = channel; |
| + this._createMainTarget(channel); |
| InspectorFrontendHost.readyForTest(); |
| - WebInspector.targetManager.setMainTargetFactory(this._recreateMainTarget.bind(this)); |
| + WebInspector.targetManager.setMainChannelInterceptor(this); |
|
pfeldman
2016/10/21 21:04:34
design: awkward API
|
| // Asynchronously run the extensions. |
| console.timeEnd("Main._connectAndCreateTarget"); |
| setTimeout(this._lateInitialization.bind(this), 100); |
| }); |
| }, |
| - _recreateMainTarget: function() |
| + /** |
| + * @override |
| + * @return {!Promise<!InspectorBackendClass.Channel>} |
| + */ |
| + takeMainChannel: function() |
| { |
| - this._createConnection().then(this._createMainTarget.bind(this)); |
| + var fulfill; |
| + var promise = new Promise(resolve => fulfill = resolve); |
| + this._mainChannel.reconnect(() => fulfill(this._mainChannel)); |
|
pfeldman
2016/10/21 21:04:34
return this._mainChannel.reconnect().then(() => th
|
| + return promise; |
| }, |
| /** |
| - * @return {!Promise<!InspectorBackendClass.Connection>} |
| + * @override |
| */ |
| - _createConnection: function() |
| + yieldMainChannel: function() |
| + { |
| + this._mainChannel.reconnect(() => this._createMainTarget(this._mainChannel)); |
| + }, |
| + |
| + /** |
| + * @return {!Promise<!InspectorBackendClass.Channel>} |
| + */ |
| + _createChannel: function() |
| { |
| if (Runtime.queryParam("ws")) { |
| var ws = "ws://" + Runtime.queryParam("ws"); |
| - return WebInspector.WebSocketConnection.Create(ws).then(connection => { |
| - connection.addEventListener(InspectorBackendClass.Connection.Events.Disconnected, onDisconnected); |
| - return connection; |
| + return WebInspector.WebSocketChannel.Create(ws).then(channel => { |
|
pfeldman
2016/10/21 21:04:34
You are just renaming connection to channel, while
|
| + channel.addEventListener(InspectorBackendClass.Channel.Events.ChannelClosed, onChannelClosed); |
| + return channel; |
| }); |
| } |
| - return /** @type {!Promise<!InspectorBackendClass.Connection>} */ (Promise.resolve(InspectorFrontendHost.isHostedMode() ? |
| - new WebInspector.StubConnection() : new WebInspector.MainConnection())); |
| + return /** @type {!Promise<!InspectorBackendClass.Channel>} */ (Promise.resolve(InspectorFrontendHost.isHostedMode() ? |
| + new WebInspector.StubChannel() : new WebInspector.MainChannel())); |
| /** |
| * @param {!WebInspector.Event} event |
| */ |
| - function onDisconnected(event) |
| + function onChannelClosed(event) |
| { |
| if (WebInspector._disconnectedScreenWithReasonWasShown) |
| return; |
| @@ -310,9 +327,9 @@ WebInspector.Main.prototype = { |
| }, |
| /** |
| - * @param {!InspectorBackendClass.Connection} connection |
| + * @param {!InspectorBackendClass.Channel} channel |
| */ |
| - _createMainTarget: function(connection) |
| + _createMainTarget: function(channel) |
| { |
| console.time("Main._createMainTarget"); |
| var capabilities = |
| @@ -327,7 +344,7 @@ WebInspector.Main.prototype = { |
| capabilities = WebInspector.Target.Capability.JS; |
| } |
| - var target = WebInspector.targetManager.createTarget(WebInspector.UIString("Main"), capabilities, connection, null); |
| + var target = WebInspector.targetManager.createTarget(WebInspector.UIString("Main"), capabilities, channel, null); |
| target.registerInspectorDispatcher(new WebInspector.Main.InspectorDomainDispatcher(target)); |
| target.runtimeAgent().runIfWaitingForDebugger(); |
| if (target.hasBrowserCapability()) |
| @@ -947,23 +964,6 @@ WebInspector.Main.InspectedNodeRevealer.prototype = { |
| } |
| /** |
| - * @param {string} method |
| - * @param {?Object} params |
| - * @return {!Promise} |
| - */ |
| -WebInspector.sendOverProtocol = function(method, params) |
| -{ |
| - var connection = WebInspector.targetManager.mainTarget().connection(); |
| - return new Promise((resolve, reject) => { |
| - connection.sendRawMessageForTesting(method, params, (err, result) => { |
| - if (err) |
| - return reject(err); |
| - return resolve(result); |
| - }); |
| - }); |
| -} |
| - |
| -/** |
| * @constructor |
| * @extends {WebInspector.VBox} |
| * @param {string} reason |