• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4
5/**
6 * @constructor
7 * @extends {WebInspector.Object}
8 */
9WebInspector.PowerProfiler = function()
10{
11    WebInspector.Object.call(this);
12    this._dispatcher = new WebInspector.PowerDispatcher(this);
13}
14
15WebInspector.PowerProfiler.EventTypes = {
16    PowerEventRecorded: "PowerEventRecorded"
17}
18
19WebInspector.PowerProfiler.prototype = {
20
21    startProfile: function ()
22    {
23        PowerAgent.start();
24    },
25
26    stopProfile: function ()
27    {
28        PowerAgent.end();
29    },
30
31    __proto__: WebInspector.Object.prototype
32}
33
34/**
35 * @constructor
36 * @implements {PowerAgent.Dispatcher}
37 */
38WebInspector.PowerDispatcher = function(profiler)
39{
40    this._profiler = profiler;
41    InspectorBackend.registerPowerDispatcher(this);
42}
43
44WebInspector.PowerDispatcher.prototype = {
45    dataAvailable: function(events)
46    {
47        for (var i = 0; i < events.length; ++i)
48            this._profiler.dispatchEventToListeners(WebInspector.PowerProfiler.EventTypes.PowerEventRecorded, events[i]);
49    }
50}
51
52/**
53 * @type {!WebInspector.PowerProfiler}
54 */
55WebInspector.powerProfiler;
56