chromium/chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer.cc

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

#include "chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer.h"
#include <string>

#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_util.h"
#include "chrome/browser/browser_process.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 "components/page_load_metrics/common/page_load_timing.h"
#include "content/public/browser/navigation_handle.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_recorder.h"

#if defined(TOOLKIT_VIEWS)
#include "chrome/browser/ui/side_search/side_search_tab_contents_helper.h"
#endif  // defined(TOOLKIT_VIEWS)

PageAbortReason;

namespace internal {

const char kHistogramFromGWSDomContentLoaded[] =;
const char kHistogramFromGWSLoad[] =;
const char kHistogramFromGWSFirstPaint[] =;
const char kHistogramFromGWSFirstImagePaint[] =;
const char kHistogramFromGWSFirstContentfulPaint[] =;
const char kHistogramFromGWSLargestContentfulPaint[] =;
const char kHistogramFromGWSParseStartToFirstContentfulPaint[] =;
const char kHistogramFromGWSParseStart[] =;
const char kHistogramFromGWSFirstInputDelay[] =;

const char kHistogramFromGWSAbortNewNavigationBeforeCommit[] =;
const char kHistogramFromGWSAbortNewNavigationBeforePaint[] =;
const char kHistogramFromGWSAbortNewNavigationBeforeInteraction[] =;
const char kHistogramFromGWSAbortStopBeforeCommit[] =;
const char kHistogramFromGWSAbortStopBeforePaint[] =;
const char kHistogramFromGWSAbortStopBeforeInteraction[] =;
const char kHistogramFromGWSAbortCloseBeforeCommit[] =;
const char kHistogramFromGWSAbortCloseBeforePaint[] =;
const char kHistogramFromGWSAbortCloseBeforeInteraction[] =;
const char kHistogramFromGWSAbortOtherBeforeCommit[] =;
const char kHistogramFromGWSAbortReloadBeforeCommit[] =;
const char kHistogramFromGWSAbortReloadBeforePaint[] =;
const char kHistogramFromGWSAbortReloadBeforeInteraction[] =;
const char kHistogramFromGWSAbortForwardBackBeforeCommit[] =;
const char kHistogramFromGWSAbortForwardBackBeforePaint[] =;
const char kHistogramFromGWSAbortForwardBackBeforeInteraction[] =;
const char kHistogramFromGWSAbortBackgroundBeforeCommit[] =;
const char kHistogramFromGWSAbortBackgroundBeforePaint[] =;
const char kHistogramFromGWSAbortBackgroundBeforeInteraction[] =;

const char kHistogramFromGWSForegroundDuration[] =;
const char kHistogramFromGWSForegroundDurationAfterPaint[] =;
const char kHistogramFromGWSForegroundDurationWithPaint[] =;
const char kHistogramFromGWSForegroundDurationWithoutPaint[] =;
const char kHistogramFromGWSForegroundDurationNoCommit[] =;

const char kHistogramFromGWSCumulativeLayoutShiftMainFrame[] =;

const char kHistogramFromGWSMaxCumulativeShiftScoreSessionWindow[] =;

const char kHistogramFromGWSFromSidePanelFirstInputDelay[] =;
const char
    kHistogramFromGWSFromSidePanelMaxCumulativeShiftScoreSessionWindow[] =;
const char kHistogramFromGWSFromSidePanelFirstContentfulPaint[] =;
const char kHistogramFromGWSFromSidePanelFirstImagePaint[] =;
const char kHistogramFromGWSFromSidePanelLargestContentfulPaint[] =;

}  // namespace internal

namespace {

void SetUpLoggerForSidePanelIfNecessary(
    content::NavigationHandle& navigation_handle,
    FromGWSPageLoadMetricsLogger& logger) {}

void LogCommittedAbortsBeforePaint(PageAbortReason abort_reason,
                                   base::TimeDelta page_end_time) {}

void LogAbortsAfterPaintBeforeInteraction(
    const page_load_metrics::PageAbortInfo& abort_info) {}

void LogProvisionalAborts(const page_load_metrics::PageAbortInfo& abort_info) {}

void LogForegroundDurations(
    const page_load_metrics::mojom::PageLoadTiming& timing,
    const page_load_metrics::PageLoadMetricsObserverDelegate& delegate,
    base::TimeTicks app_background_time) {}

bool WasAbortedInForeground(
    const page_load_metrics::PageLoadMetricsObserverDelegate& delegate,
    const page_load_metrics::PageAbortInfo& abort_info) {}

bool WasAbortedBeforeInteraction(
    const page_load_metrics::PageAbortInfo& abort_info,
    const std::optional<base::TimeDelta>& time_to_interaction) {}

int32_t LayoutShiftUmaValue(float shift_score) {}

}  // namespace

FromGWSPageLoadMetricsLogger::FromGWSPageLoadMetricsLogger() = default;
FromGWSPageLoadMetricsLogger::~FromGWSPageLoadMetricsLogger() = default;

void FromGWSPageLoadMetricsLogger::SetPreviouslyCommittedUrl(const GURL& url) {}

void FromGWSPageLoadMetricsLogger::SetProvisionalUrl(const GURL& url) {}

