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

Unified Diff: Source/devtools/front_end/timeline/TimelinePowerOverview.js

Issue 881263002: DevTools: use target-based model accessors only. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 11 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
Index: Source/devtools/front_end/timeline/TimelinePowerOverview.js
diff --git a/Source/devtools/front_end/timeline/TimelinePowerOverview.js b/Source/devtools/front_end/timeline/TimelinePowerOverview.js
index b52fa094b04baf44e946098bae604a5d5cc87a14..93d36b919e8aaa04c8f94e21f3b12e5922ff0c7a 100644
--- a/Source/devtools/front_end/timeline/TimelinePowerOverview.js
+++ b/Source/devtools/front_end/timeline/TimelinePowerOverview.js
@@ -5,19 +5,23 @@
/**
* @constructor
* @extends {WebInspector.Object}
+ * @param {?WebInspector.Target} target
*/
-WebInspector.TimelinePowerOverviewDataProvider = function()
+WebInspector.TimelinePowerOverviewDataProvider = function(target)
{
this._records = [];
this._energies = [];
this._times = [];
- WebInspector.powerProfiler.addEventListener(WebInspector.PowerProfiler.EventTypes.PowerEventRecorded, this._onRecordAdded, this);
+ this._target = target;
+ if (this._target)
+ this._target.powerProfiler.addEventListener(WebInspector.PowerProfiler.EventTypes.PowerEventRecorded, this._onRecordAdded, this);
}
WebInspector.TimelinePowerOverviewDataProvider.prototype = {
dispose: function()
{
- WebInspector.powerProfiler.removeEventListener(WebInspector.PowerProfiler.EventTypes.PowerEventRecorded, this._onRecordAdded, this);
+ if (this._target)
+ this._target.powerProfiler.removeEventListener(WebInspector.PowerProfiler.EventTypes.PowerEventRecorded, this._onRecordAdded, this);
},
/**
@@ -93,8 +97,11 @@ WebInspector.TimelinePowerOverviewDataProvider.prototype = {
WebInspector.TimelinePowerOverview = function(model)
{
WebInspector.TimelineOverviewBase.call(this, model);
+
+ // FIXME: Figure out optional targets in timeline.
+ this._target = model.target();
this.element.id = "timeline-overview-power";
- this._dataProvider = new WebInspector.TimelinePowerOverviewDataProvider();
+ this._dataProvider = new WebInspector.TimelinePowerOverviewDataProvider(this._target);
this._maxPowerLabel = this.element.createChild("div", "max memory-graph-label");
this._minPowerLabel = this.element.createChild("div", "min memory-graph-label");
@@ -111,14 +118,14 @@ WebInspector.TimelinePowerOverview.prototype = {
timelineStarted: function()
{
- if (WebInspector.targetManager.mainTarget().hasCapability(WebInspector.Target.Capabilities.CanProfilePower))
- WebInspector.powerProfiler.startProfile();
+ if (this._target && this._target.hasCapability(WebInspector.Target.Capabilities.CanProfilePower))
+ this._target.powerProfiler.startProfile();
},
timelineStopped: function()
{
- if (WebInspector.targetManager.mainTarget().hasCapability(WebInspector.Target.Capabilities.CanProfilePower))
- WebInspector.powerProfiler.stopProfile();
+ if (this._target && this._target.hasCapability(WebInspector.Target.Capabilities.CanProfilePower))
+ this._target.powerProfiler.stopProfile();
},
_resetPowerLabels: function()
@@ -217,5 +224,13 @@ WebInspector.TimelinePowerOverview.prototype = {
return this._dataProvider._calculateEnergy(minTime, maxTime);
},
+ /**
+ * @return {string}
+ */
+ accuracyLevel: function()
+ {
+ return this._target ? this._target.powerProfiler.accuracyLevel() : "";
+ },
+
__proto__: WebInspector.TimelineOverviewBase.prototype
}
« no previous file with comments | « Source/devtools/front_end/timeline/TimelinePowerGraph.js ('k') | Source/devtools/scripts/generate_protocol_externs.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698