OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_SENDER_H__ | 5 #ifndef IPC_IPC_SYNC_SENDER_H__ |
6 #define IPC_IPC_SYNC_SENDER_H__ | 6 #define IPC_IPC_SYNC_SENDER_H__ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <deque> | 10 #include <deque> |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 // be dispatched in a reentrant manner to avoid deadlock. | 56 // be dispatched in a reentrant manner to avoid deadlock. |
57 // | 57 // |
58 // | 58 // |
59 // Note that care must be taken that the lifetime of the ipc_thread argument | 59 // Note that care must be taken that the lifetime of the ipc_thread argument |
60 // is more than this object. If the message loop goes away while this object | 60 // is more than this object. If the message loop goes away while this object |
61 // is running and it's used to send a message, then it will use the invalid | 61 // is running and it's used to send a message, then it will use the invalid |
62 // message loop pointer to proxy it to the ipc thread. | 62 // message loop pointer to proxy it to the ipc thread. |
63 class IPC_EXPORT SyncChannel : public ChannelProxy, | 63 class IPC_EXPORT SyncChannel : public ChannelProxy, |
64 public base::WaitableEventWatcher::Delegate { | 64 public base::WaitableEventWatcher::Delegate { |
65 public: | 65 public: |
| 66 // Creates and initializes a sync channel. If create_pipe_now is specified, |
| 67 // the channel will be initialized synchronously. |
66 SyncChannel(const IPC::ChannelHandle& channel_handle, | 68 SyncChannel(const IPC::ChannelHandle& channel_handle, |
67 Channel::Mode mode, | 69 Channel::Mode mode, |
68 Channel::Listener* listener, | 70 Channel::Listener* listener, |
69 base::MessageLoopProxy* ipc_message_loop, | 71 base::MessageLoopProxy* ipc_message_loop, |
70 bool create_pipe_now, | 72 bool create_pipe_now, |
71 base::WaitableEvent* shutdown_event); | 73 base::WaitableEvent* shutdown_event); |
| 74 |
| 75 // Creates an uninitialized sync channel. Call ChannelProxy::Init to |
| 76 // initialize the channel. This two-step setup allows message filters to be |
| 77 // added before any messages are sent or received. |
| 78 SyncChannel(Channel::Listener* listener, |
| 79 base::MessageLoopProxy* ipc_message_loop, |
| 80 base::WaitableEvent* shutdown_event); |
| 81 |
72 virtual ~SyncChannel(); | 82 virtual ~SyncChannel(); |
73 | 83 |
74 virtual bool Send(Message* message); | 84 virtual bool Send(Message* message); |
75 virtual bool SendWithTimeout(Message* message, int timeout_ms); | 85 virtual bool SendWithTimeout(Message* message, int timeout_ms); |
76 | 86 |
77 // Whether we allow sending messages with no time-out. | 87 // Whether we allow sending messages with no time-out. |
78 void set_sync_messages_with_no_timeout_allowed(bool value) { | 88 void set_sync_messages_with_no_timeout_allowed(bool value) { |
79 sync_messages_with_no_timeout_allowed_ = value; | 89 sync_messages_with_no_timeout_allowed_ = value; |
80 } | 90 } |
81 | 91 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 201 |
192 // Used to signal events between the IPC and listener threads. | 202 // Used to signal events between the IPC and listener threads. |
193 base::WaitableEventWatcher dispatch_watcher_; | 203 base::WaitableEventWatcher dispatch_watcher_; |
194 | 204 |
195 DISALLOW_COPY_AND_ASSIGN(SyncChannel); | 205 DISALLOW_COPY_AND_ASSIGN(SyncChannel); |
196 }; | 206 }; |
197 | 207 |
198 } // namespace IPC | 208 } // namespace IPC |
199 | 209 |
200 #endif // IPC_IPC_SYNC_SENDER_H__ | 210 #endif // IPC_IPC_SYNC_SENDER_H__ |
OLD | NEW |