Chromium Code Reviews| 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 // require additional this is simply calls GenerateUniqueRandomChannelID(). | 195 // require additional this is simply calls GenerateUniqueRandomChannelID(). |
| 196 // For portability the prefix should not include the \ character. | 196 // For portability the prefix should not include the \ character. |
| 197 static std::string GenerateVerifiedChannelID(const std::string& prefix); | 197 static std::string GenerateVerifiedChannelID(const std::string& prefix); |
| 198 #endif | 198 #endif |
| 199 | 199 |
| 200 #if defined(OS_LINUX) | 200 #if defined(OS_LINUX) |
| 201 // Sandboxed processes live in a PID namespace, so when sending the IPC hello | 201 // Sandboxed processes live in a PID namespace, so when sending the IPC hello |
| 202 // message from client to server we need to send the PID from the global | 202 // message from client to server we need to send the PID from the global |
| 203 // PID namespace. | 203 // PID namespace. |
| 204 static void SetGlobalPid(int pid); | 204 static void SetGlobalPid(int pid); |
| 205 | |
| 206 // On POSIX an IPC::Channel wraps a socketpair() with set some attributes | |
|
Mark Seaborn
2014/02/07 22:53:43
"with some attributes set"
However, since this is
| |
| 207 // (such as non-blocking mode). This returns raw FD #s for the pair, which | |
| 208 // allows us to pass file descriptors between processes (such as between | |
| 209 // a plugin process and the browser process) before actual initialization | |
| 210 // of IPC server Channel instance. | |
| 211 static bool SocketPair(int* fd1, int* fd2); | |
| 205 #endif | 212 #endif |
| 206 | 213 |
| 207 protected: | 214 protected: |
| 208 // Used in Chrome by the TestSink to provide a dummy channel implementation | 215 // Used in Chrome by the TestSink to provide a dummy channel implementation |
| 209 // for testing. TestSink overrides the "interesting" functions in Channel so | 216 // for testing. TestSink overrides the "interesting" functions in Channel so |
| 210 // no actual implementation is needed. This will cause un-overridden calls to | 217 // no actual implementation is needed. This will cause un-overridden calls to |
| 211 // segfault. Do not use outside of test code! | 218 // segfault. Do not use outside of test code! |
| 212 Channel() : channel_impl_(0) { } | 219 Channel() : channel_impl_(0) { } |
| 213 | 220 |
| 214 private: | 221 private: |
| 215 // PIMPL to which all channel calls are delegated. | 222 // PIMPL to which all channel calls are delegated. |
| 216 class ChannelImpl; | 223 class ChannelImpl; |
| 217 ChannelImpl *channel_impl_; | 224 ChannelImpl *channel_impl_; |
| 218 }; | 225 }; |
| 219 | 226 |
| 220 } // namespace IPC | 227 } // namespace IPC |
| 221 | 228 |
| 222 #endif // IPC_IPC_CHANNEL_H_ | 229 #endif // IPC_IPC_CHANNEL_H_ |
| OLD | NEW |