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

Unified Diff: third_party/WebKit/Source/devtools/front_end/audits2/Audits2Panel.js

Issue 2421913003: DevTools: allow reattaching main target live. (Closed)
Patch Set: link fixed 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/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..d4026c0c1086d2fcd1fa41c1183847cc602f5ed2 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,44 @@ 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");
+ });
+ },
+
+ /**
+ * @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.yieldConnection();
+ this._backend.dispose();
+ delete this._backend;
+ delete this._backendPromise;
+ });
},
/**
- * @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;
+ 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

Powered by Google App Engine
This is Rietveld 408576698