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_client_socket_posix.h" | 5 #include "net/socket/unix_domain_client_socket_posix.h" |
6 | 6 |
7 #include <sys/socket.h> | 7 #include <sys/socket.h> |
8 #include <sys/un.h> | 8 #include <sys/un.h> |
| 9 #include <utility> |
9 | 10 |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
11 #include "base/posix/eintr_wrapper.h" | 12 #include "base/posix/eintr_wrapper.h" |
12 #include "net/base/ip_endpoint.h" | 13 #include "net/base/ip_endpoint.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 | 17 |
17 namespace net { | 18 namespace net { |
18 | 19 |
19 UnixDomainClientSocket::UnixDomainClientSocket(const std::string& socket_path, | 20 UnixDomainClientSocket::UnixDomainClientSocket(const std::string& socket_path, |
20 bool use_abstract_namespace) | 21 bool use_abstract_namespace) |
21 : socket_path_(socket_path), | 22 : socket_path_(socket_path), |
22 use_abstract_namespace_(use_abstract_namespace) { | 23 use_abstract_namespace_(use_abstract_namespace) { |
23 } | 24 } |
24 | 25 |
25 UnixDomainClientSocket::UnixDomainClientSocket(scoped_ptr<SocketPosix> socket) | 26 UnixDomainClientSocket::UnixDomainClientSocket(scoped_ptr<SocketPosix> socket) |
26 : use_abstract_namespace_(false), socket_(socket.Pass()) {} | 27 : use_abstract_namespace_(false), socket_(std::move(socket)) {} |
27 | 28 |
28 UnixDomainClientSocket::~UnixDomainClientSocket() { | 29 UnixDomainClientSocket::~UnixDomainClientSocket() { |
29 Disconnect(); | 30 Disconnect(); |
30 } | 31 } |
31 | 32 |
32 // static | 33 // static |
33 bool UnixDomainClientSocket::FillAddress(const std::string& socket_path, | 34 bool UnixDomainClientSocket::FillAddress(const std::string& socket_path, |
34 bool use_abstract_namespace, | 35 bool use_abstract_namespace, |
35 SockaddrStorage* address) { | 36 SockaddrStorage* address) { |
36 struct sockaddr_un* socket_addr = | 37 struct sockaddr_un* socket_addr = |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 SocketDescriptor UnixDomainClientSocket::ReleaseConnectedSocket() { | 183 SocketDescriptor UnixDomainClientSocket::ReleaseConnectedSocket() { |
183 DCHECK(socket_); | 184 DCHECK(socket_); |
184 DCHECK(socket_->IsConnected()); | 185 DCHECK(socket_->IsConnected()); |
185 | 186 |
186 SocketDescriptor socket_fd = socket_->ReleaseConnectedSocket(); | 187 SocketDescriptor socket_fd = socket_->ReleaseConnectedSocket(); |
187 socket_.reset(); | 188 socket_.reset(); |
188 return socket_fd; | 189 return socket_fd; |
189 } | 190 } |
190 | 191 |
191 } // namespace net | 192 } // namespace net |
OLD | NEW |