| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/tcp_server_socket.h" | 5 #include "net/socket/tcp_server_socket.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 return result; | 43 return result; |
| 44 } | 44 } |
| 45 | 45 |
| 46 return OK; | 46 return OK; |
| 47 } | 47 } |
| 48 | 48 |
| 49 int TCPServerSocket::GetLocalAddress(IPEndPoint* address) const { | 49 int TCPServerSocket::GetLocalAddress(IPEndPoint* address) const { |
| 50 return socket_.GetLocalAddress(address); | 50 return socket_.GetLocalAddress(address); |
| 51 } | 51 } |
| 52 | 52 |
| 53 int TCPServerSocket::Accept(scoped_ptr<StreamSocket>* socket, | 53 int TCPServerSocket::Accept(std::unique_ptr<StreamSocket>* socket, |
| 54 const CompletionCallback& callback) { | 54 const CompletionCallback& callback) { |
| 55 DCHECK(socket); | 55 DCHECK(socket); |
| 56 DCHECK(!callback.is_null()); | 56 DCHECK(!callback.is_null()); |
| 57 | 57 |
| 58 if (pending_accept_) { | 58 if (pending_accept_) { |
| 59 NOTREACHED(); | 59 NOTREACHED(); |
| 60 return ERR_UNEXPECTED; | 60 return ERR_UNEXPECTED; |
| 61 } | 61 } |
| 62 | 62 |
| 63 // It is safe to use base::Unretained(this). |socket_| is owned by this class, | 63 // It is safe to use base::Unretained(this). |socket_| is owned by this class, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 78 | 78 |
| 79 return result; | 79 return result; |
| 80 } | 80 } |
| 81 | 81 |
| 82 void TCPServerSocket::DetachFromThread() { | 82 void TCPServerSocket::DetachFromThread() { |
| 83 socket_.DetachFromThread(); | 83 socket_.DetachFromThread(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 int TCPServerSocket::ConvertAcceptedSocket( | 86 int TCPServerSocket::ConvertAcceptedSocket( |
| 87 int result, | 87 int result, |
| 88 scoped_ptr<StreamSocket>* output_accepted_socket) { | 88 std::unique_ptr<StreamSocket>* output_accepted_socket) { |
| 89 // Make sure the TCPSocket object is destroyed in any case. | 89 // Make sure the TCPSocket object is destroyed in any case. |
| 90 scoped_ptr<TCPSocket> temp_accepted_socket(std::move(accepted_socket_)); | 90 std::unique_ptr<TCPSocket> temp_accepted_socket(std::move(accepted_socket_)); |
| 91 if (result != OK) | 91 if (result != OK) |
| 92 return result; | 92 return result; |
| 93 | 93 |
| 94 output_accepted_socket->reset( | 94 output_accepted_socket->reset( |
| 95 new TCPClientSocket(std::move(temp_accepted_socket), accepted_address_)); | 95 new TCPClientSocket(std::move(temp_accepted_socket), accepted_address_)); |
| 96 | 96 |
| 97 return OK; | 97 return OK; |
| 98 } | 98 } |
| 99 | 99 |
| 100 void TCPServerSocket::OnAcceptCompleted( | 100 void TCPServerSocket::OnAcceptCompleted( |
| 101 scoped_ptr<StreamSocket>* output_accepted_socket, | 101 std::unique_ptr<StreamSocket>* output_accepted_socket, |
| 102 const CompletionCallback& forward_callback, | 102 const CompletionCallback& forward_callback, |
| 103 int result) { | 103 int result) { |
| 104 result = ConvertAcceptedSocket(result, output_accepted_socket); | 104 result = ConvertAcceptedSocket(result, output_accepted_socket); |
| 105 pending_accept_ = false; | 105 pending_accept_ = false; |
| 106 forward_callback.Run(result); | 106 forward_callback.Run(result); |
| 107 } | 107 } |
| 108 | 108 |
| 109 } // namespace net | 109 } // namespace net |
| OLD | NEW |