#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/platform/scheduler/main_thread/main_thread_metrics_helper.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_macros.h"
#include "base/numerics/safe_conversions.h"
#include "third_party/blink/public/platform/scheduler/web_renderer_process_type.h"
#include "third_party/blink/renderer/platform/instrumentation/histogram.h"
#include "third_party/blink/renderer/platform/instrumentation/resource_coordinator/renderer_resource_coordinator.h"
#include "third_party/blink/renderer/platform/scheduler/main_thread/frame_scheduler_impl.h"
#include "third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl.h"
#include "third_party/blink/renderer/platform/scheduler/public/frame_scheduler.h"
namespace blink {
namespace scheduler {
#define MAIN_THREAD_LOAD_METRIC_NAME …
#define EXTENSIONS_MAIN_THREAD_LOAD_METRIC_NAME …
#define QUEUEING_DELAY_HISTOGRAM_INIT(name) …
enum class MainThreadTaskLoadState { … };
namespace {
constexpr base::TimeDelta kThreadLoadTrackerReportingInterval = …;
constexpr base::TimeDelta kLongIdlePeriodDiscardingThreshold = …;
constexpr int kMainThreadTaskLoadLowPercentage = …;
}
MainThreadMetricsHelper::MainThreadMetricsHelper(
MainThreadSchedulerImpl* main_thread_scheduler,
bool has_cpu_timing_for_each_task,
base::TimeTicks now,
bool renderer_backgrounded)
: … { … }
MainThreadMetricsHelper::~MainThreadMetricsHelper() = default;
void MainThreadMetricsHelper::OnRendererForegrounded(base::TimeTicks now) { … }
void MainThreadMetricsHelper::OnRendererBackgrounded(base::TimeTicks now) { … }
void MainThreadMetricsHelper::OnRendererShutdown(base::TimeTicks now) { … }
void MainThreadMetricsHelper::ResetForTest(base::TimeTicks now) { … }
void MainThreadMetricsHelper::RecordTaskMetrics(
MainThreadTaskQueue* queue,
const base::sequence_manager::Task& task,
const base::sequence_manager::TaskQueue::TaskTiming& task_timing) { … }
void MainThreadMetricsHelper::RecordMainThreadTaskLoad(base::TimeTicks time,
double load) { … }
void MainThreadMetricsHelper::RecordForegroundMainThreadTaskLoad(
base::TimeTicks time,
double load) { … }
void MainThreadMetricsHelper::RecordBackgroundMainThreadTaskLoad(
base::TimeTicks time,
double load) { … }
void MainThreadMetricsHelper::ReportLowThreadLoadForPageAlmostIdleSignal(
int load_percentage) { … }
}
}