OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.Object} | 7 * @extends {WebInspector.Object} |
8 */ | 8 */ |
9 WebInspector.TimelinePowerOverviewDataProvider = function() | 9 WebInspector.TimelinePowerOverviewDataProvider = function() |
10 { | 10 { |
11 this._records = []; | 11 this._records = []; |
12 if (Capabilities.canProfilePower) | 12 if (Capabilities.canProfilePower) |
13 WebInspector.powerProfiler.addEventListener(WebInspector.PowerProfiler.E
ventTypes.PowerEventRecorded, this._onRecordAdded, this); | 13 WebInspector.powerProfiler.addEventListener(WebInspector.PowerProfiler.E
ventTypes.PowerEventRecorded, this._onRecordAdded, this); |
14 } | 14 } |
15 | 15 |
16 WebInspector.TimelinePowerOverviewDataProvider.prototype = { | 16 WebInspector.TimelinePowerOverviewDataProvider.prototype = { |
17 /** | 17 /** |
18 * @return {Array.<PowerEvent>} | 18 * @return {!Array.<!PowerAgent.PowerEvent>} |
19 */ | 19 */ |
20 records : function() | 20 records : function() |
21 { | 21 { |
22 // The last record is not used, as its "value" is not set. | 22 // The last record is not used, as its "value" is not set. |
23 return this._records.slice(0, this._records.length - 1); | 23 return this._records.slice(0, this._records.length - 1); |
24 }, | 24 }, |
25 | 25 |
26 _onRecordAdded: function(event) | 26 _onRecordAdded: function(event) |
27 { | 27 { |
28 // "value" of original PowerEvent means the anverage power between previ
ous sampling to current one. | 28 // "value" of original PowerEvent means the average power between previo
us sampling to current one. |
29 // Here, it is converted to anverage power between current sampling to n
ext one. | 29 // Here, it is converted to average power between current sampling to ne
xt one. |
30 var record = event.data; | 30 var record = event.data; |
31 var length = this._records.length; | 31 var length = this._records.length; |
32 if (length) | 32 if (length) |
33 this._records[length - 1].value = record.value; | 33 this._records[length - 1].value = record.value; |
34 this._records.push(record); | 34 this._records.push(record); |
35 }, | 35 }, |
36 | 36 |
37 __proto__: WebInspector.Object.prototype | 37 __proto__: WebInspector.Object.prototype |
38 } | 38 } |
39 | 39 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 ctx.restore(); | 145 ctx.restore(); |
146 | 146 |
147 this._maxPowerLabel.textContent = WebInspector.UIString("%.2f\u2009watts
", maxPower); | 147 this._maxPowerLabel.textContent = WebInspector.UIString("%.2f\u2009watts
", maxPower); |
148 this._minPowerLabel.textContent = WebInspector.UIString("%.2f\u2009watts
", minPower);; | 148 this._minPowerLabel.textContent = WebInspector.UIString("%.2f\u2009watts
", minPower);; |
149 }, | 149 }, |
150 | 150 |
151 __proto__: WebInspector.TimelineOverviewBase.prototype | 151 __proto__: WebInspector.TimelineOverviewBase.prototype |
152 } | 152 } |
153 | 153 |
154 | 154 |
OLD | NEW |