OLD | NEW |
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/notifications/notification_dispatcher.h" | 5 #include "content/child/notifications/notification_dispatcher.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "content/child/notifications/notification_manager.h" | 9 #include "content/child/notifications/notification_manager.h" |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 return next_notification_id_++; | 24 return next_notification_id_++; |
25 } | 25 } |
26 | 26 |
27 bool NotificationDispatcher::ShouldHandleMessage( | 27 bool NotificationDispatcher::ShouldHandleMessage( |
28 const IPC::Message& msg) const { | 28 const IPC::Message& msg) const { |
29 return IPC_MESSAGE_CLASS(msg) == PlatformNotificationMsgStart; | 29 return IPC_MESSAGE_CLASS(msg) == PlatformNotificationMsgStart; |
30 } | 30 } |
31 | 31 |
32 void NotificationDispatcher::OnFilteredMessageReceived( | 32 void NotificationDispatcher::OnFilteredMessageReceived( |
33 const IPC::Message& msg) { | 33 const IPC::Message& msg) { |
34 NotificationManager::ThreadSpecificInstance(thread_safe_sender(), | 34 NotificationManager::ThreadSpecificInstance(thread_safe_sender(), this) |
35 main_thread_task_runner(), this) | |
36 ->OnMessageReceived(msg); | 35 ->OnMessageReceived(msg); |
37 } | 36 } |
38 | 37 |
39 bool NotificationDispatcher::GetWorkerThreadIdForMessage( | 38 bool NotificationDispatcher::GetWorkerThreadIdForMessage( |
40 const IPC::Message& msg, | 39 const IPC::Message& msg, |
41 int* ipc_thread_id) { | 40 int* ipc_thread_id) { |
42 int notification_id = -1; | 41 int notification_id = -1; |
43 const bool success = base::PickleIterator(msg).ReadInt(¬ification_id); | 42 const bool success = base::PickleIterator(msg).ReadInt(¬ification_id); |
44 DCHECK(success); | 43 DCHECK(success); |
45 | 44 |
46 base::AutoLock lock(notification_id_map_lock_); | 45 base::AutoLock lock(notification_id_map_lock_); |
47 auto iterator = notification_id_map_.find(notification_id); | 46 auto iterator = notification_id_map_.find(notification_id); |
48 if (iterator != notification_id_map_.end()) { | 47 if (iterator != notification_id_map_.end()) { |
49 *ipc_thread_id = iterator->second; | 48 *ipc_thread_id = iterator->second; |
50 return true; | 49 return true; |
51 } | 50 } |
52 return false; | 51 return false; |
53 } | 52 } |
54 | 53 |
55 } // namespace content | 54 } // namespace content |
OLD | NEW |