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

Side by Side Diff: ipc/ipc_channel_posix.h

Issue 602193004: Refactoring: Let ChannelPosix adopt ScopedFD. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Landing Created 6 years, 2 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 | « no previous file | 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/message_loop/message_loop.h" 18 #include "base/message_loop/message_loop.h"
18 #include "base/process/process.h" 19 #include "base/process/process.h"
19 #include "ipc/file_descriptor_set_posix.h" 20 #include "ipc/file_descriptor_set_posix.h"
20 #include "ipc/ipc_channel_reader.h" 21 #include "ipc/ipc_channel_reader.h"
21 22
22 #if !defined(OS_MACOSX) 23 #if !defined(OS_MACOSX)
23 // On Linux, the seccomp sandbox makes it very expensive to call 24 // On Linux, the seccomp sandbox makes it very expensive to call
24 // recvmsg() and sendmsg(). The restriction on calling read() and write(), which 25 // recvmsg() and sendmsg(). The restriction on calling read() and write(), which
25 // 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.
26 // 27 //
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // Indicates whether we're currently blocked waiting for a write to complete. 146 // Indicates whether we're currently blocked waiting for a write to complete.
146 bool is_blocked_on_write_; 147 bool is_blocked_on_write_;
147 bool waiting_connect_; 148 bool waiting_connect_;
148 149
149 // If sending a message blocks then we use this variable 150 // If sending a message blocks then we use this variable
150 // to keep track of where we are. 151 // to keep track of where we are.
151 size_t message_send_bytes_written_; 152 size_t message_send_bytes_written_;
152 153
153 // File descriptor we're listening on for new connections if we listen 154 // File descriptor we're listening on for new connections if we listen
154 // for connections. 155 // for connections.
155 int server_listen_pipe_; 156 base::ScopedFD server_listen_pipe_;
156 157
157 // The pipe used for communication. 158 // The pipe used for communication.
158 int pipe_; 159 base::ScopedFD pipe_;
159 160
160 // For a server, the client end of our socketpair() -- the other end of our 161 // For a server, the client end of our socketpair() -- the other end of our
161 // pipe_ that is passed to the client. 162 // pipe_ that is passed to the client.
162 int client_pipe_; 163 base::ScopedFD client_pipe_;
163 mutable base::Lock client_pipe_lock_; // Lock that protects |client_pipe_|. 164 mutable base::Lock client_pipe_lock_; // Lock that protects |client_pipe_|.
164 165
165 #if defined(IPC_USES_READWRITE) 166 #if defined(IPC_USES_READWRITE)
166 // Linux/BSD use a dedicated socketpair() for passing file descriptors. 167 // Linux/BSD use a dedicated socketpair() for passing file descriptors.
167 int fd_pipe_; 168 base::ScopedFD fd_pipe_;
168 int remote_fd_pipe_; 169 base::ScopedFD remote_fd_pipe_;
169 #endif 170 #endif
170 171
171 // The "name" of our pipe. On Windows this is the global identifier for 172 // The "name" of our pipe. On Windows this is the global identifier for
172 // the pipe. On POSIX it's used as a key in a local map of file descriptors. 173 // the pipe. On POSIX it's used as a key in a local map of file descriptors.
173 std::string pipe_name_; 174 std::string pipe_name_;
174 175
175 // Messages to be sent are queued here. 176 // Messages to be sent are queued here.
176 std::queue<Message*> output_queue_; 177 std::queue<Message*> output_queue_;
177 178
178 // We assume a worst case: kReadBufferSize bytes of messages, where each 179 // We assume a worst case: kReadBufferSize bytes of messages, where each
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // If non-zero, overrides the process ID sent in the hello message. 218 // If non-zero, overrides the process ID sent in the hello message.
218 static int global_pid_; 219 static int global_pid_;
219 #endif // OS_LINUX 220 #endif // OS_LINUX
220 221
221 DISALLOW_IMPLICIT_CONSTRUCTORS(ChannelPosix); 222 DISALLOW_IMPLICIT_CONSTRUCTORS(ChannelPosix);
222 }; 223 };
223 224
224 } // namespace IPC 225 } // namespace IPC
225 226
226 #endif // IPC_IPC_CHANNEL_POSIX_H_ 227 #endif // IPC_IPC_CHANNEL_POSIX_H_
OLDNEW
« no previous file with comments | « no previous file | ipc/ipc_channel_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698