Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(587)

Side by Side Diff: net/tools/quic/test_tools/quic_test_client.h

Issue 330333006: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix linus_tsan error - reverted the change to ConnectionMigrationClientPortChanged unitttest Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 17 matching lines...) Expand all
28 namespace test { 28 namespace test {
29 29
30 class HTTPMessage; 30 class HTTPMessage;
31 class MockableQuicClient; 31 class MockableQuicClient;
32 32
33 // A quic client which allows mocking out writes. 33 // A quic client which allows mocking out writes.
34 class MockableQuicClient : public QuicClient { 34 class MockableQuicClient : public QuicClient {
35 public: 35 public:
36 MockableQuicClient(IPEndPoint server_address, 36 MockableQuicClient(IPEndPoint server_address,
37 const QuicServerId& server_id, 37 const QuicServerId& server_id,
38 const QuicVersionVector& supported_versions, 38 const QuicVersionVector& supported_versions);
39 uint32 initial_flow_control_window);
40 39
41 MockableQuicClient(IPEndPoint server_address, 40 MockableQuicClient(IPEndPoint server_address,
42 const QuicServerId& server_id, 41 const QuicServerId& server_id,
43 const QuicConfig& config, 42 const QuicConfig& config,
44 const QuicVersionVector& supported_versions, 43 const QuicVersionVector& supported_versions);
45 uint32 initial_flow_control_window);
46 44
47 virtual ~MockableQuicClient() OVERRIDE; 45 virtual ~MockableQuicClient() OVERRIDE;
48 virtual QuicPacketWriter* CreateQuicPacketWriter() OVERRIDE; 46 virtual QuicPacketWriter* CreateQuicPacketWriter() OVERRIDE;
49 virtual QuicConnectionId GenerateConnectionId() OVERRIDE; 47 virtual QuicConnectionId GenerateConnectionId() OVERRIDE;
50 void UseWriter(QuicPacketWriterWrapper* writer); 48 void UseWriter(QuicPacketWriterWrapper* writer);
51 void UseConnectionId(QuicConnectionId connection_id); 49 void UseConnectionId(QuicConnectionId connection_id);
52 50
53 private: 51 private:
54 QuicConnectionId override_connection_id_; // ConnectionId to use, if nonzero 52 QuicConnectionId override_connection_id_; // ConnectionId to use, if nonzero
55 QuicPacketWriterWrapper* test_writer_; 53 QuicPacketWriterWrapper* test_writer_;
56 54
57 DISALLOW_COPY_AND_ASSIGN(MockableQuicClient); 55 DISALLOW_COPY_AND_ASSIGN(MockableQuicClient);
58 }; 56 };
59 57
60 // A toy QUIC client used for testing, mostly following the SimpleClient APIs. 58 // A toy QUIC client used for testing, mostly following the SimpleClient APIs.
61 class QuicTestClient : public SimpleClient, 59 class QuicTestClient : public SimpleClient,
62 public QuicDataStream::Visitor { 60 public QuicDataStream::Visitor {
63 public: 61 public:
64 QuicTestClient(IPEndPoint server_address, 62 QuicTestClient(IPEndPoint server_address,
65 const string& server_hostname, 63 const string& server_hostname,
66 const QuicVersionVector& supported_versions); 64 const QuicVersionVector& supported_versions);
67 QuicTestClient(IPEndPoint server_address, 65 QuicTestClient(IPEndPoint server_address,
68 const string& server_hostname, 66 const string& server_hostname,
69 bool secure, 67 bool secure,
70 const QuicVersionVector& supported_versions); 68 const QuicVersionVector& supported_versions);
71 QuicTestClient(IPEndPoint server_address, 69 QuicTestClient(IPEndPoint server_address,
72 const string& server_hostname, 70 const string& server_hostname,
73 bool secure, 71 bool secure,
74 const QuicConfig& config, 72 const QuicConfig& config,
75 const QuicVersionVector& supported_versions, 73 const QuicVersionVector& supported_versions);
76 uint32 client_initial_flow_control_receive_window);
77 74
78 virtual ~QuicTestClient(); 75 virtual ~QuicTestClient();
79 76
80 // ExpectCertificates controls whether the server is expected to provide 77 // ExpectCertificates controls whether the server is expected to provide
81 // certificates. The certificates, if any, are not verified, but the common 78 // certificates. The certificates, if any, are not verified, but the common
82 // name is recorded and available with |cert_common_name()|. 79 // name is recorded and available with |cert_common_name()|.
83 void ExpectCertificates(bool on); 80 void ExpectCertificates(bool on);
84 81
85 // Wraps data in a quic packet and sends it. 82 // Wraps data in a quic packet and sends it.
86 ssize_t SendData(string data, bool last_data); 83 ssize_t SendData(string data, bool last_data);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 // or the empty string if no certificate was presented. 144 // or the empty string if no certificate was presented.
148 const string& cert_common_name() const; 145 const string& cert_common_name() const;
149 146
150 // Get the server config map. 147 // Get the server config map.
151 QuicTagValueMap GetServerConfig() const; 148 QuicTagValueMap GetServerConfig() const;
152 149
153 void set_auto_reconnect(bool reconnect) { auto_reconnect_ = reconnect; } 150 void set_auto_reconnect(bool reconnect) { auto_reconnect_ = reconnect; }
154 151
155 void set_priority(QuicPriority priority) { priority_ = priority; } 152 void set_priority(QuicPriority priority) { priority_ = priority; }
156 153
154 // Sets client's FEC policy. This policy applies to the data stream(s), and
155 // also to the headers and crypto streams.
156 void SetFecPolicy(FecPolicy fec_policy);
157
157 void WaitForWriteToFlush(); 158 void WaitForWriteToFlush();
158 159
159 protected: 160 protected:
160 QuicTestClient(); 161 QuicTestClient();
161 162
162 void Initialize(bool secure); 163 void Initialize(bool secure);
163 164
164 void set_client(MockableQuicClient* client) { client_.reset(client); } 165 void set_client(MockableQuicClient* client) { client_.reset(client); }
165 166
166 private: 167 private:
(...skipping 15 matching lines...) Expand all
182 int64 response_body_size_; 183 int64 response_body_size_;
183 // True if we tried to connect already since the last call to Disconnect(). 184 // True if we tried to connect already since the last call to Disconnect().
184 bool connect_attempted_; 185 bool connect_attempted_;
185 bool secure_; 186 bool secure_;
186 // The client will auto-connect exactly once before sending data. If 187 // The client will auto-connect exactly once before sending data. If
187 // something causes a connection reset, it will not automatically reconnect 188 // something causes a connection reset, it will not automatically reconnect
188 // unless auto_reconnect_ is true. 189 // unless auto_reconnect_ is true.
189 bool auto_reconnect_; 190 bool auto_reconnect_;
190 // Should we buffer the response body? Defaults to true. 191 // Should we buffer the response body? Defaults to true.
191 bool buffer_body_; 192 bool buffer_body_;
192 193 // FEC policy for data sent by this client.
194 FecPolicy fec_policy_;
193 // proof_verifier_ points to a RecordingProofVerifier that is owned by 195 // proof_verifier_ points to a RecordingProofVerifier that is owned by
194 // client_. 196 // client_.
195 ProofVerifier* proof_verifier_; 197 ProofVerifier* proof_verifier_;
196 198
197 DISALLOW_COPY_AND_ASSIGN(QuicTestClient); 199 DISALLOW_COPY_AND_ASSIGN(QuicTestClient);
198 }; 200 };
199 201
200 } // namespace test 202 } // namespace test
201 203
202 } // namespace tools 204 } // namespace tools
203 } // namespace net 205 } // namespace net
204 206
205 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ 207 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_
OLDNEW
« no previous file with comments | « net/tools/quic/test_tools/packet_dropping_test_writer.cc ('k') | net/tools/quic/test_tools/quic_test_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698