refactor: use node::tracing::Agent() directly (#45489)

refactor: use node::tracing::Agent()
This commit is contained in:
Shelley Vohr 2025-02-09 21:36:42 +01:00 committed by GitHub
parent 9199d5c610
commit a141f68c83
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 9 additions and 50 deletions

View file

@ -1,7 +1,6 @@
expose_get_builtin_module_function.patch expose_get_builtin_module_function.patch
build_add_gn_build_files.patch build_add_gn_build_files.patch
fix_add_default_values_for_variables_in_common_gypi.patch fix_add_default_values_for_variables_in_common_gypi.patch
fix_expose_tracing_agent_and_use_tracing_tracingcontroller_instead.patch
pass_all_globals_through_require.patch pass_all_globals_through_require.patch
build_modify_js2c_py_to_allow_injection_of_original-fs_and_custom_embedder_js.patch build_modify_js2c_py_to_allow_injection_of_original-fs_and_custom_embedder_js.patch
refactor_allow_embedder_overriding_of_internal_fs_calls.patch refactor_allow_embedder_overriding_of_internal_fs_calls.patch

View file

@ -1,44 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@atlassian.com>
Date: Fri, 26 Oct 2018 15:35:13 +1100
Subject: fix: expose tracing::Agent and use tracing::TracingController instead
of v8::TracingController
This API is used by Electron to create Node's tracing controller.
diff --git a/src/api/environment.cc b/src/api/environment.cc
index ad323fc800a33c010b0504a4aa55c107498dee26..e044f10284f31f1862b18be752a04b3bd5d53401 100644
--- a/src/api/environment.cc
+++ b/src/api/environment.cc
@@ -567,6 +567,10 @@ MultiIsolatePlatform* GetMultiIsolatePlatform(IsolateData* env) {
return env->platform();
}
+node::tracing::Agent* CreateAgent() {
+ return new node::tracing::Agent();
+}
+
MultiIsolatePlatform* CreatePlatform(
int thread_pool_size,
node::tracing::TracingController* tracing_controller) {
diff --git a/src/node.h b/src/node.h
index 7726d3de1e82689655e8fceb4135eec303498572..e730bde9162df23ae0c0d52cfa594c1d7c4db28b 100644
--- a/src/node.h
+++ b/src/node.h
@@ -133,6 +133,7 @@ struct SnapshotData;
namespace tracing {
+class Agent;
class TracingController;
}
@@ -832,6 +833,8 @@ NODE_EXTERN void GetNodeReport(Environment* env,
NODE_EXTERN MultiIsolatePlatform* GetMultiIsolatePlatform(Environment* env);
NODE_EXTERN MultiIsolatePlatform* GetMultiIsolatePlatform(IsolateData* env);
+NODE_EXTERN node::tracing::Agent* CreateAgent();
+
NODE_DEPRECATED("Use MultiIsolatePlatform::Create() instead",
NODE_EXTERN MultiIsolatePlatform* CreatePlatform(
int thread_pool_size,

View file

@ -90,7 +90,7 @@ v8::Isolate* JavascriptEnvironment::Initialize(uv_loop_t* event_loop,
// The V8Platform of gin relies on Chromium's task schedule, which has not // The V8Platform of gin relies on Chromium's task schedule, which has not
// been started at this point, so we have to rely on Node's V8Platform. // been started at this point, so we have to rely on Node's V8Platform.
auto* tracing_agent = node::CreateAgent(); auto* tracing_agent = new node::tracing::Agent();
auto* tracing_controller = tracing_agent->GetTracingController(); auto* tracing_controller = tracing_agent->GetTracingController();
node::tracing::TraceEventHelper::SetAgent(tracing_agent); node::tracing::TraceEventHelper::SetAgent(tracing_agent);
platform_ = node::MultiIsolatePlatform::Create( platform_ = node::MultiIsolatePlatform::Create(

View file

@ -92,8 +92,10 @@ void ElectronRendererClient::DidCreateScriptContext(
} }
// Setup node tracing controller. // Setup node tracing controller.
if (!node::tracing::TraceEventHelper::GetAgent()) if (!node::tracing::TraceEventHelper::GetAgent()) {
node::tracing::TraceEventHelper::SetAgent(node::CreateAgent()); auto* tracing_agent = new node::tracing::Agent();
node::tracing::TraceEventHelper::SetAgent(tracing_agent);
}
// Setup node environment for each window. // Setup node environment for each window.
v8::Maybe<bool> initialized = node::InitializeContext(renderer_context); v8::Maybe<bool> initialized = node::InitializeContext(renderer_context);

View file

@ -54,8 +54,10 @@ void WebWorkerObserver::WorkerScriptReadyForEvaluation(
node_bindings_->PrepareEmbedThread(); node_bindings_->PrepareEmbedThread();
// Setup node tracing controller. // Setup node tracing controller.
if (!node::tracing::TraceEventHelper::GetAgent()) if (!node::tracing::TraceEventHelper::GetAgent()) {
node::tracing::TraceEventHelper::SetAgent(node::CreateAgent()); auto* tracing_agent = new node::tracing::Agent();
node::tracing::TraceEventHelper::SetAgent(tracing_agent);
}
// Setup node environment for each window. // Setup node environment for each window.
v8::Maybe<bool> initialized = node::InitializeContext(worker_context); v8::Maybe<bool> initialized = node::InitializeContext(worker_context);