Index: content/renderer/render_thread_impl.cc |
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc |
index c7ea9c71e78c6fcd3727d6326465f816285e075e..d94c5fac44b2489fa88622cc8be44eb8223f316a 100644 |
--- a/content/renderer/render_thread_impl.cc |
+++ b/content/renderer/render_thread_impl.cc |
@@ -20,6 +20,7 @@ |
#include "base/metrics/histogram.h" |
#include "base/metrics/stats_table.h" |
#include "base/path_service.h" |
+#include "base/single_thread_task_runner.h" |
#include "base/strings/string16.h" |
#include "base/strings/string_number_conversions.h" |
#include "base/strings/string_tokenizer.h" |
@@ -106,7 +107,9 @@ |
#include "net/base/net_errors.h" |
#include "net/base/net_util.h" |
#include "skia/ext/event_tracer_impl.h" |
+#include "third_party/WebKit/public/platform/WebScheduler.h" |
#include "third_party/WebKit/public/platform/WebString.h" |
+#include "third_party/WebKit/public/platform/WebThread.h" |
#include "third_party/WebKit/public/web/WebColorName.h" |
#include "third_party/WebKit/public/web/WebDatabase.h" |
#include "third_party/WebKit/public/web/WebDocument.h" |
@@ -290,6 +293,81 @@ void CreateRenderFrameSetup(mojo::InterfaceRequest<RenderFrameSetup> request) { |
mojo::BindToRequest(new RenderFrameSetupImpl(), &request); |
} |
+class WebThreadTask: public blink::WebThread::Task { |
+ public: |
+ explicit WebThreadTask(const base::Closure& function) |
+ : m_function(function) {} |
+ virtual ~WebThreadTask() {} |
+ |
+ virtual void run() OVERRIDE { |
+ m_function.Run(); |
+ } |
+ |
+ private: |
+ base::Closure m_function; |
+}; |
+ |
+class SchedulerCompositorTaskRunner : public cc::MainThreadTaskRunner { |
+public: |
+ SchedulerCompositorTaskRunner() |
+ : scheduler_(blink::WebScheduler::create()) {} |
+ |
+ virtual void PostBeginMainFrameTask( |
+ const tracked_objects::Location& from_here, const base::Closure& task, |
+ double frame_time, double deadline, double interval) OVERRIDE { |
+ scheduler_.postBeginFrameTask( |
+ new WebThreadTask(task), frame_time, deadline, interval); |
+ } |
+ |
+ virtual bool PostDelayedTask( |
+ const tracked_objects::Location& from_here, const base::Closure& task, |
+ base::TimeDelta delay) OVERRIDE { |
+ DCHECK(delay == base::TimeDelta()); |
+ scheduler_.postCompositorTask(new WebThreadTask(task)); |
+ return true; |
+ } |
+ |
+ protected: |
+ virtual ~SchedulerCompositorTaskRunner () {} |
+ |
+ private: |
+ // TODO: Rename to WebSchedulerProxy. |
+ blink::WebScheduler scheduler_; |
+}; |
+ |
+class SchedulerInputTaskRunner : public base::SingleThreadTaskRunner { |
+ public: |
+ SchedulerInputTaskRunner() |
+ : scheduler_(blink::WebScheduler::create()) {} |
+ |
+ virtual bool PostDelayedTask(const tracked_objects::Location& from_here, |
+ const base::Closure& task, |
+ base::TimeDelta delay) OVERRIDE { |
+ DCHECK(delay == base::TimeDelta()); |
+ scheduler_.postInputTask(new WebThreadTask(task)); |
+ return true; |
+ } |
+ |
+ virtual bool PostNonNestableDelayedTask( |
+ const tracked_objects::Location& from_here, const base::Closure& task, |
+ base::TimeDelta delay) OVERRIDE { |
+ NOTREACHED(); |
+ return false; |
+ } |
+ |
+ virtual bool RunsTasksOnCurrentThread() const OVERRIDE { |
+ NOTREACHED(); |
+ return false; |
+ } |
+ |
+ protected: |
+ virtual ~SchedulerInputTaskRunner() {} |
+ |
+ private: |
+ // TODO: Rename to WebSchedulerProxy. |
+ blink::WebScheduler scheduler_; |
+}; |
+ |
} // namespace |
RenderThreadImpl::HistogramCustomizer::HistogramCustomizer() { |
@@ -790,6 +868,10 @@ void RenderThreadImpl::EnsureWebKitInitialized() { |
webkit_platform_support_.reset(new RendererWebKitPlatformSupportImpl); |
blink::initialize(webkit_platform_support_.get()); |
+ main_thread_task_runner_ = |
+ make_scoped_refptr(new SchedulerCompositorTaskRunner()); |
+ input_task_runner_ = |
+ make_scoped_refptr(new SchedulerInputTaskRunner()); |
const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
@@ -824,7 +906,8 @@ void RenderThreadImpl::EnsureWebKitInitialized() { |
#endif |
if (!input_handler_manager_client) { |
input_event_filter_ = |
- new InputEventFilter(this, compositor_message_loop_proxy_); |
+ new InputEventFilter(this, input_task_runner_, |
+ compositor_message_loop_proxy_); |
AddFilter(input_event_filter_.get()); |
input_handler_manager_client = input_event_filter_.get(); |
} |