#include "services/device/compute_pressure/cpu_probe_manager.h"
#include <memory>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/memory/weak_ptr.h"
#include "base/rand_util.h"
#include "build/build_config.h"
#include "components/system_cpu/cpu_probe.h"
#include "services/device/public/cpp/device_features.h"
namespace device {
namespace {
CpuProbe;
CpuSample;
constexpr double kThresholdDelta = …;
constexpr uint64_t kMinRandomizationTimeInSeconds = …;
constexpr uint64_t kMaxRandomizationTimeInSeconds = …;
constexpr std::array<double,
static_cast<size_t>(mojom::PressureState::kMaxValue) + 1>
kStateBaseThresholds = …;
constexpr std::array<double,
static_cast<size_t>(mojom::PressureState::kMaxValue) + 1>
kStateRandomizedThresholds = …;
}
std::unique_ptr<CpuProbeManager> CpuProbeManager::Create(
base::TimeDelta sampling_interval,
base::RepeatingCallback<void(mojom::PressureState)> sampling_callback) { … }
std::unique_ptr<CpuProbeManager> CpuProbeManager::CreateForTesting(
std::unique_ptr<CpuProbe> system_cpu_probe,
base::TimeDelta sampling_interval,
base::RepeatingCallback<void(mojom::PressureState)> sampling_callback) { … }
CpuProbeManager::CpuProbeManager(
std::unique_ptr<CpuProbe> system_cpu_probe,
base::TimeDelta sampling_interval,
base::RepeatingCallback<void(mojom::PressureState)> sampling_callback)
: … { … }
CpuProbeManager::~CpuProbeManager() { … }
void CpuProbeManager::EnsureStarted() { … }
void CpuProbeManager::Stop() { … }
system_cpu::CpuProbe* CpuProbeManager::cpu_probe() { … }
const std::array<double,
static_cast<size_t>(mojom::PressureState::kMaxValue) + 1>&
CpuProbeManager::state_thresholds() const { … }
double CpuProbeManager::hysteresis_threshold_delta() const { … }
void CpuProbeManager::ToggleStateRandomization() { … }
void CpuProbeManager::OnCpuSampleAvailable(std::optional<CpuSample> sample) { … }
mojom::PressureState CpuProbeManager::CalculateState(
std::optional<CpuSample> maybe_sample) { … }
void CpuProbeManager::SetCpuProbeForTesting(
std::unique_ptr<system_cpu::CpuProbe> cpu_probe) { … }
}