#include "components/page_load_metrics/browser/observers/core/largest_contentful_paint_handler.h"
#include "components/page_load_metrics/browser/page_load_metrics_observer_delegate.h"
#include "components/page_load_metrics/common/page_load_metrics.mojom.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/site_instance.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
namespace page_load_metrics {
static bool g_disable_subframe_navigation_start_offset = …;
namespace {
std::optional<base::TimeDelta> AdjustedTime(
std::optional<base::TimeDelta> candidate_time,
base::TimeDelta navigation_start_offset) { … }
const ContentfulPaintTimingInfo& MergeTimingsBySizeAndTime(
const ContentfulPaintTimingInfo& timing1,
const ContentfulPaintTimingInfo& timing2) { … }
void MergeForSubframesWithAdjustedTime(
ContentfulPaintTimingInfo* inout_timing,
const ContentfulPaintTimingInfo& new_candidate) { … }
void Reset(ContentfulPaintTimingInfo& timing) { … }
bool IsSameSite(const GURL& url1, const GURL& url2) { … }
std::optional<net::RequestPriority> GetImageRequestPriority(
const page_load_metrics::mojom::LargestContentfulPaintTiming&
largest_contentful_paint) { … }
}
ContentfulPaintTimingInfo::ContentfulPaintTimingInfo(
LargestContentTextOrImage text_or_image,
bool in_main_frame,
blink::LargestContentfulPaintType type)
: … { … }
ContentfulPaintTimingInfo::ContentfulPaintTimingInfo(
const std::optional<base::TimeDelta>& time,
const uint64_t& size,
const LargestContentTextOrImage text_or_image,
double image_bpp,
const std::optional<net::RequestPriority>& image_request_priority,
bool in_main_frame,
const blink::LargestContentfulPaintType type,
const std::optional<base::TimeDelta>& image_discovery_time,
const std::optional<base::TimeDelta>& image_load_start,
const std::optional<base::TimeDelta>& image_load_end)
: … { … }
ContentfulPaintTimingInfo::ContentfulPaintTimingInfo(
const ContentfulPaintTimingInfo& other) = default;
std::unique_ptr<base::trace_event::TracedValue>
ContentfulPaintTimingInfo::DataAsTraceValue() const { … }
std::string ContentfulPaintTimingInfo::TextOrImageInString() const { … }
void LargestContentfulPaintHandler::SetTestMode(bool enabled) { … }
void ContentfulPaintTimingInfo::Reset(
const std::optional<base::TimeDelta>& time,
const uint64_t& size,
blink::LargestContentfulPaintType type,
double image_bpp,
const std::optional<net::RequestPriority>& image_request_priority,
const std::optional<base::TimeDelta>& image_discovery_time,
const std::optional<base::TimeDelta>& image_load_start,
const std::optional<base::TimeDelta>& image_load_end) { … }
ContentfulPaint::ContentfulPaint(bool in_main_frame,
blink::LargestContentfulPaintType type)
: … { … }
const ContentfulPaintTimingInfo& ContentfulPaint::MergeTextAndImageTiming()
const { … }
bool LargestContentfulPaintHandler::AssignTimeAndSizeForLargestContentfulPaint(
const page_load_metrics::mojom::LargestContentfulPaintTiming&
largest_contentful_paint,
std::optional<base::TimeDelta>* largest_content_paint_time,
uint64_t* largest_content_paint_size,
ContentfulPaintTimingInfo::LargestContentTextOrImage*
largest_content_type) { … }
LargestContentfulPaintHandler::LargestContentfulPaintHandler()
: … { … }
LargestContentfulPaintHandler::~LargestContentfulPaintHandler() = default;
const ContentfulPaintTimingInfo&
LargestContentfulPaintHandler::MergeMainFrameAndSubframes() const { … }
void LargestContentfulPaintHandler::UpdateSoftNavigationLargestContentfulPaint(
const page_load_metrics::mojom::LargestContentfulPaintTiming&
largest_contentful_paint) { … }
void LargestContentfulPaintHandler::RecordMainFrameTiming(
const page_load_metrics::mojom::LargestContentfulPaintTiming&
largest_contentful_paint,
const std::optional<base::TimeDelta>&
first_input_or_scroll_notified_timestamp) { … }
void LargestContentfulPaintHandler::RecordSubFrameTiming(
const page_load_metrics::mojom::LargestContentfulPaintTiming&
largest_contentful_paint,
const std::optional<base::TimeDelta>&
first_input_or_scroll_notified_timestamp,
content::RenderFrameHost* subframe_rfh,
const GURL& main_frame_url) { … }
void LargestContentfulPaintHandler::UpdateSubFrameTiming(
const page_load_metrics::mojom::LargestContentfulPaintTiming&
largest_contentful_paint,
ContentfulPaint& subframe_contentful_paint,
const std::optional<base::TimeDelta>&
first_input_or_scroll_notified_timestamp,
const base::TimeDelta& navigation_start_offset,
const bool is_cross_site) { … }
void LargestContentfulPaintHandler::UpdateFirstInputOrScrollNotified(
const std::optional<base::TimeDelta>& candidate_new_time,
const base::TimeDelta& navigation_start_offset) { … }
void LargestContentfulPaintHandler::OnDidFinishSubFrameNavigation(
content::NavigationHandle* navigation_handle,
base::TimeTicks navigation_start) { … }
void LargestContentfulPaintHandler::OnSubFrameDeleted(int frame_tree_node_id) { … }
}