#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/page_load_metrics/browser/observers/ad_metrics/frame_tree_data.h"
#include <algorithm>
#include <limits>
#include <string>
#include "base/feature_list.h"
#include "base/metrics/field_trial_params.h"
#include "components/heavy_ad_intervention/heavy_ad_features.h"
#include "components/page_load_metrics/browser/observers/ad_metrics/ads_page_load_metrics_observer.h"
#include "components/page_load_metrics/browser/observers/ad_metrics/frame_data_utils.h"
#include "components/page_load_metrics/common/page_load_metrics.mojom.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "services/metrics/public/cpp/metrics_utils.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
#include "url/gurl.h"
namespace page_load_metrics {
namespace {
const int kMinimumVisibleFrameArea = …;
const base::FeatureParam<int> kHeavyAdUnloadPolicyParam = …;
unsigned int GetFullFrameDepth(content::RenderFrameHost* rfh) { … }
}
FrameTreeData::FrameTreeData(FrameTreeNodeId root_frame_tree_node_id,
int heavy_ad_network_threshold_noise)
: … { … }
FrameTreeData::~FrameTreeData() = default;
void FrameTreeData::MaybeUpdateFrameDepth(
content::RenderFrameHost* render_frame_host) { … }
void FrameTreeData::UpdateMemoryUsage(int64_t delta_bytes) { … }
bool FrameTreeData::ShouldRecordFrameForMetrics() const { … }
void FrameTreeData::RecordAdFrameLoadUkmEvent(ukm::SourceId source_id) const { … }
OriginStatusWithThrottling
FrameTreeData::GetCreativeOriginStatusWithThrottling() const { … }
void FrameTreeData::SetFirstEligibleToPaint(
std::optional<base::TimeDelta> time_stamp) { … }
bool FrameTreeData::SetEarliestFirstContentfulPaint(
std::optional<base::TimeDelta> time_stamp) { … }
void FrameTreeData::SetEarliestFirstContentfulPaintSinceTopNavStart(
base::TimeDelta time_since_top_nav_start) { … }
void FrameTreeData::UpdateFrameVisibility() { … }
HeavyAdStatus FrameTreeData::ComputeHeavyAdStatus(
bool use_network_threshold_noise,
HeavyAdUnloadPolicy policy) const { … }
void FrameTreeData::UpdateCpuUsage(base::TimeTicks update_time,
base::TimeDelta update) { … }
base::TimeDelta FrameTreeData::GetTotalCpuUsage() const { … }
void FrameTreeData::UpdateForNavigation(
content::RenderFrameHost* render_frame_host) { … }
void FrameTreeData::ProcessResourceLoadInFrame(
const mojom::ResourceDataUpdatePtr& resource,
int process_id,
const ResourceTracker& resource_tracker) { … }
void FrameTreeData::AdjustAdBytes(int64_t unaccounted_ad_bytes,
ResourceMimeType mime_type) { … }
void FrameTreeData::SetFrameSize(gfx::Size frame_size) { … }
void FrameTreeData::SetDisplayState(bool is_display_none) { … }
HeavyAdAction FrameTreeData::MaybeTriggerHeavyAdIntervention() { … }
}