| 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 <deque> | 8 #include <deque> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 204 |
| 205 scoped_refptr<ReceivedSyncMsgQueue> received_sync_msgs_; | 205 scoped_refptr<ReceivedSyncMsgQueue> received_sync_msgs_; |
| 206 | 206 |
| 207 base::WaitableEvent* shutdown_event_; | 207 base::WaitableEvent* shutdown_event_; |
| 208 base::WaitableEventWatcher shutdown_watcher_; | 208 base::WaitableEventWatcher shutdown_watcher_; |
| 209 base::WaitableEventWatcher::EventCallback shutdown_watcher_callback_; | 209 base::WaitableEventWatcher::EventCallback shutdown_watcher_callback_; |
| 210 int restrict_dispatch_group_; | 210 int restrict_dispatch_group_; |
| 211 }; | 211 }; |
| 212 | 212 |
| 213 private: | 213 private: |
| 214 class PumpMessagesEvent; | |
| 215 | |
| 216 SyncChannel( | 214 SyncChannel( |
| 217 Listener* listener, | 215 Listener* listener, |
| 218 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner, | 216 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner, |
| 219 base::WaitableEvent* shutdown_event); | 217 base::WaitableEvent* shutdown_event); |
| 220 | 218 |
| 221 void OnDispatchHandleReady(MojoResult result); | 219 void OnDispatchHandleReady(MojoResult result); |
| 222 | 220 |
| 223 SyncContext* sync_context() { | 221 SyncContext* sync_context() { |
| 224 return reinterpret_cast<SyncContext*>(context()); | 222 return reinterpret_cast<SyncContext*>(context()); |
| 225 } | 223 } |
| 226 | 224 |
| 227 // Both these functions wait for a reply, timeout or process shutdown. The | 225 // Both these functions wait for a reply, timeout or process shutdown. The |
| 228 // latter one also runs a nested message loop in the meantime. | 226 // latter one also runs a nested message loop in the meantime. |
| 229 static void WaitForReply(mojo::SyncHandleRegistry* registry, | 227 static void WaitForReply(mojo::SyncHandleRegistry* registry, |
| 230 SyncContext* context, | 228 SyncContext* context, |
| 231 const MojoEvent* pump_messages_event); | 229 bool pump_messages); |
| 232 | 230 |
| 233 // Runs a nested message loop until a reply arrives, times out, or the process | 231 // Runs a nested message loop until a reply arrives, times out, or the process |
| 234 // shuts down. | 232 // shuts down. |
| 235 static void WaitForReplyWithNestedMessageLoop(SyncContext* context); | 233 static void WaitForReplyWithNestedMessageLoop(SyncContext* context); |
| 236 | 234 |
| 237 // Starts the dispatch watcher. | 235 // Starts the dispatch watcher. |
| 238 void StartWatching(); | 236 void StartWatching(); |
| 239 | 237 |
| 240 // ChannelProxy overrides: | 238 // ChannelProxy overrides: |
| 241 void OnChannelInit() override; | 239 void OnChannelInit() override; |
| 242 | 240 |
| 243 scoped_refptr<PumpMessagesEvent> pump_messages_event_; | |
| 244 scoped_refptr<mojo::SyncHandleRegistry> sync_handle_registry_; | 241 scoped_refptr<mojo::SyncHandleRegistry> sync_handle_registry_; |
| 245 | 242 |
| 246 // Used to signal events between the IPC and listener threads. | 243 // Used to signal events between the IPC and listener threads. |
| 247 mojo::Watcher dispatch_watcher_; | 244 mojo::Watcher dispatch_watcher_; |
| 248 | 245 |
| 249 // Tracks SyncMessageFilters created before complete channel initialization. | 246 // Tracks SyncMessageFilters created before complete channel initialization. |
| 250 std::vector<scoped_refptr<SyncMessageFilter>> pre_init_sync_message_filters_; | 247 std::vector<scoped_refptr<SyncMessageFilter>> pre_init_sync_message_filters_; |
| 251 | 248 |
| 252 DISALLOW_COPY_AND_ASSIGN(SyncChannel); | 249 DISALLOW_COPY_AND_ASSIGN(SyncChannel); |
| 253 }; | 250 }; |
| 254 | 251 |
| 255 } // namespace IPC | 252 } // namespace IPC |
| 256 | 253 |
| 257 #endif // IPC_IPC_SYNC_CHANNEL_H_ | 254 #endif // IPC_IPC_SYNC_CHANNEL_H_ |
| OLD | NEW |