Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / devtools / front_end / sdk / PowerProfiler.js
index 63ff51e..6726b9b 100644 (file)
@@ -5,11 +5,15 @@
 /**
  * @constructor
  * @extends {WebInspector.Object}
+ * @param {!WebInspector.Target} target
  */
-WebInspector.PowerProfiler = function()
+WebInspector.PowerProfiler = function(target)
 {
     WebInspector.Object.call(this);
     this._dispatcher = new WebInspector.PowerDispatcher(this);
+    this._target = target;
+    target.registerPowerDispatcher(this._dispatcher);
+    target.powerAgent().getAccuracyLevel(this._onAccuracyLevel.bind(this));
 }
 
 WebInspector.PowerProfiler.EventTypes = {
@@ -17,15 +21,31 @@ WebInspector.PowerProfiler.EventTypes = {
 }
 
 WebInspector.PowerProfiler.prototype = {
-
     startProfile: function ()
     {
-        PowerAgent.start();
+        this._target.powerAgent().start();
     },
 
     stopProfile: function ()
     {
-        PowerAgent.end();
+        this._target.powerAgent().end();
+    },
+
+    /**
+     * @return {string}
+     */
+    getAccuracyLevel: function()
+    {
+        return this._accuracyLevel;
+    },
+
+    _onAccuracyLevel: function(error, result) {
+        this._accuracyLevel = "";
+        if (error) {
+            console.log("Unable to retrieve PowerProfiler accuracy level: " + error);
+            return;
+        }
+        this._accuracyLevel = result;
     },
 
     __proto__: WebInspector.Object.prototype
@@ -38,7 +58,6 @@ WebInspector.PowerProfiler.prototype = {
 WebInspector.PowerDispatcher = function(profiler)
 {
     this._profiler = profiler;
-    InspectorBackend.registerPowerDispatcher(this);
 }
 
 WebInspector.PowerDispatcher.prototype = {