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

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

Issue 15937012: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Small bug fixes Created 7 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_QUIC_TEST_TOOLS_QUIC_CLIENT_H_ 5 #ifndef NET_QUIC_TEST_TOOLS_QUIC_CLIENT_H_
6 #define NET_QUIC_TEST_TOOLS_QUIC_CLIENT_H_ 6 #define NET_QUIC_TEST_TOOLS_QUIC_CLIENT_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "net/quic/quic_framer.h" 11 #include "net/quic/quic_framer.h"
12 #include "net/quic/quic_packet_creator.h" 12 #include "net/quic/quic_packet_creator.h"
13 #include "net/quic/quic_protocol.h" 13 #include "net/quic/quic_protocol.h"
14 #include "net/tools/quic/quic_client.h" 14 #include "net/tools/quic/quic_client.h"
15 15
16 namespace net { 16 namespace net {
17 namespace tools { 17 namespace tools {
18 18
19 namespace test { 19 namespace test {
20 20
21 class HTTPMessage; 21 class HTTPMessage;
22 22
23 // A toy QUIC client used for testing. 23 // A toy QUIC client used for testing.
24 class QuicTestClient : public ReliableQuicStream::Visitor { 24 class QuicTestClient : public ReliableQuicStream::Visitor {
25 public: 25 public:
26 QuicTestClient(IPEndPoint server_address, const string& server_hostname); 26 QuicTestClient(IPEndPoint server_address, const string& server_hostname);
27 QuicTestClient(IPEndPoint server_address, 27 QuicTestClient(IPEndPoint server_address,
28 const string& server_hostname, 28 const string& server_hostname,
29 bool secure);
30 QuicTestClient(IPEndPoint server_address,
31 const string& server_hostname,
29 const QuicConfig& config); 32 const QuicConfig& config);
30 33
31 virtual ~QuicTestClient(); 34 virtual ~QuicTestClient();
32 35
33 // Clears any outstanding state and sends a simple GET of 'uri' to the 36 // Clears any outstanding state and sends a simple GET of 'uri' to the
34 // server. Returns 0 if the request failed and no bytes were written. 37 // server. Returns 0 if the request failed and no bytes were written.
35 ssize_t SendRequest(const string& uri); 38 ssize_t SendRequest(const string& uri);
36 ssize_t SendMessage(const HTTPMessage& message); 39 ssize_t SendMessage(const HTTPMessage& message);
37 40
38 string SendCustomSynchronousRequest(const HTTPMessage& message); 41 string SendCustomSynchronousRequest(const HTTPMessage& message);
(...skipping 28 matching lines...) Expand all
67 QuicReliableClientStream* GetOrCreateStream(); 70 QuicReliableClientStream* GetOrCreateStream();
68 71
69 QuicRstStreamErrorCode stream_error() { return stream_error_; } 72 QuicRstStreamErrorCode stream_error() { return stream_error_; }
70 QuicErrorCode connection_error() { return connection_error_; } 73 QuicErrorCode connection_error() { return connection_error_; }
71 74
72 QuicClient* client() { return &client_; } 75 QuicClient* client() { return &client_; }
73 76
74 const string& response_body() {return response_;} 77 const string& response_body() {return response_;}
75 bool connected() const; 78 bool connected() const;
76 79
80 void set_auto_reconnect(bool reconnect) { auto_reconnect_ = reconnect; }
81
77 private: 82 private:
83 void Initialize(IPEndPoint address, const string& hostname);
84
78 IPEndPoint server_address_; 85 IPEndPoint server_address_;
79 IPEndPoint client_address_; 86 IPEndPoint client_address_;
80 QuicClient client_; // The actual client 87 QuicClient client_; // The actual client
81 QuicReliableClientStream* stream_; 88 QuicReliableClientStream* stream_;
82 89
83 QuicRstStreamErrorCode stream_error_; 90 QuicRstStreamErrorCode stream_error_;
84 QuicErrorCode connection_error_; 91 QuicErrorCode connection_error_;
85 92
86 BalsaHeaders headers_; 93 BalsaHeaders headers_;
87 string response_; 94 string response_;
88 uint64 bytes_read_; 95 uint64 bytes_read_;
89 uint64 bytes_written_; 96 uint64 bytes_written_;
90 // True if the client has never connected before. The client will 97 // True if the client has never connected before. The client will
91 // auto-connect exactly once before sending data. If something causes a 98 // auto-connect exactly once before sending data. If something causes a
92 // connection reset, it will not automatically reconnect. 99 // connection reset, it will not automatically reconnect.
93 bool never_connected_; 100 bool never_connected_;
101 bool secure_;
102 // If true, the client will always reconnect if necessary before creating a
103 // stream.
104 bool auto_reconnect_;
94 }; 105 };
95 106
96 } // namespace test 107 } // namespace test
97 108
98 } // namespace tools 109 } // namespace tools
99 } // namespace net 110 } // namespace net
100 111
101 #endif // NET_QUIC_TEST_TOOLS_QUIC_CLIENT_H_ 112 #endif // NET_QUIC_TEST_TOOLS_QUIC_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698