Index: Source/devtools/front_end/TimelinePowerGraph.js |
diff --git a/Source/devtools/front_end/TimelinePowerGraph.js b/Source/devtools/front_end/TimelinePowerGraph.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6da130c718c56c598b3d75e14304919e110c6a8b |
--- /dev/null |
+++ b/Source/devtools/front_end/TimelinePowerGraph.js |
@@ -0,0 +1,45 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+/** |
+ * @constructor |
+ * @extends {WebInspector.CountersGraph} |
+ * @implements {WebInspector.TimelineModeView} |
+ * @param {!WebInspector.TimelineModeViewDelegate} delegate |
+ * @param {!WebInspector.TimelineModel} model |
+ */ |
+WebInspector.TimelinePowerGraph = function(delegate, model) |
+{ |
+ WebInspector.CountersGraph.call(this, delegate, model); |
+ |
+ this._counter = this.createCounter(WebInspector.UIString("Power"), WebInspector.UIString("Power: %.2f\u2009watts"), "#d00"); |
+ if (Capabilities.canProfilePower) |
pfeldman
2014/03/26 14:22:54
I don't think you need this check - you only get t
Pan
2014/03/26 14:30:53
yes, thanks, done.
|
+ WebInspector.powerProfiler.addEventListener(WebInspector.PowerProfiler.EventTypes.PowerEventRecorded, this._onRecordAdded, this); |
+} |
+ |
+WebInspector.TimelinePowerGraph.prototype = { |
+ _onRecordAdded: function(event) |
+ { |
+ var record = event.data; |
+ if (!this._previousRecord) { |
+ this._previousRecord = record; |
+ return; |
+ } |
+ |
+ // "value" of original PowerEvent means the average power between previous sampling to current one. |
+ // Here, it is converted to average power between current sampling to next one. |
+ this._counter.appendSample(this._previousRecord.timestamp, record.value); |
+ this._previousRecord = record; |
+ this.scheduleRefresh(); |
+ }, |
+ |
+ /** |
+ * @param {!WebInspector.TimelineModel.Record} record |
+ */ |
+ addRecord: function(record) |
+ { |
+ }, |
+ |
+ __proto__: WebInspector.CountersGraph.prototype |
+} |