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

Side by Side Diff: content/child/navigator_connect/navigator_connect_dispatcher.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, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/child/navigator_connect/navigator_connect_dispatcher.h" 5 #include "content/child/navigator_connect/navigator_connect_dispatcher.h"
6 6
7 #include "base/message_loop/message_loop_proxy.h"
8 #include "content/child/navigator_connect/navigator_connect_provider.h" 7 #include "content/child/navigator_connect/navigator_connect_provider.h"
9 #include "content/child/thread_safe_sender.h"
10 #include "content/child/worker_thread_task_runner.h"
11 #include "content/common/navigator_connect_messages.h" 8 #include "content/common/navigator_connect_messages.h"
12 9
13 namespace content { 10 namespace content {
14 11
15 NavigatorConnectDispatcher::NavigatorConnectDispatcher(ThreadSafeSender* sender) 12 NavigatorConnectDispatcher::NavigatorConnectDispatcher(ThreadSafeSender* sender)
16 : main_thread_loop_proxy_(base::MessageLoopProxy::current()), 13 : WorkerThreadMessageFilter(sender) {
17 thread_safe_sender_(sender) {
18 } 14 }
19 15
20 NavigatorConnectDispatcher::~NavigatorConnectDispatcher() { 16 NavigatorConnectDispatcher::~NavigatorConnectDispatcher() {
21 } 17 }
22 18
23 base::TaskRunner* NavigatorConnectDispatcher::OverrideTaskRunnerForMessage( 19 bool NavigatorConnectDispatcher::ShouldHandleMessage(
24 const IPC::Message& msg) { 20 const IPC::Message& msg) const {
25 if (IPC_MESSAGE_CLASS(msg) != NavigatorConnectMsgStart) 21 return IPC_MESSAGE_CLASS(msg) == NavigatorConnectMsgStart;
26 return NULL;
27 int ipc_thread_id = 0;
28 const bool success = PickleIterator(msg).ReadInt(&ipc_thread_id);
29 DCHECK(success);
30 if (!ipc_thread_id)
31 return main_thread_loop_proxy_.get();
32 return new WorkerThreadTaskRunner(ipc_thread_id);
33 } 22 }
34 23
35 bool NavigatorConnectDispatcher::OnMessageReceived(const IPC::Message& msg) { 24 void NavigatorConnectDispatcher::OnFilteredMessageReceived(
36 if (IPC_MESSAGE_CLASS(msg) != NavigatorConnectMsgStart) 25 const IPC::Message& msg) {
37 return false; 26 NavigatorConnectProvider::ThreadSpecificInstance(
38 NavigatorConnectProvider::ThreadSpecificInstance(thread_safe_sender_.get(), 27 thread_safe_sender(), main_thread_task_runner())->OnMessageReceived(msg);
39 main_thread_loop_proxy_) 28 }
40 ->OnMessageReceived(msg); 29
41 return true; 30 bool NavigatorConnectDispatcher::GetWorkerThreadIdForMessage(
31 const IPC::Message& msg,
32 int* ipc_thread_id) {
33 return PickleIterator(msg).ReadInt(ipc_thread_id);
42 } 34 }
43 35
44 } // namespace content 36 } // namespace content
OLDNEW
« no previous file with comments | « content/child/navigator_connect/navigator_connect_dispatcher.h ('k') | content/child/notifications/notification_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698