OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/lock.h" | 13 #include "base/lock.h" |
14 #include "base/ref_counted.h" | 14 #include "base/ref_counted.h" |
15 #include "base/waitable_event_watcher.h" | 15 #include "base/waitable_event_watcher.h" |
| 16 #include "ipc/ipc_channel_handle.h" |
16 #include "ipc/ipc_channel_proxy.h" | 17 #include "ipc/ipc_channel_proxy.h" |
17 #include "ipc/ipc_sync_message.h" | 18 #include "ipc/ipc_sync_message.h" |
18 | 19 |
19 namespace base { | 20 namespace base { |
20 class WaitableEvent; | 21 class WaitableEvent; |
21 }; | 22 }; |
22 | 23 |
23 namespace IPC { | 24 namespace IPC { |
24 | 25 |
25 class SyncMessage; | 26 class SyncMessage; |
26 class MessageReplyDeserializer; | 27 class MessageReplyDeserializer; |
27 | 28 |
28 // This is similar to ChannelProxy, with the added feature of supporting sending | 29 // This is similar to ChannelProxy, with the added feature of supporting sending |
29 // synchronous messages. | 30 // synchronous messages. |
30 // Note that care must be taken that the lifetime of the ipc_thread argument | 31 // Note that care must be taken that the lifetime of the ipc_thread argument |
31 // is more than this object. If the message loop goes away while this object | 32 // is more than this object. If the message loop goes away while this object |
32 // is running and it's used to send a message, then it will use the invalid | 33 // is running and it's used to send a message, then it will use the invalid |
33 // message loop pointer to proxy it to the ipc thread. | 34 // message loop pointer to proxy it to the ipc thread. |
34 class SyncChannel : public ChannelProxy, | 35 class SyncChannel : public ChannelProxy, |
35 public base::WaitableEventWatcher::Delegate { | 36 public base::WaitableEventWatcher::Delegate { |
36 public: | 37 public: |
37 SyncChannel(const std::string& channel_id, | 38 SyncChannel(const IPC::ChannelHandle& channel_handle, |
38 Channel::Mode mode, | 39 Channel::Mode mode, |
39 Channel::Listener* listener, | 40 Channel::Listener* listener, |
40 MessageLoop* ipc_message_loop, | 41 MessageLoop* ipc_message_loop, |
41 bool create_pipe_now, | 42 bool create_pipe_now, |
42 base::WaitableEvent* shutdown_event); | 43 base::WaitableEvent* shutdown_event); |
43 virtual ~SyncChannel(); | 44 virtual ~SyncChannel(); |
44 | 45 |
45 virtual bool Send(Message* message); | 46 virtual bool Send(Message* message); |
46 virtual bool SendWithTimeout(Message* message, int timeout_ms); | 47 virtual bool SendWithTimeout(Message* message, int timeout_ms); |
47 | 48 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 148 |
148 // Used to signal events between the IPC and listener threads. | 149 // Used to signal events between the IPC and listener threads. |
149 base::WaitableEventWatcher dispatch_watcher_; | 150 base::WaitableEventWatcher dispatch_watcher_; |
150 | 151 |
151 DISALLOW_COPY_AND_ASSIGN(SyncChannel); | 152 DISALLOW_COPY_AND_ASSIGN(SyncChannel); |
152 }; | 153 }; |
153 | 154 |
154 } // namespace IPC | 155 } // namespace IPC |
155 | 156 |
156 #endif // IPC_IPC_SYNC_SENDER_H__ | 157 #endif // IPC_IPC_SYNC_SENDER_H__ |
OLD | NEW |