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 #ifndef NET_SPDY_SPDY_FRAMER_H_ | 5 #ifndef NET_SPDY_SPDY_FRAMER_H_ |
6 #define NET_SPDY_SPDY_FRAMER_H_ | 6 #define NET_SPDY_SPDY_FRAMER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 static const char* StatusCodeToString(int status_code); | 497 static const char* StatusCodeToString(int status_code); |
498 static const char* ControlTypeToString(SpdyControlType type); | 498 static const char* ControlTypeToString(SpdyControlType type); |
499 | 499 |
500 int protocol_version() const { return spdy_version_; } | 500 int protocol_version() const { return spdy_version_; } |
501 | 501 |
502 bool probable_http_response() const { return probable_http_response_; } | 502 bool probable_http_response() const { return probable_http_response_; } |
503 | 503 |
504 SpdyPriority GetLowestPriority() const { return spdy_version_ < 3 ? 3 : 7; } | 504 SpdyPriority GetLowestPriority() const { return spdy_version_ < 3 ? 3 : 7; } |
505 SpdyPriority GetHighestPriority() const { return 0; } | 505 SpdyPriority GetHighestPriority() const { return 0; } |
506 | 506 |
| 507 // Deliver the given control frame's compressed headers block to the visitor |
| 508 // in decompressed form, in chunks. Returns true if the visitor has |
| 509 // accepted all of the chunks. |
| 510 bool IncrementallyDecompressControlFrameHeaderData( |
| 511 SpdyStreamId stream_id, |
| 512 const char* data, |
| 513 size_t len); |
| 514 |
507 protected: | 515 protected: |
508 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, BasicCompression); | 516 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, BasicCompression); |
509 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ControlFrameSizesAreValidated); | 517 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ControlFrameSizesAreValidated); |
510 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, HeaderCompression); | 518 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, HeaderCompression); |
511 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, DecompressUncompressedFrame); | 519 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, DecompressUncompressedFrame); |
512 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ExpandBuffer_HeapSmash); | 520 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ExpandBuffer_HeapSmash); |
513 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, HugeHeaderBlock); | 521 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, HugeHeaderBlock); |
514 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, UnclosedStreamDataCompressors); | 522 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, UnclosedStreamDataCompressors); |
515 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, | 523 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, |
516 UnclosedStreamDataCompressorsOneByteAtATime); | 524 UnclosedStreamDataCompressorsOneByteAtATime); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 bool ProcessSetting(const char* data); // Always passed exactly 8 bytes. | 557 bool ProcessSetting(const char* data); // Always passed exactly 8 bytes. |
550 | 558 |
551 // Retrieve serialized length of SpdyHeaderBlock. If compression is enabled, a | 559 // Retrieve serialized length of SpdyHeaderBlock. If compression is enabled, a |
552 // maximum estimate is returned. | 560 // maximum estimate is returned. |
553 size_t GetSerializedLength(const SpdyHeaderBlock& headers); | 561 size_t GetSerializedLength(const SpdyHeaderBlock& headers); |
554 | 562 |
555 // Get (and lazily initialize) the ZLib state. | 563 // Get (and lazily initialize) the ZLib state. |
556 z_stream* GetHeaderCompressor(); | 564 z_stream* GetHeaderCompressor(); |
557 z_stream* GetHeaderDecompressor(); | 565 z_stream* GetHeaderDecompressor(); |
558 | 566 |
559 // Deliver the given control frame's compressed headers block to the visitor | 567 private: |
560 // in decompressed form, in chunks. Returns true if the visitor has | |
561 // accepted all of the chunks. | |
562 bool IncrementallyDecompressControlFrameHeaderData( | |
563 SpdyStreamId stream_id, | |
564 const char* data, | |
565 size_t len); | |
566 | |
567 // Deliver the given control frame's uncompressed headers block to the | 568 // Deliver the given control frame's uncompressed headers block to the |
568 // visitor in chunks. Returns true if the visitor has accepted all of the | 569 // visitor in chunks. Returns true if the visitor has accepted all of the |
569 // chunks. | 570 // chunks. |
570 bool IncrementallyDeliverControlFrameHeaderData(SpdyStreamId stream_id, | 571 bool IncrementallyDeliverControlFrameHeaderData(SpdyStreamId stream_id, |
571 const char* data, | 572 const char* data, |
572 size_t len); | 573 size_t len); |
573 | 574 |
574 // Utility to copy the given data block to the current frame buffer, up | 575 // Utility to copy the given data block to the current frame buffer, up |
575 // to the given maximum number of bytes, and update the buffer | 576 // to the given maximum number of bytes, and update the buffer |
576 // data (pointer and length). Returns the number of bytes | 577 // data (pointer and length). Returns the number of bytes |
577 // read, and: | 578 // read, and: |
578 // *data is advanced the number of bytes read. | 579 // *data is advanced the number of bytes read. |
579 // *len is reduced by the number of bytes read. | 580 // *len is reduced by the number of bytes read. |
580 size_t UpdateCurrentFrameBuffer(const char** data, size_t* len, | 581 size_t UpdateCurrentFrameBuffer(const char** data, size_t* len, |
581 size_t max_bytes); | 582 size_t max_bytes); |
582 | 583 |
583 void WriteHeaderBlockToZ(const SpdyHeaderBlock* headers, | 584 void WriteHeaderBlockToZ(const SpdyHeaderBlock* headers, |
584 z_stream* out) const; | 585 z_stream* out) const; |
585 | 586 |
586 void SerializeNameValueBlockWithoutCompression( | 587 void SerializeNameValueBlockWithoutCompression( |
587 SpdyFrameBuilder* builder, | 588 SpdyFrameBuilder* builder, |
588 const SpdyFrameWithNameValueBlockIR& frame) const; | 589 const SpdyNameValueBlock& name_value_block) const; |
589 | 590 |
590 // Compresses automatically according to enable_compression_. | 591 // Compresses automatically according to enable_compression_. |
591 void SerializeNameValueBlock( | 592 void SerializeNameValueBlock( |
592 SpdyFrameBuilder* builder, | 593 SpdyFrameBuilder* builder, |
593 const SpdyFrameWithNameValueBlockIR& frame); | 594 const SpdyFrameWithNameValueBlockIR& frame); |
594 | 595 |
595 // Set the error code and moves the framer into the error state. | 596 // Set the error code and moves the framer into the error state. |
596 void set_error(SpdyError error); | 597 void set_error(SpdyError error); |
597 | 598 |
598 size_t GoAwaySize() const; | 599 size_t GoAwaySize() const; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 // starts with HTTP. If it does, we likely have an HTTP response. This | 683 // starts with HTTP. If it does, we likely have an HTTP response. This |
683 // isn't guaranteed though: we could have gotten a settings frame and then | 684 // isn't guaranteed though: we could have gotten a settings frame and then |
684 // corrupt data that just looks like HTTP, but deterministic checking requires | 685 // corrupt data that just looks like HTTP, but deterministic checking requires |
685 // a lot more state. | 686 // a lot more state. |
686 bool probable_http_response_; | 687 bool probable_http_response_; |
687 }; | 688 }; |
688 | 689 |
689 } // namespace net | 690 } // namespace net |
690 | 691 |
691 #endif // NET_SPDY_SPDY_FRAMER_H_ | 692 #endif // NET_SPDY_SPDY_FRAMER_H_ |
OLD | NEW |