Skip to content

Commit 70f2328

Browse files
committed
trace_events: move SetupTraceCategoryState into node_trace_events.cc
It makes more sense to put it in `internalBinding('trace_events')` instead of in the bootstrapper object. PR-URL: #25128 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 75d0a93 commit 70f2328

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

Diff for: lib/internal/bootstrap/node.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
/* global isMainThread */
1919

2020
const {
21-
_setupTraceCategoryState,
2221
_setupNextTick,
2322
_setupPromises
2423
} = bootstrappers;
@@ -431,7 +430,10 @@ function readAndExecuteStdin() {
431430
}
432431

433432
function setupTraceCategoryState() {
434-
const { traceCategoryState } = internalBinding('trace_events');
433+
const {
434+
traceCategoryState,
435+
setTraceCategoryStateUpdateHandler
436+
} = internalBinding('trace_events');
435437
const kCategoryAsyncHooks = 0;
436438
let traceEventsAsyncHook;
437439

@@ -453,7 +455,7 @@ function setupTraceCategoryState() {
453455
}
454456

455457
toggleTraceCategoryState();
456-
_setupTraceCategoryState(toggleTraceCategoryState);
458+
setTraceCategoryStateUpdateHandler(toggleTraceCategoryState);
457459
}
458460

459461
function setupProcessObject() {

Diff for: src/bootstrapper.cc

-7
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ void RunMicrotasks(const FunctionCallbackInfo<Value>& args) {
3030
args.GetIsolate()->RunMicrotasks();
3131
}
3232

33-
void SetupTraceCategoryState(const FunctionCallbackInfo<Value>& args) {
34-
Environment* env = Environment::GetCurrent(args);
35-
CHECK(args[0]->IsFunction());
36-
env->set_trace_category_state_function(args[0].As<Function>());
37-
}
38-
3933
void SetupNextTick(const FunctionCallbackInfo<Value>& args) {
4034
Environment* env = Environment::GetCurrent(args);
4135
Isolate* isolate = env->isolate();
@@ -136,7 +130,6 @@ void SetupPromises(const FunctionCallbackInfo<Value>& args) {
136130
// completes so that it can be gc'd as soon as possible.
137131
void SetupBootstrapObject(Environment* env,
138132
Local<Object> bootstrapper) {
139-
BOOTSTRAP_METHOD(_setupTraceCategoryState, SetupTraceCategoryState);
140133
BOOTSTRAP_METHOD(_setupNextTick, SetupNextTick);
141134
BOOTSTRAP_METHOD(_setupPromises, SetupPromises);
142135
}

Diff for: src/node_trace_events.cc

+11
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace node {
1111

1212
using v8::Array;
1313
using v8::Context;
14+
using v8::Function;
1415
using v8::FunctionCallbackInfo;
1516
using v8::FunctionTemplate;
1617
using v8::Local;
@@ -102,13 +103,23 @@ void GetEnabledCategories(const FunctionCallbackInfo<Value>& args) {
102103
}
103104
}
104105

106+
static void SetTraceCategoryStateUpdateHandler(
107+
const FunctionCallbackInfo<Value>& args) {
108+
Environment* env = Environment::GetCurrent(args);
109+
CHECK(args[0]->IsFunction());
110+
env->set_trace_category_state_function(args[0].As<Function>());
111+
}
112+
105113
void NodeCategorySet::Initialize(Local<Object> target,
106114
Local<Value> unused,
107115
Local<Context> context,
108116
void* priv) {
109117
Environment* env = Environment::GetCurrent(context);
110118

111119
env->SetMethod(target, "getEnabledCategories", GetEnabledCategories);
120+
env->SetMethod(
121+
target, "setTraceCategoryStateUpdateHandler",
122+
SetTraceCategoryStateUpdateHandler);
112123

113124
Local<FunctionTemplate> category_set =
114125
env->NewFunctionTemplate(NodeCategorySet::New);

0 commit comments

Comments
 (0)