#include "atom/browser/api/trackable_object.h"
#include "atom/browser/atom_browser_client.h"
#include "atom/browser/atom_browser_context.h"
+#include "atom/browser/bridge_task_runner.h"
#include "atom/browser/browser.h"
#include "atom/browser/javascript_environment.h"
#include "atom/browser/node_debugger.h"
#include "atom/common/api/atom_bindings.h"
#include "atom/common/node_bindings.h"
#include "base/command_line.h"
+#include "base/thread_task_runner_handle.h"
#include "chrome/browser/browser_process.h"
#include "v8/include/v8-debug.h"
SetDPIFromGSettings();
#endif
- // The ProxyResolverV8 has setup a complete V8 environment, in order to avoid
- // conflicts we only initialize our V8 environment after that.
- js_env_.reset(new JavascriptEnvironment);
+ {
+ // 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
+ // of getting current message loop's task runner, which is null for now.
+ bridge_task_runner_ = new BridgeTaskRunner;
+ base::ThreadTaskRunnerHandle handle(bridge_task_runner_);
+
+ // The ProxyResolverV8 has setup a complete V8 environment, in order to
+ // avoid conflicts we only initialize our V8 environment after that.
+ js_env_.reset(new JavascriptEnvironment);
+ }
node_bindings_->Initialize();
class JavascriptEnvironment;
class NodeBindings;
class NodeDebugger;
+class BridgeTaskRunner;
class AtomBrowserMainParts : public brightray::BrowserMainParts {
public:
// A fake BrowserProcess object that used to feed the source code from chrome.
scoped_ptr<BrowserProcess> fake_browser_process_;
+ // The gin::PerIsolateData requires a task runner to create, so we feed it
+ // with a task runner that will post all work to main loop.
+ scoped_refptr<BridgeTaskRunner> bridge_task_runner_;
+
scoped_ptr<Browser> browser_;
scoped_ptr<JavascriptEnvironment> js_env_;
scoped_ptr<NodeBindings> node_bindings_;
--- /dev/null
+// Copyright (c) 2015 GitHub, Inc.
+// Use of this source code is governed by the MIT license that can be
+// found in the LICENSE file.
+
+#include "atom/browser/bridge_task_runner.h"
+
+#include "base/message_loop/message_loop.h"
+
+namespace atom {
+
+bool BridgeTaskRunner::PostDelayedTask(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay) {
+ auto message_loop = base::MessageLoop::current();
+ if (!message_loop)
+ return false;
+
+ return message_loop->task_runner()->PostDelayedTask(from_here, task, delay);
+}
+
+bool BridgeTaskRunner::RunsTasksOnCurrentThread() const {
+ auto message_loop = base::MessageLoop::current();
+ if (!message_loop)
+ return false;
+
+ return message_loop->task_runner()->RunsTasksOnCurrentThread();
+}
+
+bool BridgeTaskRunner::PostNonNestableDelayedTask(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay) {
+ auto message_loop = base::MessageLoop::current();
+ if (!message_loop)
+ return false;
+
+ return message_loop->task_runner()->PostNonNestableDelayedTask(
+ from_here, task, delay);
+}
+
+} // namespace atom
--- /dev/null
+// Copyright (c) 2015 GitHub, Inc.
+// Use of this source code is governed by the MIT license that can be
+// found in the LICENSE file.
+
+#ifndef ATOM_BROWSER_BRIDGE_TASK_RUNNER_H_
+#define ATOM_BROWSER_BRIDGE_TASK_RUNNER_H_
+
+#include "base/single_thread_task_runner.h"
+
+namespace atom {
+
+// Post all tasks to the current message loop's task runner if available,
+// otherwise fail silently.
+class BridgeTaskRunner : public base::SingleThreadTaskRunner {
+ public:
+ BridgeTaskRunner() {}
+ ~BridgeTaskRunner() {}
+
+ // base::SingleThreadTaskRunner:
+ bool PostDelayedTask(const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay) override;
+ bool RunsTasksOnCurrentThread() const override;
+ bool PostNonNestableDelayedTask(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay) override;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BridgeTaskRunner);
+};
+
+} // namespace atom
+
+#endif // ATOM_BROWSER_BRIDGE_TASK_RUNNER_H_
'atom/browser/atom_quota_permission_context.h',
'atom/browser/atom_speech_recognition_manager_delegate.cc',
'atom/browser/atom_speech_recognition_manager_delegate.h',
+ 'atom/browser/bridge_task_runner.cc',
+ 'atom/browser/bridge_task_runner.h',
'atom/browser/browser.cc',
'atom/browser/browser.h',
'atom/browser/browser_linux.cc',