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

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

Issue 131743009: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use size_t instead of int to fix win_x64 compile error Created 6 years, 11 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_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ 5 #ifndef NET_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_
6 #define NET_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ 6 #define NET_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/quic/quic_framer.h" 12 #include "net/quic/quic_framer.h"
13 #include "net/quic/quic_packet_creator.h" 13 #include "net/quic/quic_packet_creator.h"
14 #include "net/quic/quic_protocol.h" 14 #include "net/quic/quic_protocol.h"
15 #include "net/quic/test_tools/quic_test_writer.h"
16 #include "net/tools/quic/quic_client.h" 15 #include "net/tools/quic/quic_client.h"
17 16
18 namespace net { 17 namespace net {
19 18
20 class ProofVerifier; 19 class ProofVerifier;
21 20
22 namespace tools { 21 namespace tools {
23 22
23 class QuicPacketWriterWrapper;
24
24 namespace test { 25 namespace test {
25 26
26 class HTTPMessage; 27 class HTTPMessage;
28 class MockableQuicClient;
27 29
28 // A toy QUIC client used for testing. 30 // A toy QUIC client used for testing.
29 class QuicTestClient : public QuicDataStream::Visitor { 31 class QuicTestClient : public QuicDataStream::Visitor {
30 public: 32 public:
31 QuicTestClient(IPEndPoint server_address, const string& server_hostname, 33 QuicTestClient(IPEndPoint server_address, const string& server_hostname,
32 const QuicVersionVector& supported_versions); 34 const QuicVersionVector& supported_versions);
33 QuicTestClient(IPEndPoint server_address, 35 QuicTestClient(IPEndPoint server_address,
34 const string& server_hostname, 36 const string& server_hostname,
35 bool secure, 37 bool secure,
36 const QuicVersionVector& supported_versions); 38 const QuicVersionVector& supported_versions);
(...skipping 14 matching lines...) Expand all
51 // server. Returns 0 if the request failed and no bytes were written. 53 // server. Returns 0 if the request failed and no bytes were written.
52 ssize_t SendRequest(const string& uri); 54 ssize_t SendRequest(const string& uri);
53 ssize_t SendMessage(const HTTPMessage& message); 55 ssize_t SendMessage(const HTTPMessage& message);
54 56
55 string SendCustomSynchronousRequest(const HTTPMessage& message); 57 string SendCustomSynchronousRequest(const HTTPMessage& message);
56 string SendSynchronousRequest(const string& uri); 58 string SendSynchronousRequest(const string& uri);
57 59
58 // Wraps data in a quic packet and sends it. 60 // Wraps data in a quic packet and sends it.
59 ssize_t SendData(string data, bool last_data); 61 ssize_t SendData(string data, bool last_data);
60 62
61 QuicPacketCreator::Options* options() { return client_->options(); } 63 QuicPacketCreator::Options* options();
62 64
63 void WaitForResponse(); 65 void WaitForResponse();
64 66
65 void Connect(); 67 void Connect();
66 void ResetConnection(); 68 void ResetConnection();
67 void Disconnect(); 69 void Disconnect();
68 IPEndPoint LocalSocketAddress() const; 70 IPEndPoint LocalSocketAddress() const;
69 void ClearPerRequestState(); 71 void ClearPerRequestState();
70 void WaitForResponseForMs(int timeout_ms); 72 void WaitForResponseForMs(int timeout_ms);
71 void WaitForInitialResponseForMs(int timeout_ms); 73 void WaitForInitialResponseForMs(int timeout_ms);
72 ssize_t Send(const void *buffer, size_t size); 74 ssize_t Send(const void *buffer, size_t size);
73 bool response_complete() const { return response_complete_; } 75 bool response_complete() const { return response_complete_; }
74 bool response_headers_complete() const; 76 bool response_headers_complete() const;
75 const BalsaHeaders* response_headers() const; 77 const BalsaHeaders* response_headers() const;
76 int response_size() const; 78 int response_size() const;
77 int response_header_size() const { return response_header_size_; } 79 int response_header_size() const { return response_header_size_; }
78 int response_body_size() const { return response_body_size_; } 80 int response_body_size() const { return response_body_size_; }
79 size_t bytes_read() const; 81 size_t bytes_read() const;
80 size_t bytes_written() const; 82 size_t bytes_written() const;
81 bool buffer_body() const { return buffer_body_; } 83 bool buffer_body() const { return buffer_body_; }
82 void set_buffer_body(bool buffer_body) { buffer_body_ = buffer_body; } 84 void set_buffer_body(bool buffer_body) { buffer_body_ = buffer_body; }
83 85
84 // From QuicDataStream::Visitor 86 // From QuicDataStream::Visitor
85 virtual void OnClose(QuicDataStream* stream) OVERRIDE; 87 virtual void OnClose(QuicDataStream* stream) OVERRIDE;
86 88
87 // Configures client_ to take ownership of and use the writer. 89 // Configures client_ to take ownership of and use the writer.
88 // Must be called before initial connect. 90 // Must be called before initial connect.
89 void UseWriter(net::test::QuicTestWriter* writer); 91 void UseWriter(QuicPacketWriterWrapper* writer);
90 // If the given GUID is nonzero, configures client_ to use a specific GUID 92 // If the given GUID is nonzero, configures client_ to use a specific GUID
91 // instead of a random one. 93 // instead of a random one.
92 void UseGuid(QuicGuid guid); 94 void UseGuid(QuicGuid guid);
93 95
94 // Returns NULL if the maximum number of streams have already been created. 96 // Returns NULL if the maximum number of streams have already been created.
95 QuicSpdyClientStream* GetOrCreateStream(); 97 QuicSpdyClientStream* GetOrCreateStream();
96 98
97 QuicRstStreamErrorCode stream_error() { return stream_error_; } 99 QuicRstStreamErrorCode stream_error() { return stream_error_; }
98 QuicErrorCode connection_error() { return client()->session()->error(); } 100 QuicErrorCode connection_error();
99 101
100 QuicClient* client() { return client_.get(); } 102 QuicClient* client();
101 103
102 // cert_common_name returns the common name value of the server's certificate, 104 // cert_common_name returns the common name value of the server's certificate,
103 // or the empty string if no certificate was presented. 105 // or the empty string if no certificate was presented.
104 const string& cert_common_name() const; 106 const string& cert_common_name() const;
105 107
106 // Get the server config map. 108 // Get the server config map.
107 QuicTagValueMap GetServerConfig() const; 109 QuicTagValueMap GetServerConfig() const;
108 110
109 const string& response_body() {return response_;} 111 const string& response_body() {return response_;}
110 bool connected() const; 112 bool connected() const;
111 113
112 void set_auto_reconnect(bool reconnect) { auto_reconnect_ = reconnect; } 114 void set_auto_reconnect(bool reconnect) { auto_reconnect_ = reconnect; }
113 115
114 void set_priority(QuicPriority priority) { priority_ = priority; } 116 void set_priority(QuicPriority priority) { priority_ = priority; }
115 117
116 void WaitForWriteToFlush(); 118 void WaitForWriteToFlush();
117 119
118 private: 120 private:
119 void Initialize(IPEndPoint address, const string& hostname, bool secure); 121 void Initialize(IPEndPoint address, const string& hostname, bool secure);
120 122
121 IPEndPoint server_address_; 123 IPEndPoint server_address_;
122 IPEndPoint client_address_; 124 IPEndPoint client_address_;
123 scoped_ptr<QuicClient> client_; // The actual client 125 scoped_ptr<MockableQuicClient> client_; // The actual client
124 QuicSpdyClientStream* stream_; 126 QuicSpdyClientStream* stream_;
125 127
126 QuicRstStreamErrorCode stream_error_; 128 QuicRstStreamErrorCode stream_error_;
127 129
128 bool response_complete_; 130 bool response_complete_;
129 bool response_headers_complete_; 131 bool response_headers_complete_;
130 BalsaHeaders headers_; 132 BalsaHeaders headers_;
131 QuicPriority priority_; 133 QuicPriority priority_;
132 string response_; 134 string response_;
133 uint64 bytes_read_; 135 uint64 bytes_read_;
(...skipping 16 matching lines...) Expand all
150 // client_. 152 // client_.
151 ProofVerifier* proof_verifier_; 153 ProofVerifier* proof_verifier_;
152 }; 154 };
153 155
154 } // namespace test 156 } // namespace test
155 157
156 } // namespace tools 158 } // namespace tools
157 } // namespace net 159 } // namespace net
158 160
159 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ 161 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_
OLDNEW
« no previous file with comments | « net/tools/quic/test_tools/quic_dispatcher_peer.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