Commit b1f32d9e authored by Liquan(Max) Gu's avatar Liquan(Max) Gu Committed by Commit Bot

[LCP] Browser: reuse LCP-handler for main-frame-LCP

As we already have LCP-handler since this CL
https://chromium-review.googlesource.com/c/chromium/src/+/1500254,
the main-frame-LCP can benefit from it by reusing the
LCP-handler's functions.

Bug: 940587

Change-Id: I24d2fbb6d11a50c114d767c4c87c048aaea4c167
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1517162Reviewed-by: default avatarBryan McQuade <bmcquade@chromium.org>
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#686543}
parent 5ac87529
......@@ -6,6 +6,7 @@
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include <utility>
......@@ -46,7 +47,8 @@ PageLoadType GetPageLoadType(ui::PageTransition transition) {
void RecordFirstMeaningfulPaintStatus(
internal::FirstMeaningfulPaintStatus status) {
UMA_HISTOGRAM_ENUMERATION(internal::kHistogramFirstMeaningfulPaintStatus,
status, internal::FIRST_MEANINGFUL_PAINT_LAST_ENTRY);
status,
internal::FIRST_MEANINGFUL_PAINT_LAST_ENTRY);
}
void RecordTimeToInteractiveStatus(internal::TimeToInteractiveStatus status) {
......@@ -797,41 +799,50 @@ void CorePageLoadMetricsObserver::RecordTimingHistograms(
info.first_foreground_time.value());
}
if (WasStartedInForegroundOptionalEventInForeground(
main_frame_timing.paint_timing->largest_image_paint, info)) {
PAGE_LOAD_HISTOGRAM(
internal::kHistogramLargestImagePaint,
main_frame_timing.paint_timing->largest_image_paint.value());
const page_load_metrics::ContentfulPaintTimingInfo&
main_frame_largest_image_paint =
largest_contentful_paint_handler_.MainFrameLargestImagePaint();
if (!main_frame_largest_image_paint.IsEmpty() &&
WasStartedInForegroundOptionalEventInForeground(
main_frame_largest_image_paint.Time(), info)) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramLargestImagePaint,
main_frame_largest_image_paint.Time().value());
}
if (WasStartedInForegroundOptionalEventInForeground(
main_frame_timing.paint_timing->largest_text_paint, info)) {
PAGE_LOAD_HISTOGRAM(
internal::kHistogramLargestTextPaint,
main_frame_timing.paint_timing->largest_text_paint.value());
}
base::Optional<base::TimeDelta> largest_content_paint_time;
uint64_t largest_content_paint_size;
PageLoadMetricsObserver::LargestContentType largest_content_type;
if (AssignTimeAndSizeForLargestContentfulPaint(
main_frame_timing.paint_timing, &largest_content_paint_time,
&largest_content_paint_size, &largest_content_type) &&
const page_load_metrics::ContentfulPaintTimingInfo&
main_frame_largest_text_paint =
largest_contentful_paint_handler_.MainFrameLargestTextPaint();
if (!main_frame_largest_text_paint.IsEmpty() &&
WasStartedInForegroundOptionalEventInForeground(
largest_content_paint_time, info)) {
main_frame_largest_text_paint.Time(), info)) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramLargestTextPaint,
main_frame_largest_text_paint.Time().value());
}
const page_load_metrics::ContentfulPaintTimingInfo&
main_frame_largest_contentful_paint =
largest_contentful_paint_handler_.MainFrameLargestContentfulPaint();
if (!main_frame_largest_contentful_paint.IsEmpty() &&
WasStartedInForegroundOptionalEventInForeground(
main_frame_largest_contentful_paint.Time(), info)) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramLargestContentfulPaintMainFrame,
largest_content_paint_time.value());
main_frame_largest_contentful_paint.Time().value());
UMA_HISTOGRAM_ENUMERATION(
internal::kHistogramLargestContentfulPaintMainFrameContentType,
largest_content_type);
main_frame_largest_contentful_paint.Type());
}
const page_load_metrics::ContentfulPaintTimingInfo& paint =
largest_contentful_paint_handler_.MergeMainFrameAndSubframes();
if (!paint.IsEmpty() &&
WasStartedInForegroundOptionalEventInForeground(paint.Time(), info)) {
const page_load_metrics::ContentfulPaintTimingInfo&
all_frames_largest_contentful_paint =
largest_contentful_paint_handler_.MergeMainFrameAndSubframes();
if (!all_frames_largest_contentful_paint.IsEmpty() &&
WasStartedInForegroundOptionalEventInForeground(
all_frames_largest_contentful_paint.Time(), info)) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramLargestContentfulPaint,
paint.Time().value());
all_frames_largest_contentful_paint.Time().value());
UMA_HISTOGRAM_ENUMERATION(
internal::kHistogramLargestContentfulPaintContentType, paint.Type());
internal::kHistogramLargestContentfulPaintContentType,
all_frames_largest_contentful_paint.Type());
}
if (main_frame_timing.paint_timing->first_paint &&
......
......@@ -78,6 +78,21 @@ class LargestContentfulPaintHandler {
return main_frame_tree_node_id_.value();
}
// We merge the candidates from text side and image side to get the largest
// candidate across both types of content.
const ContentfulPaintTimingInfo& MainFrameLargestContentfulPaint() {
return main_frame_contentful_paint_.MergeTextAndImageTiming();
}
const ContentfulPaintTimingInfo& SubframesLargestContentfulPaint() {
return subframe_contentful_paint_.MergeTextAndImageTiming();
}
const ContentfulPaintTimingInfo& MainFrameLargestImagePaint() {
return main_frame_contentful_paint_.Image();
}
const ContentfulPaintTimingInfo& MainFrameLargestTextPaint() {
return main_frame_contentful_paint_.Text();
}
// We merge the candidates from main frame and subframe to get the largest
// candidate across all frames.
const ContentfulPaintTimingInfo& MergeMainFrameAndSubframes();
......
......@@ -298,35 +298,41 @@ void UkmPageLoadMetricsObserver::RecordTimingMetrics(
builder.SetExperimental_PaintTiming_NavigationToFirstMeaningfulPaint(
timing.paint_timing->first_meaningful_paint.value().InMilliseconds());
}
if (timing.paint_timing->largest_image_paint.has_value() &&
const page_load_metrics::ContentfulPaintTimingInfo&
main_frame_largest_image_paint =
largest_contentful_paint_handler_.MainFrameLargestImagePaint();
if (!main_frame_largest_image_paint.IsEmpty() &&
WasStartedInForegroundOptionalEventInForeground(
timing.paint_timing->largest_image_paint, info)) {
main_frame_largest_image_paint.Time(), info)) {
builder.SetExperimental_PaintTiming_NavigationToLargestImagePaint(
timing.paint_timing->largest_image_paint.value().InMilliseconds());
}
if (timing.paint_timing->largest_text_paint.has_value() &&
const page_load_metrics::ContentfulPaintTimingInfo&
main_frame_largest_text_paint =
largest_contentful_paint_handler_.MainFrameLargestTextPaint();
if (!main_frame_largest_text_paint.IsEmpty() &&
WasStartedInForegroundOptionalEventInForeground(
timing.paint_timing->largest_text_paint, info)) {
main_frame_largest_text_paint.Time(), info)) {
builder.SetExperimental_PaintTiming_NavigationToLargestTextPaint(
timing.paint_timing->largest_text_paint.value().InMilliseconds());
}
base::Optional<base::TimeDelta> largest_content_paint_time;
uint64_t largest_content_paint_size;
PageLoadMetricsObserver::LargestContentType largest_content_type;
if (AssignTimeAndSizeForLargestContentfulPaint(
timing.paint_timing, &largest_content_paint_time,
&largest_content_paint_size, &largest_content_type) &&
const page_load_metrics::ContentfulPaintTimingInfo&
main_frame_largest_contentful_paint =
largest_contentful_paint_handler_.MainFrameLargestContentfulPaint();
if (!main_frame_largest_contentful_paint.IsEmpty() &&
WasStartedInForegroundOptionalEventInForeground(
largest_content_paint_time, info)) {
main_frame_largest_contentful_paint.Time(), info)) {
builder.SetPaintTiming_NavigationToLargestContentfulPaint_MainFrame(
largest_content_paint_time.value().InMilliseconds());
main_frame_largest_contentful_paint.Time().value().InMilliseconds());
}
const page_load_metrics::ContentfulPaintTimingInfo& paint =
largest_contentful_paint_handler_.MergeMainFrameAndSubframes();
if (!paint.IsEmpty() &&
WasStartedInForegroundOptionalEventInForeground(paint.Time(), info)) {
const page_load_metrics::ContentfulPaintTimingInfo&
all_frames_largest_contentful_paint =
largest_contentful_paint_handler_.MergeMainFrameAndSubframes();
if (!all_frames_largest_contentful_paint.IsEmpty() &&
WasStartedInForegroundOptionalEventInForeground(
all_frames_largest_contentful_paint.Time(), info)) {
builder.SetPaintTiming_NavigationToLargestContentfulPaint(
paint.Time().value().InMilliseconds());
all_frames_largest_contentful_paint.Time().value().InMilliseconds());
}
if (timing.interactive_timing->interactive) {
base::TimeDelta time_to_interactive =
......
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