chromium/components/page_load_metrics/browser/observers/core/uma_page_load_metrics_observer.h

// 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.

#ifndef COMPONENTS_PAGE_LOAD_METRICS_BROWSER_OBSERVERS_CORE_UMA_PAGE_LOAD_METRICS_OBSERVER_H_
#define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_OBSERVERS_CORE_UMA_PAGE_LOAD_METRICS_OBSERVER_H_

#include "base/time/time.h"
#include "base/trace_event/typed_macros.h"
#include "components/page_load_metrics/browser/observers/click_input_tracker.h"
#include "components/page_load_metrics/browser/page_load_metrics_observer.h"
#include "content/public/browser/navigation_handle_timing.h"
#include "services/metrics/public/cpp/ukm_source.h"
#include "third_party/perfetto/include/perfetto/tracing/event_context.h"

namespace internal {

// NOTE: Some of these histograms are separated into a separate histogram
// specified by the ".Background" suffix. For these events, we put them into the
// background histogram if the web contents was ever in the background from
// navigation start to the event in question.
extern const char kHistogramNumInteractions[];
extern const char
    kHistogramAverageUserInteractionLatencyOverBudgetMaxEventDuration[];
extern const char
    kHistogramSlowUserInteractionLatencyOverBudgetHighPercentile2MaxEventDuration
        [];
extern const char
    kHistogramUserInteractionLatencyHighPercentile2MaxEventDuration[];
extern const char
    kHistogramSumOfUserInteractionLatencyOverBudgetMaxEventDuration[];
extern const char kHistogramWorstUserInteractionLatencyMaxEventDuration[];
extern const char kHistogramInpOffset[];
extern const char kHistogramFirstInputDelay[];
extern const char kHistogramFirstInputTimestamp[];
extern const char kHistogramFirstInputDelay4[];
extern const char kHistogramFirstInputTimestamp4[];
extern const char kHistogramFirstPaint[];
extern const char kHistogramFirstImagePaint[];
extern const char kHistogramDomContentLoaded[];
extern const char kHistogramLoad[];
extern const char kHistogramFirstContentfulPaint[];
extern const char kHistogramLargestContentfulPaint[];
extern const char kHistogramLargestContentfulPaintContentType[];
extern const char kHistogramLargestContentfulPaintMainFrame[];
extern const char kHistogramLargestContentfulPaintMainFrameContentType[];
extern const char kHistogramLargestContentfulPaintCrossSiteSubFrame[];
extern const char
    kHistogramLargestContentfulPaintSetSpeculationRulesPrerender[];
extern const char kHistogramParseBlockedOnScriptLoad[];
extern const char kHistogramParseBlockedOnScriptExecution[];

extern const char kBackgroundHistogramFirstImagePaint[];
extern const char kBackgroundHistogramDomContentLoaded[];
extern const char kBackgroundHistogramLoad[];
extern const char kBackgroundHistogramFirstPaint[];

extern const char kHistogramLoadTypeFirstContentfulPaintReload[];
extern const char kHistogramLoadTypeFirstContentfulPaintForwardBack[];
extern const char kHistogramLoadTypeFirstContentfulPaintNewNavigation[];

extern const char kHistogramLoadTypeParseStartReload[];
extern const char kHistogramLoadTypeParseStartForwardBack[];
extern const char kHistogramLoadTypeParseStartNewNavigation[];

extern const char kHistogramUserGestureNavigationToForwardBack[];

extern const char kHistogramPageTimingForegroundDuration[];
extern const char kHistogramPageTimingForegroundDurationNoCommit[];

extern const char kHistogramCachedResourceLoadTimePrefix[];
extern const char kHistogramCommitSentToFirstSubresourceLoadStart[];
extern const char kHistogramNavigationToFirstSubresourceLoadStart[];
extern const char kHistogramResourceLoadTimePrefix[];
extern const char kHistogramTotalSubresourceLoadTimeAtFirstContentfulPaint[];
extern const char kHistogramFirstEligibleToPaintToFirstPaint[];

extern const char kHistogramPageLoadCpuTotalUsage[];
extern const char kHistogramPageLoadCpuTotalUsageForegrounded[];

extern const char kHistogramInputToNavigation[];
extern const char kBackgroundHistogramInputToNavigation[];
extern const char kHistogramInputToNavigationLinkClick[];
extern const char kHistogramInputToNavigationOmnibox[];
extern const char kHistogramInputToFirstContentfulPaint[];
extern const char kHistogramBackForwardCacheEvent[];

// Navigation metrics from the navigation start.
extern const char
    kHistogramNavigationTimingNavigationStartToFirstRequestStart[];
extern const char
    kHistogramNavigationTimingNavigationStartToFirstResponseStart[];
extern const char
    kHistogramNavigationTimingNavigationStartToFirstLoaderCallback[];
extern const char
    kHistogramNavigationTimingNavigationStartToFinalRequestStart[];
extern const char
    kHistogramNavigationTimingNavigationStartToFinalResponseStart[];
extern const char
    kHistogramNavigationTimingNavigationStartToFinalLoaderCallback[];
extern const char
    kHistogramNavigationTimingNavigationStartToNavigationCommitSent[];

// Navigation metrics between milestones.
extern const char
    kHistogramNavigationTimingFirstRequestStartToFirstResponseStart[];
extern const char
    kHistogramNavigationTimingFirstResponseStartToFirstLoaderCallback[];
extern const char
    kHistogramNavigationTimingFinalRequestStartToFinalResponseStart[];
extern const char
    kHistogramNavigationTimingFinalResponseStartToFinalLoaderCallback[];
extern const char
    kHistogramNavigationTimingFinalLoaderCallbackToNavigationCommitSent[];

// V8 memory usage metrics.
extern const char kHistogramMemoryMainframe[];
extern const char kHistogramMemorySubframeAggregate[];
extern const char kHistogramMemoryTotal[];

// Please keep in sync with PageLoadBackForwardCacheEvent in
// tools/metrics/histograms/enums.xml. These values should not be renumbered.
enum class PageLoadBackForwardCacheEvent {};

}  // namespace internal

// Observer responsible for recording 'core' UMA page load metrics. Core metrics
// are maintained by loading-dev team, typically the metrics under
// PageLoad.(Document|Paint|Parse)Timing.*.
// Only pages with web (http/https) schemes are observed.
// UmaFileAndDataPageLoadMetricsObserver records page load metrics for the file
// and data schemes.
class UmaPageLoadMetricsObserver
    : public page_load_metrics::PageLoadMetricsObserver {};

#endif  // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_OBSERVERS_CORE_UMA_PAGE_LOAD_METRICS_OBSERVER_H_