OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 IPC_IPC_SYNC_MESSAGE_FILTER_H_ | 5 #ifndef IPC_IPC_SYNC_MESSAGE_FILTER_H_ |
6 #define IPC_IPC_SYNC_MESSAGE_FILTER_H_ | 6 #define IPC_IPC_SYNC_MESSAGE_FILTER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 // MessageSender implementation. | 36 // MessageSender implementation. |
37 bool Send(Message* message) override; | 37 bool Send(Message* message) override; |
38 | 38 |
39 // MessageFilter implementation. | 39 // MessageFilter implementation. |
40 void OnFilterAdded(Sender* sender) override; | 40 void OnFilterAdded(Sender* sender) override; |
41 void OnChannelError() override; | 41 void OnChannelError() override; |
42 void OnChannelClosing() override; | 42 void OnChannelClosing() override; |
43 bool OnMessageReceived(const Message& message) override; | 43 bool OnMessageReceived(const Message& message) override; |
44 | 44 |
45 protected: | 45 protected: |
46 SyncMessageFilter(base::WaitableEvent* shutdown_event, | 46 explicit SyncMessageFilter(base::WaitableEvent* shutdown_event); |
47 bool is_channel_send_thread_safe); | |
48 | |
49 ~SyncMessageFilter() override; | 47 ~SyncMessageFilter() override; |
50 | 48 |
51 private: | 49 private: |
52 class IOMessageLoopObserver; | 50 class IOMessageLoopObserver; |
53 | 51 |
54 friend class SyncChannel; | 52 friend class SyncChannel; |
55 friend class IOMessageLoopObserver; | 53 friend class IOMessageLoopObserver; |
56 | 54 |
57 void set_is_channel_send_thread_safe(bool is_channel_send_thread_safe) { | |
58 is_channel_send_thread_safe_ = is_channel_send_thread_safe; | |
59 } | |
60 | |
61 void SendOnIOThread(Message* message); | 55 void SendOnIOThread(Message* message); |
62 // Signal all the pending sends as done, used in an error condition. | 56 // Signal all the pending sends as done, used in an error condition. |
63 void SignalAllEvents(); | 57 void SignalAllEvents(); |
64 | 58 |
65 void OnShutdownEventSignaled(base::WaitableEvent* event); | 59 void OnShutdownEventSignaled(base::WaitableEvent* event); |
66 void OnIOMessageLoopDestroyed(); | 60 void OnIOMessageLoopDestroyed(); |
67 | 61 |
68 // The channel to which this filter was added. | 62 // The channel to which this filter was added. |
69 Sender* sender_; | 63 Sender* sender_; |
70 | 64 |
71 // Indicates if |sender_|'s Send method is thread-safe. | |
72 bool is_channel_send_thread_safe_; | |
73 | |
74 // The process's main thread. | 65 // The process's main thread. |
75 scoped_refptr<base::SingleThreadTaskRunner> listener_task_runner_; | 66 scoped_refptr<base::SingleThreadTaskRunner> listener_task_runner_; |
76 | 67 |
77 // The message loop where the Channel lives. | 68 // The message loop where the Channel lives. |
78 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 69 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
79 | 70 |
80 typedef std::set<PendingSyncMsg*> PendingSyncMessages; | 71 typedef std::set<PendingSyncMsg*> PendingSyncMessages; |
81 PendingSyncMessages pending_sync_messages_; | 72 PendingSyncMessages pending_sync_messages_; |
82 | 73 |
83 // Messages waiting to be delivered after IO initialization. | 74 // Messages waiting to be delivered after IO initialization. |
(...skipping 15 matching lines...) Expand all Loading... |
99 scoped_refptr<IOMessageLoopObserver> io_message_loop_observer_; | 90 scoped_refptr<IOMessageLoopObserver> io_message_loop_observer_; |
100 | 91 |
101 base::WeakPtrFactory<SyncMessageFilter> weak_factory_; | 92 base::WeakPtrFactory<SyncMessageFilter> weak_factory_; |
102 | 93 |
103 DISALLOW_COPY_AND_ASSIGN(SyncMessageFilter); | 94 DISALLOW_COPY_AND_ASSIGN(SyncMessageFilter); |
104 }; | 95 }; |
105 | 96 |
106 } // namespace IPC | 97 } // namespace IPC |
107 | 98 |
108 #endif // IPC_IPC_SYNC_MESSAGE_FILTER_H_ | 99 #endif // IPC_IPC_SYNC_MESSAGE_FILTER_H_ |
OLD | NEW |