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

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

Issue 2466123002: DevTools: reformat front-end code to match chromium style. (Closed)
Patch Set: all done Created 4 years, 1 month 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 /**
5 * @unrestricted
6 */
7 WebInspector.Audits2Panel = class extends WebInspector.Panel {
8 constructor() {
9 super('audits2');
10 this.contentElement.classList.add('vbox');
11 this.contentElement.appendChild(createTextButton(WebInspector.UIString('Star t'), this._start.bind(this)));
12 this.contentElement.appendChild(createTextButton(WebInspector.UIString('Stop '), this._stop.bind(this)));
13 this._resultElement = this.contentElement.createChild('div', 'overflow-auto' );
14 }
4 15
5 /** 16 _start() {
6 * @constructor 17 WebInspector.targetManager.interceptMainConnection(this._dispatchProtocolMes sage.bind(this)).then(rawConnection => {
7 * @extends {WebInspector.Panel} 18 this._rawConnection = rawConnection;
8 */ 19 this._send('start').then(result => {
9 WebInspector.Audits2Panel = function() 20 var section = new WebInspector.ObjectPropertiesSection(
10 { 21 WebInspector.RemoteObject.fromLocalObject(result), WebInspector.UISt ring('Audit Results'));
11 WebInspector.Panel.call(this, "audits2"); 22 this._resultElement.appendChild(section.element);
12 this.contentElement.classList.add("vbox"); 23 this._stop();
13 this.contentElement.appendChild(createTextButton(WebInspector.UIString("Star t"), this._start.bind(this))); 24 });
14 this.contentElement.appendChild(createTextButton(WebInspector.UIString("Stop "), this._stop.bind(this))); 25 });
15 this._resultElement = this.contentElement.createChild("div", "overflow-auto" ); 26 }
27
28 /**
29 * @param {string} message
30 */
31 _dispatchProtocolMessage(message) {
32 this._send('dispatchProtocolMessage', {message: message});
33 }
34
35 _stop() {
36 this._send('stop').then(() => {
37 this._rawConnection.disconnect();
38 this._backend.dispose();
39 delete this._backend;
40 delete this._backendPromise;
41 });
42 }
43
44 /**
45 * @param {string} method
46 * @param {!Object=} params
47 * @return {!Promise<!Object|undefined>}
48 */
49 _send(method, params) {
50 if (!this._backendPromise) {
51 this._backendPromise =
52 WebInspector.serviceManager.createAppService('audits2_worker', 'Audits 2Service', false).then(backend => {
53 this._backend = backend;
54 this._backend.on('sendProtocolMessage', result => this._rawConnectio n.sendMessage(result.message));
55 });
56 }
57 return this._backendPromise.then(() => this._backend ? this._backend.send(me thod, params) : undefined);
58 }
16 }; 59 };
17
18 WebInspector.Audits2Panel.prototype = {
19 _start: function()
20 {
21 WebInspector.targetManager.interceptMainConnection(this._dispatchProtoco lMessage.bind(this)).then(rawConnection => {
22 this._rawConnection = rawConnection;
23 this._send("start").then(result => {
24 var section = new WebInspector.ObjectPropertiesSection(WebInspec tor.RemoteObject.fromLocalObject(result), WebInspector.UIString("Audit Results") );
25 this._resultElement.appendChild(section.element);
26 this._stop();
27 });
28 });
29 },
30
31 /**
32 * @param {string} message
33 */
34 _dispatchProtocolMessage: function(message)
35 {
36 this._send("dispatchProtocolMessage", {message: message});
37 },
38
39 _stop: function()
40 {
41 this._send("stop").then(() => {
42 this._rawConnection.disconnect();
43 this._backend.dispose();
44 delete this._backend;
45 delete this._backendPromise;
46 });
47 },
48
49 /**
50 * @param {string} method
51 * @param {!Object=} params
52 * @return {!Promise<!Object|undefined>}
53 */
54 _send: function(method, params)
55 {
56 if (!this._backendPromise) {
57 this._backendPromise = WebInspector.serviceManager.createAppService( "audits2_worker", "Audits2Service", false).then(backend => {
58 this._backend = backend;
59 this._backend.on("sendProtocolMessage", result => this._rawConne ction.sendMessage(result.message));
60 });
61 }
62 return this._backendPromise.then(() => this._backend ? this._backend.sen d(method, params) : undefined);
63 },
64
65 __proto__: WebInspector.Panel.prototype
66 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698