update libcc for using custom platform with gin

This commit is contained in:
deepak1556 2017-12-22 23:04:44 +05:30 committed by Cheng Zhao
parent 769fbd0d3b
commit b9ace16959
3 changed files with 15 additions and 4 deletions

View file

@ -145,7 +145,7 @@ void AtomBrowserMainParts::PostEarlyInitialization() {
// Enable support for v8 inspector
node_debugger_.reset(new NodeDebugger(env));
node_debugger_->Start();
node_debugger_->Start(js_env_->platform());
// Add Electron extended APIs.
atom_bindings_->BindTo(js_env_->isolate(), env->process_object());

View file

@ -26,7 +26,8 @@ JavascriptEnvironment::JavascriptEnvironment()
locker_(isolate_),
handle_scope_(isolate_),
context_(isolate_, v8::Context::New(isolate_)),
context_scope_(v8::Local<v8::Context>::New(isolate_, context_)) {}
context_scope_(v8::Local<v8::Context>::New(isolate_, context_)) {
}
void JavascriptEnvironment::OnMessageLoopCreated() {
isolate_holder_.AddRunMicrotasksObserver();
@ -44,10 +45,17 @@ bool JavascriptEnvironment::Initialize() {
if (!js_flags.empty())
v8::V8::SetFlagsFromString(js_flags.c_str(), js_flags.size());
// The V8Platform of gin relies on Chromium's task schedule, which has not
// been started at this point, so we have to rely on Node's V8Platform.
platform_ = node::CreatePlatform(
base::RecommendedMaxNumberOfThreadsInPool(3, 8, 0.1, 0),
uv_default_loop(), nullptr);
v8::V8::InitializePlatform(platform_);
gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode,
gin::IsolateHolder::kStableV8Extras,
gin::ArrayBufferAllocator::SharedInstance());
gin::ArrayBufferAllocator::SharedInstance(),
false);
return true;
}

View file

@ -32,6 +32,9 @@ class JavascriptEnvironment {
private:
bool Initialize();
// Leaked on exit.
node::NodePlatform* platform_;
bool initialized_;
gin::IsolateHolder isolate_holder_;
v8::Isolate* isolate_;