Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: ipc/ipc_channel_posix.h

Issue 835873004: IPC: Generalize FileDescriptorSet to MessageAttachmentSet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Landing Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ipc/ipc_channel_nacl.cc ('k') | ipc/ipc_channel_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 11
12 #include <queue> 12 #include <queue>
13 #include <set> 13 #include <set>
14 #include <string> 14 #include <string>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/files/scoped_file.h" 17 #include "base/files/scoped_file.h"
18 #include "base/message_loop/message_loop.h" 18 #include "base/message_loop/message_loop.h"
19 #include "base/process/process.h" 19 #include "base/process/process.h"
20 #include "ipc/file_descriptor_set_posix.h"
21 #include "ipc/ipc_channel_reader.h" 20 #include "ipc/ipc_channel_reader.h"
21 #include "ipc/ipc_message_attachment_set.h"
22 22
23 #if !defined(OS_MACOSX) 23 #if !defined(OS_MACOSX)
24 // On Linux, the seccomp sandbox makes it very expensive to call 24 // On Linux, the seccomp sandbox makes it very expensive to call
25 // recvmsg() and sendmsg(). The restriction on calling read() and write(), which 25 // recvmsg() and sendmsg(). The restriction on calling read() and write(), which
26 // are cheap, is that we can't pass file descriptors over them. 26 // are cheap, is that we can't pass file descriptors over them.
27 // 27 //
28 // As we cannot anticipate when the sender will provide us with file 28 // As we cannot anticipate when the sender will provide us with file
29 // descriptors, we have to make the decision about whether we call read() or 29 // descriptors, we have to make the decision about whether we call read() or
30 // recvmsg() before we actually make the call. The easiest option is to 30 // recvmsg() before we actually make the call. The easiest option is to
31 // create a dedicated socketpair() for exchanging file descriptors. Any file 31 // create a dedicated socketpair() for exchanging file descriptors. Any file
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 // the pipe. On POSIX it's used as a key in a local map of file descriptors. 171 // the pipe. On POSIX it's used as a key in a local map of file descriptors.
172 std::string pipe_name_; 172 std::string pipe_name_;
173 173
174 // Messages to be sent are queued here. 174 // Messages to be sent are queued here.
175 std::queue<Message*> output_queue_; 175 std::queue<Message*> output_queue_;
176 176
177 // We assume a worst case: kReadBufferSize bytes of messages, where each 177 // We assume a worst case: kReadBufferSize bytes of messages, where each
178 // message has no payload and a full complement of descriptors. 178 // message has no payload and a full complement of descriptors.
179 static const size_t kMaxReadFDs = 179 static const size_t kMaxReadFDs =
180 (Channel::kReadBufferSize / sizeof(IPC::Message::Header)) * 180 (Channel::kReadBufferSize / sizeof(IPC::Message::Header)) *
181 FileDescriptorSet::kMaxDescriptorsPerMessage; 181 MessageAttachmentSet::kMaxDescriptorsPerMessage;
182 182
183 // Buffer size for file descriptors used for recvmsg. On Mac the CMSG macros 183 // Buffer size for file descriptors used for recvmsg. On Mac the CMSG macros
184 // don't seem to be constant so we have to pick a "large enough" value. 184 // don't seem to be constant so we have to pick a "large enough" value.
185 #if defined(OS_MACOSX) 185 #if defined(OS_MACOSX)
186 static const size_t kMaxReadFDBuffer = 1024; 186 static const size_t kMaxReadFDBuffer = 1024;
187 #else 187 #else
188 static const size_t kMaxReadFDBuffer = CMSG_SPACE(sizeof(int) * kMaxReadFDs); 188 static const size_t kMaxReadFDBuffer = CMSG_SPACE(sizeof(int) * kMaxReadFDs);
189 #endif 189 #endif
190 190
191 // Temporary buffer used to receive the file descriptors from recvmsg. 191 // Temporary buffer used to receive the file descriptors from recvmsg.
(...skipping 24 matching lines...) Expand all
216 // If non-zero, overrides the process ID sent in the hello message. 216 // If non-zero, overrides the process ID sent in the hello message.
217 static int global_pid_; 217 static int global_pid_;
218 #endif // OS_LINUX 218 #endif // OS_LINUX
219 219
220 DISALLOW_IMPLICIT_CONSTRUCTORS(ChannelPosix); 220 DISALLOW_IMPLICIT_CONSTRUCTORS(ChannelPosix);
221 }; 221 };
222 222
223 } // namespace IPC 223 } // namespace IPC
224 224
225 #endif // IPC_IPC_CHANNEL_POSIX_H_ 225 #endif // IPC_IPC_CHANNEL_POSIX_H_
OLDNEW
« no previous file with comments | « ipc/ipc_channel_nacl.cc ('k') | ipc/ipc_channel_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698