OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "net/socket/unix_domain_server_socket_posix.h" | 5 #include "net/socket/unix_domain_server_socket_posix.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <sys/socket.h> | 8 #include <sys/socket.h> |
9 #include <sys/un.h> | 9 #include <sys/un.h> |
10 #include <unistd.h> | 10 #include <unistd.h> |
| 11 #include <utility> |
11 | 12 |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
14 #include "net/base/net_util.h" | 15 #include "net/base/net_util.h" |
15 #include "net/socket/socket_posix.h" | 16 #include "net/socket/socket_posix.h" |
16 #include "net/socket/unix_domain_client_socket_posix.h" | 17 #include "net/socket/unix_domain_client_socket_posix.h" |
17 | 18 |
18 namespace net { | 19 namespace net { |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 // Intended for use as SetterCallbacks in Accept() helper methods. | 23 // Intended for use as SetterCallbacks in Accept() helper methods. |
23 void SetStreamSocket(scoped_ptr<StreamSocket>* socket, | 24 void SetStreamSocket(scoped_ptr<StreamSocket>* socket, |
24 scoped_ptr<SocketPosix> accepted_socket) { | 25 scoped_ptr<SocketPosix> accepted_socket) { |
25 socket->reset(new UnixDomainClientSocket(accepted_socket.Pass())); | 26 socket->reset(new UnixDomainClientSocket(std::move(accepted_socket))); |
26 } | 27 } |
27 | 28 |
28 void SetSocketDescriptor(SocketDescriptor* socket, | 29 void SetSocketDescriptor(SocketDescriptor* socket, |
29 scoped_ptr<SocketPosix> accepted_socket) { | 30 scoped_ptr<SocketPosix> accepted_socket) { |
30 *socket = accepted_socket->ReleaseConnectedSocket(); | 31 *socket = accepted_socket->ReleaseConnectedSocket(); |
31 } | 32 } |
32 | 33 |
33 } // anonymous namespace | 34 } // anonymous namespace |
34 | 35 |
35 UnixDomainServerSocket::UnixDomainServerSocket( | 36 UnixDomainServerSocket::UnixDomainServerSocket( |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 const SetterCallback& setter_callback) { | 177 const SetterCallback& setter_callback) { |
177 DCHECK(accept_socket_); | 178 DCHECK(accept_socket_); |
178 | 179 |
179 Credentials credentials; | 180 Credentials credentials; |
180 if (!GetPeerCredentials(accept_socket_->socket_fd(), &credentials) || | 181 if (!GetPeerCredentials(accept_socket_->socket_fd(), &credentials) || |
181 !auth_callback_.Run(credentials)) { | 182 !auth_callback_.Run(credentials)) { |
182 accept_socket_.reset(); | 183 accept_socket_.reset(); |
183 return false; | 184 return false; |
184 } | 185 } |
185 | 186 |
186 setter_callback.Run(accept_socket_.Pass()); | 187 setter_callback.Run(std::move(accept_socket_)); |
187 return true; | 188 return true; |
188 } | 189 } |
189 | 190 |
190 } // namespace net | 191 } // namespace net |
OLD | NEW |