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 e6ab2af2606b6fbf011d63dd77b21d014cf6bf24..2eae04dee681ec65765a01456668b2581e5adf5a 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/audits2/Audits2Panel.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/audits2/Audits2Panel.js |
| @@ -17,22 +17,39 @@ WebInspector.Audits2Panel = function() |
| WebInspector.Audits2Panel.prototype = { |
| _start: function() |
| { |
| - this._backend().then(backend => backend ? backend.send("start") : undefined).then(console.error.bind(console, "STARTED")); |
| + WebInspector.targetManager.interceptMainConnection(this._dispatchProtocolMessage.bind(this)).then(rawConnection => { |
| + this._rawConnection = rawConnection; |
| + }); |
| + this._send("start"); |
|
dgozman
2016/10/15 00:26:26
Let's chain this.
|
| + }, |
| + |
| + /** |
| + * @param {string} message |
| + */ |
| + _dispatchProtocolMessage: function(message) |
| + { |
| + this._send("dispatchProtocolMessage", {message: message}); |
| }, |
| _stop: function() |
| { |
| - this._backend().then(backend => backend ? backend.send("stop") : undefined).then(console.error.bind(console, "STOPPED")); |
| + this._send("stop").then(() => this._rawConnection.yield()); |
| }, |
| /** |
| - * @return {!Promise<?WebInspector.ServiceManager.Service>} |
| + * @param {string} method |
| + * @param {!Object=} params |
| + * @return {!Promise<!Object|undefined>} |
| */ |
| - _backend: function() |
| + _send: function(method, params) |
| { |
| - if (!this._backendPromise) |
| - this._backendPromise = WebInspector.serviceManager.createAppService("audits2_worker", "Audits2Service", false); |
| - return this._backendPromise; |
| + if (!this._backendPromise) { |
| + this._backendPromise = WebInspector.serviceManager.createAppService("audits2_worker", "Audits2Service", false).then(backend => { |
| + this._backend = backend; |
|
dgozman
2016/10/15 00:26:26
Let's clear this._backend at some point.
|
| + this._backend.on("sendProtocolMessage", result => this._rawConnection.send(result.message)); |
| + }); |
| + } |
| + return this._backendPromise.then(() => this._backend ? this._backend.send(method, params) : undefined); |
| }, |
| __proto__: WebInspector.Panel.prototype |