| 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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 | 480 |
| 481 // Returns the maximum size a frame can be (data or control). | 481 // Returns the maximum size a frame can be (data or control). |
| 482 size_t GetFrameMaximumSize() const; | 482 size_t GetFrameMaximumSize() const; |
| 483 | 483 |
| 484 // Returns the maximum size that a control frame can be. | 484 // Returns the maximum size that a control frame can be. |
| 485 size_t GetControlFrameMaximumSize() const; | 485 size_t GetControlFrameMaximumSize() const; |
| 486 | 486 |
| 487 // Returns the maximum payload size of a DATA frame. | 487 // Returns the maximum payload size of a DATA frame. |
| 488 size_t GetDataFrameMaximumPayload() const; | 488 size_t GetDataFrameMaximumPayload() const; |
| 489 | 489 |
| 490 // Returns the prefix length for the given frame type. |
| 491 size_t GetPrefixLength(SpdyFrameType type) const; |
| 492 |
| 490 // For debugging. | 493 // For debugging. |
| 491 static const char* StateToString(int state); | 494 static const char* StateToString(int state); |
| 492 static const char* ErrorCodeToString(int error_code); | 495 static const char* ErrorCodeToString(int error_code); |
| 493 static const char* StatusCodeToString(int status_code); | 496 static const char* StatusCodeToString(int status_code); |
| 494 static const char* FrameTypeToString(SpdyFrameType type); | 497 static const char* FrameTypeToString(SpdyFrameType type); |
| 495 | 498 |
| 496 SpdyMajorVersion protocol_version() const { return spdy_version_; } | 499 SpdyMajorVersion protocol_version() const { return spdy_version_; } |
| 497 | 500 |
| 498 bool probable_http_response() const { return probable_http_response_; } | 501 bool probable_http_response() const { return probable_http_response_; } |
| 499 | 502 |
| 500 SpdyStreamId expect_continuation() const { return expect_continuation_; } | 503 SpdyStreamId expect_continuation() const { return expect_continuation_; } |
| 501 | 504 |
| 502 SpdyPriority GetLowestPriority() const { return spdy_version_ < 3 ? 3 : 7; } | 505 SpdyPriority GetLowestPriority() const { return spdy_version_ < 3 ? 3 : 7; } |
| 503 SpdyPriority GetHighestPriority() const { return 0; } | 506 SpdyPriority GetHighestPriority() const { return 0; } |
| 504 | 507 |
| 505 // Deliver the given control frame's compressed headers block to the visitor | 508 // Deliver the given control frame's compressed headers block to the visitor |
| 506 // in decompressed form, in chunks. Returns true if the visitor has | 509 // in decompressed form, in chunks. Returns true if the visitor has |
| 507 // accepted all of the chunks. | 510 // accepted all of the chunks. |
| 508 bool IncrementallyDecompressControlFrameHeaderData( | 511 bool IncrementallyDecompressControlFrameHeaderData( |
| 509 SpdyStreamId stream_id, | 512 SpdyStreamId stream_id, |
| 510 const char* data, | 513 const char* data, |
| 511 size_t len); | 514 size_t len); |
| 512 | 515 |
| 513 protected: | 516 protected: |
| 517 // TODO(jgraettinger): Switch to test peer pattern. |
| 514 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, BasicCompression); | 518 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, BasicCompression); |
| 515 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ControlFrameSizesAreValidated); | 519 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ControlFrameSizesAreValidated); |
| 516 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, HeaderCompression); | 520 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, HeaderCompression); |
| 517 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, DecompressUncompressedFrame); | 521 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, DecompressUncompressedFrame); |
| 518 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ExpandBuffer_HeapSmash); | 522 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ExpandBuffer_HeapSmash); |
| 519 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, HugeHeaderBlock); | 523 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, HugeHeaderBlock); |
| 520 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, UnclosedStreamDataCompressors); | 524 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, UnclosedStreamDataCompressors); |
| 521 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, | 525 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, |
| 522 UnclosedStreamDataCompressorsOneByteAtATime); | 526 UnclosedStreamDataCompressorsOneByteAtATime); |
| 523 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, | 527 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, |
| 524 UncompressLargerThanFrameBufferInitialSize); | 528 UncompressLargerThanFrameBufferInitialSize); |
| 525 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ReadLargeSettingsFrame); | 529 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ReadLargeSettingsFrame); |
| 526 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, | 530 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, |
| 527 ReadLargeSettingsFrameInSmallChunks); | 531 ReadLargeSettingsFrameInSmallChunks); |
| 528 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ControlFrameAtMaxSizeLimit); | 532 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ControlFrameAtMaxSizeLimit); |
| 529 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ControlFrameTooLarge); | 533 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ControlFrameTooLarge); |
| 534 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, |
| 535 TooLargeHeadersFrameUsesContinuation); |
| 536 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, |
| 537 TooLargePushPromiseFrameUsesContinuation); |
| 530 friend class net::HttpNetworkLayer; // This is temporary for the server. | 538 friend class net::HttpNetworkLayer; // This is temporary for the server. |
| 531 friend class net::HttpNetworkTransactionTest; | 539 friend class net::HttpNetworkTransactionTest; |
| 532 friend class net::HttpProxyClientSocketPoolTest; | 540 friend class net::HttpProxyClientSocketPoolTest; |
| 533 friend class net::SpdyHttpStreamTest; | 541 friend class net::SpdyHttpStreamTest; |
| 534 friend class net::SpdyNetworkTransactionTest; | 542 friend class net::SpdyNetworkTransactionTest; |
| 535 friend class net::SpdyProxyClientSocketTest; | 543 friend class net::SpdyProxyClientSocketTest; |
| 536 friend class net::SpdySessionTest; | 544 friend class net::SpdySessionTest; |
| 537 friend class net::SpdyStreamTest; | 545 friend class net::SpdyStreamTest; |
| 538 friend class net::SpdyWebSocketStreamTest; | 546 friend class net::SpdyWebSocketStreamTest; |
| 539 friend class net::WebSocketJobTest; | 547 friend class net::WebSocketJobTest; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 bool ProcessSetting(const char* data); | 579 bool ProcessSetting(const char* data); |
| 572 | 580 |
| 573 // Retrieve serialized length of SpdyHeaderBlock. If compression is enabled, a | 581 // Retrieve serialized length of SpdyHeaderBlock. If compression is enabled, a |
| 574 // maximum estimate is returned. | 582 // maximum estimate is returned. |
| 575 size_t GetSerializedLength(const SpdyHeaderBlock& headers); | 583 size_t GetSerializedLength(const SpdyHeaderBlock& headers); |
| 576 | 584 |
| 577 // Get (and lazily initialize) the ZLib state. | 585 // Get (and lazily initialize) the ZLib state. |
| 578 z_stream* GetHeaderCompressor(); | 586 z_stream* GetHeaderCompressor(); |
| 579 z_stream* GetHeaderDecompressor(); | 587 z_stream* GetHeaderDecompressor(); |
| 580 | 588 |
| 589 size_t GetNumberRequiredContinuationFrames(size_t size); |
| 590 |
| 591 void WritePayloadWithContinuation(SpdyFrameBuilder* builder, |
| 592 const std::string& hpack_encoding, |
| 593 SpdyStreamId stream_id, |
| 594 SpdyFrameType type); |
| 595 |
| 581 private: | 596 private: |
| 582 // Deliver the given control frame's uncompressed headers block to the | 597 // Deliver the given control frame's uncompressed headers block to the |
| 583 // visitor in chunks. Returns true if the visitor has accepted all of the | 598 // visitor in chunks. Returns true if the visitor has accepted all of the |
| 584 // chunks. | 599 // chunks. |
| 585 bool IncrementallyDeliverControlFrameHeaderData(SpdyStreamId stream_id, | 600 bool IncrementallyDeliverControlFrameHeaderData(SpdyStreamId stream_id, |
| 586 const char* data, | 601 const char* data, |
| 587 size_t len); | 602 size_t len); |
| 588 | 603 |
| 589 // Utility to copy the given data block to the current frame buffer, up | 604 // Utility to copy the given data block to the current frame buffer, up |
| 590 // to the given maximum number of bytes, and update the buffer | 605 // to the given maximum number of bytes, and update the buffer |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 | 735 |
| 721 // Returns true if the given StringPiece contains any upper case | 736 // Returns true if the given StringPiece contains any upper case |
| 722 // characters. Assumes ASCII input. | 737 // characters. Assumes ASCII input. |
| 723 // Implemented here for cross-compatibility with Chromium. | 738 // Implemented here for cross-compatibility with Chromium. |
| 724 bool ContainsUpperASCII(base::StringPiece s) const; | 739 bool ContainsUpperASCII(base::StringPiece s) const; |
| 725 }; | 740 }; |
| 726 | 741 |
| 727 } // namespace net | 742 } // namespace net |
| 728 | 743 |
| 729 #endif // NET_SPDY_SPDY_FRAMER_H_ | 744 #endif // NET_SPDY_SPDY_FRAMER_H_ |
| OLD | NEW |