| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_SPDY_SPDY_TEST_UTIL_COMMON_H_ | 5 #ifndef NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ |
| 6 #define NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ | 6 #define NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 | 289 |
| 290 class SpdyTestUtil { | 290 class SpdyTestUtil { |
| 291 public: | 291 public: |
| 292 explicit SpdyTestUtil(NextProto protocol, bool dependency_priorities); | 292 explicit SpdyTestUtil(NextProto protocol, bool dependency_priorities); |
| 293 ~SpdyTestUtil(); | 293 ~SpdyTestUtil(); |
| 294 | 294 |
| 295 // Add the appropriate headers to put |url| into |block|. | 295 // Add the appropriate headers to put |url| into |block|. |
| 296 void AddUrlToHeaderBlock(base::StringPiece url, | 296 void AddUrlToHeaderBlock(base::StringPiece url, |
| 297 SpdyHeaderBlock* headers) const; | 297 SpdyHeaderBlock* headers) const; |
| 298 | 298 |
| 299 std::unique_ptr<SpdyHeaderBlock> ConstructGetHeaderBlock( | 299 SpdyHeaderBlock ConstructGetHeaderBlock(base::StringPiece url) const; |
| 300 base::StringPiece url) const; | 300 SpdyHeaderBlock ConstructGetHeaderBlockForProxy(base::StringPiece url) const; |
| 301 std::unique_ptr<SpdyHeaderBlock> ConstructGetHeaderBlockForProxy( | 301 SpdyHeaderBlock ConstructHeadHeaderBlock(base::StringPiece url, |
| 302 base::StringPiece url) const; | 302 int64_t content_length) const; |
| 303 std::unique_ptr<SpdyHeaderBlock> ConstructHeadHeaderBlock( | 303 SpdyHeaderBlock ConstructPostHeaderBlock(base::StringPiece url, |
| 304 base::StringPiece url, | 304 int64_t content_length) const; |
| 305 int64_t content_length) const; | 305 SpdyHeaderBlock ConstructPutHeaderBlock(base::StringPiece url, |
| 306 std::unique_ptr<SpdyHeaderBlock> ConstructPostHeaderBlock( | 306 int64_t content_length) const; |
| 307 base::StringPiece url, | |
| 308 int64_t content_length) const; | |
| 309 std::unique_ptr<SpdyHeaderBlock> ConstructPutHeaderBlock( | |
| 310 base::StringPiece url, | |
| 311 int64_t content_length) const; | |
| 312 | 307 |
| 313 // Construct a SPDY frame. If it is a SYN_STREAM or SYN_REPLY frame (as | 308 // Construct a SPDY frame. If it is a SYN_STREAM or SYN_REPLY frame (as |
| 314 // specified in header_info.kind), the provided headers are included in the | 309 // specified in header_info.kind), the provided headers are included in the |
| 315 // frame. | 310 // frame. |
| 316 SpdySerializedFrame* ConstructSpdyFrame( | 311 SpdySerializedFrame* ConstructSpdyFrame(const SpdyHeaderInfo& header_info, |
| 317 const SpdyHeaderInfo& header_info, | 312 SpdyHeaderBlock headers) const; |
| 318 std::unique_ptr<SpdyHeaderBlock> headers) const; | |
| 319 | 313 |
| 320 // Construct a SPDY frame. If it is a SYN_STREAM or SYN_REPLY frame (as | 314 // Construct a SPDY frame. If it is a SYN_STREAM or SYN_REPLY frame (as |
| 321 // specified in header_info.kind), the headers provided in extra_headers and | 315 // specified in header_info.kind), the headers provided in extra_headers and |
| 322 // (if non-NULL) tail_headers are concatenated and included in the frame. | 316 // (if non-NULL) tail_headers are concatenated and included in the frame. |
| 323 // (extra_headers must always be non-NULL.) | 317 // (extra_headers must always be non-NULL.) |
| 324 SpdySerializedFrame* ConstructSpdyFrame(const SpdyHeaderInfo& header_info, | 318 SpdySerializedFrame* ConstructSpdyFrame(const SpdyHeaderInfo& header_info, |
| 325 const char* const extra_headers[], | 319 const char* const extra_headers[], |
| 326 int extra_header_count, | 320 int extra_header_count, |
| 327 const char* const tail_headers[], | 321 const char* const tail_headers[], |
| 328 int tail_header_count) const; | 322 int tail_header_count) const; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 int associated_stream_id, | 398 int associated_stream_id, |
| 405 const char* url); | 399 const char* url); |
| 406 SpdySerializedFrame* ConstructSpdyPush(const char* const extra_headers[], | 400 SpdySerializedFrame* ConstructSpdyPush(const char* const extra_headers[], |
| 407 int extra_header_count, | 401 int extra_header_count, |
| 408 int stream_id, | 402 int stream_id, |
| 409 int associated_stream_id, | 403 int associated_stream_id, |
| 410 const char* url, | 404 const char* url, |
| 411 const char* status, | 405 const char* status, |
| 412 const char* location); | 406 const char* location); |
| 413 | 407 |
| 414 SpdySerializedFrame* ConstructInitialSpdyPushFrame( | 408 SpdySerializedFrame* ConstructInitialSpdyPushFrame(SpdyHeaderBlock headers, |
| 415 std::unique_ptr<SpdyHeaderBlock> headers, | 409 int stream_id, |
| 416 int stream_id, | 410 int associated_stream_id); |
| 417 int associated_stream_id); | |
| 418 | 411 |
| 419 SpdySerializedFrame* ConstructSpdyPushHeaders( | 412 SpdySerializedFrame* ConstructSpdyPushHeaders( |
| 420 int stream_id, | 413 int stream_id, |
| 421 const char* const extra_headers[], | 414 const char* const extra_headers[], |
| 422 int extra_header_count); | 415 int extra_header_count); |
| 423 | 416 |
| 424 // Constructs a SPDY header frame with the request header compression context | 417 // Constructs a SPDY header frame with the request header compression context |
| 425 // with END_STREAM flag set to |fin|. | 418 // with END_STREAM flag set to |fin|. |
| 426 SpdySerializedFrame* ConstructSpdyResponseHeaders( | 419 SpdySerializedFrame* ConstructSpdyResponseHeaders(int stream_id, |
| 427 int stream_id, | 420 SpdyHeaderBlock headers, |
| 428 const SpdyHeaderBlock& headers, | 421 bool fin); |
| 429 bool fin); | |
| 430 | 422 |
| 431 // Construct a SPDY syn (HEADERS or SYN_STREAM, depending on protocol | 423 // Construct a SPDY syn (HEADERS or SYN_STREAM, depending on protocol |
| 432 // version) carrying exactly the given headers and priority. | 424 // version) carrying exactly the given headers and priority. |
| 433 SpdySerializedFrame* ConstructSpdySyn(int stream_id, | 425 SpdySerializedFrame* ConstructSpdySyn(int stream_id, |
| 434 const SpdyHeaderBlock& headers, | 426 SpdyHeaderBlock headers, |
| 435 RequestPriority priority, | 427 RequestPriority priority, |
| 436 bool fin); | 428 bool fin); |
| 437 | 429 |
| 438 // Construct a SPDY reply (HEADERS or SYN_REPLY, depending on protocol | 430 // Construct a SPDY reply (HEADERS or SYN_REPLY, depending on protocol |
| 439 // version) carrying exactly the given headers, and the default priority | 431 // version) carrying exactly the given headers, and the default priority |
| 440 // (or no priority, depending on protocol version). | 432 // (or no priority, depending on protocol version). |
| 441 SpdySerializedFrame* ConstructSpdyReply(int stream_id, | 433 SpdySerializedFrame* ConstructSpdyReply(int stream_id, |
| 442 const SpdyHeaderBlock& headers); | 434 SpdyHeaderBlock headers); |
| 443 | 435 |
| 444 // Constructs a standard SPDY SYN_REPLY frame to match the SPDY GET. | 436 // Constructs a standard SPDY SYN_REPLY frame to match the SPDY GET. |
| 445 // |extra_headers| are the extra header-value pairs, which typically | 437 // |extra_headers| are the extra header-value pairs, which typically |
| 446 // will vary the most between calls. | 438 // will vary the most between calls. |
| 447 // Returns a SpdySerializedFrame. | 439 // Returns a SpdySerializedFrame. |
| 448 SpdySerializedFrame* ConstructSpdyGetSynReply( | 440 SpdySerializedFrame* ConstructSpdyGetSynReply( |
| 449 const char* const extra_headers[], | 441 const char* const extra_headers[], |
| 450 int extra_header_count, | 442 int extra_header_count, |
| 451 int stream_id); | 443 int stream_id); |
| 452 | 444 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 const char* GetMethodKey() const; | 533 const char* GetMethodKey() const; |
| 542 const char* GetStatusKey() const; | 534 const char* GetStatusKey() const; |
| 543 const char* GetHostKey() const; | 535 const char* GetHostKey() const; |
| 544 const char* GetSchemeKey() const; | 536 const char* GetSchemeKey() const; |
| 545 const char* GetVersionKey() const; | 537 const char* GetVersionKey() const; |
| 546 const char* GetPathKey() const; | 538 const char* GetPathKey() const; |
| 547 | 539 |
| 548 private: | 540 private: |
| 549 // |content_length| may be NULL, in which case the content-length | 541 // |content_length| may be NULL, in which case the content-length |
| 550 // header will be omitted. | 542 // header will be omitted. |
| 551 std::unique_ptr<SpdyHeaderBlock> ConstructHeaderBlock( | 543 SpdyHeaderBlock ConstructHeaderBlock(base::StringPiece method, |
| 552 base::StringPiece method, | 544 base::StringPiece url, |
| 553 base::StringPiece url, | 545 int64_t* content_length) const; |
| 554 int64_t* content_length) const; | |
| 555 | 546 |
| 556 const NextProto protocol_; | 547 const NextProto protocol_; |
| 557 const SpdyMajorVersion spdy_version_; | 548 const SpdyMajorVersion spdy_version_; |
| 558 | 549 |
| 559 // Multiple SpdyFramers are required to keep track of header compression | 550 // Multiple SpdyFramers are required to keep track of header compression |
| 560 // state. | 551 // state. |
| 561 // Use to serialize frames (request or response) without headers. | 552 // Use to serialize frames (request or response) without headers. |
| 562 SpdyFramer headerless_spdy_framer_; | 553 SpdyFramer headerless_spdy_framer_; |
| 563 // Use to serialize request frames with headers. | 554 // Use to serialize request frames with headers. |
| 564 SpdyFramer request_spdy_framer_; | 555 SpdyFramer request_spdy_framer_; |
| 565 // Use to serialize response frames with headers. | 556 // Use to serialize response frames with headers. |
| 566 SpdyFramer response_spdy_framer_; | 557 SpdyFramer response_spdy_framer_; |
| 567 | 558 |
| 568 GURL default_url_; | 559 GURL default_url_; |
| 569 bool dependency_priorities_; | 560 bool dependency_priorities_; |
| 570 | 561 |
| 571 // Track a FIFO list of the stream_id of all created requests by priority. | 562 // Track a FIFO list of the stream_id of all created requests by priority. |
| 572 std::map<int, std::vector<int>> priority_to_stream_id_list_; | 563 std::map<int, std::vector<int>> priority_to_stream_id_list_; |
| 573 }; | 564 }; |
| 574 | 565 |
| 575 } // namespace net | 566 } // namespace net |
| 576 | 567 |
| 577 #endif // NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ | 568 #endif // NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ |
| OLD | NEW |