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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @constructor 6 * @constructor
7 * @extends {WebInspector.Panel} 7 * @extends {WebInspector.Panel}
8 */ 8 */
9 WebInspector.Audits2Panel = function() 9 WebInspector.Audits2Panel = function()
10 { 10 {
11 WebInspector.Panel.call(this, "audits2"); 11 WebInspector.Panel.call(this, "audits2");
12 this.contentElement.classList.add("vbox"); 12 this.contentElement.classList.add("vbox");
13 this.contentElement.appendChild(createTextButton(WebInspector.UIString("Star t"), this._start.bind(this))); 13 this.contentElement.appendChild(createTextButton(WebInspector.UIString("Star t"), this._start.bind(this)));
14 this.contentElement.appendChild(createTextButton(WebInspector.UIString("Stop "), this._stop.bind(this))); 14 this.contentElement.appendChild(createTextButton(WebInspector.UIString("Stop "), this._stop.bind(this)));
15 } 15 }
16 16
17 WebInspector.Audits2Panel.prototype = { 17 WebInspector.Audits2Panel.prototype = {
18 _start: function() 18 _start: function()
19 { 19 {
20 this._backend().then(backend => backend ? backend.send("start") : undefi ned).then(console.error.bind(console, "STARTED")); 20 WebInspector.targetManager.interceptMainConnection(this._dispatchProtoco lMessage.bind(this)).then(rawConnection => {
21 this._rawConnection = rawConnection;
22 this._send("start");
23 });
24 },
25
26 /**
27 * @param {string} message
28 */
29 _dispatchProtocolMessage: function(message)
30 {
31 this._send("dispatchProtocolMessage", {message: message});
21 }, 32 },
22 33
23 _stop: function() 34 _stop: function()
24 { 35 {
25 this._backend().then(backend => backend ? backend.send("stop") : undefin ed).then(console.error.bind(console, "STOPPED")); 36 this._send("stop").then(() => {
37 this._rawConnection.yieldConnection();
38 this._backend.dispose();
39 delete this._backend;
40 delete this._backendPromise;
41 });
26 }, 42 },
27 43
28 /** 44 /**
29 * @return {!Promise<?WebInspector.ServiceManager.Service>} 45 * @param {string} method
46 * @param {!Object=} params
47 * @return {!Promise<!Object|undefined>}
30 */ 48 */
31 _backend: function() 49 _send: function(method, params)
32 { 50 {
33 if (!this._backendPromise) 51 if (!this._backendPromise) {
34 this._backendPromise = WebInspector.serviceManager.createAppService( "audits2_worker", "Audits2Service", false); 52 this._backendPromise = WebInspector.serviceManager.createAppService( "audits2_worker", "Audits2Service", false).then(backend => {
35 return this._backendPromise; 53 this._backend = backend;
54 this._backend.on("sendProtocolMessage", result => this._rawConne ction.send(result.message));
55 });
56 }
57 return this._backendPromise.then(() => this._backend ? this._backend.sen d(method, params) : undefined);
36 }, 58 },
37 59
38 __proto__: WebInspector.Panel.prototype 60 __proto__: WebInspector.Panel.prototype
39 } 61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698