chromium/chrome/browser/performance_manager/metrics/metrics_provider_desktop.cc

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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[] =;

// This function emits trace events related to the status of the CPU throughput
// estimation task. In a trace, these events might look like this (where CSS is
// CpuStatusSampling):
//
// +-----------------------------------------------+
// |               CpuStatusSampling               |
// +-----------------------------------------------+
// |          CSS.Status.{estimated_status}        |
// +------------+----------------------------------+
// | CSS.Queued |          CSS.Running             |
// +------------+----------------+-----------------+
//              | CSS.ThreadTime | CSS.Descheduled |
//              +----------------+-----------------+
//
// CpuStatusSampling.Status.{estimated_status} will reflect what the estimation
// code thinks the status of the CPU is, between Normal, Unknown, Throttled,
// Descheduled, Migrated.
//
// CpuStatusSampling.Queued is the time between when the estimation task was
// posted and when it started running.
//
// CpuStatusSampling.Running is the time between when the task started running
// and when it finished
//
// CpuStatusSampling.ThreadTime is the CPU time of the running task
//
// CpuStatusSampling.Descheduled is the wall time the task spent off-cpu
void EmitCpuStatusSamplingTraceEvents(base::TimeTicks posted_at_time,
                                      base::TimeTicks started_running_time,
                                      base::TimeDelta thread_time,
                                      base::TimeDelta wall_time,
                                      CpuThroughputEstimatedStatus status) {}

}  // namespace

// Tracks the proportion of time a specific mode was enabled during this
// object's entire lifetime, and records it to a specified histogram on
// destruction.
class ScopedTimeInModeTracker {};

// static
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() {}

// static
void MetricsProviderDesktop::RecordCpuFrequencyMetrics(
    base::TimeTicks posted_at_time) {}

// static
void MetricsProviderDesktop::ScheduleCpuFrequencyTask() {}

// static
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) {}

}  // namespace performance_manager