chromium/components/page_load_metrics/browser/observers/core/largest_contentful_paint_handler.cc

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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 {

// TODO(crbug.com/41256933): True in test only. Since we are unable to config
// navigation start in tests, we disable the offsetting to make the test
// deterministic.
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) {}
}  // namespace

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 {}

// static
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 {}

// static
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) {}

// We handle subframe and main frame differently. For main frame, we directly
// substitute the candidate when we receive a new one. For subframes (plural),
// we merge the candidates from different subframes by keeping the largest one.
// Note that the merging of subframes' timings will make
// |subframe_contentful_paint_| unable to be replaced with a smaller paint (it
// should have been able when a large ephemeral element is removed). This is a
// trade-off we make to keep a simple algorithm, otherwise we will have to
// track one candidate per subframe.
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) {}

}  // namespace page_load_metrics