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> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/sys_byteorder.h" | 17 #include "base/sys_byteorder.h" |
18 #include "net/base/net_export.h" | 18 #include "net/base/net_export.h" |
| 19 #include "net/spdy/http2_compressor.h" |
| 20 #include "net/spdy/http2_decompressor.h" |
19 #include "net/spdy/spdy_header_block.h" | 21 #include "net/spdy/spdy_header_block.h" |
20 #include "net/spdy/spdy_protocol.h" | 22 #include "net/spdy/spdy_protocol.h" |
21 | 23 |
22 typedef struct z_stream_s z_stream; // Forward declaration for zlib. | 24 typedef struct z_stream_s z_stream; // Forward declaration for zlib. |
23 | 25 |
24 namespace net { | 26 namespace net { |
25 | 27 |
26 class HttpProxyClientSocketPoolTest; | 28 class HttpProxyClientSocketPoolTest; |
27 class HttpNetworkLayer; | 29 class HttpNetworkLayer; |
28 class HttpNetworkTransactionTest; | 30 class HttpNetworkTransactionTest; |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 | 584 |
583 // Helpers for above internal breakouts from ProcessInput. | 585 // Helpers for above internal breakouts from ProcessInput. |
584 void ProcessControlFrameHeader(uint16 control_frame_type_field); | 586 void ProcessControlFrameHeader(uint16 control_frame_type_field); |
585 bool ProcessSetting(const char* data); // Always passed exactly 8 bytes. | 587 bool ProcessSetting(const char* data); // Always passed exactly 8 bytes. |
586 | 588 |
587 // Retrieve serialized length of SpdyHeaderBlock. If compression is enabled, a | 589 // Retrieve serialized length of SpdyHeaderBlock. If compression is enabled, a |
588 // maximum estimate is returned. | 590 // maximum estimate is returned. |
589 size_t GetSerializedLength(const SpdyHeaderBlock& headers); | 591 size_t GetSerializedLength(const SpdyHeaderBlock& headers); |
590 | 592 |
591 // Get (and lazily initialize) the ZLib state. | 593 // Get (and lazily initialize) the ZLib state. |
592 z_stream* GetHeaderCompressor(); | 594 z_stream* GetSpdyHeaderCompressor(); |
593 z_stream* GetHeaderDecompressor(); | 595 z_stream* GetSpdyHeaderDecompressor(); |
| 596 |
| 597 // Get (and lazily initialize) the HTTP/2 compression/decompression |
| 598 // state. |
| 599 Http2Compressor* GetHttp2HeaderCompressor(); |
| 600 Http2Decompressor* GetHttp2HeaderDecompressor(); |
594 | 601 |
595 private: | 602 private: |
596 // Deliver the given control frame's uncompressed headers block to the | 603 // Deliver the given control frame's uncompressed headers block to the |
597 // visitor in chunks. Returns true if the visitor has accepted all of the | 604 // visitor in chunks. Returns true if the visitor has accepted all of the |
598 // chunks. | 605 // chunks. |
599 bool IncrementallyDeliverControlFrameHeaderData(SpdyStreamId stream_id, | 606 bool IncrementallyDeliverControlFrameHeaderData(SpdyStreamId stream_id, |
600 const char* data, | 607 const char* data, |
601 size_t len); | 608 size_t len); |
602 | 609 |
603 // Utility to copy the given data block to the current frame buffer, up | 610 // Utility to copy the given data block to the current frame buffer, up |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 // The stream ID field of the frame currently being read, if applicable. | 682 // The stream ID field of the frame currently being read, if applicable. |
676 SpdyStreamId current_frame_stream_id_; | 683 SpdyStreamId current_frame_stream_id_; |
677 | 684 |
678 // Scratch space for handling SETTINGS frames. | 685 // Scratch space for handling SETTINGS frames. |
679 // TODO(hkhalil): Unify memory for this scratch space with | 686 // TODO(hkhalil): Unify memory for this scratch space with |
680 // current_frame_buffer_. | 687 // current_frame_buffer_. |
681 SpdySettingsScratch settings_scratch_; | 688 SpdySettingsScratch settings_scratch_; |
682 | 689 |
683 bool enable_compression_; // Controls all compression | 690 bool enable_compression_; // Controls all compression |
684 // SPDY header compressors. | 691 // SPDY header compressors. |
685 scoped_ptr<z_stream> header_compressor_; | 692 scoped_ptr<z_stream> spdy_header_compressor_; |
686 scoped_ptr<z_stream> header_decompressor_; | 693 scoped_ptr<z_stream> spdy_header_decompressor_; |
| 694 // HTTP/2 header compressors. |
| 695 scoped_ptr<Http2Compressor> http2_header_compressor_; |
| 696 scoped_ptr<Http2Decompressor> http2_header_decompressor_; |
687 | 697 |
688 SpdyFramerVisitorInterface* visitor_; | 698 SpdyFramerVisitorInterface* visitor_; |
689 SpdyFramerDebugVisitorInterface* debug_visitor_; | 699 SpdyFramerDebugVisitorInterface* debug_visitor_; |
690 | 700 |
691 std::string display_protocol_; | 701 std::string display_protocol_; |
692 | 702 |
693 // The major SPDY version to be spoken/understood by this framer. | 703 // The major SPDY version to be spoken/understood by this framer. |
694 const SpdyMajorVersion spdy_version_; | 704 const SpdyMajorVersion spdy_version_; |
695 | 705 |
696 // Tracks if we've ever gotten far enough in framing to see a control frame of | 706 // Tracks if we've ever gotten far enough in framing to see a control frame of |
697 // type SYN_STREAM or SYN_REPLY. | 707 // type SYN_STREAM or SYN_REPLY. |
698 // | 708 // |
699 // If we ever get something which looks like a data frame before we've had a | 709 // If we ever get something which looks like a data frame before we've had a |
700 // SYN, we explicitly check to see if it looks like we got an HTTP response to | 710 // SYN, we explicitly check to see if it looks like we got an HTTP response to |
701 // a SPDY request. This boolean lets us do that. | 711 // a SPDY request. This boolean lets us do that. |
702 bool syn_frame_processed_; | 712 bool syn_frame_processed_; |
703 | 713 |
704 // If we ever get a data frame before a SYN frame, we check to see if it | 714 // If we ever get a data frame before a SYN frame, we check to see if it |
705 // starts with HTTP. If it does, we likely have an HTTP response. This | 715 // starts with HTTP. If it does, we likely have an HTTP response. This |
706 // isn't guaranteed though: we could have gotten a settings frame and then | 716 // isn't guaranteed though: we could have gotten a settings frame and then |
707 // corrupt data that just looks like HTTP, but deterministic checking requires | 717 // corrupt data that just looks like HTTP, but deterministic checking requires |
708 // a lot more state. | 718 // a lot more state. |
709 bool probable_http_response_; | 719 bool probable_http_response_; |
710 }; | 720 }; |
711 | 721 |
712 } // namespace net | 722 } // namespace net |
713 | 723 |
714 #endif // NET_SPDY_SPDY_FRAMER_H_ | 724 #endif // NET_SPDY_SPDY_FRAMER_H_ |
OLD | NEW |