#include "chrome/browser/performance_manager/metrics/metrics_provider_desktop.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/numerics/safe_conversions.h"
#include "base/power_monitor/cpu_frequency_utils.h"
#include "base/process/process_metrics.h"
#include "base/system/sys_info.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/timer/timer.h"
#include "base/trace_event/base_tracing.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/performance_manager/public/user_tuning/user_performance_tuning_manager.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "components/performance_manager/public/user_tuning/prefs.h"
#include "components/prefs/pref_service.h"
#include "ui/accessibility/ax_mode.h"
#include "ui/accessibility/platform/ax_platform_node.h"
kMemorySaverModeState;
MemorySaverModeState;
namespace performance_manager {
namespace {
MetricsProviderDesktop* g_metrics_provider = …;
uint64_t kBytesPerMb = …;
#if BUILDFLAG(IS_MAC)
uint64_t kKilobytesPerMb = 1024;
#endif
base::TimeDelta kCpuThroughputSamplingInterval = …;
enum class CpuThroughputEstimatedStatus { … };
CpuThroughputEstimatedStatus EstimateCpuThroughputStatus(
bool migrated,
std::optional<double> cpu_frequency_percent,
std::optional<double> thread_time_percent,
base::TimeDelta queued_time) { … }
constexpr char kCpuEstimationEventCategory[] = …;
constexpr char kCpuEstimationEvent[] = …;
constexpr char kCpuEstimationStatusNormalEvent[] = …;
constexpr char kCpuEstimationStatusUnknownEvent[] = …;
constexpr char kCpuEstimationStatusThrottledEvent[] = …;
constexpr char kCpuEstimationStatusDescheduledEvent[] = …;
constexpr char kCpuEstimationStatusMigratedEvent[] = …;
constexpr char kCpuEstimationQueuedEvent[] = …;
constexpr char kCpuEstimationRunningEvent[] = …;
constexpr char kCpuEstimationThreadTimeEvent[] = …;
constexpr char kCpuEstimationDescheduledEvent[] = …;
void EmitCpuStatusSamplingTraceEvents(base::TimeTicks posted_at_time,
base::TimeTicks started_running_time,
base::TimeDelta thread_time,
base::TimeDelta wall_time,
CpuThroughputEstimatedStatus status) { … }
}
class ScopedTimeInModeTracker { … };
MetricsProviderDesktop* MetricsProviderDesktop::GetInstance() { … }
MetricsProviderDesktop::~MetricsProviderDesktop() { … }
void MetricsProviderDesktop::Initialize() { … }
void MetricsProviderDesktop::ProvideCurrentSessionData(
metrics::ChromeUserMetricsExtension* uma_proto) { … }
MetricsProviderDesktop::MetricsProviderDesktop(PrefService* local_state)
: … { … }
void MetricsProviderDesktop::OnBatterySaverActiveChanged(bool is_active) { … }
void MetricsProviderDesktop::OnMemorySaverPrefChanged() { … }
void MetricsProviderDesktop::OnTuningModesChanged() { … }
MetricsProviderDesktop::EfficiencyMode
MetricsProviderDesktop::ComputeCurrentMode() const { … }
bool MetricsProviderDesktop::IsMemorySaverEnabled() const { … }
void MetricsProviderDesktop::RecordAvailableMemoryMetrics() { … }
void MetricsProviderDesktop::ResetTrackers() { … }
void MetricsProviderDesktop::RecordCpuFrequencyMetrics(
base::TimeTicks posted_at_time) { … }
void MetricsProviderDesktop::ScheduleCpuFrequencyTask() { … }
void MetricsProviderDesktop::PostCpuFrequencyEstimation() { … }
void MetricsProviderDesktop::RecordDiskMetrics() { … }
void MetricsProviderDesktop::PostDiskMetricsTask() { … }
MetricsProviderDesktop::DiskMetrics
MetricsProviderDesktop::DiskMetricsThreadPoolGetter::ComputeDiskMetrics(
const base::FilePath& user_data_dir) { … }
void MetricsProviderDesktop::SavePendingDiskMetrics(DiskMetrics metrics) { … }
}