]> khamidou — GitHub mirrors - electron.git/commitdiff
Separate LoadEnvironment from CreateEnvironment
authorCheng Zhao <zcbenz@gmail.com>
Wed, 21 Jan 2015 22:00:19 +0000 (14:00 -0800)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 21 Jan 2015 22:00:19 +0000 (14:00 -0800)
atom/browser/atom_browser_main_parts.cc
atom/common/node_bindings.cc
atom/common/node_bindings.h
atom/renderer/atom_renderer_client.cc

index 4233949c9c55478acef63a465f903e9df4d04663..4eae597b8f3222ef691a31b5df2c2a58d12d5ed3 100644 (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())
index e43c4d9625b134e24a8e9778bbf7c5e12f766364..1f3180fb89512819ee716411e85abbb5add7e80b 100644 (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));
 
index 5c3c778314485ef218215b3afccf6ff10aa97e1d..908fc89e9ae17656916dd72114d4bf8bd762bba5 100644 (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();
 
index c910014e19dcd4e26a1eb68cba2e15a411cae1fc..e9dc66e96ce85ce2bdc700c6571133c081230a44 100644 (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);