| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // Default upload data used by both, mock objects and framer when creating | 45 // Default upload data used by both, mock objects and framer when creating |
| 46 // data frames. | 46 // data frames. |
| 47 const char kDefaultURL[] = "http://www.example.org/"; | 47 const char kDefaultURL[] = "http://www.example.org/"; |
| 48 const char kUploadData[] = "hello!"; | 48 const char kUploadData[] = "hello!"; |
| 49 const int kUploadDataSize = arraysize(kUploadData)-1; | 49 const int kUploadDataSize = arraysize(kUploadData)-1; |
| 50 | 50 |
| 51 // SpdyNextProtos returns a vector of next protocols for negotiating | 51 // SpdyNextProtos returns a vector of next protocols for negotiating |
| 52 // SPDY. | 52 // SPDY. |
| 53 NextProtoVector SpdyNextProtos(); | 53 NextProtoVector SpdyNextProtos(); |
| 54 | 54 |
| 55 // Chop a frame into an array of MockWrites. | |
| 56 // |data| is the frame to chop. | |
| 57 // |length| is the length of the frame to chop. | |
| 58 // |num_chunks| is the number of chunks to create. | |
| 59 MockWrite* ChopWriteFrame(const char* data, int length, int num_chunks); | |
| 60 | |
| 61 // Chop a SpdyFrame into an array of MockWrites. | 55 // Chop a SpdyFrame into an array of MockWrites. |
| 62 // |frame| is the frame to chop. | 56 // |frame| is the frame to chop. |
| 63 // |num_chunks| is the number of chunks to create. | 57 // |num_chunks| is the number of chunks to create. |
| 64 MockWrite* ChopWriteFrame(const SpdyFrame& frame, int num_chunks); | 58 MockWrite* ChopWriteFrame(const SpdyFrame& frame, int num_chunks); |
| 65 | 59 |
| 66 // Chop a frame into an array of MockReads. | |
| 67 // |data| is the frame to chop. | |
| 68 // |length| is the length of the frame to chop. | |
| 69 // |num_chunks| is the number of chunks to create. | |
| 70 MockRead* ChopReadFrame(const char* data, int length, int num_chunks); | |
| 71 | |
| 72 // Chop a SpdyFrame into an array of MockReads. | |
| 73 // |frame| is the frame to chop. | |
| 74 // |num_chunks| is the number of chunks to create. | |
| 75 MockRead* ChopReadFrame(const SpdyFrame& frame, int num_chunks); | |
| 76 | |
| 77 // Adds headers and values to a map. | 60 // Adds headers and values to a map. |
| 78 // |extra_headers| is an array of { name, value } pairs, arranged as strings | 61 // |extra_headers| is an array of { name, value } pairs, arranged as strings |
| 79 // where the even entries are the header names, and the odd entries are the | 62 // where the even entries are the header names, and the odd entries are the |
| 80 // header values. | 63 // header values. |
| 81 // |headers| gets filled in from |extra_headers|. | 64 // |headers| gets filled in from |extra_headers|. |
| 82 void AppendToHeaderBlock(const char* const extra_headers[], | 65 void AppendToHeaderBlock(const char* const extra_headers[], |
| 83 int extra_header_count, | 66 int extra_header_count, |
| 84 SpdyHeaderBlock* headers); | 67 SpdyHeaderBlock* headers); |
| 85 | 68 |
| 86 // Create an async MockWrite from the given SpdyFrame. | 69 // Create an async MockWrite from the given SpdyFrame. |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 // Constructs a standard SPDY GET SYN frame, optionally compressed | 391 // Constructs a standard SPDY GET SYN frame, optionally compressed |
| 409 // for |url|. | 392 // for |url|. |
| 410 // |extra_headers| are the extra header-value pairs, which typically | 393 // |extra_headers| are the extra header-value pairs, which typically |
| 411 // will vary the most between calls. | 394 // will vary the most between calls. |
| 412 // Returns a SpdyFrame. | 395 // Returns a SpdyFrame. |
| 413 SpdyFrame* ConstructSpdyGet(const char* const url, | 396 SpdyFrame* ConstructSpdyGet(const char* const url, |
| 414 bool compressed, | 397 bool compressed, |
| 415 SpdyStreamId stream_id, | 398 SpdyStreamId stream_id, |
| 416 RequestPriority request_priority); | 399 RequestPriority request_priority); |
| 417 | 400 |
| 418 SpdyFrame* ConstructSpdyGetForProxy(const char* const url, | |
| 419 bool compressed, | |
| 420 SpdyStreamId stream_id, | |
| 421 RequestPriority request_priority) const; | |
| 422 | |
| 423 // Constructs a standard SPDY GET SYN frame, optionally compressed. | 401 // Constructs a standard SPDY GET SYN frame, optionally compressed. |
| 424 // |extra_headers| are the extra header-value pairs, which typically | 402 // |extra_headers| are the extra header-value pairs, which typically |
| 425 // will vary the most between calls. If |direct| is false, the | 403 // will vary the most between calls. If |direct| is false, the |
| 426 // the full url will be used instead of simply the path. | 404 // the full url will be used instead of simply the path. |
| 427 // Returns a SpdyFrame. | 405 // Returns a SpdyFrame. |
| 428 SpdyFrame* ConstructSpdyGet(const char* const extra_headers[], | 406 SpdyFrame* ConstructSpdyGet(const char* const extra_headers[], |
| 429 int extra_header_count, | 407 int extra_header_count, |
| 430 bool compressed, | 408 bool compressed, |
| 431 int stream_id, | 409 int stream_id, |
| 432 RequestPriority request_priority, | 410 RequestPriority request_priority, |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 | 528 |
| 551 // Wraps |frame| in the payload of a data frame in stream |stream_id|. | 529 // Wraps |frame| in the payload of a data frame in stream |stream_id|. |
| 552 SpdyFrame* ConstructWrappedSpdyFrame(const scoped_ptr<SpdyFrame>& frame, | 530 SpdyFrame* ConstructWrappedSpdyFrame(const scoped_ptr<SpdyFrame>& frame, |
| 553 int stream_id); | 531 int stream_id); |
| 554 | 532 |
| 555 // Called when necessary (when it will affect stream dependency specification | 533 // Called when necessary (when it will affect stream dependency specification |
| 556 // when setting dependencies based on priorioties) to notify the utility | 534 // when setting dependencies based on priorioties) to notify the utility |
| 557 // class of stream destruction. | 535 // class of stream destruction. |
| 558 void UpdateWithStreamDestruction(int stream_id); | 536 void UpdateWithStreamDestruction(int stream_id); |
| 559 | 537 |
| 560 const SpdyHeaderInfo MakeSpdyHeader(SpdyFrameType type); | |
| 561 | |
| 562 // For versions below SPDY4, adds the version HTTP/1.1 header. | 538 // For versions below SPDY4, adds the version HTTP/1.1 header. |
| 563 void MaybeAddVersionHeader(SpdyFrameWithHeaderBlockIR* frame_ir) const; | 539 void MaybeAddVersionHeader(SpdyFrameWithHeaderBlockIR* frame_ir) const; |
| 564 void MaybeAddVersionHeader(SpdyHeaderBlock* block) const; | 540 void MaybeAddVersionHeader(SpdyHeaderBlock* block) const; |
| 565 | 541 |
| 566 // Maps |priority| to SPDY version priority, and sets it on |frame_ir|. | 542 // Maps |priority| to SPDY version priority, and sets it on |frame_ir|. |
| 567 void SetPriority(RequestPriority priority, SpdySynStreamIR* frame_ir) const; | 543 void SetPriority(RequestPriority priority, SpdySynStreamIR* frame_ir) const; |
| 568 | 544 |
| 569 NextProto protocol() const { return protocol_; } | 545 NextProto protocol() const { return protocol_; } |
| 570 SpdyMajorVersion spdy_version() const { return spdy_version_; } | 546 SpdyMajorVersion spdy_version() const { return spdy_version_; } |
| 571 bool include_version_header() const { return protocol_ < kProtoHTTP2; } | 547 bool include_version_header() const { return protocol_ < kProtoHTTP2; } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 594 GURL default_url_; | 570 GURL default_url_; |
| 595 bool dependency_priorities_; | 571 bool dependency_priorities_; |
| 596 | 572 |
| 597 // Track a FIFO list of the stream_id of all created requests by priority. | 573 // Track a FIFO list of the stream_id of all created requests by priority. |
| 598 std::map<int, std::vector<int>> priority_to_stream_id_list_; | 574 std::map<int, std::vector<int>> priority_to_stream_id_list_; |
| 599 }; | 575 }; |
| 600 | 576 |
| 601 } // namespace net | 577 } // namespace net |
| 602 | 578 |
| 603 #endif // NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ | 579 #endif // NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ |
| OLD | NEW |