| 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> |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 int backlog) { | 56 int backlog) { |
| 57 DCHECK(!listen_socket_); | 57 DCHECK(!listen_socket_); |
| 58 | 58 |
| 59 SockaddrStorage address; | 59 SockaddrStorage address; |
| 60 if (!UnixDomainClientSocket::FillAddress(unix_domain_path, | 60 if (!UnixDomainClientSocket::FillAddress(unix_domain_path, |
| 61 use_abstract_namespace_, | 61 use_abstract_namespace_, |
| 62 &address)) { | 62 &address)) { |
| 63 return ERR_ADDRESS_INVALID; | 63 return ERR_ADDRESS_INVALID; |
| 64 } | 64 } |
| 65 | 65 |
| 66 listen_socket_.reset(new SocketLibevent); | 66 scoped_ptr<SocketLibevent> socket(new SocketLibevent); |
| 67 int rv = listen_socket_->Open(AF_UNIX); | 67 int rv = socket->Open(AF_UNIX); |
| 68 DCHECK_NE(ERR_IO_PENDING, rv); | 68 DCHECK_NE(ERR_IO_PENDING, rv); |
| 69 if (rv != OK) | 69 if (rv != OK) |
| 70 return rv; | 70 return rv; |
| 71 | 71 |
| 72 rv = listen_socket_->Bind(address); | 72 rv = socket->Bind(address); |
| 73 DCHECK_NE(ERR_IO_PENDING, rv); | 73 DCHECK_NE(ERR_IO_PENDING, rv); |
| 74 if (rv != OK) { | 74 if (rv != OK) { |
| 75 PLOG(ERROR) | 75 PLOG(ERROR) |
| 76 << "Could not bind unix domain socket to " << unix_domain_path | 76 << "Could not bind unix domain socket to " << unix_domain_path |
| 77 << (use_abstract_namespace_ ? " (with abstract namespace)" : ""); | 77 << (use_abstract_namespace_ ? " (with abstract namespace)" : ""); |
| 78 return rv; | 78 return rv; |
| 79 } | 79 } |
| 80 | 80 |
| 81 return listen_socket_->Listen(backlog); | 81 rv = socket->Listen(backlog); |
| 82 DCHECK_NE(ERR_IO_PENDING, rv); |
| 83 if (rv != OK) |
| 84 return rv; |
| 85 |
| 86 listen_socket_.swap(socket); |
| 87 return rv; |
| 82 } | 88 } |
| 83 | 89 |
| 84 int UnixDomainServerSocket::GetLocalAddress(IPEndPoint* address) const { | 90 int UnixDomainServerSocket::GetLocalAddress(IPEndPoint* address) const { |
| 85 NOTIMPLEMENTED(); | 91 NOTIMPLEMENTED(); |
| 86 return ERR_NOT_IMPLEMENTED; | 92 return ERR_NOT_IMPLEMENTED; |
| 87 } | 93 } |
| 88 | 94 |
| 89 int UnixDomainServerSocket::Accept(scoped_ptr<StreamSocket>* socket, | 95 int UnixDomainServerSocket::Accept(scoped_ptr<StreamSocket>* socket, |
| 90 const CompletionCallback& callback) { | 96 const CompletionCallback& callback) { |
| 91 DCHECK(socket); | 97 DCHECK(socket); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 !auth_callback_.Run(credentials)) { | 142 !auth_callback_.Run(credentials)) { |
| 137 accept_socket_.reset(); | 143 accept_socket_.reset(); |
| 138 return false; | 144 return false; |
| 139 } | 145 } |
| 140 | 146 |
| 141 socket->reset(new UnixDomainClientSocket(accept_socket_.Pass())); | 147 socket->reset(new UnixDomainClientSocket(accept_socket_.Pass())); |
| 142 return true; | 148 return true; |
| 143 } | 149 } |
| 144 | 150 |
| 145 } // namespace net | 151 } // namespace net |
| OLD | NEW |