Commit e245bc2f authored by Bryan McQuade's avatar Bryan McQuade Committed by Commit Bot

Record UKM metrics for AMP subframe documents.

Change-Id: I81602ca1ddae82456fecc5a14e98f844093405bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1506001
Commit-Queue: Bryan McQuade <bmcquade@chromium.org>
Reviewed-by: default avatarTimothy Dresser <tdresser@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638567}
parent fdf1b941
......@@ -16,6 +16,9 @@
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "net/base/url_util.h"
#include "services/metrics/public/cpp/metrics_utils.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
#include "url/gurl.h"
namespace {
......@@ -341,10 +344,12 @@ void AMPPageLoadMetricsObserver::ProcessMainFrameNavigation(
}
}
current_main_frame_nav_info_ = base::WrapUnique(
new MainFrameNavigationInfo{navigation_handle->GetURL(), subframe_rfh,
navigation_handle->NavigationStart(),
navigation_handle->IsSameDocument()});
current_main_frame_nav_info_ = base::WrapUnique(new MainFrameNavigationInfo{
navigation_handle->GetURL(),
ukm::ConvertToSourceId(navigation_handle->GetNavigationId(),
ukm::SourceIdType::NAVIGATION_ID),
subframe_rfh, navigation_handle->NavigationStart(),
navigation_handle->IsSameDocument()});
}
void AMPPageLoadMetricsObserver::MaybeRecordAmpDocumentMetrics() {
......@@ -372,6 +377,11 @@ void AMPPageLoadMetricsObserver::MaybeRecordAmpDocumentMetrics() {
current_main_frame_nav_info_->navigation_start -
subframe_info.navigation_start;
ukm::builders::AmpPageLoad builder(
current_main_frame_nav_info_->ukm_source_id);
builder.SetSubFrame_MainFrameToSubFrameNavigationDelta(
-navigation_input_delta.InMilliseconds());
if (!current_main_frame_nav_info_->is_same_document_navigation) {
// For non same document navigations, we expect the main frame navigation
// to be before the subframe navigation. This measures the time from main
......@@ -402,6 +412,10 @@ void AMPPageLoadMetricsObserver::MaybeRecordAmpDocumentMetrics() {
if (!subframe_info.timing.is_null()) {
if (subframe_info.timing->paint_timing->first_contentful_paint
.has_value()) {
builder.SetSubFrame_PaintTiming_NavigationToFirstContentfulPaint(
subframe_info.timing->paint_timing->first_contentful_paint.value()
.InMilliseconds());
base::TimeDelta first_contentful_paint = ClampToZero(
subframe_info.timing->paint_timing->first_contentful_paint.value() -
navigation_input_delta);
......@@ -425,6 +439,9 @@ void AMPPageLoadMetricsObserver::MaybeRecordAmpDocumentMetrics() {
if (AssignTimeAndSizeForLargestContentfulPaint(
subframe_info.timing->paint_timing, &largest_content_paint_time,
&largest_content_paint_size, &largest_content_type)) {
builder.SetSubFrame_PaintTiming_NavigationToLargestContentPaint(
largest_content_paint_time.value().InMilliseconds());
// Adjust by the navigation_input_delta.
largest_content_paint_time = ClampToZero(
largest_content_paint_time.value() - navigation_input_delta);
......@@ -443,6 +460,10 @@ void AMPPageLoadMetricsObserver::MaybeRecordAmpDocumentMetrics() {
if (subframe_info.timing->interactive_timing->first_input_delay
.has_value()) {
builder.SetSubFrame_InteractiveTiming_FirstInputDelay3(
subframe_info.timing->interactive_timing->first_input_delay.value()
.InMilliseconds());
if (current_main_frame_nav_info_->is_same_document_navigation) {
UMA_HISTOGRAM_CUSTOM_TIMES(
std::string(kHistogramPrefix)
......@@ -460,6 +481,8 @@ void AMPPageLoadMetricsObserver::MaybeRecordAmpDocumentMetrics() {
}
}
}
builder.Record(ukm::UkmRecorder::Get());
}
// static
......
......@@ -96,6 +96,8 @@ class AMPPageLoadMetricsObserver
struct MainFrameNavigationInfo {
GURL url;
ukm::SourceId ukm_source_id = ukm::kInvalidSourceId;
// Pointer to the RenderViewHost for the iframe hosting the AMP document
// associated with the main frame AMP navigation.
content::RenderFrameHost* subframe_rfh = nullptr;
......
......@@ -136,6 +136,39 @@ be describing additional metrics about the same event.
site-wide framework and not a reader experience.
</summary>
</metric>
<metric name="SubFrame.InteractiveTiming.FirstInputDelay3">
<summary>
Measures First Input Delay, the duration between the hardware timestamp
and the start of event processing on the main thread for the first
meaningful input per navigation, in the AMP subframe. See
https://goo.gl/tr1oTZ for a detailed explanation. In milliseconds.
</summary>
</metric>
<metric name="SubFrame.MainFrameToSubFrameNavigationDelta">
<summary>
Measures the time in milliseconds from the navigation in the main frame to
the navigation in the AMP subframe. Will be negative in cases where the
AMP subframe was prerendered. Will be positive in cases where the main
frame was a non-same-document navigation. Should be near-zero when the
main frame navigation is a same-document navigation and the AMP subframe
was not prerendered.
</summary>
</metric>
<metric name="SubFrame.PaintTiming.NavigationToFirstContentfulPaint">
<summary>
Measures the time in milliseconds from navigation timing's navigation
start to the time when the page first paints content, in the AMP subframe.
A contentful paint includes a paint of text, image, SVG, or canvas.
</summary>
</metric>
<metric name="SubFrame.PaintTiming.NavigationToLargestContentPaint">
<summary>
Measures the time in milliseconds from navigation timing's navigation
start to the time when the page first paints the largest content (text or
image) within viewport, in the AMP subframe. See
http://bit.ly/largest_contentful_paint_explainer for more details.
</summary>
</metric>
<metric name="SubFrameAmpPageLoad">
<summary>
True if the page loaded in any subframe is an AMP document (has an amp
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment