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

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

Issue 763833003: Remove using namespace in net/quic/quic_stream_sequencer.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix missing part device_cloud_policy_manager_chromeos_unittest.cc Created 6 years 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
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 QuicPacketWriterWrapper* test_writer_; 56 QuicPacketWriterWrapper* test_writer_;
57 57
58 DISALLOW_COPY_AND_ASSIGN(MockableQuicClient); 58 DISALLOW_COPY_AND_ASSIGN(MockableQuicClient);
59 }; 59 };
60 60
61 // A toy QUIC client used for testing, mostly following the SimpleClient APIs. 61 // A toy QUIC client used for testing, mostly following the SimpleClient APIs.
62 class QuicTestClient : public SimpleClient, 62 class QuicTestClient : public SimpleClient,
63 public QuicDataStream::Visitor { 63 public QuicDataStream::Visitor {
64 public: 64 public:
65 QuicTestClient(IPEndPoint server_address, 65 QuicTestClient(IPEndPoint server_address,
66 const string& server_hostname, 66 const std::string& server_hostname,
67 bool secure, 67 bool secure,
68 const QuicVersionVector& supported_versions); 68 const QuicVersionVector& supported_versions);
69 QuicTestClient(IPEndPoint server_address, 69 QuicTestClient(IPEndPoint server_address,
70 const string& server_hostname, 70 const std::string& server_hostname,
71 bool secure, 71 bool secure,
72 const QuicConfig& config, 72 const QuicConfig& config,
73 const QuicVersionVector& supported_versions); 73 const QuicVersionVector& supported_versions);
74 74
75 ~QuicTestClient() override; 75 ~QuicTestClient() override;
76 76
77 // ExpectCertificates controls whether the server is expected to provide 77 // ExpectCertificates controls whether the server is expected to provide
78 // certificates. The certificates, if any, are not verified, but the common 78 // certificates. The certificates, if any, are not verified, but the common
79 // name is recorded and available with |cert_common_name()|. 79 // name is recorded and available with |cert_common_name()|.
80 void ExpectCertificates(bool on); 80 void ExpectCertificates(bool on);
81 81
82 // Sets the |user_agent_id| of the |client_|. 82 // Sets the |user_agent_id| of the |client_|.
83 void SetUserAgentID(const string& user_agent_id); 83 void SetUserAgentID(const std::string& user_agent_id);
84 84
85 // Wraps data in a quic packet and sends it. 85 // Wraps data in a quic packet and sends it.
86 ssize_t SendData(string data, bool last_data); 86 ssize_t SendData(std::string data, bool last_data);
87 87
88 // From SimpleClient 88 // From SimpleClient
89 // Clears any outstanding state and sends a simple GET of 'uri' to the 89 // Clears any outstanding state and sends a simple GET of 'uri' to the
90 // server. Returns 0 if the request failed and no bytes were written. 90 // server. Returns 0 if the request failed and no bytes were written.
91 ssize_t SendRequest(const string& uri) override; 91 ssize_t SendRequest(const std::string& uri) override;
92 ssize_t SendMessage(const HTTPMessage& message) override; 92 ssize_t SendMessage(const HTTPMessage& message) override;
93 string SendCustomSynchronousRequest(const HTTPMessage& message) override; 93 std::string SendCustomSynchronousRequest(const HTTPMessage& message) override;
94 string SendSynchronousRequest(const string& uri) override; 94 std::string SendSynchronousRequest(const std::string& uri) override;
95 void Connect() override; 95 void Connect() override;
96 void ResetConnection() override; 96 void ResetConnection() override;
97 void Disconnect() override; 97 void Disconnect() override;
98 IPEndPoint LocalSocketAddress() const override; 98 IPEndPoint LocalSocketAddress() const override;
99 void ClearPerRequestState() override; 99 void ClearPerRequestState() override;
100 void WaitForResponseForMs(int timeout_ms) override; 100 void WaitForResponseForMs(int timeout_ms) override;
101 void WaitForInitialResponseForMs(int timeout_ms) override; 101 void WaitForInitialResponseForMs(int timeout_ms) override;
102 ssize_t Send(const void* buffer, size_t size) override; 102 ssize_t Send(const void* buffer, size_t size) override;
103 bool response_complete() const override; 103 bool response_complete() const override;
104 bool response_headers_complete() const override; 104 bool response_headers_complete() const override;
105 const BalsaHeaders* response_headers() const override; 105 const BalsaHeaders* response_headers() const override;
106 int64 response_size() const override; 106 int64 response_size() const override;
107 int response_header_size() const override; 107 int response_header_size() const override;
108 int64 response_body_size() const override; 108 int64 response_body_size() const override;
109 size_t bytes_read() const override; 109 size_t bytes_read() const override;
110 size_t bytes_written() const override; 110 size_t bytes_written() const override;
111 bool buffer_body() const override; 111 bool buffer_body() const override;
112 void set_buffer_body(bool buffer_body) override; 112 void set_buffer_body(bool buffer_body) override;
113 bool ServerInLameDuckMode() const override; 113 bool ServerInLameDuckMode() const override;
114 const string& response_body() override; 114 const std::string& response_body() override;
115 bool connected() const override; 115 bool connected() const override;
116 // These functions are all unimplemented functions from SimpleClient, and log 116 // These functions are all unimplemented functions from SimpleClient, and log
117 // DFATAL if called by users of SimpleClient. 117 // DFATAL if called by users of SimpleClient.
118 ssize_t SendAndWaitForResponse(const void* buffer, size_t size) override; 118 ssize_t SendAndWaitForResponse(const void* buffer, size_t size) override;
119 void Bind(IPEndPoint* local_address) override; 119 void Bind(IPEndPoint* local_address) override;
120 string SerializeMessage(const HTTPMessage& message) override; 120 std::string SerializeMessage(const HTTPMessage& message) override;
121 IPAddressNumber bind_to_address() const override; 121 IPAddressNumber bind_to_address() const override;
122 void set_bind_to_address(IPAddressNumber address) override; 122 void set_bind_to_address(IPAddressNumber address) override;
123 const IPEndPoint& address() const override; 123 const IPEndPoint& address() const override;
124 size_t requests_sent() const override; 124 size_t requests_sent() const override;
125 125
126 // From QuicDataStream::Visitor 126 // From QuicDataStream::Visitor
127 void OnClose(QuicDataStream* stream) override; 127 void OnClose(QuicDataStream* stream) override;
128 128
129 // Configures client_ to take ownership of and use the writer. 129 // Configures client_ to take ownership of and use the writer.
130 // Must be called before initial connect. 130 // Must be called before initial connect.
131 void UseWriter(QuicPacketWriterWrapper* writer); 131 void UseWriter(QuicPacketWriterWrapper* writer);
132 // If the given ConnectionId is nonzero, configures client_ to use a specific 132 // If the given ConnectionId is nonzero, configures client_ to use a specific
133 // ConnectionId instead of a random one. 133 // ConnectionId instead of a random one.
134 void UseConnectionId(QuicConnectionId connection_id); 134 void UseConnectionId(QuicConnectionId connection_id);
135 135
136 // Returns nullptr if the maximum number of streams have already been created. 136 // Returns nullptr if the maximum number of streams have already been created.
137 QuicSpdyClientStream* GetOrCreateStream(); 137 QuicSpdyClientStream* GetOrCreateStream();
138 138
139 QuicRstStreamErrorCode stream_error() { return stream_error_; } 139 QuicRstStreamErrorCode stream_error() { return stream_error_; }
140 QuicErrorCode connection_error(); 140 QuicErrorCode connection_error();
141 141
142 MockableQuicClient* client(); 142 MockableQuicClient* client();
143 143
144 // cert_common_name returns the common name value of the server's certificate, 144 // cert_common_name returns the common name value of the server's certificate,
145 // or the empty string if no certificate was presented. 145 // or the empty string if no certificate was presented.
146 const string& cert_common_name() const; 146 const std::string& cert_common_name() const;
147 147
148 // Get the server config map. 148 // Get the server config map.
149 QuicTagValueMap GetServerConfig() const; 149 QuicTagValueMap GetServerConfig() const;
150 150
151 void set_auto_reconnect(bool reconnect) { auto_reconnect_ = reconnect; } 151 void set_auto_reconnect(bool reconnect) { auto_reconnect_ = reconnect; }
152 152
153 void set_priority(QuicPriority priority) { priority_ = priority; } 153 void set_priority(QuicPriority priority) { priority_ = priority; }
154 154
155 // Sets client's FEC policy. This policy applies to the data stream(s), and 155 // Sets client's FEC policy. This policy applies to the data stream(s), and
156 // also to the headers and crypto streams. 156 // also to the headers and crypto streams.
(...skipping 14 matching lines...) Expand all
171 EpollServer epoll_server_; 171 EpollServer epoll_server_;
172 scoped_ptr<MockableQuicClient> client_; // The actual client 172 scoped_ptr<MockableQuicClient> client_; // The actual client
173 QuicSpdyClientStream* stream_; 173 QuicSpdyClientStream* stream_;
174 174
175 QuicRstStreamErrorCode stream_error_; 175 QuicRstStreamErrorCode stream_error_;
176 176
177 bool response_complete_; 177 bool response_complete_;
178 bool response_headers_complete_; 178 bool response_headers_complete_;
179 BalsaHeaders headers_; 179 BalsaHeaders headers_;
180 QuicPriority priority_; 180 QuicPriority priority_;
181 string response_; 181 std::string response_;
182 uint64 bytes_read_; 182 uint64 bytes_read_;
183 uint64 bytes_written_; 183 uint64 bytes_written_;
184 // The number of uncompressed HTTP header bytes received. 184 // The number of uncompressed HTTP header bytes received.
185 int response_header_size_; 185 int response_header_size_;
186 // The number of HTTP body bytes received. 186 // The number of HTTP body bytes received.
187 int64 response_body_size_; 187 int64 response_body_size_;
188 // True if we tried to connect already since the last call to Disconnect(). 188 // True if we tried to connect already since the last call to Disconnect().
189 bool connect_attempted_; 189 bool connect_attempted_;
190 bool secure_; 190 bool secure_;
191 // The client will auto-connect exactly once before sending data. If 191 // The client will auto-connect exactly once before sending data. If
(...skipping 10 matching lines...) Expand all
202 202
203 DISALLOW_COPY_AND_ASSIGN(QuicTestClient); 203 DISALLOW_COPY_AND_ASSIGN(QuicTestClient);
204 }; 204 };
205 205
206 } // namespace test 206 } // namespace test
207 207
208 } // namespace tools 208 } // namespace tools
209 } // namespace net 209 } // namespace net
210 210
211 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ 211 #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.h ('k') | net/url_request/url_request_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698