| 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.CountersGraph} | 7 * @extends {WebInspector.CountersGraph} |
| 8 * @implements {WebInspector.TimelineModeView} | 8 * @implements {WebInspector.TimelineModeView} |
| 9 * @param {!WebInspector.TimelineModeViewDelegate} delegate | 9 * @param {!WebInspector.TimelineModeViewDelegate} delegate |
| 10 * @param {!WebInspector.TimelineModel} model | 10 * @param {!WebInspector.TimelineModel} model |
| 11 */ | 11 */ |
| 12 WebInspector.TimelinePowerGraph = function(delegate, model) | 12 WebInspector.TimelinePowerGraph = function(delegate, model) |
| 13 { | 13 { |
| 14 WebInspector.CountersGraph.call(this, WebInspector.UIString("POWER"), delega
te, model); | 14 WebInspector.CountersGraph.call(this, WebInspector.UIString("POWER"), delega
te, model); |
| 15 | 15 |
| 16 this._counter = this.createCounter(WebInspector.UIString("Power"), WebInspec
tor.UIString("Power: %.2f\u2009watts"), "#d00"); | 16 this._counter = this.createCounter(WebInspector.UIString("Power"), WebInspec
tor.UIString("Power: %.2f\u2009watts"), "#d00"); |
| 17 WebInspector.powerProfiler.addEventListener(WebInspector.PowerProfiler.Event
Types.PowerEventRecorded, this._onRecordAdded, this); | 17 this.target().powerProfiler.addEventListener(WebInspector.PowerProfiler.Even
tTypes.PowerEventRecorded, this._onRecordAdded, this); |
| 18 } | 18 } |
| 19 | 19 |
| 20 WebInspector.TimelinePowerGraph.prototype = { | 20 WebInspector.TimelinePowerGraph.prototype = { |
| 21 /** | 21 /** |
| 22 * @override | 22 * @override |
| 23 */ | 23 */ |
| 24 dispose: function() | 24 dispose: function() |
| 25 { | 25 { |
| 26 WebInspector.CountersGraph.prototype.dispose.call(this); | 26 WebInspector.CountersGraph.prototype.dispose.call(this); |
| 27 WebInspector.powerProfiler.removeEventListener(WebInspector.PowerProfile
r.EventTypes.PowerEventRecorded, this._onRecordAdded, this); | 27 this.target().powerProfiler.removeEventListener(WebInspector.PowerProfil
er.EventTypes.PowerEventRecorded, this._onRecordAdded, this); |
| 28 }, | 28 }, |
| 29 | 29 |
| 30 _onRecordAdded: function(event) | 30 _onRecordAdded: function(event) |
| 31 { | 31 { |
| 32 var record = event.data; | 32 var record = event.data; |
| 33 if (!this._previousRecord) { | 33 if (!this._previousRecord) { |
| 34 this._previousRecord = record; | 34 this._previousRecord = record; |
| 35 return; | 35 return; |
| 36 } | 36 } |
| 37 | 37 |
| 38 // "value" of original PowerEvent means the average power between previo
us sampling to current one. | 38 // "value" of original PowerEvent means the average power between previo
us sampling to current one. |
| 39 // Here, it is converted to average power between current sampling to ne
xt one. | 39 // Here, it is converted to average power between current sampling to ne
xt one. |
| 40 this._counter.appendSample(this._previousRecord.timestamp, record.value)
; | 40 this._counter.appendSample(this._previousRecord.timestamp, record.value)
; |
| 41 this._previousRecord = record; | 41 this._previousRecord = record; |
| 42 this.scheduleRefresh(); | 42 this.scheduleRefresh(); |
| 43 }, | 43 }, |
| 44 | 44 |
| 45 __proto__: WebInspector.CountersGraph.prototype | 45 __proto__: WebInspector.CountersGraph.prototype |
| 46 } | 46 } |
| OLD | NEW |