#include "chrome/browser/page_load_metrics/observers/lcp_critical_path_predictor_page_load_metrics_observer.h"
#include "base/trace_event/base_tracing.h"
#include "chrome/browser/predictors/lcp_critical_path_predictor/lcp_critical_path_predictor_util.h"
#include "chrome/browser/predictors/loading_predictor.h"
#include "chrome/browser/predictors/loading_predictor_factory.h"
#include "chrome/browser/predictors/predictors_features.h"
#include "chrome/browser/profiles/profile.h"
#include "components/page_load_metrics/browser/page_load_metrics_util.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/web_contents.h"
#include "net/base/url_util.h"
#include "third_party/blink/public/common/features.h"
namespace internal {
#define HISTOGRAM_PREFIX …
const char kHistogramLCPPFirstContentfulPaint[] = …;
const char kHistogramLCPPLargestContentfulPaint[] = …;
const char kHistogramLCPPPredictResult[] = …;
const char kHistogramLCPPPredictHitIndex[] = …;
const char kHistogramLCPPActualLCPIndex[] = …;
}
namespace {
size_t GetLCPPFontURLPredictorMaxUrlCountPerOrigin() { … }
void RemoveFetchedSubresourceUrlsAfterLCP(
std::map<GURL, base::TimeDelta>& fetched_subresource_urls,
const base::TimeDelta& lcp) { … }
}
PAGE_USER_DATA_KEY_IMPL(
LcpCriticalPathPredictorPageLoadMetricsObserver::PageData);
LcpCriticalPathPredictorPageLoadMetricsObserver::PageData::PageData(
content::Page& page)
: … { … }
LcpCriticalPathPredictorPageLoadMetricsObserver::PageData::~PageData() =
default;
LcpCriticalPathPredictorPageLoadMetricsObserver::
LcpCriticalPathPredictorPageLoadMetricsObserver() = default;
LcpCriticalPathPredictorPageLoadMetricsObserver::
~LcpCriticalPathPredictorPageLoadMetricsObserver() = default;
page_load_metrics::PageLoadMetricsObserver::ObservePolicy
LcpCriticalPathPredictorPageLoadMetricsObserver::OnStart(
content::NavigationHandle* navigation_handle,
const GURL& currently_committed_url,
bool started_in_foreground) { … }
page_load_metrics::PageLoadMetricsObserver::ObservePolicy
LcpCriticalPathPredictorPageLoadMetricsObserver::OnCommit(
content::NavigationHandle* navigation_handle) { … }
page_load_metrics::PageLoadMetricsObserver::ObservePolicy
LcpCriticalPathPredictorPageLoadMetricsObserver::OnFencedFramesStart(
content::NavigationHandle* navigation_handle,
const GURL& currently_committed_url) { … }
page_load_metrics::PageLoadMetricsObserver::ObservePolicy
LcpCriticalPathPredictorPageLoadMetricsObserver::OnPrerenderStart(
content::NavigationHandle* navigation_handle,
const GURL& currently_committed_url) { … }
void LcpCriticalPathPredictorPageLoadMetricsObserver::OnComplete(
const page_load_metrics::mojom::PageLoadTiming& timing) { … }
page_load_metrics::PageLoadMetricsObserver::ObservePolicy
LcpCriticalPathPredictorPageLoadMetricsObserver::
FlushMetricsOnAppEnterBackground(
const page_load_metrics::mojom::PageLoadTiming& timing) { … }
void LcpCriticalPathPredictorPageLoadMetricsObserver::FinalizeLCP() { … }
void LcpCriticalPathPredictorPageLoadMetricsObserver::
OnFirstContentfulPaintInPage(
const page_load_metrics::mojom::PageLoadTiming& timing) { … }
void LcpCriticalPathPredictorPageLoadMetricsObserver::SetLcpElementLocator(
const std::string& lcp_element_locator,
std::optional<uint32_t> predicted_lcp_index) { … }
void LcpCriticalPathPredictorPageLoadMetricsObserver::AppendFetchedFontUrl(
const GURL& font_url,
bool hit) { … }
void LcpCriticalPathPredictorPageLoadMetricsObserver::
AppendFetchedSubresourceUrl(const GURL& subresource_url,
const base::TimeDelta& subresource_load_start) { … }
void LcpCriticalPathPredictorPageLoadMetricsObserver::
SetLcpInfluencerScriptUrls(
const std::vector<GURL>& lcp_influencer_scripts) { … }
void LcpCriticalPathPredictorPageLoadMetricsObserver::SetPreconnectOrigins(
const std::vector<GURL>& origins) { … }
void LcpCriticalPathPredictorPageLoadMetricsObserver::SetUnusedPreloads(
const std::vector<GURL>& unused_preloads) { … }
void LcpCriticalPathPredictorPageLoadMetricsObserver::
ReportUMAForTimingPredictor(
std::optional<predictors::LcppStat> lcpp_stat_prelearn) { … }