| 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> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 9 #include "base/logging.h" | 11 #include "base/logging.h" |
| 10 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
| 11 #include "net/socket/tcp_client_socket.h" | 13 #include "net/socket/tcp_client_socket.h" |
| 12 | 14 |
| 13 namespace net { | 15 namespace net { |
| 14 | 16 |
| 15 TCPServerSocket::TCPServerSocket(NetLog* net_log, const NetLog::Source& source) | 17 TCPServerSocket::TCPServerSocket(NetLog* net_log, const NetLog::Source& source) |
| 16 : socket_(net_log, source), | 18 : socket_(net_log, source), |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 } | 82 } |
| 81 | 83 |
| 82 void TCPServerSocket::DetachFromThread() { | 84 void TCPServerSocket::DetachFromThread() { |
| 83 socket_.DetachFromThread(); | 85 socket_.DetachFromThread(); |
| 84 } | 86 } |
| 85 | 87 |
| 86 int TCPServerSocket::ConvertAcceptedSocket( | 88 int TCPServerSocket::ConvertAcceptedSocket( |
| 87 int result, | 89 int result, |
| 88 scoped_ptr<StreamSocket>* output_accepted_socket) { | 90 scoped_ptr<StreamSocket>* output_accepted_socket) { |
| 89 // Make sure the TCPSocket object is destroyed in any case. | 91 // Make sure the TCPSocket object is destroyed in any case. |
| 90 scoped_ptr<TCPSocket> temp_accepted_socket(accepted_socket_.Pass()); | 92 scoped_ptr<TCPSocket> temp_accepted_socket(std::move(accepted_socket_)); |
| 91 if (result != OK) | 93 if (result != OK) |
| 92 return result; | 94 return result; |
| 93 | 95 |
| 94 output_accepted_socket->reset(new TCPClientSocket( | 96 output_accepted_socket->reset( |
| 95 temp_accepted_socket.Pass(), accepted_address_)); | 97 new TCPClientSocket(std::move(temp_accepted_socket), accepted_address_)); |
| 96 | 98 |
| 97 return OK; | 99 return OK; |
| 98 } | 100 } |
| 99 | 101 |
| 100 void TCPServerSocket::OnAcceptCompleted( | 102 void TCPServerSocket::OnAcceptCompleted( |
| 101 scoped_ptr<StreamSocket>* output_accepted_socket, | 103 scoped_ptr<StreamSocket>* output_accepted_socket, |
| 102 const CompletionCallback& forward_callback, | 104 const CompletionCallback& forward_callback, |
| 103 int result) { | 105 int result) { |
| 104 result = ConvertAcceptedSocket(result, output_accepted_socket); | 106 result = ConvertAcceptedSocket(result, output_accepted_socket); |
| 105 pending_accept_ = false; | 107 pending_accept_ = false; |
| 106 forward_callback.Run(result); | 108 forward_callback.Run(result); |
| 107 } | 109 } |
| 108 | 110 |
| 109 } // namespace net | 111 } // namespace net |
| OLD | NEW |