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_CHANNEL_H_ | 5 #ifndef IPC_IPC_CHANNEL_H_ |
6 #define IPC_IPC_CHANNEL_H_ | 6 #define IPC_IPC_CHANNEL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #if defined(OS_POSIX) | 10 #if defined(OS_POSIX) |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 // On POSIX calling close on an IPC channel that listens for connections will | 122 // On POSIX calling close on an IPC channel that listens for connections will |
123 // cause it to close any accepted connections, and it will stop listening for | 123 // cause it to close any accepted connections, and it will stop listening for |
124 // new connections. If you just want to close the currently accepted | 124 // new connections. If you just want to close the currently accepted |
125 // connection and listen for new ones, use ResetToAcceptingConnectionState. | 125 // connection and listen for new ones, use ResetToAcceptingConnectionState. |
126 void Close(); | 126 void Close(); |
127 | 127 |
128 // Modify the Channel's listener. | 128 // Modify the Channel's listener. |
129 void set_listener(Listener* listener); | 129 void set_listener(Listener* listener); |
130 | 130 |
131 // Get the process ID for the connected peer. | 131 // Get the process ID for the connected peer. |
132 // Returns base::kNullProcessId if the peer is not connected yet. | 132 // |
| 133 // Returns base::kNullProcessId if the peer is not connected yet. Watch out |
| 134 // for race conditions. You can easily get a channel to another process, but |
| 135 // if your process has not yet processed the "hello" message from the remote |
| 136 // side, this will fail. You should either make sure calling this is either |
| 137 // in response to a message from the remote side (which guarantees that it's |
| 138 // been connected), or you wait for the "connected" notification on the |
| 139 // listener. |
133 base::ProcessId peer_pid() const; | 140 base::ProcessId peer_pid() const; |
134 | 141 |
135 // Send a message over the Channel to the listener on the other end. | 142 // Send a message over the Channel to the listener on the other end. |
136 // | 143 // |
137 // |message| must be allocated using operator new. This object will be | 144 // |message| must be allocated using operator new. This object will be |
138 // deleted once the contents of the Message have been sent. | 145 // deleted once the contents of the Message have been sent. |
139 virtual bool Send(Message* message) OVERRIDE; | 146 virtual bool Send(Message* message) OVERRIDE; |
140 | 147 |
141 #if defined(OS_POSIX) | 148 #if defined(OS_POSIX) |
142 // On POSIX an IPC::Channel wraps a socketpair(), this method returns the | 149 // On POSIX an IPC::Channel wraps a socketpair(), this method returns the |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 209 |
203 private: | 210 private: |
204 // PIMPL to which all channel calls are delegated. | 211 // PIMPL to which all channel calls are delegated. |
205 class ChannelImpl; | 212 class ChannelImpl; |
206 ChannelImpl *channel_impl_; | 213 ChannelImpl *channel_impl_; |
207 }; | 214 }; |
208 | 215 |
209 } // namespace IPC | 216 } // namespace IPC |
210 | 217 |
211 #endif // IPC_IPC_CHANNEL_H_ | 218 #endif // IPC_IPC_CHANNEL_H_ |
OLD | NEW |