Separate LoadEnvironment from CreateEnvironment

This commit is contained in:
Cheng Zhao 2015-01-21 14:00:19 -08:00
parent 854c59df5c
commit 5e58915bdd
4 changed files with 10 additions and 3 deletions

View file

@ -63,8 +63,9 @@ void AtomBrowserMainParts::PostEarlyInitialization() {
// Support the "--debug" switch.
node_debugger_.reset(new NodeDebugger(js_env_->isolate()));
// Create the global environment.
// Create and load the global environment.
global_env = node_bindings_->CreateEnvironment(js_env_->context());
node_bindings_->LoadEnvironment(global_env);
// Make sure node can get correct environment when debugging.
if (node_debugger_->IsRunning())

View file

@ -247,11 +247,13 @@ node::Environment* NodeBindings::CreateEnvironment(
env->set_process_object(process_object);
SetupProcessObject(env, argc, argv, exec_argc, exec_argv);
LoadEnvironment(env);
return env;
}
void NodeBindings::LoadEnvironment(node::Environment* env) {
node::LoadEnvironment(env);
}
void NodeBindings::PrepareMessageLoop() {
DCHECK(!is_browser_ || BrowserThread::CurrentlyOn(BrowserThread::UI));

View file

@ -32,6 +32,9 @@ class NodeBindings {
// Create the environment and load node.js.
virtual node::Environment* CreateEnvironment(v8::Handle<v8::Context> context);
// Load node.js in the environment.
void LoadEnvironment(node::Environment* env);
// Prepare for message loop integration.
virtual void PrepareMessageLoop();

View file

@ -148,6 +148,7 @@ void AtomRendererClient::DidCreateScriptContext(blink::WebFrame* frame,
// Setup node environment for each window.
node::Environment* env = node_bindings_->CreateEnvironment(context);
node_bindings_->LoadEnvironment(env);
// Add atom-shell extended APIs.
atom_bindings_->BindToFrame(frame);