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

Unified Diff: Source/devtools/front_end/TimelinePowerGraph.js

Issue 212843003: DevTools: Add TimelinePowerGraph (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/front_end/TimelinePanel.js ('k') | Source/devtools/scripts/frontend_modules.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
+}
« no previous file with comments | « Source/devtools/front_end/TimelinePanel.js ('k') | Source/devtools/scripts/frontend_modules.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698