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

Unified Diff: content/child/worker_thread_task_runner.cc

Issue 63843002: Add ChildMessageFilter, a base class for renderer/worker cross-thread MessageFilter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cross thread -> child message filter Created 7 years, 1 month 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
Index: content/child/worker_thread_task_runner.cc
diff --git a/content/child/worker_thread_task_runner.cc b/content/child/worker_thread_task_runner.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8353d081c5c3e24d618e39458d0a5df7c2be4502
--- /dev/null
+++ b/content/child/worker_thread_task_runner.cc
@@ -0,0 +1,37 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/child/worker_thread_task_runner.h"
+
+#include "webkit/child/worker_task_runner.h"
+
+using webkit_glue::WorkerTaskRunner;
+
+namespace content {
+
+WorkerThreadTaskRunner::WorkerThreadTaskRunner(int worker_thread_id)
+ : worker_thread_id_(worker_thread_id) {
+}
+
+scoped_refptr<WorkerThreadTaskRunner> WorkerThreadTaskRunner::current() {
+ int worker_thread_id = WorkerTaskRunner::Instance()->CurrentWorkerId();
+ if (!worker_thread_id)
+ return scoped_refptr<WorkerThreadTaskRunner>();
+ return make_scoped_refptr(new WorkerThreadTaskRunner(worker_thread_id));
+}
+
+bool WorkerThreadTaskRunner::PostDelayedTask(
+ const tracked_objects::Location& /* from_here */,
+ const base::Closure& task,
+ base::TimeDelta /* delay */) {
michaeln 2013/11/18 17:51:42 should we assert if delay != 0 for now?
kinuko 2013/11/19 04:51:34 Done.
+ return WorkerTaskRunner::Instance()->PostTask(worker_thread_id_, task);
+}
+
+bool WorkerThreadTaskRunner::RunsTasksOnCurrentThread() const {
+ return worker_thread_id_ == WorkerTaskRunner::Instance()->CurrentWorkerId();
+}
+
+WorkerThreadTaskRunner::~WorkerThreadTaskRunner() {}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698