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
3 // found in the LICENSE file.
7 * @extends {WebInspector.CountersGraph}
8 * @implements {WebInspector.TimelineModeView}
9 * @param {!WebInspector.TimelineModeViewDelegate} delegate
10 * @param {!WebInspector.TimelineModel} model
12 WebInspector.TimelinePowerGraph = function(delegate, model)
14 WebInspector.CountersGraph.call(this, WebInspector.UIString("POWER"), delegate, model);
16 this._counter = this.createCounter(WebInspector.UIString("Power"), WebInspector.UIString("Power: %.2f\u2009watts"), "#d00");
17 WebInspector.powerProfiler.addEventListener(WebInspector.PowerProfiler.EventTypes.PowerEventRecorded, this._onRecordAdded, this);
20 WebInspector.TimelinePowerGraph.prototype = {
23 WebInspector.CountersGraph.prototype.dispose.call(this);
24 WebInspector.powerProfiler.removeEventListener(WebInspector.PowerProfiler.EventTypes.PowerEventRecorded, this._onRecordAdded, this);
27 _onRecordAdded: function(event)
29 var record = event.data;
30 if (!this._previousRecord) {
31 this._previousRecord = record;
35 // "value" of original PowerEvent means the average power between previous sampling to current one.
36 // Here, it is converted to average power between current sampling to next one.
37 this._counter.appendSample(this._previousRecord.timestamp, record.value);
38 this._previousRecord = record;
39 this.scheduleRefresh();
43 * @param {!WebInspector.TimelineModel.Record} record
45 addRecord: function(record)
49 __proto__: WebInspector.CountersGraph.prototype