#include "chrome/browser/performance_manager/user_tuning/cpu_health_tracker.h"
#include <algorithm>
#include <memory>
#include <optional>
#include <utility>
#include <vector>
#include "base/check_op.h"
#include "base/containers/to_vector.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/system/sys_info.h"
#include "base/time/time.h"
#include "chrome/browser/performance_manager/policies/page_discarding_helper.h"
#include "components/performance_manager/public/features.h"
#include "components/performance_manager/public/graph/graph.h"
#include "components/performance_manager/public/graph/page_node.h"
#include "components/performance_manager/public/resource_attribution/page_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/resource_context.h"
namespace performance_manager::user_tuning {
CpuHealthTracker::CpuHealthTracker(
StatusChangeCallback on_status_change_cb,
ActionableTabResultCallback on_actionability_change_cb)
: … { … }
CpuHealthTracker::~CpuHealthTracker() = default;
CpuHealthTracker::HealthLevel CpuHealthTracker::GetCurrentHealthLevel() { … }
int CpuHealthTracker::GetTotalCpuPercentUsage(ActionableTabsResult tabs) { … }
void CpuHealthTracker::QueryAndProcessTabActionability(
std::optional<CpuPercent> system_cpu_usage_percentage) { … }
base::OnceCallback<void(CpuHealthTracker::ActionableTabsResult)>
CpuHealthTracker::GetStatusAndActionabilityCallback(
bool did_status_change,
CpuHealthTracker::HealthLevel health_level) { … }
CpuHealthTracker::HealthLevel CpuHealthTracker::GetHealthLevelForMeasurement(
CpuPercent measurement) { … }
void CpuHealthTracker::GetFilteredActionableTabs(
PageResourceMeasurements unfiltered_measurements,
CpuPercent recent_measurement,
base::OnceCallback<void(ActionableTabsResult)> callback) { … }
bool CpuHealthTracker::CanDiscardPage(
resource_attribution::PageContext context) { … }
bool CpuHealthTracker::RecordAndUpdateHealthStatus(CpuPercent measurement) { … }
void CpuHealthTracker::ProcessCpuProbeResult(
std::optional<system_cpu::CpuSample> cpu_sample) { … }
void CpuHealthTracker::ProcessQueryResultMap(
CpuPercent system_cpu_usage_percentage,
const resource_attribution::QueryResultMap& results) { … }
CpuHealthTracker::PageResourceMeasurements
CpuHealthTracker::FilterForPossibleActionablePages(
std::map<resource_attribution::ResourceContext, double> page_cpu) { … }
}