Chromium Code Reviews| Index: content/child/navigator_connect/navigator_connect_dispatcher.cc |
| diff --git a/content/child/navigator_connect/navigator_connect_dispatcher.cc b/content/child/navigator_connect/navigator_connect_dispatcher.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2108214b5c0a6abff12d5873c6be17955c143a8a |
| --- /dev/null |
| +++ b/content/child/navigator_connect/navigator_connect_dispatcher.cc |
| @@ -0,0 +1,47 @@ |
| +// Copyright 2014 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/navigator_connect/navigator_connect_dispatcher.h" |
| + |
| +#include "base/message_loop/message_loop_proxy.h" |
| +#include "content/child/navigator_connect/navigator_connect_provider.h" |
| +#include "content/child/thread_safe_sender.h" |
| +#include "content/child/worker_thread_task_runner.h" |
| +#include "content/common/navigator_connect_messages.h" |
| + |
| +namespace content { |
| + |
| +NavigatorConnectDispatcher::NavigatorConnectDispatcher(ThreadSafeSender* sender) |
| + : main_thread_loop_proxy_(base::MessageLoopProxy::current()), |
| + thread_safe_sender_(sender) { |
| +} |
| + |
| +NavigatorConnectDispatcher::~NavigatorConnectDispatcher() { |
| +} |
| + |
| +base::TaskRunner* NavigatorConnectDispatcher::OverrideTaskRunnerForMessage( |
| + const IPC::Message& msg) { |
| + if (IPC_MESSAGE_CLASS(msg) != NavigatorConnectMsgStart) |
| + return NULL; |
| + int ipc_thread_id = 0; |
| + const bool success = PickleIterator(msg).ReadInt(&ipc_thread_id); |
| + DCHECK(success); |
| + if (!ipc_thread_id) |
| + return main_thread_loop_proxy_.get(); |
| + return new WorkerThreadTaskRunner(ipc_thread_id); |
| +} |
| + |
| +bool NavigatorConnectDispatcher::OnMessageReceived(const IPC::Message& msg) { |
| + bool handled = true; |
| + IPC_BEGIN_MESSAGE_MAP(NavigatorConnectDispatcher, msg) |
| + IPC_MESSAGE_FORWARD(NavigatorConnectMsg_ConnectResult, |
|
scheib
2014/12/05 05:49:50
Why not the pattern as in GeofencingMessageFilter,
Marijn Kruisselbrink
2014/12/05 14:25:50
No functional difference, no. Just saving some lin
|
| + NavigatorConnectProvider::ThreadSpecificInstance( |
| + thread_safe_sender_.get()), |
| + NavigatorConnectProvider::OnConnectResult) |
| + IPC_MESSAGE_UNHANDLED(handled = false) |
| + IPC_END_MESSAGE_MAP() |
| + return handled; |
| +} |
| + |
| +} // namespace content |