#include "components/page_load_metrics/browser/page_load_metrics_update_dispatcher.h"
#include <optional>
#include <ostream>
#include <utility>
#include "base/debug/dump_without_crashing.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "components/page_load_metrics/browser/layout_shift_normalization.h"
#include "components/page_load_metrics/browser/page_load_metrics_embedder_interface.h"
#include "components/page_load_metrics/browser/page_load_metrics_util.h"
#include "components/page_load_metrics/browser/page_load_tracker.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "url/gurl.h"
namespace page_load_metrics {
namespace internal {
const char kPageLoadTimingStatus[] = …;
const char kPageLoadTimingDispatchStatus[] = …;
const char kPageLoadTimingPrerenderStatus[] = …;
const char kPageLoadTimingFencedFramesStatus[] = …;
}
namespace {
std::ostream& operator<<(std::ostream& os,
const std::optional<base::TimeDelta>& opt) { … }
bool EventsInOrder(const std::optional<base::TimeDelta>& first,
const std::optional<base::TimeDelta>& second) { … }
internal::PageLoadTimingStatus IsValidPageLoadTiming(
const mojom::PageLoadTiming& timing) { … }
class PageLoadTimingMerger { … };
}
PageLoadMetricsUpdateDispatcher::PageLoadMetricsUpdateDispatcher(
PageLoadMetricsUpdateDispatcher::Client* client,
content::NavigationHandle* navigation_handle,
PageLoadMetricsEmbedderInterface* embedder_interface)
: … { … }
PageLoadMetricsUpdateDispatcher::~PageLoadMetricsUpdateDispatcher() { … }
void PageLoadMetricsUpdateDispatcher::ShutDown() { … }
void PageLoadMetricsUpdateDispatcher::UpdateMetrics(
content::RenderFrameHost* render_frame_host,
mojom::PageLoadTimingPtr new_timing,
mojom::FrameMetadataPtr new_metadata,
const std::vector<blink::UseCounterFeature>& new_features,
const std::vector<mojom::ResourceDataUpdatePtr>& resources,
mojom::FrameRenderDataUpdatePtr render_data,
mojom::CpuTimingPtr new_cpu_timing,
mojom::InputTimingPtr input_timing_delta,
const std::optional<blink::SubresourceLoadMetrics>&
subresource_load_metrics,
mojom::SoftNavigationMetricsPtr soft_navigation_metrics,
internal::PageLoadTrackerPageType page_type) { … }
void PageLoadMetricsUpdateDispatcher::UpdateHasSeenInputOrScroll(
const mojom::PageLoadTiming& new_timing) { … }
void PageLoadMetricsUpdateDispatcher::UpdateFeatures(
content::RenderFrameHost* render_frame_host,
const std::vector<blink::UseCounterFeature>& new_features) { … }
void PageLoadMetricsUpdateDispatcher::SetUpSharedMemoryForSmoothness(
content::RenderFrameHost* render_frame_host,
base::ReadOnlySharedMemoryRegion shared_memory) { … }
void PageLoadMetricsUpdateDispatcher::DidFinishSubFrameNavigation(
content::NavigationHandle* navigation_handle) { … }
void PageLoadMetricsUpdateDispatcher::OnSubFrameDeleted(
int frame_tree_node_id) { … }
void PageLoadMetricsUpdateDispatcher::UpdateSubFrameTiming(
content::RenderFrameHost* render_frame_host,
mojom::PageLoadTimingPtr new_timing) { … }
void PageLoadMetricsUpdateDispatcher::UpdateSubFrameInputTiming(
content::RenderFrameHost* render_frame_host,
const mojom::InputTiming& input_timing_delta) { … }
void PageLoadMetricsUpdateDispatcher::UpdateFrameCpuTiming(
content::RenderFrameHost* render_frame_host,
mojom::CpuTimingPtr new_timing) { … }
void PageLoadMetricsUpdateDispatcher::UpdateSubFrameMetadata(
content::RenderFrameHost* render_frame_host,
mojom::FrameMetadataPtr subframe_metadata) { … }
void PageLoadMetricsUpdateDispatcher::UpdateMainFrameSubresourceLoadMetrics(
const blink::SubresourceLoadMetrics& subresource_load_metrics) { … }
void PageLoadMetricsUpdateDispatcher::UpdateSoftNavigation(
const mojom::SoftNavigationMetrics& soft_navigation_metrics) { … }
void PageLoadMetricsUpdateDispatcher::UpdateSoftNavigationIntervalLayoutShift(
const mojom::FrameRenderDataUpdate& render_data) { … }
void PageLoadMetricsUpdateDispatcher::
UpdateSoftNavigationIntervalResponsivenessMetrics(
const mojom::InputTiming& input_timing_delta) { … }
void PageLoadMetricsUpdateDispatcher::MaybeUpdateMainFrameIntersectionRect(
content::RenderFrameHost* render_frame_host,
const mojom::FrameMetadataPtr& frame_metadata) { … }
void PageLoadMetricsUpdateDispatcher::MaybeUpdateMainFrameViewportRect(
const mojom::FrameMetadataPtr& frame_metadata) { … }
void PageLoadMetricsUpdateDispatcher::UpdateMainFrameTiming(
mojom::PageLoadTimingPtr new_timing,
internal::PageLoadTrackerPageType page_type) { … }
void PageLoadMetricsUpdateDispatcher::UpdateMainFrameMetadata(
content::RenderFrameHost* render_frame_host,
mojom::FrameMetadataPtr new_metadata) { … }
void PageLoadMetricsUpdateDispatcher::UpdatePageInputTiming(
const mojom::InputTiming& input_timing_delta) { … }
void PageLoadMetricsUpdateDispatcher::UpdatePageRenderData(
const mojom::FrameRenderDataUpdate& render_data,
bool is_main_frame) { … }
void PageLoadMetricsUpdateDispatcher::UpdateMainFrameRenderData(
const mojom::FrameRenderDataUpdate& render_data) { … }
void PageLoadMetricsUpdateDispatcher::OnSubFrameRenderDataChanged(
content::RenderFrameHost* render_frame_host,
const mojom::FrameRenderDataUpdate& render_data) { … }
void PageLoadMetricsUpdateDispatcher::FlushPendingTimingUpdates() { … }
void PageLoadMetricsUpdateDispatcher::MaybeDispatchTimingUpdates(
bool should_buffer_timing_update_callback) { … }
void PageLoadMetricsUpdateDispatcher::DispatchTimingUpdates() { … }
}