Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(698)

Unified Diff: content/browser/devtools/devtools_power_handler.cc

Issue 332943005: [Chromium] [PowerProfiler] Support accuracy level attribute for power data provider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch for landing! Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
}
« no previous file with comments | « content/browser/devtools/devtools_power_handler.h ('k') | content/browser/power_profiler/power_data_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698