Design doc: https://docs.google.com/document/d/1bBhfhO7BotUB7Myy_8mtFF_4lI5N8hUyNayV_gI019Y
This document will become truth once the CL https://crrev.com/c/6884362 has landed. TODO(crrev.com/360094997): Remove the above.
Enable collecting, recording, and analyzing serving metrics of preloads. For example:
Logs/metrics are processed in three steps:
PreloadServingMetrics collects per-navigation, serving-related data about preloads, and contains logs objects collected from several preloading components.
While PreloadServingMetrics must be serving-side metrics, it also collects and uses non-serving-side data (e.g., data about prefetching or the initial prerender navigation) insofar as it relates to the serving navigation.
(Some of the non-serving-side data contained in log objects are also used for non-serving-side metrics outside PreloadServingMetrics.)
Examples:
PreloadServingMetrics: Log of preloads associated with a navigation. May hold:PrefetchMatchMetrics andPreloadServingMetrics for prerender initial navigation (if the navigation is prerender activation navigation).PrefetchMatchMetrics: Log of prefetch matching. May hold PrefetchContainerMetrics.PrefetchContainerMetrics: Log of PrefetchContainer.PreloadServingMetrics, only in the context of serving metrics (e.g., when the corresponding prefetch received the non-redirect header relative to the serving/navigation timing).PreloadServingMetrics (including prefetching-side metrics).The log objects are always:
structstd::unique_ptr<>.Each log object is built by a related component, and becomes read-only outside that component. For example, PrefetchContainerMetrics is built by PrefetchContainer. It will be copied to a field of PrefetchMatchMetrics, and read-only after the copy. See each log object's comment to identify its builder component.
PreloadServingMetricsA PreloadServingMetrics object is created per-navigation and is owned by PreloadServingMetricsHolder until navigation commit or failure.
After that, the ownership is moved to:
PrerenderHost for committed prerender initial navigation.PreloadServingMetrics from the initial prerender navigation is then moved to the activation navigation's PreloadServingMetrics and processed along with it.PreloadServingMetricsPageLoadMetricsObserver (via PreloadServingMetricsCapsule that exposes PreloadServingMetrics to //content public) for committed non-prerender-initial navigation.PreloadServingMetricsPageLoadMetricsObserver records UMAs/UKMs based on PreloadServingMetrics, when a navigation is committed and FCP is received.Non-prerender navigation:
flowchart LR subgraph PreloadServingMetricsPageLoadObserver PreloadServingMetricsCapsule end subgraph non-prerender-navigation PreloadServingMetricsHolder end PreloadServingMetricsHolder --> PreloadServingMetricsCapsule
PreloadServingMetrics is not taken.Prerender navigations:
flowchart LR subgraph PreloadServingMetricsPageLoadObserver PreloadServingMetricsCapsule end subgraph prerender initial navigation PreloadServingMetricsHolder-1 end subgraph prerender activation navigation PreloadServingMetricsHolder-2 end PreloadServingMetricsHolder-1 --> PrerenderHost PrerenderHost --> PreloadServingMetricsHolder-2 PreloadServingMetricsHolder-2 --> PreloadServingMetricsCapsule
PreloadServingMetrics is taken by PrerenderHost and used to report metrics for failure.PrerenderHost is cancelled, the same applies.Tests are managed in
PreloadServingMetrics structure and the recorded metrics.PreloadServingMetricsPageLoadMetricsObserver.