chromium/components/page_load_metrics/browser/observers/prerender_page_load_metrics_observer.cc

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

#include "components/page_load_metrics/browser/observers/prerender_page_load_metrics_observer.h"

#include "base/metrics/histogram_functions.h"
#include "components/page_load_metrics/browser/metrics_web_contents_observer.h"
#include "components/page_load_metrics/browser/navigation_handle_user_data.h"
#include "components/page_load_metrics/browser/observers/core/largest_contentful_paint_handler.h"
#include "components/page_load_metrics/browser/page_load_metrics_util.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "net/http/http_response_headers.h"
#include "services/metrics/public/cpp/metrics_utils.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/network/public/mojom/fetch_api.mojom.h"

namespace internal {

const char kHistogramPrerenderNavigationToActivation[] =;
const char kHistogramPrerenderActivationToFirstPaint[] =;
const char kHistogramPrerenderActivationToFirstContentfulPaint[] =;
const char kHistogramPrerenderActivationToLargestContentfulPaint2[] =;
const char kHistogramPrerenderFirstInputDelay4[] =;
const char kHistogramPrerenderCumulativeShiftScore[] =;
const char kHistogramPrerenderCumulativeShiftScoreMainFrame[] =;
const char
    kHistogramPrerenderMaxCumulativeShiftScoreSessionWindowGap1000msMax5000ms2
        [] =;

// Responsiveness metrics.
const char kHistogramPrerenderNumInteractions[] =;
const char
    kHistogramPrerenderUserInteractionLatencyHighPercentile2MaxEventDuration[] =;
const char kHistogramPrerenderWorstUserInteractionLatencyMaxEventDuration[] =;

// Monitors serving preload cache to prerender.
const char kPageLoadPrerenderActivatedPageLoaderStatus[] =;

// This metric is used for debugging https://crbug.com/1379491.
// Intentionally this metric doesn't record observer events per trigger type
// (e.g., SpeculationRules) because some functions can be called before
// `PrerenderPageLoadMetricsObserver::trigger_type_` is set (e.g., when
// `OnComplete()` called from the destructor of PageLoadTracker before
// prerender activation).
const char kPageLoadPrerenderObserverEvent[] =;

}  // namespace internal

PrerenderPageLoadMetricsObserver::PrerenderPageLoadMetricsObserver() = default;
PrerenderPageLoadMetricsObserver::~PrerenderPageLoadMetricsObserver() = default;

page_load_metrics::PageLoadMetricsObserver::ObservePolicy
PrerenderPageLoadMetricsObserver::OnStart(
    content::NavigationHandle* navigation_handle,
    const GURL& currently_committed_url,
    bool started_in_foreground) {}

page_load_metrics::PageLoadMetricsObserver::ObservePolicy
PrerenderPageLoadMetricsObserver::OnFencedFramesStart(
    content::NavigationHandle* navigation_handle,
    const GURL& currently_committed_url) {}

page_load_metrics::PageLoadMetricsObserver::ObservePolicy
PrerenderPageLoadMetricsObserver::OnPrerenderStart(
    content::NavigationHandle* navigation_handle,
    const GURL& currently_committed_url) {}

void PrerenderPageLoadMetricsObserver::DidActivatePrerenderedPage(
    content::NavigationHandle* navigation_handle) {}

void PrerenderPageLoadMetricsObserver::OnFirstPaintInPage(
    const page_load_metrics::mojom::PageLoadTiming& timing) {}

void PrerenderPageLoadMetricsObserver::OnFirstContentfulPaintInPage(
    const page_load_metrics::mojom::PageLoadTiming& timing) {}

void PrerenderPageLoadMetricsObserver::OnFirstInputInPage(
    const page_load_metrics::mojom::PageLoadTiming& timing) {}

void PrerenderPageLoadMetricsObserver::OnComplete(
    const page_load_metrics::mojom::PageLoadTiming& timing) {}

void PrerenderPageLoadMetricsObserver::OnLoadedResource(
    const page_load_metrics::ExtraRequestCompleteInfo&
        extra_request_complete_info) {}

void PrerenderPageLoadMetricsObserver::MaybeRecordMainResourceLoadStatus() {}

page_load_metrics::PageLoadMetricsObserver::ObservePolicy
PrerenderPageLoadMetricsObserver::FlushMetricsOnAppEnterBackground(
    const page_load_metrics::mojom::PageLoadTiming& timing) {}

void PrerenderPageLoadMetricsObserver::RecordSessionEndHistograms(
    const page_load_metrics::mojom::PageLoadTiming& main_frame_timing) {}

void PrerenderPageLoadMetricsObserver::RecordLayoutShiftScoreMetrics(
    const page_load_metrics::mojom::PageLoadTiming& main_frame_timing) {}

void PrerenderPageLoadMetricsObserver::RecordNormalizedResponsivenessMetrics() {}

std::string PrerenderPageLoadMetricsObserver::AppendSuffix(
    const std::string& histogram_name) const {}