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 #include "ipc/ipc_channel_posix.h" | 5 #include "ipc/ipc_channel_posix.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 const char *modestr = (mode_ & MODE_SERVER_FLAG) ? "server" : "client"; | 188 const char *modestr = (mode_ & MODE_SERVER_FLAG) ? "server" : "client"; |
189 LOG(WARNING) << "Unable to create pipe named \"" << channel_handle.name | 189 LOG(WARNING) << "Unable to create pipe named \"" << channel_handle.name |
190 << "\" in " << modestr << " mode"; | 190 << "\" in " << modestr << " mode"; |
191 } | 191 } |
192 } | 192 } |
193 | 193 |
194 Channel::ChannelImpl::~ChannelImpl() { | 194 Channel::ChannelImpl::~ChannelImpl() { |
195 Close(); | 195 Close(); |
196 } | 196 } |
197 | 197 |
198 bool SocketPair(int* fd1, int* fd2) { | 198 bool Channel::ChannelImpl::SocketPair(int* fd1, int* fd2) { |
199 int pipe_fds[2]; | 199 int pipe_fds[2]; |
200 if (socketpair(AF_UNIX, SOCK_STREAM, 0, pipe_fds) != 0) { | 200 if (socketpair(AF_UNIX, SOCK_STREAM, 0, pipe_fds) != 0) { |
201 PLOG(ERROR) << "socketpair()"; | 201 PLOG(ERROR) << "socketpair()"; |
202 return false; | 202 return false; |
203 } | 203 } |
204 | 204 |
205 // Set both ends to be non-blocking. | 205 // Set both ends to be non-blocking. |
206 if (fcntl(pipe_fds[0], F_SETFL, O_NONBLOCK) == -1 || | 206 if (fcntl(pipe_fds[0], F_SETFL, O_NONBLOCK) == -1 || |
207 fcntl(pipe_fds[1], F_SETFL, O_NONBLOCK) == -1) { | 207 fcntl(pipe_fds[1], F_SETFL, O_NONBLOCK) == -1) { |
208 PLOG(ERROR) << "fcntl(O_NONBLOCK)"; | 208 PLOG(ERROR) << "fcntl(O_NONBLOCK)"; |
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1098 | 1098 |
1099 return id.append(GenerateUniqueRandomChannelID()); | 1099 return id.append(GenerateUniqueRandomChannelID()); |
1100 } | 1100 } |
1101 | 1101 |
1102 | 1102 |
1103 #if defined(OS_LINUX) | 1103 #if defined(OS_LINUX) |
1104 // static | 1104 // static |
1105 void Channel::SetGlobalPid(int pid) { | 1105 void Channel::SetGlobalPid(int pid) { |
1106 ChannelImpl::SetGlobalPid(pid); | 1106 ChannelImpl::SetGlobalPid(pid); |
1107 } | 1107 } |
1108 | |
1109 // static | |
1110 bool Channel::SocketPair(int* fd1, int* fd2) { | |
Mark Seaborn
2014/02/03 22:59:07
Why have a layer of wrapping?
You could just decl
| |
1111 return Channel::ChannelImpl::SocketPair(fd1, fd2); | |
1112 } | |
1108 #endif // OS_LINUX | 1113 #endif // OS_LINUX |
1109 | 1114 |
1110 } // namespace IPC | 1115 } // namespace IPC |
OLD | NEW |