| 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 #ifndef NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ | 5 #ifndef NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ |
| 6 #define NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ | 6 #define NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 CachedNetworkParameters cached_network_paramaters_; | 62 CachedNetworkParameters cached_network_paramaters_; |
| 63 | 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(MockableQuicClient); | 64 DISALLOW_COPY_AND_ASSIGN(MockableQuicClient); |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 // A toy QUIC client used for testing, mostly following the SimpleClient APIs. | 67 // A toy QUIC client used for testing, mostly following the SimpleClient APIs. |
| 68 class QuicTestClient : public SimpleClient, public QuicSpdyStream::Visitor { | 68 class QuicTestClient : public SimpleClient, public QuicSpdyStream::Visitor { |
| 69 public: | 69 public: |
| 70 QuicTestClient(IPEndPoint server_address, | 70 QuicTestClient(IPEndPoint server_address, |
| 71 const std::string& server_hostname, | 71 const std::string& server_hostname, |
| 72 bool secure, | |
| 73 const QuicVersionVector& supported_versions); | 72 const QuicVersionVector& supported_versions); |
| 74 QuicTestClient(IPEndPoint server_address, | 73 QuicTestClient(IPEndPoint server_address, |
| 75 const std::string& server_hostname, | 74 const std::string& server_hostname, |
| 76 bool secure, | |
| 77 const QuicConfig& config, | 75 const QuicConfig& config, |
| 78 const QuicVersionVector& supported_versions); | 76 const QuicVersionVector& supported_versions); |
| 79 | 77 |
| 80 ~QuicTestClient() override; | 78 ~QuicTestClient() override; |
| 81 | 79 |
| 82 // ExpectCertificates controls whether the server is expected to provide | |
| 83 // certificates. The certificates, if any, are not verified, but the common | |
| 84 // name is recorded and available with |cert_common_name()|. | |
| 85 void ExpectCertificates(bool on); | |
| 86 | |
| 87 // Sets the |user_agent_id| of the |client_|. | 80 // Sets the |user_agent_id| of the |client_|. |
| 88 void SetUserAgentID(const std::string& user_agent_id); | 81 void SetUserAgentID(const std::string& user_agent_id); |
| 89 | 82 |
| 90 // Wraps data in a quic packet and sends it. | 83 // Wraps data in a quic packet and sends it. |
| 91 ssize_t SendData(const std::string& data, bool last_data); | 84 ssize_t SendData(const std::string& data, bool last_data); |
| 92 // As above, but |delegate| will be notified when |data| is ACKed. | 85 // As above, but |delegate| will be notified when |data| is ACKed. |
| 93 ssize_t SendData(const std::string& data, | 86 ssize_t SendData(const std::string& data, |
| 94 bool last_data, | 87 bool last_data, |
| 95 QuicAckListenerInterface* delegate); | 88 QuicAckListenerInterface* delegate); |
| 96 | 89 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 178 |
| 186 void set_allow_bidirectional_data(bool value) { | 179 void set_allow_bidirectional_data(bool value) { |
| 187 allow_bidirectional_data_ = value; | 180 allow_bidirectional_data_ = value; |
| 188 } | 181 } |
| 189 | 182 |
| 190 bool allow_bidirectional_data() const { return allow_bidirectional_data_; } | 183 bool allow_bidirectional_data() const { return allow_bidirectional_data_; } |
| 191 | 184 |
| 192 protected: | 185 protected: |
| 193 QuicTestClient(); | 186 QuicTestClient(); |
| 194 | 187 |
| 195 void Initialize(bool secure); | 188 void Initialize(); |
| 196 | 189 |
| 197 void set_client(MockableQuicClient* client) { client_.reset(client); } | 190 void set_client(MockableQuicClient* client) { client_.reset(client); } |
| 198 | 191 |
| 199 private: | 192 private: |
| 200 class TestClientDataToResend : public QuicClient::QuicDataToResend { | 193 class TestClientDataToResend : public QuicClient::QuicDataToResend { |
| 201 public: | 194 public: |
| 202 TestClientDataToResend(BalsaHeaders* headers, | 195 TestClientDataToResend(BalsaHeaders* headers, |
| 203 StringPiece body, | 196 StringPiece body, |
| 204 bool fin, | 197 bool fin, |
| 205 QuicTestClient* test_client, | 198 QuicTestClient* test_client, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 232 QuicPriority priority_; | 225 QuicPriority priority_; |
| 233 std::string response_; | 226 std::string response_; |
| 234 uint64 bytes_read_; | 227 uint64 bytes_read_; |
| 235 uint64 bytes_written_; | 228 uint64 bytes_written_; |
| 236 // The number of uncompressed HTTP header bytes received. | 229 // The number of uncompressed HTTP header bytes received. |
| 237 int response_header_size_; | 230 int response_header_size_; |
| 238 // The number of HTTP body bytes received. | 231 // The number of HTTP body bytes received. |
| 239 int64 response_body_size_; | 232 int64 response_body_size_; |
| 240 // True if we tried to connect already since the last call to Disconnect(). | 233 // True if we tried to connect already since the last call to Disconnect(). |
| 241 bool connect_attempted_; | 234 bool connect_attempted_; |
| 242 bool secure_; | |
| 243 // The client will auto-connect exactly once before sending data. If | 235 // The client will auto-connect exactly once before sending data. If |
| 244 // something causes a connection reset, it will not automatically reconnect | 236 // something causes a connection reset, it will not automatically reconnect |
| 245 // unless auto_reconnect_ is true. | 237 // unless auto_reconnect_ is true. |
| 246 bool auto_reconnect_; | 238 bool auto_reconnect_; |
| 247 // Should we buffer the response body? Defaults to true. | 239 // Should we buffer the response body? Defaults to true. |
| 248 bool buffer_body_; | 240 bool buffer_body_; |
| 249 // FEC policy for data sent by this client. | 241 // FEC policy for data sent by this client. |
| 250 FecPolicy fec_policy_; | 242 FecPolicy fec_policy_; |
| 251 // When true allows the sending of a request to continue while the response is | 243 // When true allows the sending of a request to continue while the response is |
| 252 // arriving. | 244 // arriving. |
| 253 bool allow_bidirectional_data_; | 245 bool allow_bidirectional_data_; |
| 254 // proof_verifier_ points to a RecordingProofVerifier that is owned by | |
| 255 // client_. | |
| 256 ProofVerifier* proof_verifier_; | |
| 257 | 246 |
| 258 DISALLOW_COPY_AND_ASSIGN(QuicTestClient); | 247 DISALLOW_COPY_AND_ASSIGN(QuicTestClient); |
| 259 }; | 248 }; |
| 260 | 249 |
| 261 } // namespace test | 250 } // namespace test |
| 262 | 251 |
| 263 } // namespace tools | 252 } // namespace tools |
| 264 } // namespace net | 253 } // namespace net |
| 265 | 254 |
| 266 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ | 255 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ |
| OLD | NEW |