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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 MODE_NAMED_CLIENT = MODE_CLIENT_FLAG | MODE_NAMED_FLAG, | 68 MODE_NAMED_CLIENT = MODE_CLIENT_FLAG | MODE_NAMED_FLAG, |
| 69 #if defined(OS_POSIX) | 69 #if defined(OS_POSIX) |
| 70 // An "open" named server accepts connections from ANY client. | 70 // An "open" named server accepts connections from ANY client. |
| 71 // The caller must then implement their own access-control based on the | 71 // The caller must then implement their own access-control based on the |
| 72 // client process' user Id. | 72 // client process' user Id. |
| 73 MODE_OPEN_NAMED_SERVER = MODE_OPEN_ACCESS_FLAG | MODE_SERVER_FLAG | | 73 MODE_OPEN_NAMED_SERVER = MODE_OPEN_ACCESS_FLAG | MODE_SERVER_FLAG | |
| 74 MODE_NAMED_FLAG | 74 MODE_NAMED_FLAG |
| 75 #endif | 75 #endif |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 // The Hello message is internal to the Channel class. It is sent | 78 // Messages internal to the IPC implementation are defined here. |
| 79 // by the peer when the channel is connected. The message contains | |
| 80 // just the process id (pid). The message has a special routing_id | |
| 81 // (MSG_ROUTING_NONE) and type (HELLO_MESSAGE_TYPE). | |
| 82 enum { | 79 enum { |
| 83 HELLO_MESSAGE_TYPE = kuint16max // Maximum value of message type (uint16), | 80 // The Hello message is sent by the peer when the channel is connected. |
| 81 // The message contains just the process id (pid). | |
| 82 // The message has a special routing_id (MSG_ROUTING_NONE) | |
| 83 // and type (HELLO_MESSAGE_TYPE). | |
| 84 HELLO_MESSAGE_TYPE = kuint16max, // Maximum value of message type (uint16), | |
|
agl
2013/10/09 21:52:38
// lines misaligned.
hubbe
2013/10/09 21:59:40
better?
| |
| 84 // to avoid conflicting with normal | 85 // to avoid conflicting with normal |
| 85 // message types, which are enumeration | 86 // message types, which are enumeration |
| 86 // constants starting from 0. | 87 // constants starting from 0. |
| 88 | |
| 89 // The CLOSE_FD_MESSAGE_TYPE is used in the IPC class to | |
| 90 // work around a bug in sendmsg() on Mac. When an FD is sent | |
| 91 // over the socket, a CLOSE_FD_MESSAGE is sent with hops = 2. | |
| 92 // The client will return the message with hops = 1, *after* it | |
| 93 // has received the message that contains the FD. When we | |
| 94 // receive it again on the sender side, we close the FD. | |
| 95 CLOSE_FD_MESSAGE_TYPE = HELLO_MESSAGE_TYPE - 1 | |
| 87 }; | 96 }; |
| 88 | 97 |
| 89 // The maximum message size in bytes. Attempting to receive a message of this | 98 // The maximum message size in bytes. Attempting to receive a message of this |
| 90 // size or bigger results in a channel error. | 99 // size or bigger results in a channel error. |
| 91 static const size_t kMaximumMessageSize = 128 * 1024 * 1024; | 100 static const size_t kMaximumMessageSize = 128 * 1024 * 1024; |
| 92 | 101 |
| 93 // Amount of data to read at once from the pipe. | 102 // Amount of data to read at once from the pipe. |
| 94 static const size_t kReadBufferSize = 4 * 1024; | 103 static const size_t kReadBufferSize = 4 * 1024; |
| 95 | 104 |
| 96 // Initialize a Channel. | 105 // Initialize a Channel. |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 | 215 |
| 207 private: | 216 private: |
| 208 // PIMPL to which all channel calls are delegated. | 217 // PIMPL to which all channel calls are delegated. |
| 209 class ChannelImpl; | 218 class ChannelImpl; |
| 210 ChannelImpl *channel_impl_; | 219 ChannelImpl *channel_impl_; |
| 211 }; | 220 }; |
| 212 | 221 |
| 213 } // namespace IPC | 222 } // namespace IPC |
| 214 | 223 |
| 215 #endif // IPC_IPC_CHANNEL_H_ | 224 #endif // IPC_IPC_CHANNEL_H_ |
| OLD | NEW |