| 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_POSIX_H_ | 5 #ifndef IPC_IPC_CHANNEL_POSIX_H_ |
| 6 #define IPC_IPC_CHANNEL_POSIX_H_ | 6 #define IPC_IPC_CHANNEL_POSIX_H_ |
| 7 | 7 |
| 8 #include "ipc/ipc_channel.h" | 8 #include "ipc/ipc_channel.h" |
| 9 | 9 |
| 10 #include <sys/socket.h> // for CMSG macros | 10 #include <sys/socket.h> // for CMSG macros |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // Messages to be sent are queued here. | 132 // Messages to be sent are queued here. |
| 133 std::queue<Message*> output_queue_; | 133 std::queue<Message*> output_queue_; |
| 134 | 134 |
| 135 // We assume a worst case: kReadBufferSize bytes of messages, where each | 135 // We assume a worst case: kReadBufferSize bytes of messages, where each |
| 136 // message has no payload and a full complement of descriptors. | 136 // message has no payload and a full complement of descriptors. |
| 137 static const size_t kMaxReadFDs = | 137 static const size_t kMaxReadFDs = |
| 138 (Channel::kReadBufferSize / sizeof(IPC::Message::Header)) * | 138 (Channel::kReadBufferSize / sizeof(IPC::Message::Header)) * |
| 139 MessageAttachmentSet::kMaxDescriptorsPerMessage; | 139 MessageAttachmentSet::kMaxDescriptorsPerMessage; |
| 140 | 140 |
| 141 // Buffer size for file descriptors used for recvmsg. On Mac the CMSG macros | 141 // Buffer size for file descriptors used for recvmsg. On Mac the CMSG macros |
| 142 // don't seem to be constant so we have to pick a "large enough" value. | 142 // are not constant so we have to pick a "large enough" padding for headers. |
| 143 #if defined(OS_MACOSX) | 143 #if defined(OS_MACOSX) |
| 144 static const size_t kMaxReadFDBuffer = 1024; | 144 static const size_t kMaxReadFDBuffer = 1024 + sizeof(int) * kMaxReadFDs; |
| 145 #else | 145 #else |
| 146 static const size_t kMaxReadFDBuffer = CMSG_SPACE(sizeof(int) * kMaxReadFDs); | 146 static const size_t kMaxReadFDBuffer = CMSG_SPACE(sizeof(int) * kMaxReadFDs); |
| 147 #endif | 147 #endif |
| 148 | 148 |
| 149 // Temporary buffer used to receive the file descriptors from recvmsg. | |
| 150 // Code that writes into this should immediately read them out and save | |
| 151 // them to input_fds_, since this buffer will be re-used anytime we call | |
| 152 // recvmsg. | |
| 153 char input_cmsg_buf_[kMaxReadFDBuffer]; | |
| 154 | |
| 155 // File descriptors extracted from messages coming off of the channel. The | 149 // File descriptors extracted from messages coming off of the channel. The |
| 156 // handles may span messages and come off different channels from the message | 150 // handles may span messages and come off different channels from the message |
| 157 // data (in the case of READWRITE), and are processed in FIFO here. | 151 // data (in the case of READWRITE), and are processed in FIFO here. |
| 158 // NOTE: The implementation assumes underlying storage here is contiguous, so | 152 // NOTE: The implementation assumes underlying storage here is contiguous, so |
| 159 // don't change to something like std::deque<> without changing the | 153 // don't change to something like std::deque<> without changing the |
| 160 // implementation! | 154 // implementation! |
| 161 std::vector<int> input_fds_; | 155 std::vector<int> input_fds_; |
| 162 | 156 |
| 163 | 157 |
| 164 void ResetSafely(base::ScopedFD* fd); | 158 void ResetSafely(base::ScopedFD* fd); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 178 // If non-zero, overrides the process ID sent in the hello message. | 172 // If non-zero, overrides the process ID sent in the hello message. |
| 179 static int global_pid_; | 173 static int global_pid_; |
| 180 #endif // OS_LINUX | 174 #endif // OS_LINUX |
| 181 | 175 |
| 182 DISALLOW_IMPLICIT_CONSTRUCTORS(ChannelPosix); | 176 DISALLOW_IMPLICIT_CONSTRUCTORS(ChannelPosix); |
| 183 }; | 177 }; |
| 184 | 178 |
| 185 } // namespace IPC | 179 } // namespace IPC |
| 186 | 180 |
| 187 #endif // IPC_IPC_CHANNEL_POSIX_H_ | 181 #endif // IPC_IPC_CHANNEL_POSIX_H_ |
| OLD | NEW |