#include "base/process/process_metrics.h"
#include <utility>
#include "base/check.h"
#include "base/notimplemented.h"
#include "base/numerics/safe_conversions.h"
#include "base/values.h"
#include "build/build_config.h"
namespace base {
namespace {
#if BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || \
BUILDFLAG(IS_AIX)
int CalculateEventsPerSecond(uint64_t event_count,
uint64_t* last_event_count,
base::TimeTicks* last_calculated) { … }
#endif
}
SystemMemoryInfoKB::SystemMemoryInfoKB() = default;
SystemMemoryInfoKB::SystemMemoryInfoKB(const SystemMemoryInfoKB&) = default;
SystemMemoryInfoKB& SystemMemoryInfoKB::operator=(const SystemMemoryInfoKB&) =
default;
SystemMetrics::SystemMetrics() { … }
SystemMetrics SystemMetrics::Sample() { … }
Value::Dict SystemMetrics::ToDict() const { … }
ProcessMetrics::~ProcessMetrics() = default;
std::unique_ptr<ProcessMetrics> ProcessMetrics::CreateCurrentProcessMetrics() { … }
#if !BUILDFLAG(IS_FREEBSD) || !BUILDFLAG(IS_POSIX)
double ProcessMetrics::GetPlatformIndependentCPUUsage(
TimeDelta cumulative_cpu) { … }
base::expected<double, ProcessCPUUsageError>
ProcessMetrics::GetPlatformIndependentCPUUsage() { … }
#endif
#if BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || \
BUILDFLAG(IS_AIX)
int ProcessMetrics::CalculateIdleWakeupsPerSecond(
uint64_t absolute_idle_wakeups) { … }
#else
int ProcessMetrics::GetIdleWakeupsPerSecond() {
NOTIMPLEMENTED();
return 0;
}
#endif
#if BUILDFLAG(IS_APPLE)
int ProcessMetrics::CalculatePackageIdleWakeupsPerSecond(
uint64_t absolute_package_idle_wakeups) {
return CalculateEventsPerSecond(absolute_package_idle_wakeups,
&last_absolute_package_idle_wakeups_,
&last_package_idle_wakeups_time_);
}
#endif
}