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 #ifndef CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_DISPATCHER_H_ | |
6 #define CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_DISPATCHER_H_ | |
7 | |
8 #include <map> | |
9 | |
10 #include "base/memory/ref_counted.h" | |
11 #include "base/synchronization/lock.h" | |
12 #include "content/child/child_message_filter.h" | |
13 | |
14 namespace base { | |
15 class MessageLoopProxy; | |
16 } | |
17 | |
18 namespace content { | |
19 | |
20 class ThreadSafeSender; | |
21 | |
22 class NotificationDispatcher : public ChildMessageFilter { | |
23 public: | |
24 explicit NotificationDispatcher(ThreadSafeSender* thread_safe_sender); | |
25 | |
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. | |
28 int GenerateNotificationId(int thread_id); | |
29 | |
30 protected: | |
31 ~NotificationDispatcher() override; | |
32 | |
33 private: | |
34 bool ShouldHandleMessage(const IPC::Message& msg); | |
35 | |
36 // ChildMessageFilter implementation. | |
37 base::TaskRunner* OverrideTaskRunnerForMessage(const IPC::Message& msg) | |
38 override; | |
39 bool OnMessageReceived(const IPC::Message& msg) override; | |
40 | |
41 scoped_refptr<base::MessageLoopProxy> main_thread_loop_proxy_; | |
42 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | |
43 | |
44 typedef std::map<int, int> NotificationIdToThreadId; | |
Mike West
2014/10/24 13:20:18
Nit: `using NotificationIdToThreadId = ...`.
Peter Beverloo
2014/10/24 13:57:35
Done.
| |
45 | |
46 base::Lock notification_id_map_lock_; | |
47 NotificationIdToThreadId notification_id_map_; | |
48 int next_notification_id_; | |
49 | |
50 DISALLOW_COPY_AND_ASSIGN(NotificationDispatcher); | |
51 }; | |
52 | |
53 } // namespace content | |
54 | |
55 #endif // CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_DISPATCHER_H_ | |
OLD | NEW |