Enable Chrome OS support for SystemPowerMonitor
On Chrome OS, energy metrics collection works the same way as on Linux, which also gets data from perf event and requires '/proc/sys/kernel/perf_event_paranoid' set to 0. Modifying the paranoid's value needs sudo permission, so it requires developer mode to use SystemPowerMonitor on Chrome OS. Bug: 1385251 Change-Id: Id9e20d54d8e969988c308c78f7795a0bfe472404 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4550470 Reviewed-by: Francois Pierre Doray <fdoray@chromium.org> Commit-Queue: Shiyi Zou <shiyi.zou@intel.com> Reviewed-by: Mark Pearson <mpearson@chromium.org> Cr-Commit-Position: refs/heads/main@{#1152314}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
d2d08cb7c3
commit
6aeee6592f
chrome/browser
components/power_metrics
@ -42,14 +42,14 @@ static_library("power_metrics") {
|
||||
ldflags = [ "/DELAYLOAD:setupapi.dll" ]
|
||||
}
|
||||
|
||||
if (is_linux) {
|
||||
if (is_linux || is_chromeos) {
|
||||
sources += [
|
||||
"energy_metrics_provider_linux.cc",
|
||||
"energy_metrics_provider_linux.h",
|
||||
]
|
||||
}
|
||||
|
||||
if (is_win || is_linux) {
|
||||
if (is_win || is_linux || is_chromeos) {
|
||||
sources += [
|
||||
"system_power_monitor.cc",
|
||||
"system_power_monitor.h",
|
||||
@ -78,7 +78,7 @@ source_set("unit_tests") {
|
||||
data = [ "test/data/" ]
|
||||
}
|
||||
|
||||
if (is_win || is_linux) {
|
||||
if (is_win || is_linux || is_chromeos) {
|
||||
sources += [ "system_power_monitor_unittest.cc" ]
|
||||
|
||||
deps += [ "//base/test:test_support" ]
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "build/build_config.h"
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "components/power_metrics/energy_metrics_provider_win.h"
|
||||
#elif BUILDFLAG(IS_LINUX)
|
||||
#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
#include "components/power_metrics/energy_metrics_provider_linux.h"
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
|
||||
@ -20,7 +20,7 @@ EnergyMetricsProvider::~EnergyMetricsProvider() = default;
|
||||
std::unique_ptr<EnergyMetricsProvider> EnergyMetricsProvider::Create() {
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
return EnergyMetricsProviderWin::Create();
|
||||
#elif BUILDFLAG(IS_LINUX)
|
||||
#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
return EnergyMetricsProviderLinux::Create();
|
||||
#else
|
||||
return nullptr;
|
||||
|
Reference in New Issue
Block a user