|
30 | 30 |
|
31 | 31 | // TODO(mcollina): should this be moved in a more public space? |
32 | 32 | // embedders will not be able to use this field |
33 | | -#define CURRENT_RESOURCE_FIELD 10 |
| 33 | +#define EXECUTION_RESOURCE_FIELD 10 |
34 | 34 |
|
35 | 35 | using v8::Context; |
36 | 36 | using v8::DontDelete; |
@@ -152,7 +152,7 @@ void AsyncWrap::EmitTraceEventBefore() { |
152 | 152 | void AsyncWrap::EmitBefore(Environment* env, double async_id, |
153 | 153 | v8::Local<v8::Object> resource) { |
154 | 154 | v8::Local<v8::Context> context = env->isolate()->GetCurrentContext(); |
155 | | - context->SetEmbedderData(CURRENT_RESOURCE_FIELD, resource); |
| 155 | + context->SetEmbedderData(EXECUTION_RESOURCE_FIELD, resource); |
156 | 156 |
|
157 | 157 | Emit(env, async_id, AsyncHooks::kBefore, |
158 | 158 | env->async_hooks_before_function()); |
@@ -184,7 +184,7 @@ void AsyncWrap::EmitAfter(Environment* env, double async_id) { |
184 | 184 | Emit(env, async_id, AsyncHooks::kAfter, |
185 | 185 | env->async_hooks_after_function()); |
186 | 186 |
|
187 | | - context->SetEmbedderData(CURRENT_RESOURCE_FIELD, v8::Null(isolate)); |
| 187 | + context->SetEmbedderData(EXECUTION_RESOURCE_FIELD, v8::Null(isolate)); |
188 | 188 | } |
189 | 189 |
|
190 | 190 | class PromiseWrap : public AsyncWrap { |
@@ -270,7 +270,7 @@ static void PromiseHook(PromiseHookType type, Local<Promise> promise, |
270 | 270 |
|
271 | 271 | // needed for async functions :/ |
272 | 272 | // the top level will not emit before and after |
273 | | - env->context()->SetEmbedderData(CURRENT_RESOURCE_FIELD, wrap->object()); |
| 273 | + env->context()->SetEmbedderData(EXECUTION_RESOURCE_FIELD, wrap->object()); |
274 | 274 | } |
275 | 275 | } |
276 | 276 |
|
@@ -399,16 +399,16 @@ static void RegisterDestroyHook(const FunctionCallbackInfo<Value>& args) { |
399 | 399 | p->target.SetWeak(p, AsyncWrap::WeakCallback, WeakCallbackType::kParameter); |
400 | 400 | } |
401 | 401 |
|
402 | | -static void CurrentResource(const FunctionCallbackInfo<Value>& args) { |
| 402 | +static void GetExecutionAsyncResource(const FunctionCallbackInfo<Value>& args) { |
403 | 403 | Isolate* isolate = args.GetIsolate(); |
404 | 404 | v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
405 | | - args.GetReturnValue().Set(context->GetEmbedderData(CURRENT_RESOURCE_FIELD)); |
| 405 | + args.GetReturnValue().Set(context->GetEmbedderData(EXECUTION_RESOURCE_FIELD)); |
406 | 406 | } |
407 | 407 |
|
408 | | -static void SetCurrentResource(const FunctionCallbackInfo<Value>& args) { |
| 408 | +static void SetExecutionAsyncResource(const FunctionCallbackInfo<Value>& args) { |
409 | 409 | Isolate* isolate = args.GetIsolate(); |
410 | 410 | v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
411 | | - context->SetEmbedderData(CURRENT_RESOURCE_FIELD, args[0]); |
| 411 | + context->SetEmbedderData(EXECUTION_RESOURCE_FIELD, args[0]); |
412 | 412 | } |
413 | 413 |
|
414 | 414 | void AsyncWrap::GetAsyncId(const FunctionCallbackInfo<Value>& args) { |
@@ -498,10 +498,11 @@ void AsyncWrap::Initialize(Local<Object> target, |
498 | 498 | env->SetMethod(target, "enablePromiseHook", EnablePromiseHook); |
499 | 499 | env->SetMethod(target, "disablePromiseHook", DisablePromiseHook); |
500 | 500 | env->SetMethod(target, "registerDestroyHook", RegisterDestroyHook); |
501 | | - env->SetMethod(target, "currentResource", CurrentResource); |
502 | | - env->SetMethod(target, "setCurrentResource", SetCurrentResource); |
| 501 | + env->SetMethod(target, "executionAsyncResource", GetExecutionAsyncResource); |
| 502 | + env->SetMethod(target, "setExecutionAsyncResource", |
| 503 | + SetExecutionAsyncResource); |
503 | 504 |
|
504 | | - context->SetEmbedderData(CURRENT_RESOURCE_FIELD, v8::Null(isolate)); |
| 505 | + context->SetEmbedderData(EXECUTION_RESOURCE_FIELD, v8::Null(isolate)); |
505 | 506 |
|
506 | 507 | PropertyAttribute ReadOnlyDontDelete = |
507 | 508 | static_cast<PropertyAttribute>(ReadOnly | DontDelete); |
|
0 commit comments