| 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 WINDOW_UPDATE, | 284 WINDOW_UPDATE, |
| 285 CREDENTIAL, // No longer valid. Kept for identifiability/enum order. | 285 CREDENTIAL, // No longer valid. Kept for identifiability/enum order. |
| 286 BLOCKED, | 286 BLOCKED, |
| 287 PUSH_PROMISE, | 287 PUSH_PROMISE, |
| 288 CONTINUATION, | 288 CONTINUATION, |
| 289 LAST_CONTROL_TYPE = CONTINUATION | 289 LAST_CONTROL_TYPE = CONTINUATION |
| 290 }; | 290 }; |
| 291 | 291 |
| 292 // Flags on data packets. | 292 // Flags on data packets. |
| 293 enum SpdyDataFlags { | 293 enum SpdyDataFlags { |
| 294 DATA_FLAG_NONE = 0, | 294 DATA_FLAG_NONE = 0x00, |
| 295 DATA_FLAG_FIN = 1, | 295 DATA_FLAG_FIN = 0x01, |
| 296 DATA_FLAG_END_SEGMENT = 0x02, |
| 297 DATA_FLAG_PAD_LOW = 0x10, |
| 298 DATA_FLAG_PAD_HIGH = 0x20 |
| 296 }; | 299 }; |
| 297 | 300 |
| 298 // Flags on control packets | 301 // Flags on control packets |
| 299 enum SpdyControlFlags { | 302 enum SpdyControlFlags { |
| 300 CONTROL_FLAG_NONE = 0, | 303 CONTROL_FLAG_NONE = 0, |
| 301 CONTROL_FLAG_FIN = 1, | 304 CONTROL_FLAG_FIN = 1, |
| 302 CONTROL_FLAG_UNIDIRECTIONAL = 2 | 305 CONTROL_FLAG_UNIDIRECTIONAL = 2 |
| 303 }; | 306 }; |
| 304 | 307 |
| 305 enum SpdyPingFlags { | 308 enum SpdyPingFlags { |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 // Performs deep copy on data. | 479 // Performs deep copy on data. |
| 477 SpdyDataIR(SpdyStreamId stream_id, const base::StringPiece& data); | 480 SpdyDataIR(SpdyStreamId stream_id, const base::StringPiece& data); |
| 478 | 481 |
| 479 // Use in conjunction with SetDataShallow() for shallow-copy on data. | 482 // Use in conjunction with SetDataShallow() for shallow-copy on data. |
| 480 explicit SpdyDataIR(SpdyStreamId stream_id); | 483 explicit SpdyDataIR(SpdyStreamId stream_id); |
| 481 | 484 |
| 482 virtual ~SpdyDataIR(); | 485 virtual ~SpdyDataIR(); |
| 483 | 486 |
| 484 base::StringPiece data() const { return data_; } | 487 base::StringPiece data() const { return data_; } |
| 485 | 488 |
| 489 bool pad_low() const { return pad_low_; } |
| 490 |
| 491 bool pad_high() const { return pad_high_; } |
| 492 |
| 493 int padding_payload_len() const { return padding_payload_len_; } |
| 494 |
| 495 void set_padding_len(int padding_len) { |
| 496 // The padding_len should be in (0, 65535 + 2]. |
| 497 // Note that SpdyFramer::GetDataFrameMaximumPayload() enforces the overall |
| 498 // payload size later so we actually can't pad more than 16375 bytes. |
| 499 DCHECK_GT(padding_len, 0); |
| 500 DCHECK_LT(padding_len, 65537); |
| 501 |
| 502 if (padding_len <= 256) { |
| 503 pad_low_ = true; |
| 504 --padding_len; |
| 505 } else { |
| 506 pad_low_ = pad_high_ = true; |
| 507 padding_len -= 2; |
| 508 } |
| 509 padding_payload_len_ = padding_len; |
| 510 } |
| 511 |
| 486 // Deep-copy of data (keep private copy). | 512 // Deep-copy of data (keep private copy). |
| 487 void SetDataDeep(const base::StringPiece& data) { | 513 void SetDataDeep(const base::StringPiece& data) { |
| 488 data_store_.reset(new std::string(data.data(), data.length())); | 514 data_store_.reset(new std::string(data.data(), data.length())); |
| 489 data_ = *(data_store_.get()); | 515 data_ = *(data_store_.get()); |
| 490 } | 516 } |
| 491 | 517 |
| 492 // Shallow-copy of data (do not keep private copy). | 518 // Shallow-copy of data (do not keep private copy). |
| 493 void SetDataShallow(const base::StringPiece& data) { | 519 void SetDataShallow(const base::StringPiece& data) { |
| 494 data_store_.reset(); | 520 data_store_.reset(); |
| 495 data_ = data; | 521 data_ = data; |
| 496 } | 522 } |
| 497 | 523 |
| 498 virtual void Visit(SpdyFrameVisitor* visitor) const OVERRIDE; | 524 virtual void Visit(SpdyFrameVisitor* visitor) const OVERRIDE; |
| 499 | 525 |
| 500 private: | 526 private: |
| 501 // Used to store data that this SpdyDataIR should own. | 527 // Used to store data that this SpdyDataIR should own. |
| 502 scoped_ptr<std::string> data_store_; | 528 scoped_ptr<std::string> data_store_; |
| 503 base::StringPiece data_; | 529 base::StringPiece data_; |
| 504 | 530 |
| 531 bool pad_low_; |
| 532 bool pad_high_; |
| 533 // padding_payload_len_ = desired padding length - len(padding length field). |
| 534 int padding_payload_len_; |
| 535 |
| 505 DISALLOW_COPY_AND_ASSIGN(SpdyDataIR); | 536 DISALLOW_COPY_AND_ASSIGN(SpdyDataIR); |
| 506 }; | 537 }; |
| 507 | 538 |
| 508 class NET_EXPORT_PRIVATE SpdySynStreamIR | 539 class NET_EXPORT_PRIVATE SpdySynStreamIR |
| 509 : public SpdyFrameWithNameValueBlockIR { | 540 : public SpdyFrameWithNameValueBlockIR { |
| 510 public: | 541 public: |
| 511 explicit SpdySynStreamIR(SpdyStreamId stream_id) | 542 explicit SpdySynStreamIR(SpdyStreamId stream_id) |
| 512 : SpdyFrameWithNameValueBlockIR(stream_id), | 543 : SpdyFrameWithNameValueBlockIR(stream_id), |
| 513 associated_to_stream_id_(0), | 544 associated_to_stream_id_(0), |
| 514 priority_(0), | 545 priority_(0), |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 SpdyFrameVisitor() {} | 870 SpdyFrameVisitor() {} |
| 840 virtual ~SpdyFrameVisitor() {} | 871 virtual ~SpdyFrameVisitor() {} |
| 841 | 872 |
| 842 private: | 873 private: |
| 843 DISALLOW_COPY_AND_ASSIGN(SpdyFrameVisitor); | 874 DISALLOW_COPY_AND_ASSIGN(SpdyFrameVisitor); |
| 844 }; | 875 }; |
| 845 | 876 |
| 846 } // namespace net | 877 } // namespace net |
| 847 | 878 |
| 848 #endif // NET_SPDY_SPDY_PROTOCOL_H_ | 879 #endif // NET_SPDY_SPDY_PROTOCOL_H_ |
| OLD | NEW |