From 74679dd96d2bb624125737123ff93526af5c26e1 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Wed, 6 Sep 2017 17:49:10 +0200 Subject: [PATCH] src: move DomainEnter,DomainExit to node.cc PR-URL: https://github.com/nodejs/node/pull/14697 Reviewed-By: Trevor Norris --- src/async-wrap.cc | 36 ------------------------------------ src/async-wrap.h | 4 ---- src/node.cc | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 40 deletions(-) diff --git a/src/async-wrap.cc b/src/async-wrap.cc index fe53d27994..e08b2adc35 100644 --- a/src/async-wrap.cc +++ b/src/async-wrap.cc @@ -181,42 +181,6 @@ static void PushBackDestroyId(Environment* env, double id) { } -bool DomainEnter(Environment* env, Local object) { - Local domain_v = object->Get(env->domain_string()); - if (domain_v->IsObject()) { - Local domain = domain_v.As(); - if (domain->Get(env->disposed_string())->IsTrue()) - return true; - Local enter_v = domain->Get(env->enter_string()); - if (enter_v->IsFunction()) { - if (enter_v.As()->Call(domain, 0, nullptr).IsEmpty()) { - FatalError("node::AsyncWrap::MakeCallback", - "domain enter callback threw, please report this"); - } - } - } - return false; -} - - -bool DomainExit(Environment* env, v8::Local object) { - Local domain_v = object->Get(env->domain_string()); - if (domain_v->IsObject()) { - Local domain = domain_v.As(); - if (domain->Get(env->disposed_string())->IsTrue()) - return true; - Local exit_v = domain->Get(env->exit_string()); - if (exit_v->IsFunction()) { - if (exit_v.As()->Call(domain, 0, nullptr).IsEmpty()) { - FatalError("node::AsyncWrap::MakeCallback", - "domain exit callback threw, please report this"); - } - } - } - return false; -} - - void AsyncWrap::EmitBefore(Environment* env, double async_id) { AsyncHooks* async_hooks = env->async_hooks(); diff --git a/src/async-wrap.h b/src/async-wrap.h index 2b631234b1..681d4fd13b 100644 --- a/src/async-wrap.h +++ b/src/async-wrap.h @@ -156,10 +156,6 @@ class AsyncWrap : public BaseObject { void LoadAsyncWrapperInfo(Environment* env); -// Return value is an indicator whether the domain was disposed. -bool DomainEnter(Environment* env, v8::Local object); -bool DomainExit(Environment* env, v8::Local object); - } // namespace node #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS diff --git a/src/node.cc b/src/node.cc index 3cfaf8d129..8999014713 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1162,6 +1162,42 @@ bool ShouldAbortOnUncaughtException(Isolate* isolate) { } +bool DomainEnter(Environment* env, Local object) { + Local domain_v = object->Get(env->domain_string()); + if (domain_v->IsObject()) { + Local domain = domain_v.As(); + if (domain->Get(env->disposed_string())->IsTrue()) + return true; + Local enter_v = domain->Get(env->enter_string()); + if (enter_v->IsFunction()) { + if (enter_v.As()->Call(domain, 0, nullptr).IsEmpty()) { + FatalError("node::AsyncWrap::MakeCallback", + "domain enter callback threw, please report this"); + } + } + } + return false; +} + + +bool DomainExit(Environment* env, v8::Local object) { + Local domain_v = object->Get(env->domain_string()); + if (domain_v->IsObject()) { + Local domain = domain_v.As(); + if (domain->Get(env->disposed_string())->IsTrue()) + return true; + Local exit_v = domain->Get(env->exit_string()); + if (exit_v->IsFunction()) { + if (exit_v.As()->Call(domain, 0, nullptr).IsEmpty()) { + FatalError("node::AsyncWrap::MakeCallback", + "domain exit callback threw, please report this"); + } + } + } + return false; +} + + void DomainPromiseHook(PromiseHookType type, Local promise, Local parent,