#include "components/page_load_metrics/renderer/metrics_render_frame_observer.h"
#include <string>
#include <utility>
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_functions.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "components/page_load_metrics/renderer/page_timing_metrics_sender.h"
#include "components/page_load_metrics/renderer/page_timing_sender.h"
#include "content/public/renderer/render_frame.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/common/loader/resource_type_util.h"
#include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_document_loader.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/public/web/web_performance_metrics_for_reporting.h"
#include "url/gurl.h"
namespace page_load_metrics {
namespace {
base::TimeDelta CreateTimeDeltaFromTimestampsInSeconds(
double event_time_in_seconds,
double start_time_in_seconds) { … }
base::TimeTicks ClampToStart(base::TimeTicks event, base::TimeTicks start) { … }
class MojoPageTimingSender : public PageTimingSender { … };
}
MetricsRenderFrameObserver::MetricsRenderFrameObserver(
content::RenderFrame* render_frame)
: … { … }
MetricsRenderFrameObserver::~MetricsRenderFrameObserver() { … }
void MetricsRenderFrameObserver::DidChangePerformanceTiming() { … }
void MetricsRenderFrameObserver::DidObserveUserInteraction(
base::TimeTicks max_event_start,
base::TimeTicks max_event_queued_main_thread,
base::TimeTicks max_event_commit_finish,
base::TimeTicks max_event_end,
blink::UserInteractionType interaction_type,
uint64_t interaction_offset) { … }
void MetricsRenderFrameObserver::DidChangeCpuTiming(base::TimeDelta time) { … }
void MetricsRenderFrameObserver::DidObserveLoadingBehavior(
blink::LoadingBehaviorFlag behavior) { … }
void MetricsRenderFrameObserver::DidObserveJavaScriptFrameworks(
const blink::JavaScriptFrameworkDetectionResult& result) { … }
void MetricsRenderFrameObserver::DidObserveSubresourceLoad(
const blink::SubresourceLoadMetrics& subresource_load_metrics) { … }
void MetricsRenderFrameObserver::DidObserveNewFeatureUsage(
const blink::UseCounterFeature& feature) { … }
void MetricsRenderFrameObserver::DidObserveSoftNavigation(
blink::SoftNavigationMetrics soft_nav_metrics) { … }
void MetricsRenderFrameObserver::DidObserveLayoutShift(
double score,
bool after_input_or_scroll) { … }
void MetricsRenderFrameObserver::DidStartResponse(
const url::SchemeHostPort& final_response_url,
int request_id,
const network::mojom::URLResponseHead& response_head,
network::mojom::RequestDestination request_destination,
bool is_ad_resource) { … }
void MetricsRenderFrameObserver::DidCompleteResponse(
int request_id,
const network::URLLoaderCompletionStatus& status) { … }
void MetricsRenderFrameObserver::DidCancelResponse(int request_id) { … }
void MetricsRenderFrameObserver::DidReceiveTransferSizeUpdate(
int request_id,
int received_data_length) { … }
void MetricsRenderFrameObserver::DidLoadResourceFromMemoryCache(
const GURL& response_url,
int request_id,
int64_t encoded_body_length,
const std::string& mime_type,
bool from_archive) { … }
void MetricsRenderFrameObserver::WillDetach(blink::DetachReason detach_reason) { … }
void MetricsRenderFrameObserver::DidStartNavigation(
const GURL& url,
std::optional<blink::WebNavigationType> navigation_type) { … }
void MetricsRenderFrameObserver::DidSetPageLifecycleState(
bool restoring_from_bfcache) { … }
void MetricsRenderFrameObserver::ReadyToCommitNavigation(
blink::WebDocumentLoader* document_loader) { … }
void MetricsRenderFrameObserver::DidFailProvisionalLoad() { … }
void MetricsRenderFrameObserver::DidCreateDocumentElement() { … }
void MetricsRenderFrameObserver::DidCommitProvisionalLoad(
ui::PageTransition transition) { … }
void MetricsRenderFrameObserver::OnMainFrameIntersectionChanged(
const gfx::Rect& main_frame_intersection_rect) { … }
void MetricsRenderFrameObserver::OnMainFrameViewportRectangleChanged(
const gfx::Rect& main_frame_viewport_rect) { … }
void MetricsRenderFrameObserver::OnMainFrameImageAdRectangleChanged(
int element_id,
const gfx::Rect& image_ad_rect) { … }
void MetricsRenderFrameObserver::OnFrameDetached() { … }
bool MetricsRenderFrameObserver::SetUpSmoothnessReporting(
base::ReadOnlySharedMemoryRegion& shared_memory) { … }
MetricsRenderFrameObserver::Timing::Timing(
mojom::PageLoadTimingPtr relative_timing,
const PageTimingMetadataRecorder::MonotonicTiming& monotonic_timing)
: … { … }
MetricsRenderFrameObserver::Timing::~Timing() = default;
MetricsRenderFrameObserver::Timing::Timing(Timing&&) = default;
MetricsRenderFrameObserver::Timing&
MetricsRenderFrameObserver::Timing::operator=(Timing&&) = default;
void MetricsRenderFrameObserver::UpdateResourceMetadata(int request_id) { … }
void MetricsRenderFrameObserver::SendMetrics() { … }
void MetricsRenderFrameObserver::OnMetricsSenderCreated() { … }
mojom::SoftNavigationMetricsPtr
MetricsRenderFrameObserver::GetSoftNavigationMetrics() const { … }
MetricsRenderFrameObserver::Timing MetricsRenderFrameObserver::GetTiming()
const { … }
mojom::CustomUserTimingMarkPtr
MetricsRenderFrameObserver::GetCustomUserTimingMark() const { … }
std::unique_ptr<base::OneShotTimer> MetricsRenderFrameObserver::CreateTimer() { … }
std::unique_ptr<PageTimingSender>
MetricsRenderFrameObserver::CreatePageTimingSender(bool limited_sending_mode) { … }
bool MetricsRenderFrameObserver::HasNoRenderFrame() const { … }
bool MetricsRenderFrameObserver::IsMainFrame() const { … }
void MetricsRenderFrameObserver::OnDestruct() { … }
}