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

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

Issue 341083007: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compile fix 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"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "net/base/ip_endpoint.h" 12 #include "net/base/ip_endpoint.h"
13 #include "net/quic/quic_framer.h" 13 #include "net/quic/quic_framer.h"
14 #include "net/quic/quic_packet_creator.h" 14 #include "net/quic/quic_packet_creator.h"
15 #include "net/quic/quic_protocol.h" 15 #include "net/quic/quic_protocol.h"
16 #include "net/tools/balsa/balsa_frame.h" 16 #include "net/tools/balsa/balsa_frame.h"
17 #include "net/tools/epoll_server/epoll_server.h"
17 #include "net/tools/quic/quic_client.h" 18 #include "net/tools/quic/quic_client.h"
18 #include "net/tools/quic/test_tools/simple_client.h" 19 #include "net/tools/quic/test_tools/simple_client.h"
19 20
20 namespace net { 21 namespace net {
21 22
22 class ProofVerifier; 23 class ProofVerifier;
23 24
24 namespace tools { 25 namespace tools {
25 26
26 class QuicPacketWriterWrapper; 27 class QuicPacketWriterWrapper;
27 28
28 namespace test { 29 namespace test {
29 30
30 class HTTPMessage; 31 class HTTPMessage;
31 class MockableQuicClient; 32 class MockableQuicClient;
32 33
33 // A quic client which allows mocking out writes. 34 // A quic client which allows mocking out writes.
34 class MockableQuicClient : public QuicClient { 35 class MockableQuicClient : public QuicClient {
35 public: 36 public:
36 MockableQuicClient(IPEndPoint server_address, 37 MockableQuicClient(IPEndPoint server_address,
37 const QuicServerId& server_id, 38 const QuicServerId& server_id,
38 const QuicVersionVector& supported_versions); 39 const QuicVersionVector& supported_versions,
40 EpollServer* epoll_server);
39 41
40 MockableQuicClient(IPEndPoint server_address, 42 MockableQuicClient(IPEndPoint server_address,
41 const QuicServerId& server_id, 43 const QuicServerId& server_id,
42 const QuicConfig& config, 44 const QuicConfig& config,
43 const QuicVersionVector& supported_versions); 45 const QuicVersionVector& supported_versions,
46 EpollServer* epoll_server);
44 47
45 virtual ~MockableQuicClient() OVERRIDE; 48 virtual ~MockableQuicClient() OVERRIDE;
46 virtual QuicPacketWriter* CreateQuicPacketWriter() OVERRIDE; 49 virtual QuicPacketWriter* CreateQuicPacketWriter() OVERRIDE;
47 virtual QuicConnectionId GenerateConnectionId() OVERRIDE; 50 virtual QuicConnectionId GenerateConnectionId() OVERRIDE;
48 void UseWriter(QuicPacketWriterWrapper* writer); 51 void UseWriter(QuicPacketWriterWrapper* writer);
49 void UseConnectionId(QuicConnectionId connection_id); 52 void UseConnectionId(QuicConnectionId connection_id);
50 53
51 private: 54 private:
52 QuicConnectionId override_connection_id_; // ConnectionId to use, if nonzero 55 QuicConnectionId override_connection_id_; // ConnectionId to use, if nonzero
53 QuicPacketWriterWrapper* test_writer_; 56 QuicPacketWriterWrapper* test_writer_;
(...skipping 18 matching lines...) Expand all
72 const QuicConfig& config, 75 const QuicConfig& config,
73 const QuicVersionVector& supported_versions); 76 const QuicVersionVector& supported_versions);
74 77
75 virtual ~QuicTestClient(); 78 virtual ~QuicTestClient();
76 79
77 // ExpectCertificates controls whether the server is expected to provide 80 // ExpectCertificates controls whether the server is expected to provide
78 // certificates. The certificates, if any, are not verified, but the common 81 // certificates. The certificates, if any, are not verified, but the common
79 // name is recorded and available with |cert_common_name()|. 82 // name is recorded and available with |cert_common_name()|.
80 void ExpectCertificates(bool on); 83 void ExpectCertificates(bool on);
81 84
85 // Sets the |user_agent_id| of the |client_|.
86 void SetUserAgentID(const string& user_agent_id);
87
82 // Wraps data in a quic packet and sends it. 88 // Wraps data in a quic packet and sends it.
83 ssize_t SendData(string data, bool last_data); 89 ssize_t SendData(string data, bool last_data);
84 90
85 // From SimpleClient 91 // From SimpleClient
86 // Clears any outstanding state and sends a simple GET of 'uri' to the 92 // Clears any outstanding state and sends a simple GET of 'uri' to the
87 // server. Returns 0 if the request failed and no bytes were written. 93 // server. Returns 0 if the request failed and no bytes were written.
88 virtual ssize_t SendRequest(const string& uri) OVERRIDE; 94 virtual ssize_t SendRequest(const string& uri) OVERRIDE;
89 virtual ssize_t SendMessage(const HTTPMessage& message) OVERRIDE; 95 virtual ssize_t SendMessage(const HTTPMessage& message) OVERRIDE;
90 virtual string SendCustomSynchronousRequest( 96 virtual string SendCustomSynchronousRequest(
91 const HTTPMessage& message) OVERRIDE; 97 const HTTPMessage& message) OVERRIDE;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 void set_auto_reconnect(bool reconnect) { auto_reconnect_ = reconnect; } 156 void set_auto_reconnect(bool reconnect) { auto_reconnect_ = reconnect; }
151 157
152 void set_priority(QuicPriority priority) { priority_ = priority; } 158 void set_priority(QuicPriority priority) { priority_ = priority; }
153 159
154 // Sets client's FEC policy. This policy applies to the data stream(s), and 160 // Sets client's FEC policy. This policy applies to the data stream(s), and
155 // also to the headers and crypto streams. 161 // also to the headers and crypto streams.
156 void SetFecPolicy(FecPolicy fec_policy); 162 void SetFecPolicy(FecPolicy fec_policy);
157 163
158 void WaitForWriteToFlush(); 164 void WaitForWriteToFlush();
159 165
166 EpollServer* epoll_server() { return &epoll_server_; }
167
160 protected: 168 protected:
161 QuicTestClient(); 169 QuicTestClient();
162 170
163 void Initialize(bool secure); 171 void Initialize(bool secure);
164 172
165 void set_client(MockableQuicClient* client) { client_.reset(client); } 173 void set_client(MockableQuicClient* client) { client_.reset(client); }
166 174
167 private: 175 private:
176 EpollServer epoll_server_;
168 scoped_ptr<MockableQuicClient> client_; // The actual client 177 scoped_ptr<MockableQuicClient> client_; // The actual client
169 QuicSpdyClientStream* stream_; 178 QuicSpdyClientStream* stream_;
170 179
171 QuicRstStreamErrorCode stream_error_; 180 QuicRstStreamErrorCode stream_error_;
172 181
173 bool response_complete_; 182 bool response_complete_;
174 bool response_headers_complete_; 183 bool response_headers_complete_;
175 BalsaHeaders headers_; 184 BalsaHeaders headers_;
176 QuicPriority priority_; 185 QuicPriority priority_;
177 string response_; 186 string response_;
(...skipping 20 matching lines...) Expand all
198 207
199 DISALLOW_COPY_AND_ASSIGN(QuicTestClient); 208 DISALLOW_COPY_AND_ASSIGN(QuicTestClient);
200 }; 209 };
201 210
202 } // namespace test 211 } // namespace test
203 212
204 } // namespace tools 213 } // namespace tools
205 } // namespace net 214 } // namespace net
206 215
207 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ 216 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_
OLDNEW
« no previous file with comments | « net/tools/quic/test_tools/mock_quic_dispatcher.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