void FromGWSPageLoadMetricsLogger::SetNavigationStateForSidePanel(
    const GURL& initiating_side_panel_url,
    bool navigation_initiated_via_link) {}

FromGWSPageLoadMetricsObserver::FromGWSPageLoadMetricsObserver() = default;

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

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

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

page_load_metrics::PageLoadMetricsObserver::ObservePolicy
FromGWSPageLoadMetricsObserver::OnCommit(
    content::NavigationHandle* navigation_handle) {}

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

void FromGWSPageLoadMetricsObserver::OnDomContentLoadedEventStart(
    const page_load_metrics::mojom::PageLoadTiming& timing) {}

void FromGWSPageLoadMetricsObserver::OnLoadEventStart(
    const page_load_metrics::mojom::PageLoadTiming& timing) {}

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

void FromGWSPageLoadMetricsObserver::OnFirstImagePaintInPage(
    const page_load_metrics::mojom::PageLoadTiming& timing) {}

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

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

void FromGWSPageLoadMetricsObserver::OnParseStart(
    const page_load_metrics::mojom::PageLoadTiming& timing) {}

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

void FromGWSPageLoadMetricsObserver::OnFailedProvisionalLoad(
    const page_load_metrics::FailedProvisionalLoadInfo& failed_load_info) {}

void FromGWSPageLoadMetricsObserver::OnUserInput(
    const blink::WebInputEvent& event,
    const page_load_metrics::mojom::PageLoadTiming& timing) {}

void FromGWSPageLoadMetricsObserver::SetNavigationStateForSidePanelForTesting(
    const GURL& initiating_side_panel_url,
    bool navigation_initiated_via_link) {}

void FromGWSPageLoadMetricsLogger::OnCommit(
    content::NavigationHandle* navigation_handle,
    ukm::SourceId source_id) {}

void FromGWSPageLoadMetricsLogger::OnComplete(
    const page_load_metrics::mojom::PageLoadTiming& timing,
    const page_load_metrics::PageLoadMetricsObserverDelegate& delegate) {}

void FromGWSPageLoadMetricsLogger::OnFailedProvisionalLoad(
    const page_load_metrics::FailedProvisionalLoadInfo& failed_load_info,
    const page_load_metrics::PageLoadMetricsObserverDelegate& delegate) {}

bool FromGWSPageLoadMetricsLogger::ShouldLogFailedProvisionalLoadMetrics() {}

bool FromGWSPageLoadMetricsLogger::ShouldLogPostCommitMetrics(const GURL& url) {}

bool FromGWSPageLoadMetricsLogger::ShouldLogForegroundEventAfterCommit(
    const std::optional<base::TimeDelta>& event,
    const page_load_metrics::PageLoadMetricsObserverDelegate& delegate) {}

void FromGWSPageLoadMetricsLogger::OnDomContentLoadedEventStart(
    const page_load_metrics::mojom::PageLoadTiming& timing,
    const page_load_metrics::PageLoadMetricsObserverDelegate& delegate) {}

void FromGWSPageLoadMetricsLogger::OnLoadEventStart(
    const page_load_metrics::mojom::PageLoadTiming& timing,
    const page_load_metrics::PageLoadMetricsObserverDelegate& delegate) {}

void FromGWSPageLoadMetricsLogger::OnFirstPaintInPage(
    const page_load_metrics::mojom::PageLoadTiming& timing,
    const page_load_metrics::PageLoadMetricsObserverDelegate& delegate) {}

void FromGWSPageLoadMetricsLogger::OnFirstImagePaintInPage(
    const page_load_metrics::mojom::PageLoadTiming& timing,
    const page_load_metrics::PageLoadMetricsObserverDelegate& delegate) {}

void FromGWSPageLoadMetricsLogger::OnFirstContentfulPaintInPage(
    const page_load_metrics::mojom::PageLoadTiming& timing,
    const page_load_metrics::PageLoadMetricsObserverDelegate& delegate) {}

void FromGWSPageLoadMetricsLogger::OnFirstInputInPage(
    const page_load_metrics::mojom::PageLoadTiming& timing,
    const page_load_metrics::PageLoadMetricsObserverDelegate& delegate) {}

void FromGWSPageLoadMetricsLogger::OnParseStart(
    const page_load_metrics::mojom::PageLoadTiming& timing,
    const page_load_metrics::PageLoadMetricsObserverDelegate& delegate) {}

void FromGWSPageLoadMetricsLogger::OnUserInput(
    const blink::WebInputEvent& event,
    const page_load_metrics::mojom::PageLoadTiming& timing,
    const page_load_metrics::PageLoadMetricsObserverDelegate& delegate) {}

void FromGWSPageLoadMetricsLogger::FlushMetricsOnAppEnterBackground(
    const page_load_metrics::mojom::PageLoadTiming& timing,
    const page_load_metrics::PageLoadMetricsObserverDelegate& delegate) {}

bool FromGWSPageLoadMetricsLogger::IsSidePanelInitiatedNavigation() const {}

bool FromGWSPageLoadMetricsLogger::ShouldLogSidePanelMetrics() const {}

void FromGWSPageLoadMetricsLogger::LogMetricsOnComplete(
    const page_load_metrics::PageLoadMetricsObserverDelegate& delegate) {}