| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "blimp/net/tcp_engine_transport.h" | 5 #include "blimp/net/tcp_engine_transport.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 base::Bind(callback, result)); | 54 base::Bind(callback, result)); |
| 55 } | 55 } |
| 56 | 56 |
| 57 scoped_ptr<BlimpConnection> TCPEngineTransport::TakeConnection() { | 57 scoped_ptr<BlimpConnection> TCPEngineTransport::TakeConnection() { |
| 58 DCHECK(connect_callback_.is_null()); | 58 DCHECK(connect_callback_.is_null()); |
| 59 DCHECK(accepted_socket_); | 59 DCHECK(accepted_socket_); |
| 60 return make_scoped_ptr( | 60 return make_scoped_ptr( |
| 61 new StreamSocketConnection(std::move(accepted_socket_))); | 61 new StreamSocketConnection(std::move(accepted_socket_))); |
| 62 } | 62 } |
| 63 | 63 |
| 64 const std::string TCPEngineTransport::GetName() const { | 64 const char* TCPEngineTransport::GetName() const { |
| 65 return "TCP"; | 65 return "TCP"; |
| 66 } | 66 } |
| 67 | 67 |
| 68 int TCPEngineTransport::GetLocalAddressForTesting( | 68 int TCPEngineTransport::GetLocalAddressForTesting( |
| 69 net::IPEndPoint* address) const { | 69 net::IPEndPoint* address) const { |
| 70 DCHECK(server_socket_); | 70 DCHECK(server_socket_); |
| 71 return server_socket_->GetLocalAddress(address); | 71 return server_socket_->GetLocalAddress(address); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void TCPEngineTransport::OnTCPConnectAccepted(int result) { | 74 void TCPEngineTransport::OnTCPConnectAccepted(int result) { |
| 75 DCHECK_NE(net::ERR_IO_PENDING, result); | 75 DCHECK_NE(net::ERR_IO_PENDING, result); |
| 76 DCHECK(accepted_socket_); | 76 DCHECK(accepted_socket_); |
| 77 if (result != net::OK) { | 77 if (result != net::OK) { |
| 78 accepted_socket_.reset(); | 78 accepted_socket_.reset(); |
| 79 } | 79 } |
| 80 base::ResetAndReturn(&connect_callback_).Run(result); | 80 base::ResetAndReturn(&connect_callback_).Run(result); |
| 81 } | 81 } |
| 82 | 82 |
| 83 } // namespace blimp | 83 } // namespace blimp |
| OLD | NEW |