| 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 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 14 #include "base/synchronization/waitable_event_watcher.h" | 14 #include "base/synchronization/waitable_event_watcher.h" |
| 15 #include "ipc/ipc_channel_handle.h" | 15 #include "ipc/ipc_channel_handle.h" |
| 16 #include "ipc/ipc_channel_proxy.h" | 16 #include "ipc/ipc_channel_proxy.h" |
| 17 #include "ipc/ipc_sync_message.h" | 17 #include "ipc/ipc_sync_message.h" |
| 18 | 18 |
| 19 namespace base { | 19 namespace base { |
| 20 class WaitableEvent; | 20 class WaitableEvent; |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 namespace IPC { | 23 namespace IPC { |
| 24 | 24 |
| 25 class SyncMessage; | 25 class SyncMessage; |
| 26 class ChannelFactory; |
| 26 | 27 |
| 27 // This is similar to ChannelProxy, with the added feature of supporting sending | 28 // This is similar to ChannelProxy, with the added feature of supporting sending |
| 28 // synchronous messages. | 29 // synchronous messages. |
| 29 // | 30 // |
| 30 // Overview of how the sync channel works | 31 // Overview of how the sync channel works |
| 31 // -------------------------------------- | 32 // -------------------------------------- |
| 32 // When the sending thread sends a synchronous message, we create a bunch | 33 // When the sending thread sends a synchronous message, we create a bunch |
| 33 // of tracking info (created in Send, stored in the PendingSyncMsg | 34 // of tracking info (created in Send, stored in the PendingSyncMsg |
| 34 // structure) associated with the message that we identify by the unique | 35 // structure) associated with the message that we identify by the unique |
| 35 // "MessageId" on the SyncMessage. Among the things we save is the | 36 // "MessageId" on the SyncMessage. Among the things we save is the |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 // the channel will be initialized synchronously. | 69 // the channel will be initialized synchronously. |
| 69 // The naming pattern follows IPC::Channel. | 70 // The naming pattern follows IPC::Channel. |
| 70 static scoped_ptr<SyncChannel> Create( | 71 static scoped_ptr<SyncChannel> Create( |
| 71 const IPC::ChannelHandle& channel_handle, | 72 const IPC::ChannelHandle& channel_handle, |
| 72 IPC::Channel::Mode mode, | 73 IPC::Channel::Mode mode, |
| 73 Listener* listener, | 74 Listener* listener, |
| 74 base::SingleThreadTaskRunner* ipc_task_runner, | 75 base::SingleThreadTaskRunner* ipc_task_runner, |
| 75 bool create_pipe_now, | 76 bool create_pipe_now, |
| 76 base::WaitableEvent* shutdown_event); | 77 base::WaitableEvent* shutdown_event); |
| 77 | 78 |
| 79 static scoped_ptr<SyncChannel> Create( |
| 80 scoped_ptr<ChannelFactory> factory, |
| 81 Listener* listener, |
| 82 base::SingleThreadTaskRunner* ipc_task_runner, |
| 83 bool create_pipe_now, |
| 84 base::WaitableEvent* shutdown_event); |
| 85 |
| 78 // Creates an uninitialized sync channel. Call ChannelProxy::Init to | 86 // Creates an uninitialized sync channel. Call ChannelProxy::Init to |
| 79 // 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 |
| 80 // added before any messages are sent or received. | 88 // added before any messages are sent or received. |
| 81 static scoped_ptr<SyncChannel> Create( | 89 static scoped_ptr<SyncChannel> Create( |
| 82 Listener* listener, | 90 Listener* listener, |
| 83 base::SingleThreadTaskRunner* ipc_task_runner, | 91 base::SingleThreadTaskRunner* ipc_task_runner, |
| 84 base::WaitableEvent* shutdown_event); | 92 base::WaitableEvent* shutdown_event); |
| 85 | 93 |
| 86 virtual ~SyncChannel(); | 94 virtual ~SyncChannel(); |
| 87 | 95 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 // Used to signal events between the IPC and listener threads. | 224 // Used to signal events between the IPC and listener threads. |
| 217 base::WaitableEventWatcher dispatch_watcher_; | 225 base::WaitableEventWatcher dispatch_watcher_; |
| 218 base::WaitableEventWatcher::EventCallback dispatch_watcher_callback_; | 226 base::WaitableEventWatcher::EventCallback dispatch_watcher_callback_; |
| 219 | 227 |
| 220 DISALLOW_COPY_AND_ASSIGN(SyncChannel); | 228 DISALLOW_COPY_AND_ASSIGN(SyncChannel); |
| 221 }; | 229 }; |
| 222 | 230 |
| 223 } // namespace IPC | 231 } // namespace IPC |
| 224 | 232 |
| 225 #endif // IPC_IPC_SYNC_CHANNEL_H_ | 233 #endif // IPC_IPC_SYNC_CHANNEL_H_ |
| OLD | NEW |