From 6c520af6d5f4646d904ca2810cd6c7411722bfa8 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 468ac975247829..f3cfe8917bd973 100644 --- a/src/async-wrap.cc +++ b/src/async-wrap.cc @@ -183,42 +183,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 a4c42d01b73d36..384911ad171e81 100644 --- a/src/async-wrap.h +++ b/src/async-wrap.h @@ -157,10 +157,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 5cd0ffc29db1e9..0144ebb268f2bb 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1158,6 +1158,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,