| OLD | NEW |
| 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 * @unrestricted | 5 * @unrestricted |
| 6 */ | 6 */ |
| 7 WebInspector.Audits2Panel = class extends WebInspector.Panel { | 7 Audits2.Audits2Panel = class extends UI.Panel { |
| 8 constructor() { | 8 constructor() { |
| 9 super('audits2'); | 9 super('audits2'); |
| 10 this.contentElement.classList.add('vbox'); | 10 this.contentElement.classList.add('vbox'); |
| 11 this.contentElement.appendChild(createTextButton(WebInspector.UIString('Star
t'), this._start.bind(this))); | 11 this.contentElement.appendChild(createTextButton(Common.UIString('Start'), t
his._start.bind(this))); |
| 12 this.contentElement.appendChild(createTextButton(WebInspector.UIString('Stop
'), this._stop.bind(this))); | 12 this.contentElement.appendChild(createTextButton(Common.UIString('Stop'), th
is._stop.bind(this))); |
| 13 this._resultElement = this.contentElement.createChild('div', 'overflow-auto'
); | 13 this._resultElement = this.contentElement.createChild('div', 'overflow-auto'
); |
| 14 } | 14 } |
| 15 | 15 |
| 16 _start() { | 16 _start() { |
| 17 WebInspector.targetManager.interceptMainConnection(this._dispatchProtocolMes
sage.bind(this)).then(rawConnection => { | 17 SDK.targetManager.interceptMainConnection(this._dispatchProtocolMessage.bind
(this)).then(rawConnection => { |
| 18 this._rawConnection = rawConnection; | 18 this._rawConnection = rawConnection; |
| 19 this._send('start').then(result => { | 19 this._send('start').then(result => { |
| 20 var section = new WebInspector.ObjectPropertiesSection( | 20 var section = new Components.ObjectPropertiesSection( |
| 21 WebInspector.RemoteObject.fromLocalObject(result), WebInspector.UISt
ring('Audit Results')); | 21 SDK.RemoteObject.fromLocalObject(result), Common.UIString('Audit Res
ults')); |
| 22 this._resultElement.appendChild(section.element); | 22 this._resultElement.appendChild(section.element); |
| 23 this._stop(); | 23 this._stop(); |
| 24 }); | 24 }); |
| 25 }); | 25 }); |
| 26 } | 26 } |
| 27 | 27 |
| 28 /** | 28 /** |
| 29 * @param {string} message | 29 * @param {string} message |
| 30 */ | 30 */ |
| 31 _dispatchProtocolMessage(message) { | 31 _dispatchProtocolMessage(message) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 42 } | 42 } |
| 43 | 43 |
| 44 /** | 44 /** |
| 45 * @param {string} method | 45 * @param {string} method |
| 46 * @param {!Object=} params | 46 * @param {!Object=} params |
| 47 * @return {!Promise<!Object|undefined>} | 47 * @return {!Promise<!Object|undefined>} |
| 48 */ | 48 */ |
| 49 _send(method, params) { | 49 _send(method, params) { |
| 50 if (!this._backendPromise) { | 50 if (!this._backendPromise) { |
| 51 this._backendPromise = | 51 this._backendPromise = |
| 52 WebInspector.serviceManager.createAppService('audits2_worker', 'Audits
2Service', false).then(backend => { | 52 Services.serviceManager.createAppService('audits2_worker', 'Audits2Ser
vice', false).then(backend => { |
| 53 this._backend = backend; | 53 this._backend = backend; |
| 54 this._backend.on('sendProtocolMessage', result => this._rawConnectio
n.sendMessage(result.message)); | 54 this._backend.on('sendProtocolMessage', result => this._rawConnectio
n.sendMessage(result.message)); |
| 55 }); | 55 }); |
| 56 } | 56 } |
| 57 return this._backendPromise.then(() => this._backend ? this._backend.send(me
thod, params) : undefined); | 57 return this._backendPromise.then(() => this._backend ? this._backend.send(me
thod, params) : undefined); |
| 58 } | 58 } |
| 59 }; | 59 }; |
| OLD | NEW |