diff --git a/src/node.cc b/src/node.cc index d59f57df50f..b06c7df60a1 100644 --- a/src/node.cc +++ b/src/node.cc @@ -5068,6 +5068,29 @@ NODE_EXTERN void g_uv_init_nw(int worker) { void UvNoOp(uv_async_t* handle) { } +NODE_EXTERN bool g_nw_enter_dom() { + thread_ctx_st* tls_ctx = (struct thread_ctx_st*)uv_key_get(&thread_ctx_key); + if (tls_ctx && tls_ctx->env) { + v8::Isolate* isolate = tls_ctx->env->isolate(); + v8::HandleScope handleScope(isolate); + v8::Local context = isolate->GetEnteredContext(); + if (context == tls_ctx->env->context()) { + context->Exit(); + return true; + } + } + return false; +} + +NODE_EXTERN void g_nw_leave_dom(bool reenter) { + thread_ctx_st* tls_ctx = (struct thread_ctx_st*)uv_key_get(&thread_ctx_key); + if (reenter && tls_ctx && tls_ctx->env) { + v8::Isolate* isolate = tls_ctx->env->isolate(); + v8::HandleScope handleScope(isolate); + tls_ctx->env->context()->Enter(); + } +} + NODE_EXTERN void g_msg_pump_ctor_osx(msg_pump_context_t* ctx, void* EmbedThreadRunner, void* kevent_hook, void* data, int worker_support) { uv_init_nw(worker_support); g_worker_support = worker_support; diff --git a/src/node_webkit.h b/src/node_webkit.h index 2375157f723..b98cb49a2ee 100644 --- a/src/node_webkit.h +++ b/src/node_webkit.h @@ -47,5 +47,7 @@ typedef void (*VoidVoidFn)(); typedef int (*IntVoidFn)(); typedef void (*VoidIntFn)(int); typedef bool (*BoolPtrFn)(void*); +typedef bool (*BoolVoidFn)(); +typedef void (*VoidBoolFn)(bool); #endif