Upgrade node for new V8 API
This commit is contained in:
parent
5dd73e74cb
commit
7bc364a374
5 changed files with 41 additions and 7 deletions
|
@ -72,8 +72,6 @@ Window::Window(const mate::Dictionary& options)
|
|||
Window::~Window() {
|
||||
if (window_)
|
||||
Destroy();
|
||||
|
||||
Emit("destroyed");
|
||||
}
|
||||
|
||||
void Window::OnPageTitleUpdated(bool* prevent_default,
|
||||
|
|
|
@ -89,6 +89,19 @@ namespace {
|
|||
void UvNoOp(uv_async_t* handle) {
|
||||
}
|
||||
|
||||
// Moved from node.cc.
|
||||
void HandleCloseCb(uv_handle_t* handle) {
|
||||
node::Environment* env = reinterpret_cast<node::Environment*>(handle->data);
|
||||
env->FinishHandleCleanup(handle);
|
||||
}
|
||||
|
||||
void HandleCleanup(node::Environment* env,
|
||||
uv_handle_t* handle,
|
||||
void* arg) {
|
||||
handle->data = env;
|
||||
uv_close(handle, HandleCloseCb);
|
||||
}
|
||||
|
||||
// Convert the given vector to an array of C-strings. The strings in the
|
||||
// returned vector are only guaranteed valid so long as the vector of strings
|
||||
// is not modified.
|
||||
|
@ -181,6 +194,7 @@ node::Environment* NodeBindings::CreateEnvironment(
|
|||
|
||||
// Construct the parameters that passed to node::CreateEnvironment:
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
uv_loop_t* loop = uv_default_loop();
|
||||
int argc = args.size();
|
||||
const char** argv = c_argv.get();
|
||||
int exec_argc = 0;
|
||||
|
@ -191,13 +205,16 @@ node::Environment* NodeBindings::CreateEnvironment(
|
|||
|
||||
// Following code are stripped from node::CreateEnvironment in node.cc:
|
||||
HandleScope handle_scope(isolate);
|
||||
Context::Scope context_scope(context);
|
||||
|
||||
Environment* env = Environment::New(context);
|
||||
Context::Scope context_scope(context);
|
||||
Environment* env = Environment::New(context, loop);
|
||||
|
||||
isolate->SetAutorunMicrotasks(false);
|
||||
|
||||
uv_check_init(env->event_loop(), env->immediate_check_handle());
|
||||
uv_unref(
|
||||
reinterpret_cast<uv_handle_t*>(env->immediate_check_handle()));
|
||||
|
||||
uv_idle_init(env->event_loop(), env->immediate_idle_handle());
|
||||
|
||||
uv_prepare_init(env->event_loop(), env->idle_prepare_handle());
|
||||
|
@ -205,6 +222,24 @@ node::Environment* NodeBindings::CreateEnvironment(
|
|||
uv_unref(reinterpret_cast<uv_handle_t*>(env->idle_prepare_handle()));
|
||||
uv_unref(reinterpret_cast<uv_handle_t*>(env->idle_check_handle()));
|
||||
|
||||
// Register handle cleanups
|
||||
env->RegisterHandleCleanup(
|
||||
reinterpret_cast<uv_handle_t*>(env->immediate_check_handle()),
|
||||
HandleCleanup,
|
||||
nullptr);
|
||||
env->RegisterHandleCleanup(
|
||||
reinterpret_cast<uv_handle_t*>(env->immediate_idle_handle()),
|
||||
HandleCleanup,
|
||||
nullptr);
|
||||
env->RegisterHandleCleanup(
|
||||
reinterpret_cast<uv_handle_t*>(env->idle_prepare_handle()),
|
||||
HandleCleanup,
|
||||
nullptr);
|
||||
env->RegisterHandleCleanup(
|
||||
reinterpret_cast<uv_handle_t*>(env->idle_check_handle()),
|
||||
HandleCleanup,
|
||||
nullptr);
|
||||
|
||||
Local<FunctionTemplate> process_template = FunctionTemplate::New(isolate);
|
||||
process_template->SetClassName(FIXED_ONE_BYTE_STRING(isolate, "process"));
|
||||
|
||||
|
@ -212,7 +247,7 @@ node::Environment* NodeBindings::CreateEnvironment(
|
|||
env->set_process_object(process_object);
|
||||
|
||||
SetupProcessObject(env, argc, argv, exec_argc, exec_argv);
|
||||
Load(env);
|
||||
LoadEnvironment(env);
|
||||
|
||||
return env;
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ void AtomRendererClient::WebKitInitialized() {
|
|||
v8::Isolate* isolate = blink::mainThreadIsolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
v8::Local<v8::Context> context = v8::Context::New(isolate);
|
||||
global_env = node::Environment::New(context);
|
||||
global_env = node::Environment::New(context, uv_default_loop());
|
||||
}
|
||||
|
||||
void AtomRendererClient::RenderThreadStarted() {
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
'uv_parent_path': 'vendor/node/deps/uv',
|
||||
'uv_use_dtrace': 'false',
|
||||
'v8_postmortem_support': 'false',
|
||||
'v8_enable_i18n_support': 'false',
|
||||
# Required by Linux (empty for now, should support it in future).
|
||||
'sysroot': '',
|
||||
},
|
||||
|
|
2
vendor/node
vendored
2
vendor/node
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 6403ce1c2ff752e81c1145112fa73f9273b8e73a
|
||||
Subproject commit b1d7464f1c05456027d41fa97384765bc1790212
|
Loading…
Add table
Add a link
Reference in a new issue