Make sure current task runner is available

When calling makeSingleInstance we have to ensure current task runnder
is available, otherwise crash may happen.
This commit is contained in:
Cheng Zhao 2015-10-22 14:56:57 +08:00
parent 63cc2ec369
commit acb2c099f6

View file

@ -62,17 +62,15 @@ void AtomBrowserMainParts::PreEarlyInitialization() {
void AtomBrowserMainParts::PostEarlyInitialization() { void AtomBrowserMainParts::PostEarlyInitialization() {
brightray::BrowserMainParts::PostEarlyInitialization(); brightray::BrowserMainParts::PostEarlyInitialization();
{ // Temporary set the bridge_task_runner_ as current thread's task runner,
// Temporary set the bridge_task_runner_ as current thread's task runner, // so we can fool gin::PerIsolateData to use it as its task runner, instead
// so we can fool gin::PerIsolateData to use it as its task runner, instead // of getting current message loop's task runner, which is null for now.
// of getting current message loop's task runner, which is null for now. bridge_task_runner_ = new BridgeTaskRunner;
bridge_task_runner_ = new BridgeTaskRunner; base::ThreadTaskRunnerHandle handle(bridge_task_runner_);
base::ThreadTaskRunnerHandle handle(bridge_task_runner_);
// The ProxyResolverV8 has setup a complete V8 environment, in order to // The ProxyResolverV8 has setup a complete V8 environment, in order to
// avoid conflicts we only initialize our V8 environment after that. // avoid conflicts we only initialize our V8 environment after that.
js_env_.reset(new JavascriptEnvironment); js_env_.reset(new JavascriptEnvironment);
}
node_bindings_->Initialize(); node_bindings_->Initialize();