Chromium Code Reviews| Index: content/renderer/render_thread_impl.cc |
| diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc |
| index acafe552a838d58482e50bb918c03fda92b0a55d..541397496837435e8516ae3fb341d9a3ef7beb6a 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" |
| @@ -107,7 +108,10 @@ |
| #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/WebSchedulerProxy.h" |
| #include "third_party/WebKit/public/platform/WebString.h" |
| +#include "third_party/WebKit/public/platform/WebThread.h" |
| +#include "third_party/WebKit/public/platform/WebTraceLocation.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" |
| @@ -291,6 +295,59 @@ void CreateRenderFrameSetup(mojo::InterfaceRequest<RenderFrameSetup> request) { |
| mojo::BindToRequest(new RenderFrameSetupImpl(), &request); |
| } |
| +// Helper for forwarding posted tasks into different WebSchedulerProxy queues. |
| +template <void (blink::WebSchedulerProxy::*ProxyFunction)( |
| + const blink::WebTraceLocation&, |
| + blink::WebThread::Task*)> |
| +class SchedulerProxyTaskRunner : public base::SingleThreadTaskRunner { |
| + public: |
| + SchedulerProxyTaskRunner() |
| + : scheduler_proxy_(blink::WebSchedulerProxy::create()), |
| + main_thread_id_(base::PlatformThread::CurrentId()) {} |
| + |
| + virtual bool PostDelayedTask(const tracked_objects::Location& from_here, |
| + const base::Closure& task, |
| + base::TimeDelta delay) OVERRIDE { |
| + DCHECK(delay == base::TimeDelta()); |
| + blink::WebTraceLocation location(from_here.function_name(), |
| + from_here.file_name()); |
| + (scheduler_proxy_.*ProxyFunction)(location, new TaskAdapter(task)); |
|
jamesr
2014/07/22 01:07:23
hm, so another malloc/free pair for every task we
Sami
2014/07/22 16:24:33
Yeah :( Both of these are a consequence of the fac
|
| + 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 { |
| + return base::PlatformThread::CurrentId() == main_thread_id_; |
| + } |
| + |
| + protected: |
| + virtual ~SchedulerProxyTaskRunner() {} |
| + |
| + private: |
| + class TaskAdapter : public blink::WebThread::Task { |
| + public: |
| + explicit TaskAdapter(const base::Closure& function) : function_(function) {} |
| + virtual ~TaskAdapter() {} |
| + |
| + virtual void run() OVERRIDE { function_.Run(); } |
|
jamesr
2014/07/22 01:07:23
and an extra closure wrapper. hmmm
|
| + |
| + private: |
| + base::Closure function_; |
| + }; |
| + |
| + blink::WebSchedulerProxy scheduler_proxy_; |
| + const base::PlatformThreadId main_thread_id_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SchedulerProxyTaskRunner); |
| +}; |
| + |
| } // namespace |
| // For measuring memory usage after each task. Behind a command line flag. |
| @@ -809,6 +866,11 @@ void RenderThreadImpl::EnsureWebKitInitialized() { |
| webkit_platform_support_.reset(new RendererWebKitPlatformSupportImpl); |
| blink::initialize(webkit_platform_support_.get()); |
| + main_thread_compositor_task_runner_ = |
| + make_scoped_refptr(new SchedulerProxyTaskRunner< |
| + &blink::WebSchedulerProxy::postCompositorTask>()); |
| + main_thread_input_task_runner_ = make_scoped_refptr( |
| + new SchedulerProxyTaskRunner<&blink::WebSchedulerProxy::postInputTask>()); |
| v8::Isolate* isolate = blink::mainThreadIsolate(); |
| @@ -848,8 +910,8 @@ void RenderThreadImpl::EnsureWebKitInitialized() { |
| } |
| #endif |
| if (!input_handler_manager_client) { |
| - input_event_filter_ = |
| - new InputEventFilter(this, compositor_message_loop_proxy_); |
| + input_event_filter_ = new InputEventFilter( |
| + this, main_thread_input_task_runner_, compositor_message_loop_proxy_); |
| AddFilter(input_event_filter_.get()); |
| input_handler_manager_client = input_event_filter_.get(); |
| } |