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

Unified Diff: content/child/worker_thread_message_filter.cc

Issue 892543002: workers: Introduce a WorkerMessageFilter to ease routing/processing worker messages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 11 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/child/worker_thread_message_filter.h ('k') | content/content_child.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/worker_thread_message_filter.cc
diff --git a/content/child/worker_thread_message_filter.cc b/content/child/worker_thread_message_filter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ac11a3dbd19d0eee4a71b76fecfe1e27885f87fc
--- /dev/null
+++ b/content/child/worker_thread_message_filter.cc
@@ -0,0 +1,42 @@
+// Copyright 2015 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_message_filter.h"
+
+#include "base/thread_task_runner_handle.h"
+#include "content/child/thread_safe_sender.h"
+#include "content/child/worker_thread_task_runner.h"
+#include "ipc/ipc_message_macros.h"
+
+namespace content {
+
+WorkerThreadMessageFilter::WorkerThreadMessageFilter(
+ ThreadSafeSender* thread_safe_sender)
+ : main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
+ thread_safe_sender_(thread_safe_sender) {
+}
+
+WorkerThreadMessageFilter::~WorkerThreadMessageFilter() {
+}
+
+base::TaskRunner* WorkerThreadMessageFilter::OverrideTaskRunnerForMessage(
+ const IPC::Message& msg) {
+ if (!ShouldHandleMessage(msg))
+ return nullptr;
+ int ipc_thread_id = 0;
+ const bool success = GetWorkerThreadIdForMessage(msg, &ipc_thread_id);
+ DCHECK(success);
+ if (!ipc_thread_id)
+ return main_thread_task_runner_.get();
+ return new WorkerThreadTaskRunner(ipc_thread_id);
+}
+
+bool WorkerThreadMessageFilter::OnMessageReceived(const IPC::Message& msg) {
+ if (!ShouldHandleMessage(msg))
+ return false;
+ OnFilteredMessageReceived(msg);
+ return true;
+}
+
+} // namespace content
« no previous file with comments | « content/child/worker_thread_message_filter.h ('k') | content/content_child.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698