node_debugger_.reset(new NodeDebugger(js_env_->isolate()));
// Create the global environment.
- global_env = node_bindings_->CreateEnvironment(js_env_->context());
+ node::Environment* env =
+ node_bindings_->CreateEnvironment(js_env_->context());
// Make sure node can get correct environment when debugging.
if (node_debugger_->IsRunning())
- global_env->AssignToContext(v8::Debug::GetDebugContext());
+ env->AssignToContext(v8::Debug::GetDebugContext());
// Add atom-shell extended APIs.
- atom_bindings_->BindTo(js_env_->isolate(), global_env->process_object());
+ atom_bindings_->BindTo(js_env_->isolate(), env->process_object());
// Load everything.
- node_bindings_->LoadEnvironment(global_env);
+ node_bindings_->LoadEnvironment(env);
+
+ // Wrap the uv loop with global env.
+ node_bindings_->set_uv_env(env);
}
void AtomBrowserMainParts::PreMainMessageLoopRun() {
} // namespace
-node::Environment* global_env = nullptr;
-
NodeBindings::NodeBindings(bool is_browser)
: is_browser_(is_browser),
message_loop_(nullptr),
void NodeBindings::UvRunOnce() {
DCHECK(!is_browser_ || BrowserThread::CurrentlyOn(BrowserThread::UI));
- // By default the global env would be used unless user specified another one
- // (this happens for renderer process, which wraps the uv loop with web page
- // context).
- node::Environment* env = uv_env() ? uv_env() : global_env;
+ node::Environment* env = uv_env();
+ CHECK(env);
// Use Locker in browser process.
mate::Locker locker(env->isolate());
#include "vendor/node/src/node_buffer.h"
#include "vendor/node/src/node_internals.h"
-namespace atom {
-// Defined in node_bindings.cc.
-// For renderer it's created in atom_renderer_client.cc.
-// For browser it's created in atom_browser_main_parts.cc.
-extern node::Environment* global_env;
-}
-
#endif // ATOM_COMMON_NODE_INCLUDES_H_
// Add atom-shell extended APIs.
atom_bindings_->BindTo(env->isolate(), env->process_object());
+ // Load everything.
+ node_bindings_->LoadEnvironment(env);
+
if (first_time) {
// Make uv loop being wrapped by window context.
node_bindings_->set_uv_env(env);
// Give the node loop a run to make sure everything is ready.
node_bindings_->RunMessageLoop();
}
-
- // Load everything.
- node_bindings_->LoadEnvironment(env);
}
void AtomRendererClient::WillReleaseScriptContext(