Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/audits2/Audits2Panel.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/audits2/Audits2Panel.js b/third_party/WebKit/Source/devtools/front_end/audits2/Audits2Panel.js |
| index d4026c0c1086d2fcd1fa41c1183847cc602f5ed2..2e0d0d9270f70449917cf908db5c8002fd812fc4 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/audits2/Audits2Panel.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/audits2/Audits2Panel.js |
| @@ -17,27 +17,31 @@ WebInspector.Audits2Panel = function() |
| WebInspector.Audits2Panel.prototype = { |
| _start: function() |
| { |
| - WebInspector.targetManager.interceptMainConnection(this._dispatchProtocolMessage.bind(this)).then(rawConnection => { |
| - this._rawConnection = rawConnection; |
| + WebInspector.targetManager.mainChannelInterceptor().takeMainChannel().then(channel => { |
| + this._channel = channel; |
| + this._channel.addEventListener(InspectorBackendClass.Channel.Events.MessageReceived, this._dispatchProtocolMessage, this); |
|
pfeldman
2016/10/21 21:04:34
design: You don't want to expose the MessageReceiv
|
| this._send("start"); |
| }); |
| }, |
| /** |
| - * @param {string} message |
| + * @param {!WebInspector.Event} event |
| */ |
| - _dispatchProtocolMessage: function(message) |
| + _dispatchProtocolMessage: function(event) |
| { |
| + var message = /** @type {!Object|string} */ (event.data); |
| this._send("dispatchProtocolMessage", {message: message}); |
| }, |
| _stop: function() |
| { |
| this._send("stop").then(() => { |
| - this._rawConnection.yieldConnection(); |
| + this._channel.removeEventListener(InspectorBackendClass.Channel.Events.MessageReceived, this._dispatchProtocolMessage, this); |
| this._backend.dispose(); |
| + delete this._channel; |
| delete this._backend; |
| delete this._backendPromise; |
| + WebInspector.targetManager.mainChannelInterceptor().yieldMainChannel(); |
|
pfeldman
2016/10/21 21:04:33
design: only the one how has connection should be
|
| }); |
| }, |
| @@ -51,7 +55,7 @@ WebInspector.Audits2Panel.prototype = { |
| if (!this._backendPromise) { |
| this._backendPromise = WebInspector.serviceManager.createAppService("audits2_worker", "Audits2Service", false).then(backend => { |
| this._backend = backend; |
| - this._backend.on("sendProtocolMessage", result => this._rawConnection.send(result.message)); |
| + this._backend.on("sendProtocolMessage", result => this._channel.sendMessage(result.message)); |
| }); |
| } |
| return this._backendPromise.then(() => this._backend ? this._backend.send(method, params) : undefined); |