#include "components/performance_manager/public/metrics/metrics_collector.h"
#include <array>
#include <optional>
#include <set>
#include <string>
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_functions.h"
#include "base/notreached.h"
#include "base/numerics/clamped_math.h"
#include "base/strings/strcat.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "components/performance_manager/public/graph/graph_operations.h"
#include "components/performance_manager/public/graph/node_attached_data.h"
#include "content/public/common/process_type.h"
namespace performance_manager {
namespace {
void RecordProcessLifetime(const std::string& histogram_name,
base::TimeDelta lifetime) { … }
void RecordShortProcessLifetime(const std::string& histogram_name,
base::TimeDelta lifetime) { … }
void OnRendererDestroyed(const ProcessNode* process_node,
base::TimeDelta lifetime) { … }
bool LoadingStateIsQuiescent(PageNode::LoadingState loading_state) { … }
}
class MetricsReportRecordHolder
: public ExternalNodeAttachedDataImpl<MetricsReportRecordHolder> { … };
class UkmCollectionStateHolder
: public ExternalNodeAttachedDataImpl<UkmCollectionStateHolder> { … };
const base::TimeDelta kMetricsReportDelayTimeout = …;
const char kTabNavigationWithSameOriginTabHistogramName[] = …;
const int kDefaultFrequencyUkmEQTReported = …;
MetricsCollector::MetricsCollector() = default;
MetricsCollector::~MetricsCollector() = default;
void MetricsCollector::OnPassedToGraph(Graph* graph) { … }
void MetricsCollector::OnTakenFromGraph(Graph* graph) { … }
void MetricsCollector::OnPageNodeAdded(const PageNode* page_node) { … }
void MetricsCollector::OnBeforePageNodeRemoved(const PageNode* page_node) { … }
void MetricsCollector::OnIsVisibleChanged(const PageNode* page_node) { … }
void MetricsCollector::OnLoadingStateChanged(
const PageNode* page_node,
PageNode::LoadingState previous_state) { … }
void MetricsCollector::OnUkmSourceIdChanged(const PageNode* page_node) { … }
void MetricsCollector::OnMainFrameDocumentChanged(const PageNode* page_node) { … }
void MetricsCollector::OnProcessLifetimeChange(
const ProcessNode* process_node) { … }
void MetricsCollector::OnBeforeProcessNodeRemoved(
const ProcessNode* process_node) { … }
MetricsCollector::MetricsReportRecord* MetricsCollector::GetMetricsReportRecord(
const PageNode* page_node) { … }
MetricsCollector::UkmCollectionState* MetricsCollector::GetUkmCollectionState(
const PageNode* page_node) { … }
void MetricsCollector::RegisterObservers(Graph* graph) { … }
void MetricsCollector::UnregisterObservers(Graph* graph) { … }
bool MetricsCollector::ShouldReportMetrics(const PageNode* page_node) { … }
void MetricsCollector::UpdateUkmSourceIdForPage(const PageNode* page_node,
ukm::SourceId ukm_source_id) { … }
MetricsCollector::MetricsReportRecord::MetricsReportRecord() = default;
MetricsCollector::MetricsReportRecord::MetricsReportRecord(
const MetricsReportRecord& other) = default;
void MetricsCollector::OnProcessDestroyed(const ProcessNode* process_node) { … }
void MetricsCollector::UpdateLoadingPageCounts(
std::optional<PageLoadingState> old_state,
std::optional<PageLoadingState> new_state) { … }
void MetricsCollector::RecordLoadingAndQuiescentPageCount() const { … }
}