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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 172 |
173 // Closes any currently connected socket, and returns to a listening state | 173 // Closes any currently connected socket, and returns to a listening state |
174 // for more connections. | 174 // for more connections. |
175 void ResetToAcceptingConnectionState(); | 175 void ResetToAcceptingConnectionState(); |
176 #endif // defined(OS_POSIX) && !defined(OS_NACL) | 176 #endif // defined(OS_POSIX) && !defined(OS_NACL) |
177 | 177 |
178 // Returns true if a named server channel is initialized on the given channel | 178 // Returns true if a named server channel is initialized on the given channel |
179 // ID. Even if true, the server may have already accepted a connection. | 179 // ID. Even if true, the server may have already accepted a connection. |
180 static bool IsNamedServerInitialized(const std::string& channel_id); | 180 static bool IsNamedServerInitialized(const std::string& channel_id); |
181 | 181 |
| 182 #if !defined(OS_NACL) |
182 // Generates a channel ID that's non-predictable and unique. | 183 // Generates a channel ID that's non-predictable and unique. |
183 static std::string GenerateUniqueRandomChannelID(); | 184 static std::string GenerateUniqueRandomChannelID(); |
184 | 185 |
185 // Generates a channel ID that, if passed to the client as a shared secret, | 186 // Generates a channel ID that, if passed to the client as a shared secret, |
186 // will validate that the client's authenticity. On platforms that do not | 187 // will validate that the client's authenticity. On platforms that do not |
187 // require additional this is simply calls GenerateUniqueRandomChannelID(). | 188 // require additional this is simply calls GenerateUniqueRandomChannelID(). |
188 // For portability the prefix should not include the \ character. | 189 // For portability the prefix should not include the \ character. |
189 static std::string GenerateVerifiedChannelID(const std::string& prefix); | 190 static std::string GenerateVerifiedChannelID(const std::string& prefix); |
| 191 #endif |
190 | 192 |
191 #if defined(OS_LINUX) | 193 #if defined(OS_LINUX) |
192 // Sandboxed processes live in a PID namespace, so when sending the IPC hello | 194 // Sandboxed processes live in a PID namespace, so when sending the IPC hello |
193 // message from client to server we need to send the PID from the global | 195 // message from client to server we need to send the PID from the global |
194 // PID namespace. | 196 // PID namespace. |
195 static void SetGlobalPid(int pid); | 197 static void SetGlobalPid(int pid); |
196 #endif | 198 #endif |
197 | 199 |
198 protected: | 200 protected: |
199 // Used in Chrome by the TestSink to provide a dummy channel implementation | 201 // Used in Chrome by the TestSink to provide a dummy channel implementation |
200 // for testing. TestSink overrides the "interesting" functions in Channel so | 202 // for testing. TestSink overrides the "interesting" functions in Channel so |
201 // no actual implementation is needed. This will cause un-overridden calls to | 203 // no actual implementation is needed. This will cause un-overridden calls to |
202 // segfault. Do not use outside of test code! | 204 // segfault. Do not use outside of test code! |
203 Channel() : channel_impl_(0) { } | 205 Channel() : channel_impl_(0) { } |
204 | 206 |
205 private: | 207 private: |
206 // PIMPL to which all channel calls are delegated. | 208 // PIMPL to which all channel calls are delegated. |
207 class ChannelImpl; | 209 class ChannelImpl; |
208 ChannelImpl *channel_impl_; | 210 ChannelImpl *channel_impl_; |
209 }; | 211 }; |
210 | 212 |
211 } // namespace IPC | 213 } // namespace IPC |
212 | 214 |
213 #endif // IPC_IPC_CHANNEL_H_ | 215 #endif // IPC_IPC_CHANNEL_H_ |
OLD | NEW |