| OLD | NEW |
| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 ~QuicTestClient() override; | 108 ~QuicTestClient() override; |
| 109 | 109 |
| 110 // Sets the |user_agent_id| of the |client_|. | 110 // Sets the |user_agent_id| of the |client_|. |
| 111 void SetUserAgentID(const std::string& user_agent_id); | 111 void SetUserAgentID(const std::string& user_agent_id); |
| 112 | 112 |
| 113 // Wraps data in a quic packet and sends it. | 113 // Wraps data in a quic packet and sends it. |
| 114 ssize_t SendData(const std::string& data, bool last_data); | 114 ssize_t SendData(const std::string& data, bool last_data); |
| 115 // As above, but |delegate| will be notified when |data| is ACKed. | 115 // As above, but |delegate| will be notified when |data| is ACKed. |
| 116 ssize_t SendData(const std::string& data, | 116 ssize_t SendData(const std::string& data, |
| 117 bool last_data, | 117 bool last_data, |
| 118 QuicAckListenerInterface* delegate); | 118 const scoped_refptr<QuicAckListenerInterface>& delegate); |
| 119 | 119 |
| 120 // Clears any outstanding state and sends a simple GET of 'uri' to the | 120 // Clears any outstanding state and sends a simple GET of 'uri' to the |
| 121 // server. Returns 0 if the request failed and no bytes were written. | 121 // server. Returns 0 if the request failed and no bytes were written. |
| 122 ssize_t SendRequest(const std::string& uri); | 122 ssize_t SendRequest(const std::string& uri); |
| 123 // Sends requests for all the urls and waits for the responses. To process | 123 // Sends requests for all the urls and waits for the responses. To process |
| 124 // the individual responses as they are returned, the caller should use the | 124 // the individual responses as they are returned, the caller should use the |
| 125 // set the response_listener on the client(). | 125 // set the response_listener on the client(). |
| 126 void SendRequestsAndWaitForResponses( | 126 void SendRequestsAndWaitForResponses( |
| 127 const std::vector<std::string>& url_list); | 127 const std::vector<std::string>& url_list); |
| 128 // Sends a request containing |headers| and |body| and returns the number of | 128 // Sends a request containing |headers| and |body| and returns the number of |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 void UseConnectionId(QuicConnectionId connection_id); | 208 void UseConnectionId(QuicConnectionId connection_id); |
| 209 | 209 |
| 210 // Update internal stream_ pointer and perform accompanying housekeeping. | 210 // Update internal stream_ pointer and perform accompanying housekeeping. |
| 211 void SetStream(QuicSpdyClientStream* stream); | 211 void SetStream(QuicSpdyClientStream* stream); |
| 212 // Returns nullptr if the maximum number of streams have already been created. | 212 // Returns nullptr if the maximum number of streams have already been created. |
| 213 QuicSpdyClientStream* GetOrCreateStream(); | 213 QuicSpdyClientStream* GetOrCreateStream(); |
| 214 | 214 |
| 215 // Calls GetOrCreateStream(), sends the request on the stream, and | 215 // Calls GetOrCreateStream(), sends the request on the stream, and |
| 216 // stores the request in case it needs to be resent. If |headers| is | 216 // stores the request in case it needs to be resent. If |headers| is |
| 217 // null, only the body will be sent on the stream. | 217 // null, only the body will be sent on the stream. |
| 218 ssize_t GetOrCreateStreamAndSendRequest(const SpdyHeaderBlock* headers, | 218 ssize_t GetOrCreateStreamAndSendRequest( |
| 219 base::StringPiece body, | 219 const SpdyHeaderBlock* headers, |
| 220 bool fin, | 220 base::StringPiece body, |
| 221 QuicAckListenerInterface* delegate); | 221 bool fin, |
| 222 const scoped_refptr<QuicAckListenerInterface>& delegate); |
| 222 | 223 |
| 223 QuicRstStreamErrorCode stream_error() { return stream_error_; } | 224 QuicRstStreamErrorCode stream_error() { return stream_error_; } |
| 224 QuicErrorCode connection_error(); | 225 QuicErrorCode connection_error(); |
| 225 | 226 |
| 226 MockableQuicClient* client(); | 227 MockableQuicClient* client(); |
| 227 | 228 |
| 228 // cert_common_name returns the common name value of the server's certificate, | 229 // cert_common_name returns the common name value of the server's certificate, |
| 229 // or the empty string if no certificate was presented. | 230 // or the empty string if no certificate was presented. |
| 230 const std::string& cert_common_name() const; | 231 const std::string& cert_common_name() const; |
| 231 | 232 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 void Initialize(); | 269 void Initialize(); |
| 269 | 270 |
| 270 void set_client(MockableQuicClient* client) { client_.reset(client); } | 271 void set_client(MockableQuicClient* client) { client_.reset(client); } |
| 271 | 272 |
| 272 protected: | 273 protected: |
| 273 QuicTestClient(); | 274 QuicTestClient(); |
| 274 | 275 |
| 275 private: | 276 private: |
| 276 class TestClientDataToResend : public QuicClient::QuicDataToResend { | 277 class TestClientDataToResend : public QuicClient::QuicDataToResend { |
| 277 public: | 278 public: |
| 278 TestClientDataToResend(std::unique_ptr<SpdyHeaderBlock> headers, | 279 TestClientDataToResend( |
| 279 base::StringPiece body, | 280 std::unique_ptr<SpdyHeaderBlock> headers, |
| 280 bool fin, | 281 base::StringPiece body, |
| 281 QuicTestClient* test_client, | 282 bool fin, |
| 282 QuicAckListenerInterface* delegate) | 283 QuicTestClient* test_client, |
| 283 : QuicClient::QuicDataToResend(std::move(headers), body, fin), | 284 const scoped_refptr<QuicAckListenerInterface>& delegate); |
| 284 test_client_(test_client), | |
| 285 delegate_(delegate) {} | |
| 286 | 285 |
| 287 ~TestClientDataToResend() override {} | 286 ~TestClientDataToResend() override; |
| 288 | 287 |
| 289 void Resend() override; | 288 void Resend() override; |
| 290 | 289 |
| 291 protected: | 290 protected: |
| 292 QuicTestClient* test_client_; | 291 QuicTestClient* test_client_; |
| 293 QuicAckListenerInterface* delegate_; | 292 scoped_refptr<QuicAckListenerInterface> delegate_; |
| 294 }; | 293 }; |
| 295 | 294 |
| 296 // Given |uri|, populates the fields in |headers| for a simple GET | 295 // Given |uri|, populates the fields in |headers| for a simple GET |
| 297 // request. If |uri| is a relative URL, the QuicServerId will be | 296 // request. If |uri| is a relative URL, the QuicServerId will be |
| 298 // use to specify the authority. | 297 // use to specify the authority. |
| 299 bool PopulateHeaderBlockFromUrl(const std::string& uri, | 298 bool PopulateHeaderBlockFromUrl(const std::string& uri, |
| 300 SpdyHeaderBlock* headers); | 299 SpdyHeaderBlock* headers); |
| 301 | 300 |
| 302 bool HaveActiveStream(); | 301 bool HaveActiveStream(); |
| 303 | 302 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 std::string override_sni_; | 345 std::string override_sni_; |
| 347 | 346 |
| 348 DISALLOW_COPY_AND_ASSIGN(QuicTestClient); | 347 DISALLOW_COPY_AND_ASSIGN(QuicTestClient); |
| 349 }; | 348 }; |
| 350 | 349 |
| 351 } // namespace test | 350 } // namespace test |
| 352 | 351 |
| 353 } // namespace net | 352 } // namespace net |
| 354 | 353 |
| 355 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ | 354 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ |
| OLD | NEW |