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.Object}
9 WebInspector.PowerProfiler = function()
11 WebInspector.Object.call(this);
12 this._dispatcher = new WebInspector.PowerDispatcher(this);
13 PowerAgent.getAccuracyLevel(this._onAccuracyLevel.bind(this));
16 WebInspector.PowerProfiler.EventTypes = {
17 PowerEventRecorded: "PowerEventRecorded"
20 WebInspector.PowerProfiler.prototype = {
22 startProfile: function ()
27 stopProfile: function ()
35 getAccuracyLevel: function()
37 return this._accuracyLevel;
40 _onAccuracyLevel: function(error, result) {
41 this._accuracyLevel = "";
43 console.log("Unable to retrieve PowerProfiler accuracy level: " + error);
46 this._accuracyLevel = result;
49 __proto__: WebInspector.Object.prototype
54 * @implements {PowerAgent.Dispatcher}
56 WebInspector.PowerDispatcher = function(profiler)
58 this._profiler = profiler;
59 InspectorBackend.registerPowerDispatcher(this);
62 WebInspector.PowerDispatcher.prototype = {
63 dataAvailable: function(events)
65 for (var i = 0; i < events.length; ++i)
66 this._profiler.dispatchEventToListeners(WebInspector.PowerProfiler.EventTypes.PowerEventRecorded, events[i]);
71 * @type {!WebInspector.PowerProfiler}
73 WebInspector.powerProfiler;