| 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_client_transport.h" | 5 #include "blimp/net/tcp_client_transport.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/callback_helpers.h" | 11 #include "base/callback_helpers.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "blimp/net/message_port.h" |
| 15 #include "blimp/net/message_port_util.h" |
| 14 #include "blimp/net/stream_socket_connection.h" | 16 #include "blimp/net/stream_socket_connection.h" |
| 15 #include "net/socket/client_socket_factory.h" | 17 #include "net/socket/client_socket_factory.h" |
| 16 #include "net/socket/stream_socket.h" | 18 #include "net/socket/stream_socket.h" |
| 17 #include "net/socket/tcp_client_socket.h" | 19 #include "net/socket/tcp_client_socket.h" |
| 18 | 20 |
| 19 namespace blimp { | 21 namespace blimp { |
| 20 | 22 |
| 21 TCPClientTransport::TCPClientTransport(const net::IPEndPoint& ip_endpoint, | 23 TCPClientTransport::TCPClientTransport(const net::IPEndPoint& ip_endpoint, |
| 22 net::NetLog* net_log) | 24 net::NetLog* net_log) |
| 23 : ip_endpoint_(ip_endpoint), | 25 : ip_endpoint_(ip_endpoint), |
| (...skipping 19 matching lines...) Expand all Loading... |
| 43 &TCPClientTransport::OnTCPConnectComplete, base::Unretained(this)); | 45 &TCPClientTransport::OnTCPConnectComplete, base::Unretained(this)); |
| 44 | 46 |
| 45 int result = socket_->Connect(completion_callback); | 47 int result = socket_->Connect(completion_callback); |
| 46 if (result == net::ERR_IO_PENDING) { | 48 if (result == net::ERR_IO_PENDING) { |
| 47 return; | 49 return; |
| 48 } | 50 } |
| 49 | 51 |
| 50 OnTCPConnectComplete(result); | 52 OnTCPConnectComplete(result); |
| 51 } | 53 } |
| 52 | 54 |
| 53 std::unique_ptr<BlimpConnection> TCPClientTransport::TakeConnection() { | 55 std::unique_ptr<MessagePort> TCPClientTransport::TakeMessagePort() { |
| 54 DCHECK(connect_callback_.is_null()); | 56 DCHECK(connect_callback_.is_null()); |
| 55 DCHECK(socket_); | 57 DCHECK(socket_); |
| 56 return base::MakeUnique<StreamSocketConnection>(std::move(socket_)); | 58 return CreateMessagePortForStreamSocket(std::move(socket_)); |
| 57 } | 59 } |
| 58 | 60 |
| 59 const char* TCPClientTransport::GetName() const { | 61 const char* TCPClientTransport::GetName() const { |
| 60 return "TCP"; | 62 return "TCP"; |
| 61 } | 63 } |
| 62 | 64 |
| 63 void TCPClientTransport::OnTCPConnectComplete(int result) { | 65 void TCPClientTransport::OnTCPConnectComplete(int result) { |
| 64 DCHECK_NE(net::ERR_IO_PENDING, result); | 66 DCHECK_NE(net::ERR_IO_PENDING, result); |
| 65 OnConnectComplete(result); | 67 OnConnectComplete(result); |
| 66 } | 68 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 79 void TCPClientTransport::SetSocket(std::unique_ptr<net::StreamSocket> socket) { | 81 void TCPClientTransport::SetSocket(std::unique_ptr<net::StreamSocket> socket) { |
| 80 DCHECK(socket); | 82 DCHECK(socket); |
| 81 socket_ = std::move(socket); | 83 socket_ = std::move(socket); |
| 82 } | 84 } |
| 83 | 85 |
| 84 net::ClientSocketFactory* TCPClientTransport::socket_factory() const { | 86 net::ClientSocketFactory* TCPClientTransport::socket_factory() const { |
| 85 return socket_factory_; | 87 return socket_factory_; |
| 86 } | 88 } |
| 87 | 89 |
| 88 } // namespace blimp | 90 } // namespace blimp |
| OLD | NEW |