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 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "blimp/net/blimp_connection_statistics.h" | |
13 #include "blimp/net/stream_socket_connection.h" | 14 #include "blimp/net/stream_socket_connection.h" |
14 #include "net/socket/client_socket_factory.h" | 15 #include "net/socket/client_socket_factory.h" |
15 #include "net/socket/stream_socket.h" | 16 #include "net/socket/stream_socket.h" |
16 #include "net/socket/tcp_client_socket.h" | 17 #include "net/socket/tcp_client_socket.h" |
17 | 18 |
18 namespace blimp { | 19 namespace blimp { |
19 | 20 |
20 TCPClientTransport::TCPClientTransport(const net::IPEndPoint& ip_endpoint, | 21 TCPClientTransport::TCPClientTransport(const net::IPEndPoint& ip_endpoint, |
22 BlimpConnectionStatistics* statistics, | |
21 net::NetLog* net_log) | 23 net::NetLog* net_log) |
22 : ip_endpoint_(ip_endpoint), | 24 : ip_endpoint_(ip_endpoint), |
25 blimp_connection_statistics_(statistics), | |
23 net_log_(net_log), | 26 net_log_(net_log), |
24 socket_factory_(net::ClientSocketFactory::GetDefaultFactory()) {} | 27 socket_factory_(net::ClientSocketFactory::GetDefaultFactory()) {} |
Kevin M
2016/05/24 22:56:40
DCHECK(statistics)
| |
25 | 28 |
26 TCPClientTransport::~TCPClientTransport() {} | 29 TCPClientTransport::~TCPClientTransport() {} |
27 | 30 |
28 void TCPClientTransport::SetClientSocketFactoryForTest( | 31 void TCPClientTransport::SetClientSocketFactoryForTest( |
29 net::ClientSocketFactory* factory) { | 32 net::ClientSocketFactory* factory) { |
30 DCHECK(factory); | 33 DCHECK(factory); |
31 socket_factory_ = factory; | 34 socket_factory_ = factory; |
32 } | 35 } |
33 | 36 |
34 void TCPClientTransport::Connect(const net::CompletionCallback& callback) { | 37 void TCPClientTransport::Connect(const net::CompletionCallback& callback) { |
(...skipping 10 matching lines...) Expand all Loading... | |
45 if (result == net::ERR_IO_PENDING) { | 48 if (result == net::ERR_IO_PENDING) { |
46 return; | 49 return; |
47 } | 50 } |
48 | 51 |
49 OnTCPConnectComplete(result); | 52 OnTCPConnectComplete(result); |
50 } | 53 } |
51 | 54 |
52 std::unique_ptr<BlimpConnection> TCPClientTransport::TakeConnection() { | 55 std::unique_ptr<BlimpConnection> TCPClientTransport::TakeConnection() { |
53 DCHECK(connect_callback_.is_null()); | 56 DCHECK(connect_callback_.is_null()); |
54 DCHECK(socket_); | 57 DCHECK(socket_); |
55 return base::WrapUnique(new StreamSocketConnection(std::move(socket_))); | 58 return base::WrapUnique(new StreamSocketConnection( |
59 std::move(socket_), blimp_connection_statistics_)); | |
56 } | 60 } |
57 | 61 |
58 const char* TCPClientTransport::GetName() const { | 62 const char* TCPClientTransport::GetName() const { |
59 return "TCP"; | 63 return "TCP"; |
60 } | 64 } |
61 | 65 |
62 void TCPClientTransport::OnTCPConnectComplete(int result) { | 66 void TCPClientTransport::OnTCPConnectComplete(int result) { |
63 DCHECK_NE(net::ERR_IO_PENDING, result); | 67 DCHECK_NE(net::ERR_IO_PENDING, result); |
64 OnConnectComplete(result); | 68 OnConnectComplete(result); |
65 } | 69 } |
(...skipping 12 matching lines...) Expand all Loading... | |
78 void TCPClientTransport::SetSocket(std::unique_ptr<net::StreamSocket> socket) { | 82 void TCPClientTransport::SetSocket(std::unique_ptr<net::StreamSocket> socket) { |
79 DCHECK(socket); | 83 DCHECK(socket); |
80 socket_ = std::move(socket); | 84 socket_ = std::move(socket); |
81 } | 85 } |
82 | 86 |
83 net::ClientSocketFactory* TCPClientTransport::socket_factory() const { | 87 net::ClientSocketFactory* TCPClientTransport::socket_factory() const { |
84 return socket_factory_; | 88 return socket_factory_; |
85 } | 89 } |
86 | 90 |
87 } // namespace blimp | 91 } // namespace blimp |
OLD | NEW |