OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/child/geofencing/geofencing_message_filter.h" |
| 6 |
| 7 #include "base/message_loop/message_loop_proxy.h" |
| 8 #include "content/child/geofencing/geofencing_dispatcher.h" |
| 9 #include "content/child/thread_safe_sender.h" |
| 10 #include "content/child/worker_thread_task_runner.h" |
| 11 #include "ipc/ipc_message_macros.h" |
| 12 |
| 13 namespace content { |
| 14 |
| 15 GeofencingMessageFilter::GeofencingMessageFilter(ThreadSafeSender* sender) |
| 16 : main_thread_loop_proxy_(base::MessageLoopProxy::current()), |
| 17 thread_safe_sender_(sender) { |
| 18 } |
| 19 |
| 20 GeofencingMessageFilter::~GeofencingMessageFilter() { |
| 21 } |
| 22 |
| 23 base::TaskRunner* GeofencingMessageFilter::OverrideTaskRunnerForMessage( |
| 24 const IPC::Message& msg) { |
| 25 if (IPC_MESSAGE_CLASS(msg) != GeofencingMsgStart) |
| 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 } |
| 34 |
| 35 bool GeofencingMessageFilter::OnMessageReceived(const IPC::Message& msg) { |
| 36 if (IPC_MESSAGE_CLASS(msg) != GeofencingMsgStart) |
| 37 return false; |
| 38 GeofencingDispatcher::GetOrCreateThreadSpecificInstance( |
| 39 thread_safe_sender_.get())->OnMessageReceived(msg); |
| 40 return true; |
| 41 } |
| 42 |
| 43 } // namespace content |
OLD | NEW |