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_CHANNEL_H_ | 5 #ifndef IPC_IPC_SYNC_CHANNEL_H_ |
6 #define IPC_IPC_SYNC_CHANNEL_H_ | 6 #define IPC_IPC_SYNC_CHANNEL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <deque> | 9 #include <deque> |
10 | 10 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 base::WaitableEvent* shutdown_event); | 84 base::WaitableEvent* shutdown_event); |
85 | 85 |
86 // Creates an uninitialized sync channel. Call ChannelProxy::Init to | 86 // Creates an uninitialized sync channel. Call ChannelProxy::Init to |
87 // initialize the channel. This two-step setup allows message filters to be | 87 // initialize the channel. This two-step setup allows message filters to be |
88 // added before any messages are sent or received. | 88 // added before any messages are sent or received. |
89 static scoped_ptr<SyncChannel> Create( | 89 static scoped_ptr<SyncChannel> Create( |
90 Listener* listener, | 90 Listener* listener, |
91 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner, | 91 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner, |
92 base::WaitableEvent* shutdown_event); | 92 base::WaitableEvent* shutdown_event); |
93 | 93 |
94 virtual ~SyncChannel(); | 94 ~SyncChannel() override; |
95 | 95 |
96 virtual bool Send(Message* message) override; | 96 bool Send(Message* message) override; |
97 | 97 |
98 // Sets the dispatch group for this channel, to only allow re-entrant dispatch | 98 // Sets the dispatch group for this channel, to only allow re-entrant dispatch |
99 // of messages to other channels in the same group. | 99 // of messages to other channels in the same group. |
100 // | 100 // |
101 // Normally, any unblocking message coming from any channel can be dispatched | 101 // Normally, any unblocking message coming from any channel can be dispatched |
102 // when any (possibly other) channel is blocked on sending a message. This is | 102 // when any (possibly other) channel is blocked on sending a message. This is |
103 // needed in some cases to unblock certain loops (e.g. necessary when some | 103 // needed in some cases to unblock certain loops (e.g. necessary when some |
104 // processes share a window hierarchy), but may cause re-entrancy issues in | 104 // processes share a window hierarchy), but may cause re-entrancy issues in |
105 // some cases where such loops are not possible. This flags allows the tagging | 105 // some cases where such loops are not possible. This flags allows the tagging |
106 // of some particular channels to only re-enter in known correct cases. | 106 // of some particular channels to only re-enter in known correct cases. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 restrict_dispatch_group_ = group; | 163 restrict_dispatch_group_ = group; |
164 } | 164 } |
165 | 165 |
166 int restrict_dispatch_group() const { | 166 int restrict_dispatch_group() const { |
167 return restrict_dispatch_group_; | 167 return restrict_dispatch_group_; |
168 } | 168 } |
169 | 169 |
170 base::WaitableEventWatcher::EventCallback MakeWaitableEventCallback(); | 170 base::WaitableEventWatcher::EventCallback MakeWaitableEventCallback(); |
171 | 171 |
172 private: | 172 private: |
173 virtual ~SyncContext(); | 173 ~SyncContext() override; |
174 // ChannelProxy methods that we override. | 174 // ChannelProxy methods that we override. |
175 | 175 |
176 // Called on the listener thread. | 176 // Called on the listener thread. |
177 virtual void Clear() override; | 177 void Clear() override; |
178 | 178 |
179 // Called on the IPC thread. | 179 // Called on the IPC thread. |
180 virtual bool OnMessageReceived(const Message& msg) override; | 180 bool OnMessageReceived(const Message& msg) override; |
181 virtual void OnChannelError() override; | 181 void OnChannelError() override; |
182 virtual void OnChannelOpened() override; | 182 void OnChannelOpened() override; |
183 virtual void OnChannelClosed() override; | 183 void OnChannelClosed() override; |
184 | 184 |
185 // Cancels all pending Send calls. | 185 // Cancels all pending Send calls. |
186 void CancelPendingSends(); | 186 void CancelPendingSends(); |
187 | 187 |
188 void OnWaitableEventSignaled(base::WaitableEvent* event); | 188 void OnWaitableEventSignaled(base::WaitableEvent* event); |
189 | 189 |
190 typedef std::deque<PendingSyncMsg> PendingSyncMessageQueue; | 190 typedef std::deque<PendingSyncMsg> PendingSyncMessageQueue; |
191 PendingSyncMessageQueue deserializers_; | 191 PendingSyncMessageQueue deserializers_; |
192 base::Lock deserializers_lock_; | 192 base::Lock deserializers_lock_; |
193 | 193 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 // Used to signal events between the IPC and listener threads. | 226 // Used to signal events between the IPC and listener threads. |
227 base::WaitableEventWatcher dispatch_watcher_; | 227 base::WaitableEventWatcher dispatch_watcher_; |
228 base::WaitableEventWatcher::EventCallback dispatch_watcher_callback_; | 228 base::WaitableEventWatcher::EventCallback dispatch_watcher_callback_; |
229 | 229 |
230 DISALLOW_COPY_AND_ASSIGN(SyncChannel); | 230 DISALLOW_COPY_AND_ASSIGN(SyncChannel); |
231 }; | 231 }; |
232 | 232 |
233 } // namespace IPC | 233 } // namespace IPC |
234 | 234 |
235 #endif // IPC_IPC_SYNC_CHANNEL_H_ | 235 #endif // IPC_IPC_SYNC_CHANNEL_H_ |
OLD | NEW |