| 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 // This file contains some protocol structures for use with SPDY 2 and 3 | 5 // This file contains some protocol structures for use with SPDY 2 and 3 |
| 6 // The SPDY 2 spec can be found at: | 6 // The SPDY 2 spec can be found at: |
| 7 // http://dev.chromium.org/spdy/spdy-protocol/spdy-protocol-draft2 | 7 // http://dev.chromium.org/spdy/spdy-protocol/spdy-protocol-draft2 |
| 8 // The SPDY 3 spec can be found at: | 8 // The SPDY 3 spec can be found at: |
| 9 // http://dev.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3 | 9 // http://dev.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3 |
| 10 | 10 |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 GOAWAY_ENHANCE_YOUR_CALM = 11, | 413 GOAWAY_ENHANCE_YOUR_CALM = 11, |
| 414 GOAWAY_INADEQUATE_SECURITY = 12, | 414 GOAWAY_INADEQUATE_SECURITY = 12, |
| 415 GOAWAY_HTTP_1_1_REQUIRED = 13 | 415 GOAWAY_HTTP_1_1_REQUIRED = 13 |
| 416 }; | 416 }; |
| 417 | 417 |
| 418 // A SPDY priority is a number between 0 and 7 (inclusive). | 418 // A SPDY priority is a number between 0 and 7 (inclusive). |
| 419 // SPDY priority range is version-dependent. For SPDY 2 and below, priority is a | 419 // SPDY priority range is version-dependent. For SPDY 2 and below, priority is a |
| 420 // number between 0 and 3. | 420 // number between 0 and 3. |
| 421 typedef uint8 SpdyPriority; | 421 typedef uint8 SpdyPriority; |
| 422 | 422 |
| 423 typedef std::map<std::string, std::string> SpdyNameValueBlock; | 423 // A datastructure for holding a set of headers from a HEADERS, PUSH_PROMISE, |
| 424 // SYN_STREAM, or SYN_REPLY frame. |
| 425 typedef std::map<std::string, std::string> SpdyHeaderBlock; |
| 424 | 426 |
| 425 typedef uint64 SpdyPingId; | 427 typedef uint64 SpdyPingId; |
| 426 | 428 |
| 427 typedef std::string SpdyProtocolId; | 429 typedef std::string SpdyProtocolId; |
| 428 | 430 |
| 429 enum class SpdyHeaderValidatorType { REQUEST, RESPONSE }; | 431 enum class SpdyHeaderValidatorType { REQUEST, RESPONSE }; |
| 430 | 432 |
| 431 // TODO(hkhalil): Add direct testing for this? It won't increase coverage any, | 433 // TODO(hkhalil): Add direct testing for this? It won't increase coverage any, |
| 432 // but is good to do anyway. | 434 // but is good to do anyway. |
| 433 class NET_EXPORT_PRIVATE SpdyConstants { | 435 class NET_EXPORT_PRIVATE SpdyConstants { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 explicit SpdyFrameWithFinIR(SpdyStreamId stream_id) | 596 explicit SpdyFrameWithFinIR(SpdyStreamId stream_id) |
| 595 : SpdyFrameWithStreamIdIR(stream_id), | 597 : SpdyFrameWithStreamIdIR(stream_id), |
| 596 fin_(false) {} | 598 fin_(false) {} |
| 597 | 599 |
| 598 private: | 600 private: |
| 599 bool fin_; | 601 bool fin_; |
| 600 | 602 |
| 601 DISALLOW_COPY_AND_ASSIGN(SpdyFrameWithFinIR); | 603 DISALLOW_COPY_AND_ASSIGN(SpdyFrameWithFinIR); |
| 602 }; | 604 }; |
| 603 | 605 |
| 604 // Abstract class intended to be inherited by IRs that contain a name-value | 606 // Abstract class intended to be inherited by IRs that contain a header |
| 605 // block. Implies SpdyFrameWithFinIR. | 607 // block. Implies SpdyFrameWithFinIR. |
| 606 class NET_EXPORT_PRIVATE SpdyFrameWithNameValueBlockIR | 608 class NET_EXPORT_PRIVATE SpdyFrameWithHeaderBlockIR |
| 607 : public NON_EXPORTED_BASE(SpdyFrameWithFinIR) { | 609 : public NON_EXPORTED_BASE(SpdyFrameWithFinIR) { |
| 608 public: | 610 public: |
| 609 const SpdyNameValueBlock& name_value_block() const { | 611 const SpdyHeaderBlock& header_block() const { return header_block_; } |
| 610 return name_value_block_; | 612 void set_header_block(const SpdyHeaderBlock& header_block) { |
| 611 } | |
| 612 void set_name_value_block(const SpdyNameValueBlock& name_value_block) { | |
| 613 // Deep copy. | 613 // Deep copy. |
| 614 name_value_block_ = name_value_block; | 614 header_block_ = header_block; |
| 615 } | 615 } |
| 616 void SetHeader(base::StringPiece name, base::StringPiece value) { | 616 void SetHeader(base::StringPiece name, base::StringPiece value) { |
| 617 name_value_block_[name.as_string()] = value.as_string(); | 617 header_block_[name.as_string()] = value.as_string(); |
| 618 } | 618 } |
| 619 SpdyNameValueBlock* mutable_name_value_block() { | 619 SpdyHeaderBlock* mutable_header_block() { return &header_block_; } |
| 620 return &name_value_block_; | |
| 621 } | |
| 622 | 620 |
| 623 protected: | 621 protected: |
| 624 explicit SpdyFrameWithNameValueBlockIR(SpdyStreamId stream_id); | 622 explicit SpdyFrameWithHeaderBlockIR(SpdyStreamId stream_id); |
| 625 ~SpdyFrameWithNameValueBlockIR() override; | 623 ~SpdyFrameWithHeaderBlockIR() override; |
| 626 | 624 |
| 627 private: | 625 private: |
| 628 SpdyNameValueBlock name_value_block_; | 626 SpdyHeaderBlock header_block_; |
| 629 | 627 |
| 630 DISALLOW_COPY_AND_ASSIGN(SpdyFrameWithNameValueBlockIR); | 628 DISALLOW_COPY_AND_ASSIGN(SpdyFrameWithHeaderBlockIR); |
| 631 }; | 629 }; |
| 632 | 630 |
| 633 class NET_EXPORT_PRIVATE SpdyDataIR | 631 class NET_EXPORT_PRIVATE SpdyDataIR |
| 634 : public NON_EXPORTED_BASE(SpdyFrameWithFinIR) { | 632 : public NON_EXPORTED_BASE(SpdyFrameWithFinIR) { |
| 635 public: | 633 public: |
| 636 // Performs deep copy on data. | 634 // Performs deep copy on data. |
| 637 SpdyDataIR(SpdyStreamId stream_id, base::StringPiece data); | 635 SpdyDataIR(SpdyStreamId stream_id, base::StringPiece data); |
| 638 | 636 |
| 639 // Use in conjunction with SetDataShallow() for shallow-copy on data. | 637 // Use in conjunction with SetDataShallow() for shallow-copy on data. |
| 640 explicit SpdyDataIR(SpdyStreamId stream_id); | 638 explicit SpdyDataIR(SpdyStreamId stream_id); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 scoped_ptr<std::string> data_store_; | 672 scoped_ptr<std::string> data_store_; |
| 675 base::StringPiece data_; | 673 base::StringPiece data_; |
| 676 | 674 |
| 677 bool padded_; | 675 bool padded_; |
| 678 // padding_payload_len_ = desired padding length - len(padding length field). | 676 // padding_payload_len_ = desired padding length - len(padding length field). |
| 679 int padding_payload_len_; | 677 int padding_payload_len_; |
| 680 | 678 |
| 681 DISALLOW_COPY_AND_ASSIGN(SpdyDataIR); | 679 DISALLOW_COPY_AND_ASSIGN(SpdyDataIR); |
| 682 }; | 680 }; |
| 683 | 681 |
| 684 class NET_EXPORT_PRIVATE SpdySynStreamIR | 682 class NET_EXPORT_PRIVATE SpdySynStreamIR : public SpdyFrameWithHeaderBlockIR { |
| 685 : public SpdyFrameWithNameValueBlockIR { | |
| 686 public: | 683 public: |
| 687 explicit SpdySynStreamIR(SpdyStreamId stream_id) | 684 explicit SpdySynStreamIR(SpdyStreamId stream_id) |
| 688 : SpdyFrameWithNameValueBlockIR(stream_id), | 685 : SpdyFrameWithHeaderBlockIR(stream_id), |
| 689 associated_to_stream_id_(0), | 686 associated_to_stream_id_(0), |
| 690 priority_(0), | 687 priority_(0), |
| 691 unidirectional_(false) {} | 688 unidirectional_(false) {} |
| 692 SpdyStreamId associated_to_stream_id() const { | 689 SpdyStreamId associated_to_stream_id() const { |
| 693 return associated_to_stream_id_; | 690 return associated_to_stream_id_; |
| 694 } | 691 } |
| 695 void set_associated_to_stream_id(SpdyStreamId stream_id) { | 692 void set_associated_to_stream_id(SpdyStreamId stream_id) { |
| 696 associated_to_stream_id_ = stream_id; | 693 associated_to_stream_id_ = stream_id; |
| 697 } | 694 } |
| 698 SpdyPriority priority() const { return priority_; } | 695 SpdyPriority priority() const { return priority_; } |
| 699 void set_priority(SpdyPriority priority) { priority_ = priority; } | 696 void set_priority(SpdyPriority priority) { priority_ = priority; } |
| 700 bool unidirectional() const { return unidirectional_; } | 697 bool unidirectional() const { return unidirectional_; } |
| 701 void set_unidirectional(bool unidirectional) { | 698 void set_unidirectional(bool unidirectional) { |
| 702 unidirectional_ = unidirectional; | 699 unidirectional_ = unidirectional; |
| 703 } | 700 } |
| 704 | 701 |
| 705 void Visit(SpdyFrameVisitor* visitor) const override; | 702 void Visit(SpdyFrameVisitor* visitor) const override; |
| 706 | 703 |
| 707 private: | 704 private: |
| 708 SpdyStreamId associated_to_stream_id_; | 705 SpdyStreamId associated_to_stream_id_; |
| 709 SpdyPriority priority_; | 706 SpdyPriority priority_; |
| 710 bool unidirectional_; | 707 bool unidirectional_; |
| 711 | 708 |
| 712 DISALLOW_COPY_AND_ASSIGN(SpdySynStreamIR); | 709 DISALLOW_COPY_AND_ASSIGN(SpdySynStreamIR); |
| 713 }; | 710 }; |
| 714 | 711 |
| 715 class NET_EXPORT_PRIVATE SpdySynReplyIR : public SpdyFrameWithNameValueBlockIR { | 712 class NET_EXPORT_PRIVATE SpdySynReplyIR : public SpdyFrameWithHeaderBlockIR { |
| 716 public: | 713 public: |
| 717 explicit SpdySynReplyIR(SpdyStreamId stream_id) | 714 explicit SpdySynReplyIR(SpdyStreamId stream_id) |
| 718 : SpdyFrameWithNameValueBlockIR(stream_id) {} | 715 : SpdyFrameWithHeaderBlockIR(stream_id) {} |
| 719 | 716 |
| 720 void Visit(SpdyFrameVisitor* visitor) const override; | 717 void Visit(SpdyFrameVisitor* visitor) const override; |
| 721 | 718 |
| 722 private: | 719 private: |
| 723 DISALLOW_COPY_AND_ASSIGN(SpdySynReplyIR); | 720 DISALLOW_COPY_AND_ASSIGN(SpdySynReplyIR); |
| 724 }; | 721 }; |
| 725 | 722 |
| 726 class NET_EXPORT_PRIVATE SpdyRstStreamIR : public SpdyFrameWithStreamIdIR { | 723 class NET_EXPORT_PRIVATE SpdyRstStreamIR : public SpdyFrameWithStreamIdIR { |
| 727 public: | 724 public: |
| 728 SpdyRstStreamIR(SpdyStreamId stream_id, SpdyRstStreamStatus status, | 725 SpdyRstStreamIR(SpdyStreamId stream_id, SpdyRstStreamStatus status, |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 void Visit(SpdyFrameVisitor* visitor) const override; | 830 void Visit(SpdyFrameVisitor* visitor) const override; |
| 834 | 831 |
| 835 private: | 832 private: |
| 836 SpdyStreamId last_good_stream_id_; | 833 SpdyStreamId last_good_stream_id_; |
| 837 SpdyGoAwayStatus status_; | 834 SpdyGoAwayStatus status_; |
| 838 const base::StringPiece description_; | 835 const base::StringPiece description_; |
| 839 | 836 |
| 840 DISALLOW_COPY_AND_ASSIGN(SpdyGoAwayIR); | 837 DISALLOW_COPY_AND_ASSIGN(SpdyGoAwayIR); |
| 841 }; | 838 }; |
| 842 | 839 |
| 843 class NET_EXPORT_PRIVATE SpdyHeadersIR : public SpdyFrameWithNameValueBlockIR { | 840 class NET_EXPORT_PRIVATE SpdyHeadersIR : public SpdyFrameWithHeaderBlockIR { |
| 844 public: | 841 public: |
| 845 explicit SpdyHeadersIR(SpdyStreamId stream_id) | 842 explicit SpdyHeadersIR(SpdyStreamId stream_id) |
| 846 : SpdyFrameWithNameValueBlockIR(stream_id) {} | 843 : SpdyFrameWithHeaderBlockIR(stream_id) {} |
| 847 | 844 |
| 848 void Visit(SpdyFrameVisitor* visitor) const override; | 845 void Visit(SpdyFrameVisitor* visitor) const override; |
| 849 | 846 |
| 850 bool has_priority() const { return has_priority_; } | 847 bool has_priority() const { return has_priority_; } |
| 851 void set_has_priority(bool has_priority) { has_priority_ = has_priority; } | 848 void set_has_priority(bool has_priority) { has_priority_ = has_priority; } |
| 852 uint32 priority() const { return priority_; } | 849 uint32 priority() const { return priority_; } |
| 853 void set_priority(SpdyPriority priority) { priority_ = priority; } | 850 void set_priority(SpdyPriority priority) { priority_ = priority; } |
| 854 SpdyStreamId parent_stream_id() const { return parent_stream_id_; } | 851 SpdyStreamId parent_stream_id() const { return parent_stream_id_; } |
| 855 void set_parent_stream_id(SpdyStreamId id) { parent_stream_id_ = id; } | 852 void set_parent_stream_id(SpdyStreamId id) { parent_stream_id_ = id; } |
| 856 bool exclusive() const { return exclusive_; } | 853 bool exclusive() const { return exclusive_; } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 public: | 900 public: |
| 904 explicit SpdyBlockedIR(SpdyStreamId stream_id) | 901 explicit SpdyBlockedIR(SpdyStreamId stream_id) |
| 905 : SpdyFrameWithStreamIdIR(stream_id) {} | 902 : SpdyFrameWithStreamIdIR(stream_id) {} |
| 906 | 903 |
| 907 void Visit(SpdyFrameVisitor* visitor) const override; | 904 void Visit(SpdyFrameVisitor* visitor) const override; |
| 908 | 905 |
| 909 private: | 906 private: |
| 910 DISALLOW_COPY_AND_ASSIGN(SpdyBlockedIR); | 907 DISALLOW_COPY_AND_ASSIGN(SpdyBlockedIR); |
| 911 }; | 908 }; |
| 912 | 909 |
| 913 class NET_EXPORT_PRIVATE SpdyPushPromiseIR | 910 class NET_EXPORT_PRIVATE SpdyPushPromiseIR : public SpdyFrameWithHeaderBlockIR { |
| 914 : public SpdyFrameWithNameValueBlockIR { | |
| 915 public: | 911 public: |
| 916 SpdyPushPromiseIR(SpdyStreamId stream_id, SpdyStreamId promised_stream_id) | 912 SpdyPushPromiseIR(SpdyStreamId stream_id, SpdyStreamId promised_stream_id) |
| 917 : SpdyFrameWithNameValueBlockIR(stream_id), | 913 : SpdyFrameWithHeaderBlockIR(stream_id), |
| 918 promised_stream_id_(promised_stream_id), | 914 promised_stream_id_(promised_stream_id), |
| 919 padded_(false), | 915 padded_(false), |
| 920 padding_payload_len_(0) {} | 916 padding_payload_len_(0) {} |
| 921 SpdyStreamId promised_stream_id() const { return promised_stream_id_; } | 917 SpdyStreamId promised_stream_id() const { return promised_stream_id_; } |
| 922 | 918 |
| 923 void Visit(SpdyFrameVisitor* visitor) const override; | 919 void Visit(SpdyFrameVisitor* visitor) const override; |
| 924 | 920 |
| 925 bool padded() const { return padded_; } | 921 bool padded() const { return padded_; } |
| 926 int padding_payload_len() const { return padding_payload_len_; } | 922 int padding_payload_len() const { return padding_payload_len_; } |
| 927 void set_padding_len(int padding_len) { | 923 void set_padding_len(int padding_len) { |
| 928 DCHECK_GT(padding_len, 0); | 924 DCHECK_GT(padding_len, 0); |
| 929 DCHECK_LE(padding_len, kPaddingSizePerFrame); | 925 DCHECK_LE(padding_len, kPaddingSizePerFrame); |
| 930 padded_ = true; | 926 padded_ = true; |
| 931 // The pad field takes one octet on the wire. | 927 // The pad field takes one octet on the wire. |
| 932 padding_payload_len_ = padding_len - 1; | 928 padding_payload_len_ = padding_len - 1; |
| 933 } | 929 } |
| 934 | 930 |
| 935 private: | 931 private: |
| 936 SpdyStreamId promised_stream_id_; | 932 SpdyStreamId promised_stream_id_; |
| 937 | 933 |
| 938 bool padded_; | 934 bool padded_; |
| 939 int padding_payload_len_; | 935 int padding_payload_len_; |
| 940 | 936 |
| 941 DISALLOW_COPY_AND_ASSIGN(SpdyPushPromiseIR); | 937 DISALLOW_COPY_AND_ASSIGN(SpdyPushPromiseIR); |
| 942 }; | 938 }; |
| 943 | 939 |
| 944 // TODO(jgraettinger): This representation needs review. SpdyContinuationIR | 940 // TODO(jgraettinger): This representation needs review. SpdyContinuationIR |
| 945 // needs to frame a portion of a single, arbitrarily-broken encoded buffer. | 941 // needs to frame a portion of a single, arbitrarily-broken encoded buffer. |
| 946 class NET_EXPORT_PRIVATE SpdyContinuationIR | 942 class NET_EXPORT_PRIVATE SpdyContinuationIR |
| 947 : public SpdyFrameWithNameValueBlockIR { | 943 : public SpdyFrameWithHeaderBlockIR { |
| 948 public: | 944 public: |
| 949 explicit SpdyContinuationIR(SpdyStreamId stream_id) | 945 explicit SpdyContinuationIR(SpdyStreamId stream_id) |
| 950 : SpdyFrameWithNameValueBlockIR(stream_id), | 946 : SpdyFrameWithHeaderBlockIR(stream_id), end_headers_(false) {} |
| 951 end_headers_(false) {} | |
| 952 | 947 |
| 953 void Visit(SpdyFrameVisitor* visitor) const override; | 948 void Visit(SpdyFrameVisitor* visitor) const override; |
| 954 | 949 |
| 955 bool end_headers() const { return end_headers_; } | 950 bool end_headers() const { return end_headers_; } |
| 956 void set_end_headers(bool end_headers) {end_headers_ = end_headers;} | 951 void set_end_headers(bool end_headers) {end_headers_ = end_headers;} |
| 957 | 952 |
| 958 private: | 953 private: |
| 959 bool end_headers_; | 954 bool end_headers_; |
| 960 DISALLOW_COPY_AND_ASSIGN(SpdyContinuationIR); | 955 DISALLOW_COPY_AND_ASSIGN(SpdyContinuationIR); |
| 961 }; | 956 }; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1082 SpdyFrameVisitor() {} | 1077 SpdyFrameVisitor() {} |
| 1083 virtual ~SpdyFrameVisitor() {} | 1078 virtual ~SpdyFrameVisitor() {} |
| 1084 | 1079 |
| 1085 private: | 1080 private: |
| 1086 DISALLOW_COPY_AND_ASSIGN(SpdyFrameVisitor); | 1081 DISALLOW_COPY_AND_ASSIGN(SpdyFrameVisitor); |
| 1087 }; | 1082 }; |
| 1088 | 1083 |
| 1089 } // namespace net | 1084 } // namespace net |
| 1090 | 1085 |
| 1091 #endif // NET_SPDY_SPDY_PROTOCOL_H_ | 1086 #endif // NET_SPDY_SPDY_PROTOCOL_H_ |
| OLD | NEW |