| 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 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/posix/eintr_wrapper.h" | 11 #include "base/posix/eintr_wrapper.h" |
| 12 #include "net/base/ip_endpoint.h" |
| 12 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 13 #include "net/base/net_util.h" | 14 #include "net/base/net_util.h" |
| 14 #include "net/socket/socket_libevent.h" | 15 #include "net/socket/socket_libevent.h" |
| 15 | 16 |
| 16 namespace net { | 17 namespace net { |
| 17 | 18 |
| 18 UnixDomainClientSocket::UnixDomainClientSocket(const std::string& socket_path, | 19 UnixDomainClientSocket::UnixDomainClientSocket(const std::string& socket_path, |
| 19 bool use_abstract_namespace) | 20 bool use_abstract_namespace) |
| 20 : socket_path_(socket_path), | 21 : socket_path_(socket_path), |
| 21 use_abstract_namespace_(use_abstract_namespace) { | 22 use_abstract_namespace_(use_abstract_namespace) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 92 |
| 92 bool UnixDomainClientSocket::IsConnected() const { | 93 bool UnixDomainClientSocket::IsConnected() const { |
| 93 return socket_ && socket_->IsConnected(); | 94 return socket_ && socket_->IsConnected(); |
| 94 } | 95 } |
| 95 | 96 |
| 96 bool UnixDomainClientSocket::IsConnectedAndIdle() const { | 97 bool UnixDomainClientSocket::IsConnectedAndIdle() const { |
| 97 return socket_ && socket_->IsConnectedAndIdle(); | 98 return socket_ && socket_->IsConnectedAndIdle(); |
| 98 } | 99 } |
| 99 | 100 |
| 100 int UnixDomainClientSocket::GetPeerAddress(IPEndPoint* address) const { | 101 int UnixDomainClientSocket::GetPeerAddress(IPEndPoint* address) const { |
| 101 NOTIMPLEMENTED(); | 102 // Unix domain sockets have no valid associated addr/port; |
| 102 return ERR_NOT_IMPLEMENTED; | 103 // return either not connected or address invalid. |
| 104 DCHECK(address); |
| 105 |
| 106 if (!IsConnected()) |
| 107 return ERR_SOCKET_NOT_CONNECTED; |
| 108 |
| 109 return ERR_ADDRESS_INVALID; |
| 103 } | 110 } |
| 104 | 111 |
| 105 int UnixDomainClientSocket::GetLocalAddress(IPEndPoint* address) const { | 112 int UnixDomainClientSocket::GetLocalAddress(IPEndPoint* address) const { |
| 106 NOTIMPLEMENTED(); | 113 // Unix domain sockets have no valid associated addr/port; |
| 107 return ERR_NOT_IMPLEMENTED; | 114 // return either not connected or address invalid. |
| 115 DCHECK(address); |
| 116 |
| 117 if (!socket_) |
| 118 return ERR_SOCKET_NOT_CONNECTED; |
| 119 |
| 120 return ERR_ADDRESS_INVALID; |
| 108 } | 121 } |
| 109 | 122 |
| 110 const BoundNetLog& UnixDomainClientSocket::NetLog() const { | 123 const BoundNetLog& UnixDomainClientSocket::NetLog() const { |
| 111 return net_log_; | 124 return net_log_; |
| 112 } | 125 } |
| 113 | 126 |
| 114 void UnixDomainClientSocket::SetSubresourceSpeculation() { | 127 void UnixDomainClientSocket::SetSubresourceSpeculation() { |
| 115 } | 128 } |
| 116 | 129 |
| 117 void UnixDomainClientSocket::SetOmniboxSpeculation() { | 130 void UnixDomainClientSocket::SetOmniboxSpeculation() { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 SocketDescriptor UnixDomainClientSocket::ReleaseConnectedSocket() { | 175 SocketDescriptor UnixDomainClientSocket::ReleaseConnectedSocket() { |
| 163 DCHECK(socket_); | 176 DCHECK(socket_); |
| 164 DCHECK(socket_->IsConnected()); | 177 DCHECK(socket_->IsConnected()); |
| 165 | 178 |
| 166 SocketDescriptor socket_fd = socket_->ReleaseConnectedSocket(); | 179 SocketDescriptor socket_fd = socket_->ReleaseConnectedSocket(); |
| 167 socket_.reset(); | 180 socket_.reset(); |
| 168 return socket_fd; | 181 return socket_fd; |
| 169 } | 182 } |
| 170 | 183 |
| 171 } // namespace net | 184 } // namespace net |
| OLD | NEW |