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 | 79 // Uses Maximum value of message type (uint16), to avoid conflicting |
80 // just the process id (pid). The message has a special routing_id | 80 // with normal message types, which are enumeration constants starting from 0. |
81 // (MSG_ROUTING_NONE) and type (HELLO_MESSAGE_TYPE). | |
82 enum { | 81 enum { |
83 HELLO_MESSAGE_TYPE = kuint16max // Maximum value of message type (uint16), | 82 // The Hello message is sent by the peer when the channel is connected. |
84 // to avoid conflicting with normal | 83 // The message contains just the process id (pid). |
85 // message types, which are enumeration | 84 // The message has a special routing_id (MSG_ROUTING_NONE) |
86 // constants starting from 0. | 85 // and type (HELLO_MESSAGE_TYPE). |
| 86 HELLO_MESSAGE_TYPE = kuint16max, |
| 87 // The CLOSE_FD_MESSAGE_TYPE is used in the IPC class to |
| 88 // work around a bug in sendmsg() on Mac. When an FD is sent |
| 89 // over the socket, a CLOSE_FD_MESSAGE is sent with hops = 2. |
| 90 // The client will return the message with hops = 1, *after* it |
| 91 // has received the message that contains the FD. When we |
| 92 // receive it again on the sender side, we close the FD. |
| 93 CLOSE_FD_MESSAGE_TYPE = HELLO_MESSAGE_TYPE - 1 |
87 }; | 94 }; |
88 | 95 |
89 // The maximum message size in bytes. Attempting to receive a message of this | 96 // The maximum message size in bytes. Attempting to receive a message of this |
90 // size or bigger results in a channel error. | 97 // size or bigger results in a channel error. |
91 static const size_t kMaximumMessageSize = 128 * 1024 * 1024; | 98 static const size_t kMaximumMessageSize = 128 * 1024 * 1024; |
92 | 99 |
93 // Amount of data to read at once from the pipe. | 100 // Amount of data to read at once from the pipe. |
94 static const size_t kReadBufferSize = 4 * 1024; | 101 static const size_t kReadBufferSize = 4 * 1024; |
95 | 102 |
96 // Initialize a Channel. | 103 // Initialize a Channel. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 213 |
207 private: | 214 private: |
208 // PIMPL to which all channel calls are delegated. | 215 // PIMPL to which all channel calls are delegated. |
209 class ChannelImpl; | 216 class ChannelImpl; |
210 ChannelImpl *channel_impl_; | 217 ChannelImpl *channel_impl_; |
211 }; | 218 }; |
212 | 219 |
213 } // namespace IPC | 220 } // namespace IPC |
214 | 221 |
215 #endif // IPC_IPC_CHANNEL_H_ | 222 #endif // IPC_IPC_CHANNEL_H_ |
OLD | NEW |