Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4893)

Unified Diff: content/renderer/render_thread_impl.cc

Issue 363383002: Forward input tasks to the Blink scheduler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed fallback. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_thread_impl.cc
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
index d0db6f87ea8255c7fc0b9365316e952bd933f90e..297cfd5ad218f19f325ffc7fd42517d328ecea9e 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"
@@ -109,7 +110,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"
@@ -302,6 +306,61 @@ bool ShouldUseMojoChannel() {
switches::kEnableRendererMojoChannel);
}
+// Helper for forwarding posted tasks into different WebSchedulerProxy queues.
jamesr 2014/08/08 17:06:49 this belongs in its own .h/.cc and should have som
Sami 2014/08/08 18:40:27 Done.
+template <void (blink::WebSchedulerProxy::*ProxyFunction)(
+ const blink::WebTraceLocation&,
+ blink::WebThread::Task*)>
+class SchedulerProxyTaskRunner : public base::SingleThreadTaskRunner {
+ public:
+ SchedulerProxyTaskRunner()
+ : main_thread_id_(base::PlatformThread::CurrentId()),
+ scheduler_proxy_(blink::WebSchedulerProxy::create()) {}
+
+ // base::SingleThreadTaskRunner implementation:
+ virtual bool RunsTasksOnCurrentThread() const OVERRIDE {
+ return base::PlatformThread::CurrentId() == main_thread_id_;
+ }
+
+ virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay) OVERRIDE {
+ DCHECK(RenderThreadImpl::current());
+ DCHECK(delay == base::TimeDelta());
+ blink::WebTraceLocation location(from_here.function_name(),
+ from_here.file_name());
jamesr 2014/08/08 17:09:01 this isn't a full fidelity copy of a tracked_objec
+ (scheduler_proxy_.*ProxyFunction)(location, new TaskAdapter(task));
jamesr 2014/08/08 17:52:49 what if you put the original tracked_objects::Loca
+ return true;
+ }
+
+ virtual bool PostNonNestableDelayedTask(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay) OVERRIDE {
+ NOTREACHED();
+ return false;
+ }
+
+ 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/08/08 17:06:49 NAK, you should never use OVERRIDE for cross-repos
Sami 2014/08/08 18:40:27 Oops, good catch!
+
+ private:
+ base::Closure function_;
+ };
+
+ const base::PlatformThreadId main_thread_id_;
+ blink::WebSchedulerProxy scheduler_proxy_;
+
+ DISALLOW_COPY_AND_ASSIGN(SchedulerProxyTaskRunner);
+};
+
} // namespace
// For measuring memory usage after each task. Behind a command line flag.
@@ -644,6 +703,9 @@ void RenderThreadImpl::Shutdown() {
// hold pointers to V8 objects (e.g., via pending requests).
main_thread_indexed_db_dispatcher_.reset();
+ main_thread_compositor_task_runner_ = NULL;
+ main_thread_input_task_runner_ = NULL;
+
if (webkit_platform_support_)
blink::shutdown();
@@ -826,6 +888,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();
@@ -865,8 +932,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();
}
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698