Skip to content

Commit

Permalink
chore: ensure correct scopes are in place (#22479)
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Mar 3, 2020
1 parent faee8a0 commit 2021f25
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions shell/app/node_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,16 @@ int NodeMain(int argc, char* argv[]) {
// Initialize gin::IsolateHolder.
JavascriptEnvironment gin_env(loop);

v8::Isolate* isolate = gin_env.isolate();

node::IsolateData* isolate_data =
node::CreateIsolateData(gin_env.isolate(), loop, gin_env.platform());
node::CreateIsolateData(isolate, loop, gin_env.platform());
CHECK_NE(nullptr, isolate_data);

v8::Locker locker(isolate);
v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);

node::Environment* env =
node::CreateEnvironment(isolate_data, gin_env.context(), argc, argv,
exec_argc, exec_argv, false);
Expand All @@ -92,15 +98,14 @@ int NodeMain(int argc, char* argv[]) {

node::BootstrapEnvironment(env);

gin_helper::Dictionary process(gin_env.isolate(), env->process_object());
gin_helper::Dictionary process(isolate, env->process_object());
#if defined(OS_WIN)
process.SetMethod("log", &ElectronBindings::Log);
#endif
process.SetMethod("crash", &ElectronBindings::Crash);

// Setup process.crashReporter.start in child node processes
gin_helper::Dictionary reporter =
gin::Dictionary::CreateEmpty(gin_env.isolate());
gin_helper::Dictionary reporter = gin::Dictionary::CreateEmpty(isolate);
reporter.SetMethod("start", &crash_reporter::CrashReporter::StartInstance);

#if !defined(OS_LINUX)
Expand All @@ -116,15 +121,14 @@ int NodeMain(int argc, char* argv[]) {
}

node::LoadEnvironment(env);
v8::Isolate* isolate = env->isolate();

{
v8::SealHandleScope seal(isolate);
bool more;
do {
uv_run(env->event_loop(), UV_RUN_DEFAULT);

gin_env.platform()->DrainTasks(env->isolate());
gin_env.platform()->DrainTasks(isolate);

more = uv_loop_alive(env->event_loop());
if (more && !env->is_stopping())
Expand Down

0 comments on commit 2021f25

Please sign in to comment.