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 #ifndef BLIMP_NET_TCP_ENGINE_TRANSPORT_H_ | 5 #ifndef BLIMP_NET_TCP_ENGINE_TRANSPORT_H_ |
6 #define BLIMP_NET_TCP_ENGINE_TRANSPORT_H_ | 6 #define BLIMP_NET_TCP_ENGINE_TRANSPORT_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "blimp/net/blimp_net_export.h" | 12 #include "blimp/net/blimp_net_export.h" |
13 #include "blimp/net/blimp_transport.h" | 13 #include "blimp/net/blimp_transport.h" |
14 #include "net/base/ip_endpoint.h" | 14 #include "net/base/ip_endpoint.h" |
15 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 class NetLog; | 18 class NetLog; |
19 class ServerSocket; | 19 class ServerSocket; |
20 class StreamSocket; | 20 class StreamSocket; |
21 } // namespace net | 21 } // namespace net |
22 | 22 |
23 namespace blimp { | 23 namespace blimp { |
24 | 24 |
25 class BlimpConnection; | 25 class BlimpConnection; |
26 class BlimpConnectionStatistics; | |
27 | 26 |
28 // BlimpTransport which listens for a TCP connection at |address|. | 27 // BlimpTransport which listens for a TCP connection at |address|. |
29 class BLIMP_NET_EXPORT TCPEngineTransport : public BlimpTransport { | 28 class BLIMP_NET_EXPORT TCPEngineTransport : public BlimpTransport { |
30 public: | 29 public: |
31 // Caller retains the ownership of |statistics| and |net_log|. | 30 // Caller retains the ownership of |net_log|. |
32 TCPEngineTransport(const net::IPEndPoint& address, | 31 TCPEngineTransport(const net::IPEndPoint& address, net::NetLog* net_log); |
33 BlimpConnectionStatistics* statistics, | |
34 net::NetLog* net_log); | |
35 ~TCPEngineTransport() override; | 32 ~TCPEngineTransport() override; |
36 | 33 |
37 // BlimpTransport implementation. | 34 // BlimpTransport implementation. |
38 void Connect(const net::CompletionCallback& callback) override; | 35 void Connect(const net::CompletionCallback& callback) override; |
39 std::unique_ptr<BlimpConnection> TakeConnection() override; | 36 std::unique_ptr<BlimpConnection> TakeConnection() override; |
40 const char* GetName() const override; | 37 const char* GetName() const override; |
41 | 38 |
42 int GetLocalAddress(net::IPEndPoint* address) const; | 39 int GetLocalAddress(net::IPEndPoint* address) const; |
43 | 40 |
44 private: | 41 private: |
45 void OnTCPConnectAccepted(int result); | 42 void OnTCPConnectAccepted(int result); |
46 | 43 |
47 const net::IPEndPoint address_; | 44 const net::IPEndPoint address_; |
48 BlimpConnectionStatistics* blimp_connection_statistics_; | |
49 net::NetLog* net_log_; | 45 net::NetLog* net_log_; |
50 std::unique_ptr<net::ServerSocket> server_socket_; | 46 std::unique_ptr<net::ServerSocket> server_socket_; |
51 std::unique_ptr<net::StreamSocket> accepted_socket_; | 47 std::unique_ptr<net::StreamSocket> accepted_socket_; |
52 net::CompletionCallback connect_callback_; | 48 net::CompletionCallback connect_callback_; |
53 | 49 |
54 DISALLOW_COPY_AND_ASSIGN(TCPEngineTransport); | 50 DISALLOW_COPY_AND_ASSIGN(TCPEngineTransport); |
55 }; | 51 }; |
56 | 52 |
57 } // namespace blimp | 53 } // namespace blimp |
58 | 54 |
59 #endif // BLIMP_NET_TCP_ENGINE_TRANSPORT_H_ | 55 #endif // BLIMP_NET_TCP_ENGINE_TRANSPORT_H_ |
OLD | NEW |