]> khamidou — GitHub mirrors - electron.git/commitdiff
Upgrade node for new V8 API
authorCheng Zhao <zcbenz@gmail.com>
Sun, 7 Dec 2014 21:09:50 +0000 (13:09 -0800)
committerCheng Zhao <zcbenz@gmail.com>
Sun, 7 Dec 2014 21:09:50 +0000 (13:09 -0800)
atom/browser/api/atom_api_window.cc
atom/common/node_bindings.cc
atom/renderer/atom_renderer_client.cc
common.gypi
vendor/node

index 615adb512cddae953a0ada21eb8f96d6186acc2c..17255fd238ecd32bed9b1f59066a843533a3e405 100644 (file)
@@ -72,8 +72,6 @@ Window::Window(const mate::Dictionary& options)
 Window::~Window() {
   if (window_)
     Destroy();
-
-  Emit("destroyed");
 }
 
 void Window::OnPageTitleUpdated(bool* prevent_default,
index 9bfd0c4f3c5e08a52140219a280bd66154a6555e..e43c4d9625b134e24a8e9778bbf7c5e12f766364 100644 (file)
@@ -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, loop);
 
-  Environment* env = Environment::New(context);
+  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;
 }
index 7a108d72c5e1255d59b80faa05b0a9340c449d2b..c910014e19dcd4e26a1eb68cba2e15a411cae1fc 100644 (file)
@@ -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() {
index 2bf92e790e20d4f1641cb2150722f49a98ac0075..d3835bbd89f25b3049652eaf63fd2d61b0250206 100644 (file)
@@ -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': '',
   },
index 6403ce1c2ff752e81c1145112fa73f9273b8e73a..b1d7464f1c05456027d41fa97384765bc1790212 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 6403ce1c2ff752e81c1145112fa73f9273b8e73a
+Subproject commit b1d7464f1c05456027d41fa97384765bc1790212