fix: missing handlescopes in event emission (#23140)

* fix: missing event emitter handlescopes

* refactor: add static getter to js env
This commit is contained in:
shelley vohr 2020-04-27 11:38:43 -07:00 committed by GitHub
parent 9bb8e43c9b
commit ac5c30a707
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 0 deletions

View file

@ -20,6 +20,10 @@
#include "shell/common/node_includes.h"
#include "tracing/trace_event.h"
namespace {
v8::Isolate* g_isolate;
}
namespace electron {
JavascriptEnvironment::JavascriptEnvironment(uv_loop_t* event_loop)
@ -46,6 +50,7 @@ JavascriptEnvironment::~JavascriptEnvironment() {
context_.Get(isolate_)->Exit();
}
isolate_->Exit();
g_isolate = nullptr;
}
v8::Isolate* JavascriptEnvironment::Initialize(uv_loop_t* event_loop) {
@ -73,10 +78,17 @@ v8::Isolate* JavascriptEnvironment::Initialize(uv_loop_t* event_loop) {
v8::Isolate* isolate = v8::Isolate::Allocate();
platform_->RegisterIsolate(isolate, event_loop);
g_isolate = isolate;
return isolate;
}
// static
v8::Isolate* JavascriptEnvironment::GetIsolate() {
CHECK(g_isolate);
return g_isolate;
}
void JavascriptEnvironment::OnMessageLoopCreated() {
DCHECK(!microtasks_runner_);
microtasks_runner_ = std::make_unique<MicrotasksRunner>(isolate());