| 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 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 class NET_EXPORT_PRIVATE SpdyFrameWithNameValueBlockIR | 607 class NET_EXPORT_PRIVATE SpdyFrameWithNameValueBlockIR |
| 608 : public NON_EXPORTED_BASE(SpdyFrameWithFinIR) { | 608 : public NON_EXPORTED_BASE(SpdyFrameWithFinIR) { |
| 609 public: | 609 public: |
| 610 const SpdyNameValueBlock& name_value_block() const { | 610 const SpdyNameValueBlock& name_value_block() const { |
| 611 return name_value_block_; | 611 return name_value_block_; |
| 612 } | 612 } |
| 613 void set_name_value_block(const SpdyNameValueBlock& name_value_block) { | 613 void set_name_value_block(const SpdyNameValueBlock& name_value_block) { |
| 614 // Deep copy. | 614 // Deep copy. |
| 615 name_value_block_ = name_value_block; | 615 name_value_block_ = name_value_block; |
| 616 } | 616 } |
| 617 void SetHeader(const base::StringPiece& name, | 617 void SetHeader(base::StringPiece name, base::StringPiece value) { |
| 618 const base::StringPiece& value) { | |
| 619 name_value_block_[name.as_string()] = value.as_string(); | 618 name_value_block_[name.as_string()] = value.as_string(); |
| 620 } | 619 } |
| 621 SpdyNameValueBlock* mutable_name_value_block() { | 620 SpdyNameValueBlock* mutable_name_value_block() { |
| 622 return &name_value_block_; | 621 return &name_value_block_; |
| 623 } | 622 } |
| 624 | 623 |
| 625 protected: | 624 protected: |
| 626 explicit SpdyFrameWithNameValueBlockIR(SpdyStreamId stream_id); | 625 explicit SpdyFrameWithNameValueBlockIR(SpdyStreamId stream_id); |
| 627 ~SpdyFrameWithNameValueBlockIR() override; | 626 ~SpdyFrameWithNameValueBlockIR() override; |
| 628 | 627 |
| 629 private: | 628 private: |
| 630 SpdyNameValueBlock name_value_block_; | 629 SpdyNameValueBlock name_value_block_; |
| 631 | 630 |
| 632 DISALLOW_COPY_AND_ASSIGN(SpdyFrameWithNameValueBlockIR); | 631 DISALLOW_COPY_AND_ASSIGN(SpdyFrameWithNameValueBlockIR); |
| 633 }; | 632 }; |
| 634 | 633 |
| 635 class NET_EXPORT_PRIVATE SpdyDataIR | 634 class NET_EXPORT_PRIVATE SpdyDataIR |
| 636 : public NON_EXPORTED_BASE(SpdyFrameWithFinIR) { | 635 : public NON_EXPORTED_BASE(SpdyFrameWithFinIR) { |
| 637 public: | 636 public: |
| 638 // Performs deep copy on data. | 637 // Performs deep copy on data. |
| 639 SpdyDataIR(SpdyStreamId stream_id, const base::StringPiece& data); | 638 SpdyDataIR(SpdyStreamId stream_id, base::StringPiece data); |
| 640 | 639 |
| 641 // Use in conjunction with SetDataShallow() for shallow-copy on data. | 640 // Use in conjunction with SetDataShallow() for shallow-copy on data. |
| 642 explicit SpdyDataIR(SpdyStreamId stream_id); | 641 explicit SpdyDataIR(SpdyStreamId stream_id); |
| 643 | 642 |
| 644 ~SpdyDataIR() override; | 643 ~SpdyDataIR() override; |
| 645 | 644 |
| 646 base::StringPiece data() const { return data_; } | 645 base::StringPiece data() const { return data_; } |
| 647 | 646 |
| 648 bool padded() const { return padded_; } | 647 bool padded() const { return padded_; } |
| 649 | 648 |
| 650 int padding_payload_len() const { return padding_payload_len_; } | 649 int padding_payload_len() const { return padding_payload_len_; } |
| 651 | 650 |
| 652 void set_padding_len(int padding_len) { | 651 void set_padding_len(int padding_len) { |
| 653 DCHECK_GT(padding_len, 0); | 652 DCHECK_GT(padding_len, 0); |
| 654 DCHECK_LE(padding_len, kPaddingSizePerFrame); | 653 DCHECK_LE(padding_len, kPaddingSizePerFrame); |
| 655 padded_ = true; | 654 padded_ = true; |
| 656 // The pad field takes one octet on the wire. | 655 // The pad field takes one octet on the wire. |
| 657 padding_payload_len_ = padding_len - 1; | 656 padding_payload_len_ = padding_len - 1; |
| 658 } | 657 } |
| 659 | 658 |
| 660 // Deep-copy of data (keep private copy). | 659 // Deep-copy of data (keep private copy). |
| 661 void SetDataDeep(const base::StringPiece& data) { | 660 void SetDataDeep(base::StringPiece data) { |
| 662 data_store_.reset(new std::string(data.data(), data.length())); | 661 data_store_.reset(new std::string(data.data(), data.length())); |
| 663 data_ = *(data_store_.get()); | 662 data_ = *(data_store_.get()); |
| 664 } | 663 } |
| 665 | 664 |
| 666 // Shallow-copy of data (do not keep private copy). | 665 // Shallow-copy of data (do not keep private copy). |
| 667 void SetDataShallow(const base::StringPiece& data) { | 666 void SetDataShallow(base::StringPiece data) { |
| 668 data_store_.reset(); | 667 data_store_.reset(); |
| 669 data_ = data; | 668 data_ = data; |
| 670 } | 669 } |
| 671 | 670 |
| 672 void Visit(SpdyFrameVisitor* visitor) const override; | 671 void Visit(SpdyFrameVisitor* visitor) const override; |
| 673 | 672 |
| 674 private: | 673 private: |
| 675 // Used to store data that this SpdyDataIR should own. | 674 // Used to store data that this SpdyDataIR should own. |
| 676 scoped_ptr<std::string> data_store_; | 675 scoped_ptr<std::string> data_store_; |
| 677 base::StringPiece data_; | 676 base::StringPiece data_; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 | 806 |
| 808 private: | 807 private: |
| 809 SpdyPingId id_; | 808 SpdyPingId id_; |
| 810 bool is_ack_; | 809 bool is_ack_; |
| 811 | 810 |
| 812 DISALLOW_COPY_AND_ASSIGN(SpdyPingIR); | 811 DISALLOW_COPY_AND_ASSIGN(SpdyPingIR); |
| 813 }; | 812 }; |
| 814 | 813 |
| 815 class NET_EXPORT_PRIVATE SpdyGoAwayIR : public SpdyFrameIR { | 814 class NET_EXPORT_PRIVATE SpdyGoAwayIR : public SpdyFrameIR { |
| 816 public: | 815 public: |
| 817 SpdyGoAwayIR(SpdyStreamId last_good_stream_id, SpdyGoAwayStatus status, | 816 SpdyGoAwayIR(SpdyStreamId last_good_stream_id, |
| 818 const base::StringPiece& description); | 817 SpdyGoAwayStatus status, |
| 818 base::StringPiece description); |
| 819 ~SpdyGoAwayIR() override; | 819 ~SpdyGoAwayIR() override; |
| 820 SpdyStreamId last_good_stream_id() const { return last_good_stream_id_; } | 820 SpdyStreamId last_good_stream_id() const { return last_good_stream_id_; } |
| 821 void set_last_good_stream_id(SpdyStreamId last_good_stream_id) { | 821 void set_last_good_stream_id(SpdyStreamId last_good_stream_id) { |
| 822 DCHECK_LE(0u, last_good_stream_id); | 822 DCHECK_LE(0u, last_good_stream_id); |
| 823 DCHECK_EQ(0u, last_good_stream_id & ~kStreamIdMask); | 823 DCHECK_EQ(0u, last_good_stream_id & ~kStreamIdMask); |
| 824 last_good_stream_id_ = last_good_stream_id; | 824 last_good_stream_id_ = last_good_stream_id; |
| 825 } | 825 } |
| 826 SpdyGoAwayStatus status() const { return status_; } | 826 SpdyGoAwayStatus status() const { return status_; } |
| 827 void set_status(SpdyGoAwayStatus status) { | 827 void set_status(SpdyGoAwayStatus status) { |
| 828 // TODO(hkhalil): Check valid ranges of status? | 828 // TODO(hkhalil): Check valid ranges of status? |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1091 SpdyFrameVisitor() {} | 1091 SpdyFrameVisitor() {} |
| 1092 virtual ~SpdyFrameVisitor() {} | 1092 virtual ~SpdyFrameVisitor() {} |
| 1093 | 1093 |
| 1094 private: | 1094 private: |
| 1095 DISALLOW_COPY_AND_ASSIGN(SpdyFrameVisitor); | 1095 DISALLOW_COPY_AND_ASSIGN(SpdyFrameVisitor); |
| 1096 }; | 1096 }; |
| 1097 | 1097 |
| 1098 } // namespace net | 1098 } // namespace net |
| 1099 | 1099 |
| 1100 #endif // NET_SPDY_SPDY_PROTOCOL_H_ | 1100 #endif // NET_SPDY_SPDY_PROTOCOL_H_ |
| OLD | NEW |