| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, | 68 class QuicTestClient : public SimpleClient, |
| 69 public QuicDataStream::Visitor { | 69 public QuicDataStream::Visitor { |
| 70 public: | 70 public: |
| 71 QuicTestClient(IPEndPoint server_address, | 71 QuicTestClient(IPEndPoint server_address, |
| 72 const std::string& server_hostname, | 72 const std::string& server_hostname, |
| 73 bool secure, | |
| 74 const QuicVersionVector& supported_versions); | 73 const QuicVersionVector& supported_versions); |
| 75 QuicTestClient(IPEndPoint server_address, | 74 QuicTestClient(IPEndPoint server_address, |
| 76 const std::string& server_hostname, | 75 const std::string& server_hostname, |
| 77 bool secure, | |
| 78 const QuicConfig& config, | 76 const QuicConfig& config, |
| 79 const QuicVersionVector& supported_versions); | 77 const QuicVersionVector& supported_versions); |
| 80 | 78 |
| 81 ~QuicTestClient() override; | 79 ~QuicTestClient() override; |
| 82 | 80 |
| 83 // ExpectCertificates controls whether the server is expected to provide | |
| 84 // certificates. The certificates, if any, are not verified, but the common | |
| 85 // name is recorded and available with |cert_common_name()|. | |
| 86 void ExpectCertificates(bool on); | |
| 87 | |
| 88 // Sets the |user_agent_id| of the |client_|. | 81 // Sets the |user_agent_id| of the |client_|. |
| 89 void SetUserAgentID(const std::string& user_agent_id); | 82 void SetUserAgentID(const std::string& user_agent_id); |
| 90 | 83 |
| 91 // Wraps data in a quic packet and sends it. | 84 // Wraps data in a quic packet and sends it. |
| 92 ssize_t SendData(const std::string& data, bool last_data); | 85 ssize_t SendData(const std::string& data, bool last_data); |
| 93 // As above, but |delegate| will be notified when |data| is ACKed. | 86 // As above, but |delegate| will be notified when |data| is ACKed. |
| 94 ssize_t SendData(const std::string& data, | 87 ssize_t SendData(const std::string& data, |
| 95 bool last_data, | 88 bool last_data, |
| 96 QuicAckListenerInterface* delegate); | 89 QuicAckListenerInterface* delegate); |
| 97 | 90 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 // also to the headers and crypto streams. | 173 // also to the headers and crypto streams. |
| 181 void SetFecPolicy(FecPolicy fec_policy); | 174 void SetFecPolicy(FecPolicy fec_policy); |
| 182 | 175 |
| 183 void WaitForWriteToFlush(); | 176 void WaitForWriteToFlush(); |
| 184 | 177 |
| 185 EpollServer* epoll_server() { return &epoll_server_; } | 178 EpollServer* epoll_server() { return &epoll_server_; } |
| 186 | 179 |
| 187 protected: | 180 protected: |
| 188 QuicTestClient(); | 181 QuicTestClient(); |
| 189 | 182 |
| 190 void Initialize(bool secure); | 183 void Initialize(); |
| 191 | 184 |
| 192 void set_client(MockableQuicClient* client) { client_.reset(client); } | 185 void set_client(MockableQuicClient* client) { client_.reset(client); } |
| 193 | 186 |
| 194 private: | 187 private: |
| 195 class TestClientDataToResend : public QuicClient::QuicDataToResend { | 188 class TestClientDataToResend : public QuicClient::QuicDataToResend { |
| 196 public: | 189 public: |
| 197 TestClientDataToResend(BalsaHeaders* headers, | 190 TestClientDataToResend(BalsaHeaders* headers, |
| 198 StringPiece body, | 191 StringPiece body, |
| 199 bool fin, | 192 bool fin, |
| 200 QuicTestClient* test_client, | 193 QuicTestClient* test_client, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 227 QuicPriority priority_; | 220 QuicPriority priority_; |
| 228 std::string response_; | 221 std::string response_; |
| 229 uint64 bytes_read_; | 222 uint64 bytes_read_; |
| 230 uint64 bytes_written_; | 223 uint64 bytes_written_; |
| 231 // The number of uncompressed HTTP header bytes received. | 224 // The number of uncompressed HTTP header bytes received. |
| 232 int response_header_size_; | 225 int response_header_size_; |
| 233 // The number of HTTP body bytes received. | 226 // The number of HTTP body bytes received. |
| 234 int64 response_body_size_; | 227 int64 response_body_size_; |
| 235 // True if we tried to connect already since the last call to Disconnect(). | 228 // True if we tried to connect already since the last call to Disconnect(). |
| 236 bool connect_attempted_; | 229 bool connect_attempted_; |
| 237 bool secure_; | |
| 238 // The client will auto-connect exactly once before sending data. If | 230 // The client will auto-connect exactly once before sending data. If |
| 239 // something causes a connection reset, it will not automatically reconnect | 231 // something causes a connection reset, it will not automatically reconnect |
| 240 // unless auto_reconnect_ is true. | 232 // unless auto_reconnect_ is true. |
| 241 bool auto_reconnect_; | 233 bool auto_reconnect_; |
| 242 // Should we buffer the response body? Defaults to true. | 234 // Should we buffer the response body? Defaults to true. |
| 243 bool buffer_body_; | 235 bool buffer_body_; |
| 244 // FEC policy for data sent by this client. | 236 // FEC policy for data sent by this client. |
| 245 FecPolicy fec_policy_; | 237 FecPolicy fec_policy_; |
| 246 // proof_verifier_ points to a RecordingProofVerifier that is owned by | |
| 247 // client_. | |
| 248 ProofVerifier* proof_verifier_; | |
| 249 | 238 |
| 250 DISALLOW_COPY_AND_ASSIGN(QuicTestClient); | 239 DISALLOW_COPY_AND_ASSIGN(QuicTestClient); |
| 251 }; | 240 }; |
| 252 | 241 |
| 253 } // namespace test | 242 } // namespace test |
| 254 | 243 |
| 255 } // namespace tools | 244 } // namespace tools |
| 256 } // namespace net | 245 } // namespace net |
| 257 | 246 |
| 258 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ | 247 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ |
| OLD | NEW |