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