|
@@ -139,55 +139,59 @@ int NodeMain(int argc, char* argv[]) {
|
|
|
JavascriptEnvironment gin_env(loop);
|
|
|
|
|
|
v8::Isolate* isolate = gin_env.isolate();
|
|
|
-
|
|
|
- node::IsolateData* isolate_data =
|
|
|
- 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);
|
|
|
+ v8::Locker locker(isolate);
|
|
|
+ node::Environment* env = nullptr;
|
|
|
+ node::IsolateData* isolate_data = nullptr;
|
|
|
+ {
|
|
|
+ v8::HandleScope scope(isolate);
|
|
|
|
|
|
- node::Environment* env = node::CreateEnvironment(
|
|
|
- isolate_data, gin_env.context(), argc, argv, exec_argc, exec_argv);
|
|
|
- CHECK_NE(nullptr, env);
|
|
|
+ isolate_data = node::CreateIsolateData(isolate, loop, gin_env.platform());
|
|
|
+ CHECK_NE(nullptr, isolate_data);
|
|
|
|
|
|
- // Enable support for v8 inspector.
|
|
|
- NodeDebugger node_debugger(env);
|
|
|
- node_debugger.Start();
|
|
|
+ env = node::CreateEnvironment(isolate_data, gin_env.context(), argc, argv,
|
|
|
+ exec_argc, exec_argv);
|
|
|
+ CHECK_NE(nullptr, env);
|
|
|
|
|
|
- // TODO(codebytere): we shouldn't have to call this - upstream?
|
|
|
- env->InitializeDiagnostics();
|
|
|
+ // TODO(codebytere): we shouldn't have to call this - upstream?
|
|
|
+ env->InitializeDiagnostics();
|
|
|
|
|
|
- // This is needed in order to enable v8 host weakref hooks.
|
|
|
- // TODO(codebytere): we shouldn't have to call this - upstream?
|
|
|
- isolate->SetHostCleanupFinalizationGroupCallback(
|
|
|
- HostCleanupFinalizationGroupCallback);
|
|
|
+ // This is needed in order to enable v8 host weakref hooks.
|
|
|
+ // TODO(codebytere): we shouldn't have to call this - upstream?
|
|
|
+ isolate->SetHostCleanupFinalizationGroupCallback(
|
|
|
+ HostCleanupFinalizationGroupCallback);
|
|
|
|
|
|
- gin_helper::Dictionary process(isolate, env->process_object());
|
|
|
+ gin_helper::Dictionary process(isolate, env->process_object());
|
|
|
#if defined(OS_WIN)
|
|
|
- process.SetMethod("log", &ElectronBindings::Log);
|
|
|
+ process.SetMethod("log", &ElectronBindings::Log);
|
|
|
#endif
|
|
|
- process.SetMethod("crash", &ElectronBindings::Crash);
|
|
|
+ process.SetMethod("crash", &ElectronBindings::Crash);
|
|
|
|
|
|
- // Setup process.crashReporter.start in child node processes
|
|
|
- gin_helper::Dictionary reporter = gin::Dictionary::CreateEmpty(isolate);
|
|
|
- reporter.SetMethod("start", &crash_reporter::CrashReporter::StartInstance);
|
|
|
+ // Setup process.crashReporter.start in child node processes
|
|
|
+ gin_helper::Dictionary reporter = gin::Dictionary::CreateEmpty(isolate);
|
|
|
+ reporter.SetMethod("start",
|
|
|
+ &crash_reporter::CrashReporter::StartInstance);
|
|
|
|
|
|
#if !defined(OS_LINUX)
|
|
|
- reporter.SetMethod("addExtraParameter", &AddExtraParameter);
|
|
|
- reporter.SetMethod("removeExtraParameter", &RemoveExtraParameter);
|
|
|
+ reporter.SetMethod("addExtraParameter", &AddExtraParameter);
|
|
|
+ reporter.SetMethod("removeExtraParameter", &RemoveExtraParameter);
|
|
|
#endif
|
|
|
|
|
|
- process.Set("crashReporter", reporter);
|
|
|
+ process.Set("crashReporter", reporter);
|
|
|
|
|
|
- gin_helper::Dictionary versions;
|
|
|
- if (process.Get("versions", &versions)) {
|
|
|
- versions.SetReadOnly(ELECTRON_PROJECT_NAME, ELECTRON_VERSION_STRING);
|
|
|
+ gin_helper::Dictionary versions;
|
|
|
+ if (process.Get("versions", &versions)) {
|
|
|
+ versions.SetReadOnly(ELECTRON_PROJECT_NAME, ELECTRON_VERSION_STRING);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ // Enable support for v8 inspector.
|
|
|
+ NodeDebugger node_debugger(env);
|
|
|
+ node_debugger.Start();
|
|
|
+
|
|
|
// TODO(codebytere): we should try to handle this upstream.
|
|
|
{
|
|
|
+ v8::HandleScope scope(isolate);
|
|
|
node::InternalCallbackScope callback_scope(
|
|
|
env, v8::Local<v8::Object>(), {1, 0},
|
|
|
node::InternalCallbackScope::kAllowEmptyResource |
|