Upstream version 7.35.144.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / devtools / front_end / PowerProfiler.js
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  */
9 WebInspector.PowerProfiler = function()
10 {
11     WebInspector.Object.call(this);
12     this._dispatcher = new WebInspector.PowerDispatcher(this);
13 }
14
15 WebInspector.PowerProfiler.EventTypes = {
16     PowerEventRecorded: "PowerEventRecorded"
17 }
18
19 WebInspector.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  */
38 WebInspector.PowerDispatcher = function(profiler)
39 {
40     this._profiler = profiler;
41     InspectorBackend.registerPowerDispatcher(this);
42 }
43
44 WebInspector.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  */
55 WebInspector.powerProfiler;