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

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

Issue 2441933002: [DevTools] Refactor connection-related classes. (Closed)
Patch Set: tests.js 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 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 {
(...skipping 16 matching lines...) Expand all
27 * @param {string} message 27 * @param {string} message
28 */ 28 */
29 _dispatchProtocolMessage: function(message) 29 _dispatchProtocolMessage: function(message)
30 { 30 {
31 this._send("dispatchProtocolMessage", {message: message}); 31 this._send("dispatchProtocolMessage", {message: message});
32 }, 32 },
33 33
34 _stop: function() 34 _stop: function()
35 { 35 {
36 this._send("stop").then(() => { 36 this._send("stop").then(() => {
37 this._rawConnection.yieldConnection(); 37 this._rawConnection.disconnect();
38 this._backend.dispose(); 38 this._backend.dispose();
39 delete this._backend; 39 delete this._backend;
40 delete this._backendPromise; 40 delete this._backendPromise;
41 }); 41 });
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: function(method, params) 49 _send: function(method, params)
50 { 50 {
51 if (!this._backendPromise) { 51 if (!this._backendPromise) {
52 this._backendPromise = WebInspector.serviceManager.createAppService( "audits2_worker", "Audits2Service", false).then(backend => { 52 this._backendPromise = WebInspector.serviceManager.createAppService( "audits2_worker", "Audits2Service", false).then(backend => {
53 this._backend = backend; 53 this._backend = backend;
54 this._backend.on("sendProtocolMessage", result => this._rawConne ction.send(result.message)); 54 this._backend.on("sendProtocolMessage", result => this._rawConne ction.sendMessage(result.message));
55 }); 55 });
56 } 56 }
57 return this._backendPromise.then(() => this._backend ? this._backend.sen d(method, params) : undefined); 57 return this._backendPromise.then(() => this._backend ? this._backend.sen d(method, params) : undefined);
58 }, 58 },
59 59
60 __proto__: WebInspector.Panel.prototype 60 __proto__: WebInspector.Panel.prototype
61 }; 61 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698