#include "chrome/browser/predictors/loading_stats_collector.h"
#include <set>
#include <vector>
#include "base/containers/contains.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/ranges/algorithm.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/predictors/loading_data_collector.h"
#include "chrome/browser/predictors/preconnect_manager.h"
#include "chrome/browser/predictors/resource_prefetch_predictor.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
#include "services/metrics/public/cpp/ukm_source.h"
namespace predictors {
namespace {
RedirectStatus;
RedirectStatus GetPredictionRedirectStatus(const GURL& initial_url,
const GURL& main_frame_url,
const std::string& prediction_key,
bool is_redirected,
bool is_host) { … }
std::string GetHistogramNameForHintOrigin(HintOrigin hint_origin,
const char* histogram_base) { … }
size_t ReportPreconnectPredictionAccuracy(
const PreconnectPrediction& prediction,
const PageRequestSummary& summary,
HintOrigin hint_origin) { … }
void ReportPreconnectAccuracy(
const PreconnectStats& stats,
const std::map<url::Origin, OriginRequestSummary>& requests) { … }
}
LoadingStatsCollector::LoadingStatsCollector(
ResourcePrefetchPredictor* predictor,
const LoadingPredictorConfig& config)
: … { … }
LoadingStatsCollector::~LoadingStatsCollector() = default;
void LoadingStatsCollector::RecordPreconnectStats(
std::unique_ptr<PreconnectStats> stats) { … }
void LoadingStatsCollector::RecordPageRequestSummary(
const PageRequestSummary& summary,
const std::optional<OptimizationGuidePrediction>&
optimization_guide_prediction) { … }
void LoadingStatsCollector::CleanupAbandonedStats() { … }
}