Index: content/browser/devtools/devtools_power_handler.cc |
diff --git a/content/browser/devtools/devtools_power_handler.cc b/content/browser/devtools/devtools_power_handler.cc |
index 8915c03e8f1da81cbd04d1a63fae39e7a575146c..d71482ff9b0c955ba5e30572dc1408c4e7747b68 100644 |
--- a/content/browser/devtools/devtools_power_handler.cc |
+++ b/content/browser/devtools/devtools_power_handler.cc |
@@ -21,6 +21,11 @@ DevToolsPowerHandler::DevToolsPowerHandler() { |
RegisterCommandHandler(devtools::Power::canProfilePower::kName, |
base::Bind(&DevToolsPowerHandler::OnCanProfilePower, |
base::Unretained(this))); |
+ // TODO(vivekg): Replace hardcoded "Power.getAccuracyLevel" with |
+ // devtools::Power::getAccuracyLevel::kName once crrev.com/336713005 lands |
+ RegisterCommandHandler("Power.getAccuracyLevel" , |
+ base::Bind(&DevToolsPowerHandler::OnGetAccuracyLevel, |
+ base::Unretained(this))); |
} |
DevToolsPowerHandler::~DevToolsPowerHandler() { |
@@ -80,6 +85,19 @@ DevToolsPowerHandler::OnCanProfilePower( |
return command->SuccessResponse(result); |
} |
+scoped_refptr<DevToolsProtocol::Response> |
+DevToolsPowerHandler::OnGetAccuracyLevel( |
+ scoped_refptr<DevToolsProtocol::Command> command) { |
+ if (PowerProfilerService::GetInstance()->IsAvailable()) { |
+ base::DictionaryValue* result = new base::DictionaryValue(); |
+ result->SetString( |
+ devtools::kResult, |
+ PowerProfilerService::GetInstance()->GetAccuracyLevel()); |
+ return command->SuccessResponse(result); |
+ } |
+ return command->InternalErrorResponse("Power profiler service unavailable"); |
+} |
+ |
void DevToolsPowerHandler::OnClientDetached() { |
PowerProfilerService::GetInstance()->RemoveObserver(this); |
} |