0

Move SamplingEventSource and co to components/power_metrics/

This class and its subclasses will be used in the future to drive
the collection of power metrics in Chrome.

Bug: 1248057
Change-Id: Ie0b0c7ef9d29ebb56a6962847f4e321559d773b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3319536
Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org>
Commit-Queue: Patrick Monette <pmonette@chromium.org>
Cr-Commit-Position: refs/heads/main@{#950286}
This commit is contained in:
Patrick Monette
2021-12-09 21:49:47 +00:00
committed by Chromium LUCI CQ
parent 3f89c3d6bc
commit 4f7bf4eaac
10 changed files with 26 additions and 24 deletions

@ -7,14 +7,20 @@ if (is_mac) {
sources = [
"energy_impact_mac.h",
"energy_impact_mac.mm",
"iopm_power_source_sampling_event_source.cc",
"iopm_power_source_sampling_event_source.h",
"mach_time_mac.h",
"mach_time_mac.mm",
"resource_coalition_internal_types_mac.h",
"resource_coalition_mac.h",
"resource_coalition_mac.mm",
"sampling_event_source.cc",
"sampling_event_source.h",
"smc_internal_types_mac.h",
"smc_mac.h",
"smc_mac.mm",
"timer_sampling_event_source.cc",
"timer_sampling_event_source.h",
]
deps = [ "//base" ]
@ -26,6 +32,7 @@ if (is_mac) {
sources = [
"energy_impact_mac_unittest.mm",
"resource_coalition_mac_unittest.mm",
"timer_sampling_event_source_unittest.cc",
]
data = [ "test/data/" ]
@ -33,6 +40,7 @@ if (is_mac) {
deps = [
":power_metrics",
"//base",
"//base/test:test_support",
"//testing/gtest",
]
}

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "tools/mac/power/power_sampler/iopm_power_source_sampling_event_source.h"
#include "components/power_metrics/iopm_power_source_sampling_event_source.h"
#include <IOKit/IOMessage.h>
#include <dispatch/queue.h>

@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef TOOLS_MAC_POWER_POWER_SAMPLER_IOPM_POWER_SOURCE_SAMPLING_EVENT_SOURCE_H_
#define TOOLS_MAC_POWER_POWER_SAMPLER_IOPM_POWER_SOURCE_SAMPLING_EVENT_SOURCE_H_
#ifndef COMPONENTS_POWER_METRICS_IOPM_POWER_SOURCE_SAMPLING_EVENT_SOURCE_H_
#define COMPONENTS_POWER_METRICS_IOPM_POWER_SOURCE_SAMPLING_EVENT_SOURCE_H_
#include "base/callback.h"
#include "base/mac/scoped_ionotificationportref.h"
#include "base/mac/scoped_ioobject.h"
#include "tools/mac/power/power_sampler/sampling_event_source.h"
#include "components/power_metrics/sampling_event_source.h"
namespace power_sampler {
@ -37,4 +37,4 @@ class IOPMPowerSourceSamplingEventSource : public SamplingEventSource {
} // namespace power_sampler
#endif // TOOLS_MAC_POWER_POWER_SAMPLER_IOPM_POWER_SOURCE_SAMPLING_EVENT_SOURCE_H_
#endif // COMPONENTS_POWER_METRICS_IOPM_POWER_SOURCE_SAMPLING_EVENT_SOURCE_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "tools/mac/power/power_sampler/sampling_event_source.h"
#include "components/power_metrics/sampling_event_source.h"
namespace power_sampler {

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef TOOLS_MAC_POWER_POWER_SAMPLER_SAMPLING_EVENT_SOURCE_H_
#define TOOLS_MAC_POWER_POWER_SAMPLER_SAMPLING_EVENT_SOURCE_H_
#ifndef COMPONENTS_POWER_METRICS_SAMPLING_EVENT_SOURCE_H_
#define COMPONENTS_POWER_METRICS_SAMPLING_EVENT_SOURCE_H_
#include "base/callback_forward.h"
@ -23,4 +23,4 @@ class SamplingEventSource {
} // namespace power_sampler
#endif // TOOLS_MAC_POWER_POWER_SAMPLER_SAMPLING_EVENT_SOURCE_H_
#endif // COMPONENTS_POWER_METRICS_SAMPLING_EVENT_SOURCE_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "tools/mac/power/power_sampler/timer_sampling_event_source.h"
#include "components/power_metrics/timer_sampling_event_source.h"
#include "base/check.h"

@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef TOOLS_MAC_POWER_POWER_SAMPLER_TIMER_SAMPLING_EVENT_SOURCE_H_
#define TOOLS_MAC_POWER_POWER_SAMPLER_TIMER_SAMPLING_EVENT_SOURCE_H_
#ifndef COMPONENTS_POWER_METRICS_TIMER_SAMPLING_EVENT_SOURCE_H_
#define COMPONENTS_POWER_METRICS_TIMER_SAMPLING_EVENT_SOURCE_H_
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "tools/mac/power/power_sampler/sampling_event_source.h"
#include "components/power_metrics/sampling_event_source.h"
namespace power_sampler {
@ -29,4 +29,4 @@ class TimerSamplingEventSource : public SamplingEventSource {
} // namespace power_sampler
#endif // TOOLS_MAC_POWER_POWER_SAMPLER_TIMER_SAMPLING_EVENT_SOURCE_H_
#endif // COMPONENTS_POWER_METRICS_TIMER_SAMPLING_EVENT_SOURCE_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "tools/mac/power/power_sampler/timer_sampling_event_source.h"
#include "components/power_metrics/timer_sampling_event_source.h"
#include "base/test/bind.h"
#include "base/test/task_environment.h"

@ -29,8 +29,6 @@ static_library("power_sampler_lib") {
"power_sampler/battery_sampler.mm",
"power_sampler/csv_exporter.cc",
"power_sampler/csv_exporter.h",
"power_sampler/iopm_power_source_sampling_event_source.cc",
"power_sampler/iopm_power_source_sampling_event_source.h",
"power_sampler/json_exporter.cc",
"power_sampler/json_exporter.h",
"power_sampler/main_display_sampler.cc",
@ -45,12 +43,8 @@ static_library("power_sampler_lib") {
"power_sampler/sampler.h",
"power_sampler/sampling_controller.cc",
"power_sampler/sampling_controller.h",
"power_sampler/sampling_event_source.cc",
"power_sampler/sampling_event_source.h",
"power_sampler/smc_sampler.h",
"power_sampler/smc_sampler.mm",
"power_sampler/timer_sampling_event_source.cc",
"power_sampler/timer_sampling_event_source.h",
"power_sampler/user_idle_level_sampler.cc",
"power_sampler/user_idle_level_sampler.h",
]
@ -74,6 +68,7 @@ executable("power_sampler") {
deps = [
":power_sampler_lib",
"//base",
"//components/power_metrics",
]
}
@ -87,7 +82,6 @@ test("power_sampler_unittests") {
"power_sampler/resource_coalition_sampler_unittest.cc",
"power_sampler/sampling_controller_unittest.cc",
"power_sampler/smc_sampler_unittest.mm",
"power_sampler/timer_sampling_event_source_unittest.cc",
"power_sampler/user_idle_level_sampler_unittest.cc",
]

@ -15,9 +15,10 @@
#include "base/strings/string_split.h"
#include "base/task/single_thread_task_executor.h"
#include "base/time/time.h"
#include "components/power_metrics/iopm_power_source_sampling_event_source.h"
#include "components/power_metrics/timer_sampling_event_source.h"
#include "tools/mac/power/power_sampler/battery_sampler.h"
#include "tools/mac/power/power_sampler/csv_exporter.h"
#include "tools/mac/power/power_sampler/iopm_power_source_sampling_event_source.h"
#include "tools/mac/power/power_sampler/json_exporter.h"
#include "tools/mac/power/power_sampler/main_display_sampler.h"
#include "tools/mac/power/power_sampler/resource_coalition_sampler.h"
@ -25,7 +26,6 @@
#include "tools/mac/power/power_sampler/sampler.h"
#include "tools/mac/power/power_sampler/sampling_controller.h"
#include "tools/mac/power/power_sampler/smc_sampler.h"
#include "tools/mac/power/power_sampler/timer_sampling_event_source.h"
#include "tools/mac/power/power_sampler/user_idle_level_sampler.h"
namespace {