| 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/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/containers/hash_tables.h" | |
| 15 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 16 #include "net/base/ip_endpoint.h" | 15 #include "net/base/ip_endpoint.h" |
| 17 #include "net/quic/crypto/crypto_handshake.h" | 16 #include "net/quic/crypto/crypto_handshake.h" |
| 18 #include "net/quic/quic_config.h" | 17 #include "net/quic/quic_config.h" |
| 19 #include "net/quic/quic_framer.h" | 18 #include "net/quic/quic_framer.h" |
| 20 #include "net/quic/quic_packet_creator.h" | 19 #include "net/quic/quic_packet_creator.h" |
| 21 #include "net/tools/epoll_server/epoll_server.h" | 20 #include "net/tools/epoll_server/epoll_server.h" |
| 22 #include "net/tools/quic/quic_client_session.h" | 21 #include "net/tools/quic/quic_client_session.h" |
| 23 #include "net/tools/quic/quic_reliable_client_stream.h" | 22 #include "net/tools/quic/quic_spdy_client_stream.h" |
| 24 | 23 |
| 25 namespace net { | 24 namespace net { |
| 26 | 25 |
| 27 class ProofVerifier; | 26 class ProofVerifier; |
| 28 | 27 |
| 29 namespace tools { | 28 namespace tools { |
| 30 | 29 |
| 31 class QuicEpollConnectionHelper; | 30 class QuicEpollConnectionHelper; |
| 32 | 31 |
| 33 namespace test { | 32 namespace test { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 68 |
| 70 // Disconnects from the QUIC server. | 69 // Disconnects from the QUIC server. |
| 71 void Disconnect(); | 70 void Disconnect(); |
| 72 | 71 |
| 73 // Sends a request simple GET for each URL in arg, and then waits for | 72 // Sends a request simple GET for each URL in arg, and then waits for |
| 74 // each to complete. | 73 // each to complete. |
| 75 void SendRequestsAndWaitForResponse(const CommandLine::StringVector& args); | 74 void SendRequestsAndWaitForResponse(const CommandLine::StringVector& args); |
| 76 | 75 |
| 77 // Returns a newly created CreateReliableClientStream, owned by the | 76 // Returns a newly created CreateReliableClientStream, owned by the |
| 78 // QuicClient. | 77 // QuicClient. |
| 79 QuicReliableClientStream* CreateReliableClientStream(); | 78 QuicSpdyClientStream* CreateReliableClientStream(); |
| 80 | 79 |
| 81 // Wait for events until the stream with the given ID is closed. | 80 // Wait for events until the stream with the given ID is closed. |
| 82 void WaitForStreamToClose(QuicStreamId id); | 81 void WaitForStreamToClose(QuicStreamId id); |
| 83 | 82 |
| 84 // Wait for events until the handshake is confirmed. | 83 // Wait for events until the handshake is confirmed. |
| 85 void WaitForCryptoHandshakeConfirmed(); | 84 void WaitForCryptoHandshakeConfirmed(); |
| 86 | 85 |
| 87 // Wait up to 50ms, and handle any events which occur. | 86 // Wait up to 50ms, and handle any events which occur. |
| 88 // Returns true if there are any outstanding requests. | 87 // Returns true if there are any outstanding requests. |
| 89 bool WaitForEvents(); | 88 bool WaitForEvents(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 virtual QuicGuid GenerateGuid(); | 146 virtual QuicGuid GenerateGuid(); |
| 148 virtual QuicEpollConnectionHelper* CreateQuicConnectionHelper(); | 147 virtual QuicEpollConnectionHelper* CreateQuicConnectionHelper(); |
| 149 virtual QuicPacketWriter* CreateQuicPacketWriter(); | 148 virtual QuicPacketWriter* CreateQuicPacketWriter(); |
| 150 | 149 |
| 151 private: | 150 private: |
| 152 friend class net::tools::test::QuicClientPeer; | 151 friend class net::tools::test::QuicClientPeer; |
| 153 | 152 |
| 154 // Read a UDP packet and hand it to the framer. | 153 // Read a UDP packet and hand it to the framer. |
| 155 bool ReadAndProcessPacket(); | 154 bool ReadAndProcessPacket(); |
| 156 | 155 |
| 157 // Set of streams created (and owned) by this client | |
| 158 base::hash_set<QuicReliableClientStream*> streams_; | |
| 159 | |
| 160 // Address of the server. | 156 // Address of the server. |
| 161 const IPEndPoint server_address_; | 157 const IPEndPoint server_address_; |
| 162 | 158 |
| 163 // Hostname of the server. This may be a DNS name or an IP address literal. | 159 // Hostname of the server. This may be a DNS name or an IP address literal. |
| 164 std::string server_hostname_; | 160 std::string server_hostname_; |
| 165 | 161 |
| 166 // config_ and crypto_config_ contain configuration and cached state about | 162 // config_ and crypto_config_ contain configuration and cached state about |
| 167 // servers. | 163 // servers. |
| 168 QuicConfig config_; | 164 QuicConfig config_; |
| 169 QuicCryptoClientConfig crypto_config_; | 165 QuicCryptoClientConfig crypto_config_; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // when the stream is closed (in OnClose). | 208 // when the stream is closed (in OnClose). |
| 213 bool print_response_; | 209 bool print_response_; |
| 214 | 210 |
| 215 DISALLOW_COPY_AND_ASSIGN(QuicClient); | 211 DISALLOW_COPY_AND_ASSIGN(QuicClient); |
| 216 }; | 212 }; |
| 217 | 213 |
| 218 } // namespace tools | 214 } // namespace tools |
| 219 } // namespace net | 215 } // namespace net |
| 220 | 216 |
| 221 #endif // NET_TOOLS_QUIC_QUIC_CLIENT_H_ | 217 #endif // NET_TOOLS_QUIC_QUIC_CLIENT_H_ |
| OLD | NEW |