#include "components/power_metrics/system_power_monitor.h"
#include <array>
#include <cstring>
#include "base/functional/bind.h"
#include "base/no_destructor.h"
#include "base/notreached.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/trace_event/trace_event.h"
namespace power_metrics {
namespace {
constexpr const char kTraceCategory[] = …);
constexpr const char kPackagePowerTraceCounterName[] = …;
constexpr const char kCpuPowerTraceCounterName[] = …;
constexpr const char kIntegratedGpuPowerTraceCounterName[] = …;
constexpr const char kDramPowerTraceCounterName[] = …;
constexpr const char kPsysPowerTraceCounterName[] = …;
constexpr const char kVddcrVddTraceCounterName[] = …;
constexpr const char kVddcrSocTraceCounterName[] = …;
constexpr const char kCurrentSocketTraceCounterName[] = …;
constexpr const char kApuPowerTraceCounterName[] = …;
bool GenerateValidMetrics(const EnergyMetricsProvider::EnergyMetrics& sample,
std::vector<const char*>& valid_metrics) { … }
int64_t CalculateNanojoulesDeltaFromSamples(
const EnergyMetricsProvider::EnergyMetrics& new_sample,
const EnergyMetricsProvider::EnergyMetrics& old_sample,
const char* metric) { … }
}
SystemPowerMonitorDelegate::SystemPowerMonitorDelegate() = default;
SystemPowerMonitorDelegate::~SystemPowerMonitorDelegate() = default;
void SystemPowerMonitorDelegate::RecordSystemPower(const char* metric,
base::TimeTicks timestamp,
int64_t power) { … }
bool SystemPowerMonitorDelegate::IsTraceCategoryEnabled() const { … }
SystemPowerMonitorHelper::SystemPowerMonitorHelper(
std::unique_ptr<EnergyMetricsProvider> provider,
std::unique_ptr<SystemPowerMonitorDelegate> delegate)
: … { … }
SystemPowerMonitorHelper::~SystemPowerMonitorHelper() = default;
void SystemPowerMonitorHelper::Start() { … }
void SystemPowerMonitorHelper::Stop() { … }
void SystemPowerMonitorHelper::Sample() { … }
bool SystemPowerMonitorHelper::IsTimerRunningForTesting() { … }
SystemPowerMonitor::SystemPowerMonitor()
: … { … }
SystemPowerMonitor::SystemPowerMonitor(
std::unique_ptr<EnergyMetricsProvider> provider,
std::unique_ptr<SystemPowerMonitorDelegate> delegate) { … }
SystemPowerMonitor::~SystemPowerMonitor() = default;
SystemPowerMonitor* SystemPowerMonitor::GetInstance() { … }
void SystemPowerMonitor::OnTraceLogEnabled() { … }
void SystemPowerMonitor::OnTraceLogDisabled() { … }
base::SequenceBound<SystemPowerMonitorHelper>*
SystemPowerMonitor::GetHelperForTesting() { … }
}