Chromium Code Reviews| Index: Source/devtools/front_end/PowerProfiler.js |
| diff --git a/Source/devtools/front_end/PowerProfiler.js b/Source/devtools/front_end/PowerProfiler.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..613e37573ac326dc93be953705699a3ff6234c8f |
| --- /dev/null |
| +++ b/Source/devtools/front_end/PowerProfiler.js |
| @@ -0,0 +1,58 @@ |
| +// 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.Object} |
| + */ |
| +WebInspector.PowerProfiler = function() |
| +{ |
| + WebInspector.Object.call(this); |
| + this._dispatcher = new WebInspector.PowerDispatcher(this); |
| +} |
| + |
| +WebInspector.PowerProfiler.EventTypes = { |
| + PowerEventRecorded: "PowerEventRecorded" |
| +} |
| + |
| +WebInspector.PowerProfiler.prototype = { |
| + |
| + startProfile: function () |
| + { |
| + PowerAgent.start(); |
| + }, |
| + |
| + stopProfile: function () |
| + { |
| + PowerAgent.end(); |
| + }, |
| + |
| + __proto__: WebInspector.Object.prototype |
| +} |
| + |
| +/** |
| + * @constructor |
| + * @implements {WebInspector.PowerEventDispatcher} |
| + */ |
| +WebInspector.PowerDispatcher = function(profiler) |
| +{ |
| + this._profiler = profiler; |
| + InspectorBackend.registerPowerDispatcher(this); |
| +} |
| + |
| +WebInspector.PowerDispatcher.prototype = { |
| + dataAvailable: function(events) |
| + { |
| + for (var i in events) { |
| + events[i]["startTime"] = events[i].timestamp; |
| + delete events[i].timestamp; |
| + this._profiler.dispatchEventToListeners(WebInspector.PowerProfiler.EventTypes.PowerEventRecorded, events[i]); |
|
pfeldman
2014/03/11 12:24:02
It is better to repack data here instead of renami
Pan
2014/03/18 10:16:48
Done.
|
| + } |
| + } |
| +} |
| + |
| +/** |
| + * @type {!WebInspector.PowerProfiler} |
| + */ |
| +WebInspector.powerProfiler; |