#include "components/performance_manager/v8_memory/web_memory_aggregator.h"
#include <utility>
#include <vector>
#include "base/check.h"
#include "base/containers/stack.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/ranges/algorithm.h"
#include "components/performance_manager/public/graph/frame_node.h"
#include "components/performance_manager/public/graph/page_node.h"
#include "components/performance_manager/public/graph/worker_node.h"
#include "components/performance_manager/public/v8_memory/v8_detailed_memory.h"
#include "components/performance_manager/v8_memory/v8_context_tracker.h"
#include "url/gurl.h"
namespace performance_manager {
namespace v8_memory {
class AggregationPointVisitor { … };
namespace {
AttributionScope;
enum class NodeAggregationType { … };
NodeAggregationType GetNodeAggregationType(const url::Origin& requesting_origin,
const url::Origin& enclosing_origin,
const url::Origin& node_origin) { … }
mojom::WebMemoryAttribution* GetAttributionFromBreakdown(
mojom::WebMemoryBreakdownEntry* breakdown) { … }
const mojom::WebMemoryAttribution* GetAttributionFromBreakdown(
const mojom::WebMemoryBreakdownEntry* breakdown) { … }
AttributionScope AttributionScopeFromWorkerType(
WorkerNode::WorkerType worker_type) { … }
void AddMemoryBytes(mojom::WebMemoryBreakdownEntry* aggregation_point,
const V8DetailedMemoryExecutionContextData* data,
bool is_same_process) { … }
const FrameNode* GetTopFrame(const FrameNode* frame) { … }
const ProcessNode* GetMainProcess(const FrameNode* frame) { … }
}
AggregationPointVisitor::AggregationPointVisitor(
const url::Origin& requesting_origin,
const ProcessNode* requesting_process_node,
const url::Origin& main_origin)
: … { … }
AggregationPointVisitor::~AggregationPointVisitor() { … }
mojom::WebMemoryMeasurementPtr
AggregationPointVisitor::TakeAggregationResult() { … }
void AggregationPointVisitor::OnRootEntered() { … }
void AggregationPointVisitor::OnRootExited() { … }
void AggregationPointVisitor::OnFrameEntered(const FrameNode* frame_node) { … }
void AggregationPointVisitor::OnFrameExited(const FrameNode* frame_node) { … }
void AggregationPointVisitor::OnWorkerEntered(const WorkerNode* worker_node) { … }
void AggregationPointVisitor::OnWorkerExited(const WorkerNode* worker_node) { … }
WebMemoryAggregator::WebMemoryAggregator(const FrameNode* requesting_node)
: … { … }
WebMemoryAggregator::~WebMemoryAggregator() = default;
namespace {
double GetBrowsingInstanceV8BytesFraction(
const ProcessNode* process_node,
content::BrowsingInstanceId browsing_instance_id) { … }
}
mojom::WebMemoryMeasurementPtr
WebMemoryAggregator::AggregateMeasureMemoryResult() { … }
void WebMemoryAggregator::VisitFrame(AggregationPointVisitor* ap_visitor,
const FrameNode* frame_node) { … }
void WebMemoryAggregator::VisitWorker(AggregationPointVisitor* ap_visitor,
const WorkerNode* worker_node) { … }
mojom::WebMemoryBreakdownEntry* WebMemoryAggregator::CreateBreakdownEntry(
AttributionScope scope,
std::optional<std::string> url,
mojom::WebMemoryMeasurement* measurement) { … }
void WebMemoryAggregator::SetBreakdownAttributionFromFrame(
const FrameNode* frame_node,
mojom::WebMemoryBreakdownEntry* breakdown) { … }
void WebMemoryAggregator::CopyBreakdownAttribution(
const mojom::WebMemoryBreakdownEntry* from,
mojom::WebMemoryBreakdownEntry* to) { … }
}
}