| 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 #ifndef CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_DISPATCHER_H_ | 5 #ifndef CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_DISPATCHER_H_ |
| 6 #define CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_DISPATCHER_H_ | 6 #define CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_DISPATCHER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 explicit NotificationDispatcher(ThreadSafeSender* thread_safe_sender); | 24 explicit NotificationDispatcher(ThreadSafeSender* thread_safe_sender); |
| 25 | 25 |
| 26 // Generates a, process-unique new notification Id mapped to |thread_id|, and | 26 // Generates a, process-unique new notification Id mapped to |thread_id|, and |
| 27 // return the notification Id. This method can be called on any thread. | 27 // return the notification Id. This method can be called on any thread. |
| 28 int GenerateNotificationId(int thread_id); | 28 int GenerateNotificationId(int thread_id); |
| 29 | 29 |
| 30 protected: | 30 protected: |
| 31 ~NotificationDispatcher() override; | 31 ~NotificationDispatcher() override; |
| 32 | 32 |
| 33 private: | 33 private: |
| 34 bool ShouldHandleMessage(const IPC::Message& msg); | |
| 35 | |
| 36 // ChildMessageFilter implementation. | 34 // ChildMessageFilter implementation. |
| 37 base::TaskRunner* OverrideTaskRunnerForMessage(const IPC::Message& msg) | 35 base::TaskRunner* OverrideTaskRunnerForMessage(const IPC::Message& msg) |
| 38 override; | 36 override; |
| 39 bool OnMessageReceived(const IPC::Message& msg) override; | 37 bool OnMessageReceived(const IPC::Message& msg) override; |
| 40 | 38 |
| 41 scoped_refptr<base::MessageLoopProxy> main_thread_loop_proxy_; | 39 scoped_refptr<base::MessageLoopProxy> main_thread_loop_proxy_; |
| 42 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 40 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 43 | 41 |
| 44 using NotificationIdToThreadId = std::map<int, int>; | 42 using NotificationIdToThreadId = std::map<int, int>; |
| 45 | 43 |
| 46 base::Lock notification_id_map_lock_; | 44 base::Lock notification_id_map_lock_; |
| 47 NotificationIdToThreadId notification_id_map_; | 45 NotificationIdToThreadId notification_id_map_; |
| 48 int next_notification_id_; | 46 int next_notification_id_; |
| 49 | 47 |
| 50 DISALLOW_COPY_AND_ASSIGN(NotificationDispatcher); | 48 DISALLOW_COPY_AND_ASSIGN(NotificationDispatcher); |
| 51 }; | 49 }; |
| 52 | 50 |
| 53 } // namespace content | 51 } // namespace content |
| 54 | 52 |
| 55 #endif // CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_DISPATCHER_H_ | 53 #endif // CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_DISPATCHER_H_ |
| OLD | NEW |