#include "components/performance_manager/v8_memory/v8_context_tracker.h"
#include <string_view>
#include <utility>
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/memory/weak_ptr.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/task_traits.h"
#include "base/values.h"
#include "components/performance_manager/graph/frame_node_impl.h"
#include "components/performance_manager/graph/process_node_impl.h"
#include "components/performance_manager/public/execution_context/execution_context_registry.h"
#include "components/performance_manager/public/graph/graph.h"
#include "components/performance_manager/public/graph/node_data_describer_registry.h"
#include "components/performance_manager/public/performance_manager.h"
#include "components/performance_manager/public/render_process_host_id.h"
#include "components/performance_manager/v8_memory/v8_context_tracker_helpers.h"
#include "components/performance_manager/v8_memory/v8_context_tracker_internal.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "mojo/public/cpp/bindings/message.h"
namespace performance_manager {
namespace v8_memory {
namespace {
ExecutionContextData;
ProcessData;
RemoteFrameData;
V8ContextData;
void FakeReportBadMessageForTesting(std::string_view error) { … }
}
V8ContextTracker::ExecutionContextState::ExecutionContextState(
const blink::ExecutionContextToken& token,
mojom::IframeAttributionDataPtr iframe_attribution_data)
: … { … }
V8ContextTracker::ExecutionContextState::~ExecutionContextState() = default;
V8ContextTracker::V8ContextState::V8ContextState(
const mojom::V8ContextDescription& description,
ExecutionContextState* execution_context_state)
: … { … }
V8ContextTracker::V8ContextState::~V8ContextState() = default;
V8ContextTracker::V8ContextTracker()
: … { … }
V8ContextTracker::~V8ContextTracker() = default;
const V8ContextTracker::ExecutionContextState*
V8ContextTracker::GetExecutionContextState(
const blink::ExecutionContextToken& token) const { … }
const V8ContextTracker::V8ContextState* V8ContextTracker::GetV8ContextState(
const blink::V8ContextToken& token) const { … }
void V8ContextTracker::OnV8ContextCreated(
base::PassKey<ProcessNodeImpl> key,
ProcessNodeImpl* process_node,
const mojom::V8ContextDescription& description,
mojom::IframeAttributionDataPtr iframe_attribution_data) { … }
void V8ContextTracker::OnV8ContextDetached(
base::PassKey<ProcessNodeImpl> key,
ProcessNodeImpl* process_node,
const blink::V8ContextToken& v8_context_token) { … }
void V8ContextTracker::OnV8ContextDestroyed(
base::PassKey<ProcessNodeImpl> key,
ProcessNodeImpl* process_node,
const blink::V8ContextToken& v8_context_token) { … }
void V8ContextTracker::OnRemoteIframeAttached(
base::PassKey<ProcessNodeImpl> key,
FrameNodeImpl* parent_frame_node,
const blink::RemoteFrameToken& remote_frame_token,
mojom::IframeAttributionDataPtr iframe_attribution_data) { … }
void V8ContextTracker::OnRemoteIframeDetached(
base::PassKey<ProcessNodeImpl> key,
FrameNodeImpl* parent_frame_node,
const blink::RemoteFrameToken& remote_frame_token) { … }
void V8ContextTracker::OnRemoteIframeAttachedForTesting(
FrameNodeImpl* frame_node,
FrameNodeImpl* parent_frame_node,
const blink::RemoteFrameToken& remote_frame_token,
mojom::IframeAttributionDataPtr iframe_attribution_data) { … }
void V8ContextTracker::OnRemoteIframeDetachedForTesting(
FrameNodeImpl* parent_frame_node,
const blink::RemoteFrameToken& remote_frame_token) { … }
size_t V8ContextTracker::GetExecutionContextCountForTesting() const { … }
size_t V8ContextTracker::GetV8ContextCountForTesting() const { … }
size_t V8ContextTracker::GetDestroyedExecutionContextCountForTesting() const { … }
size_t V8ContextTracker::GetDetachedV8ContextCountForTesting() const { … }
void V8ContextTracker::OnBeforeExecutionContextRemoved(
const execution_context::ExecutionContext* ec) { … }
void V8ContextTracker::OnPassedToGraph(Graph* graph) { … }
void V8ContextTracker::OnTakenFromGraph(Graph* graph) { … }
base::Value::Dict V8ContextTracker::DescribeFrameNodeData(
const FrameNode* node) const { … }
base::Value::Dict V8ContextTracker::DescribeProcessNodeData(
const ProcessNode* node) const { … }
base::Value::Dict V8ContextTracker::DescribeWorkerNodeData(
const WorkerNode* node) const { … }
void V8ContextTracker::OnBeforeProcessNodeRemoved(const ProcessNode* node) { … }
void V8ContextTracker::OnRemoteIframeAttachedImpl(
mojo::ReportBadMessageCallback bad_message_callback,
FrameNodeImpl* frame_node,
FrameNodeImpl* parent_frame_node,
const blink::RemoteFrameToken& remote_frame_token,
mojom::IframeAttributionDataPtr iframe_attribution_data) { … }
void V8ContextTracker::OnRemoteIframeDetachedImpl(
FrameNodeImpl* parent_frame_node,
const blink::RemoteFrameToken& remote_frame_token) { … }
}
}