Wrap uv loop with web page context in renderer.

This commit is contained in:
Cheng Zhao 2014-01-09 21:35:29 +08:00
parent 968fc71b78
commit e7b7efeb0a
3 changed files with 21 additions and 3 deletions

View file

@ -51,10 +51,13 @@ void AtomRendererClient::DidCreateScriptContext(WebKit::WebFrame* frame,
node_bindings_->RunMessageLoop();
// Setup node environment for each window.
node_bindings_->CreateEnvironment(context);
node::Environment* env = node_bindings_->CreateEnvironment(context);
// Add atom-shell extended APIs.
atom_bindings_->BindToFrame(frame);
// Make uv loop being wrapped by window context.
node_bindings_->set_uv_env(env);
}
void AtomRendererClient::WillReleaseScriptContext(
@ -67,6 +70,9 @@ void AtomRendererClient::WillReleaseScriptContext(
return;
}
if (env == node_bindings_->get_uv_env())
node_bindings_->set_uv_env(NULL);
env->Dispose();
}