OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // A toy client, which connects to a specified port and sends QUIC | 5 // A toy client, which connects to a specified port and sends QUIC |
6 // request to that endpoint. | 6 // request to that endpoint. |
7 | 7 |
8 #ifndef NET_TOOLS_QUIC_QUIC_CLIENT_H_ | 8 #ifndef NET_TOOLS_QUIC_QUIC_CLIENT_H_ |
9 #define NET_TOOLS_QUIC_QUIC_CLIENT_H_ | 9 #define NET_TOOLS_QUIC_QUIC_CLIENT_H_ |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/hash_tables.h" | 13 #include "base/hash_tables.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "net/base/ip_endpoint.h" | 15 #include "net/base/ip_endpoint.h" |
16 #include "net/quic/crypto/crypto_handshake.h" | 16 #include "net/quic/crypto/crypto_handshake.h" |
17 #include "net/quic/quic_config.h" | 17 #include "net/quic/quic_config.h" |
18 #include "net/quic/quic_framer.h" | 18 #include "net/quic/quic_framer.h" |
19 #include "net/quic/quic_packet_creator.h" | 19 #include "net/quic/quic_packet_creator.h" |
20 #include "net/tools/flip_server/epoll_server.h" | 20 #include "net/tools/flip_server/epoll_server.h" |
21 #include "net/tools/quic/quic_client_session.h" | 21 #include "net/tools/quic/quic_client_session.h" |
22 #include "net/tools/quic/quic_reliable_client_stream.h" | 22 #include "net/tools/quic/quic_reliable_client_stream.h" |
23 | 23 |
24 namespace net { | 24 namespace net { |
25 namespace tools { | 25 namespace tools { |
26 | 26 |
| 27 namespace test { |
| 28 class QuicClientPeer; |
| 29 } // namespace test |
| 30 |
27 class QuicClient : public EpollCallbackInterface { | 31 class QuicClient : public EpollCallbackInterface { |
28 public: | 32 public: |
29 QuicClient(IPEndPoint server_address, const std::string& server_hostname); | 33 QuicClient(IPEndPoint server_address, const std::string& server_hostname); |
30 QuicClient(IPEndPoint server_address, | 34 QuicClient(IPEndPoint server_address, |
31 const std::string& server_hostname, | 35 const std::string& server_hostname, |
32 const QuicConfig& config); | 36 const QuicConfig& config); |
33 | 37 |
34 virtual ~QuicClient(); | 38 virtual ~QuicClient(); |
35 | 39 |
36 // Initializes the client to create a connection. Should be called exactly | 40 // Initializes the client to create a connection. Should be called exactly |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 105 |
102 const IPEndPoint& server_address() const { return server_address_; } | 106 const IPEndPoint& server_address() const { return server_address_; } |
103 | 107 |
104 const IPEndPoint& client_address() const { return client_address_; } | 108 const IPEndPoint& client_address() const { return client_address_; } |
105 | 109 |
106 EpollServer* epoll_server() { return &epoll_server_; } | 110 EpollServer* epoll_server() { return &epoll_server_; } |
107 | 111 |
108 int fd() { return fd_; } | 112 int fd() { return fd_; } |
109 | 113 |
110 private: | 114 private: |
| 115 friend class net::tools::test::QuicClientPeer; |
| 116 |
111 // Read a UDP packet and hand it to the framer. | 117 // Read a UDP packet and hand it to the framer. |
112 bool ReadAndProcessPacket(); | 118 bool ReadAndProcessPacket(); |
113 | 119 |
114 // Set of streams created (and owned) by this client | 120 // Set of streams created (and owned) by this client |
115 base::hash_set<QuicReliableClientStream*> streams_; | 121 base::hash_set<QuicReliableClientStream*> streams_; |
116 | 122 |
117 // Address of the server. | 123 // Address of the server. |
118 const IPEndPoint server_address_; | 124 const IPEndPoint server_address_; |
119 | 125 |
120 // Hostname of the server. This may be a DNS name or an IP address literal. | 126 // Hostname of the server. This may be a DNS name or an IP address literal. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 // because the socket would otherwise overflow. | 158 // because the socket would otherwise overflow. |
153 bool overflow_supported_; | 159 bool overflow_supported_; |
154 | 160 |
155 DISALLOW_COPY_AND_ASSIGN(QuicClient); | 161 DISALLOW_COPY_AND_ASSIGN(QuicClient); |
156 }; | 162 }; |
157 | 163 |
158 } // namespace tools | 164 } // namespace tools |
159 } // namespace net | 165 } // namespace net |
160 | 166 |
161 #endif // NET_TOOLS_QUIC_QUIC_CLIENT_H_ | 167 #endif // NET_TOOLS_QUIC_QUIC_CLIENT_H_ |
OLD | NEW |