Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: net/spdy/spdy_framer.h

Issue 1961573002: Avoids the "re-encode HPACK as SPDY3" step. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Avoids the "re-encode HPACK as SPDY3" step. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <map> 11 #include <map>
12 #include <memory> 12 #include <memory>
13 #include <string> 13 #include <string>
14 #include <utility> 14 #include <utility>
15 15
16 #include "base/strings/string_piece.h" 16 #include "base/strings/string_piece.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/hpack/hpack_decoder.h" 19 #include "net/spdy/hpack/hpack_decoder.h"
20 #include "net/spdy/hpack/hpack_encoder.h" 20 #include "net/spdy/hpack/hpack_encoder.h"
21 #include "net/spdy/spdy_alt_svc_wire_format.h" 21 #include "net/spdy/spdy_alt_svc_wire_format.h"
22 #include "net/spdy/spdy_header_block.h" 22 #include "net/spdy/spdy_header_block.h"
23 #include "net/spdy/spdy_headers_block_parser.h"
23 #include "net/spdy/spdy_protocol.h" 24 #include "net/spdy/spdy_protocol.h"
24 25
25 typedef struct z_stream_s z_stream; // Forward declaration for zlib. 26 typedef struct z_stream_s z_stream; // Forward declaration for zlib.
26 27
27 namespace net { 28 namespace net {
28 29
29 class HttpProxyClientSocketPoolTest; 30 class HttpProxyClientSocketPoolTest;
30 class HttpNetworkLayer; 31 class HttpNetworkLayer;
31 class HttpNetworkTransactionTest; 32 class HttpNetworkTransactionTest;
32 class SpdyHttpStreamTest; 33 class SpdyHttpStreamTest;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 virtual void OnStreamEnd(SpdyStreamId stream_id) = 0; 121 virtual void OnStreamEnd(SpdyStreamId stream_id) = 0;
121 122
122 // Called when padding is received (padding length field or padding octets). 123 // Called when padding is received (padding length field or padding octets).
123 // |stream_id| The stream receiving data. 124 // |stream_id| The stream receiving data.
124 // |len| The number of padding octets. 125 // |len| The number of padding octets.
125 virtual void OnStreamPadding(SpdyStreamId stream_id, size_t len) = 0; 126 virtual void OnStreamPadding(SpdyStreamId stream_id, size_t len) = 0;
126 127
127 // Called just before processing the payload of a frame containing header 128 // Called just before processing the payload of a frame containing header
128 // data. Should return an implementation of SpdyHeadersHandlerInterface that 129 // data. Should return an implementation of SpdyHeadersHandlerInterface that
129 // will receive headers for stream |stream_id|. The caller will not take 130 // will receive headers for stream |stream_id|. The caller will not take
130 // ownership of the headers handler. The same instance should be returned 131 // ownership of the headers handler. The same instance should remain live
131 // for all header frames comprising a logical header block (i.e. until 132 // and be returned for all header frames comprising a logical header block
132 // OnHeaderFrameEnd() is called with end_headers == true). 133 // (i.e. until OnHeaderFrameEnd() is called with end_headers == true).
133 virtual SpdyHeadersHandlerInterface* OnHeaderFrameStart( 134 virtual SpdyHeadersHandlerInterface* OnHeaderFrameStart(
134 SpdyStreamId stream_id) = 0; 135 SpdyStreamId stream_id) = 0;
135 136
136 // Called after processing the payload of a frame containing header data. 137 // Called after processing the payload of a frame containing header data.
137 // |end_headers| is true if there will not be any subsequent CONTINUATION 138 // |end_headers| is true if there will not be any subsequent CONTINUATION
138 // frames. 139 // frames.
139 virtual void OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) = 0; 140 virtual void OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) = 0;
140 141
141 // Called when a chunk of header data is available. This is called 142 // Called when a chunk of header data is available. This is called
142 // after OnSynStream, OnSynReply, OnHeaders(), or OnPushPromise. 143 // after OnSynStream, OnSynReply, OnHeaders(), or OnPushPromise.
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 SPDY_ZLIB_INIT_FAILURE, // The Zlib library could not initialize. 332 SPDY_ZLIB_INIT_FAILURE, // The Zlib library could not initialize.
332 SPDY_UNSUPPORTED_VERSION, // Control frame has unsupported version. 333 SPDY_UNSUPPORTED_VERSION, // Control frame has unsupported version.
333 SPDY_DECOMPRESS_FAILURE, // There was an error decompressing. 334 SPDY_DECOMPRESS_FAILURE, // There was an error decompressing.
334 SPDY_COMPRESS_FAILURE, // There was an error compressing. 335 SPDY_COMPRESS_FAILURE, // There was an error compressing.
335 SPDY_GOAWAY_FRAME_CORRUPT, // GOAWAY frame could not be parsed. 336 SPDY_GOAWAY_FRAME_CORRUPT, // GOAWAY frame could not be parsed.
336 SPDY_RST_STREAM_FRAME_CORRUPT, // RST_STREAM frame could not be parsed. 337 SPDY_RST_STREAM_FRAME_CORRUPT, // RST_STREAM frame could not be parsed.
337 SPDY_INVALID_PADDING, // HEADERS or DATA frame padding invalid 338 SPDY_INVALID_PADDING, // HEADERS or DATA frame padding invalid
338 SPDY_INVALID_DATA_FRAME_FLAGS, // Data frame has invalid flags. 339 SPDY_INVALID_DATA_FRAME_FLAGS, // Data frame has invalid flags.
339 SPDY_INVALID_CONTROL_FRAME_FLAGS, // Control frame has invalid flags. 340 SPDY_INVALID_CONTROL_FRAME_FLAGS, // Control frame has invalid flags.
340 SPDY_UNEXPECTED_FRAME, // Frame received out of order. 341 SPDY_UNEXPECTED_FRAME, // Frame received out of order.
342 SPDY_INTERNAL_FRAMER_ERROR, // SpdyFramer was used incorrectly.
341 SPDY_INVALID_CONTROL_FRAME_SIZE, // Control frame not sized to spec 343 SPDY_INVALID_CONTROL_FRAME_SIZE, // Control frame not sized to spec
342 344
343 LAST_ERROR, // Must be the last entry in the enum. 345 LAST_ERROR, // Must be the last entry in the enum.
344 }; 346 };
345 347
346 // Constant for invalid (or unknown) stream IDs. 348 // Constant for invalid (or unknown) stream IDs.
347 static const SpdyStreamId kInvalidStream; 349 static const SpdyStreamId kInvalidStream;
348 350
349 // The maximum size of header data chunks delivered to the framer visitor 351 // The maximum size of header data chunks delivered to the framer visitor
350 // through OnControlFrameHeaderData. (It is exposed here for unit test 352 // through OnControlFrameHeaderData. (It is exposed here for unit test
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 const char* data, 561 const char* data,
560 size_t len); 562 size_t len);
561 563
562 // Updates the maximum size of the header encoder compression table. 564 // Updates the maximum size of the header encoder compression table.
563 void UpdateHeaderEncoderTableSize(uint32_t value); 565 void UpdateHeaderEncoderTableSize(uint32_t value);
564 566
565 // Returns the maximum size of the header encoder compression table. 567 // Returns the maximum size of the header encoder compression table.
566 size_t header_encoder_table_size() const; 568 size_t header_encoder_table_size() const;
567 569
568 protected: 570 protected:
571 friend class BufferedSpdyFramer;
569 friend class HttpNetworkLayer; // This is temporary for the server. 572 friend class HttpNetworkLayer; // This is temporary for the server.
570 friend class HttpNetworkTransactionTest; 573 friend class HttpNetworkTransactionTest;
571 friend class HttpProxyClientSocketPoolTest; 574 friend class HttpProxyClientSocketPoolTest;
572 friend class SpdyHttpStreamTest; 575 friend class SpdyHttpStreamTest;
573 friend class SpdyNetworkTransactionTest; 576 friend class SpdyNetworkTransactionTest;
574 friend class SpdyProxyClientSocketTest; 577 friend class SpdyProxyClientSocketTest;
575 friend class SpdySessionTest; 578 friend class SpdySessionTest;
576 friend class SpdyStreamTest; 579 friend class SpdyStreamTest;
577 friend class test::TestSpdyVisitor; 580 friend class test::TestSpdyVisitor;
578 friend class test::SpdyFramerPeer; 581 friend class test::SpdyFramerPeer;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 // SPDY header compressors. 761 // SPDY header compressors.
759 std::unique_ptr<z_stream> header_compressor_; 762 std::unique_ptr<z_stream> header_compressor_;
760 std::unique_ptr<z_stream> header_decompressor_; 763 std::unique_ptr<z_stream> header_decompressor_;
761 764
762 std::unique_ptr<HpackEncoder> hpack_encoder_; 765 std::unique_ptr<HpackEncoder> hpack_encoder_;
763 std::unique_ptr<HpackDecoder> hpack_decoder_; 766 std::unique_ptr<HpackDecoder> hpack_decoder_;
764 767
765 SpdyFramerVisitorInterface* visitor_; 768 SpdyFramerVisitorInterface* visitor_;
766 SpdyFramerDebugVisitorInterface* debug_visitor_; 769 SpdyFramerDebugVisitorInterface* debug_visitor_;
767 770
771 std::unique_ptr<SpdyHeadersBlockParser> header_parser_;
772 SpdyHeadersHandlerInterface* header_handler_;
773
768 std::string display_protocol_; 774 std::string display_protocol_;
769 775
770 // The protocol version to be spoken/understood by this framer. 776 // The protocol version to be spoken/understood by this framer.
771 const SpdyMajorVersion protocol_version_; 777 const SpdyMajorVersion protocol_version_;
772 778
773 // The flags field of the frame currently being read. 779 // The flags field of the frame currently being read.
774 uint8_t current_frame_flags_; 780 uint8_t current_frame_flags_;
775 781
776 // Determines whether HPACK or gzip compression is used. 782 // Determines whether HPACK or gzip compression is used.
777 bool enable_compression_; 783 bool enable_compression_;
(...skipping 20 matching lines...) Expand all
798 bool end_stream_when_done_; 804 bool end_stream_when_done_;
799 805
800 // If true, then ProcessInput returns after processing a full frame, 806 // If true, then ProcessInput returns after processing a full frame,
801 // rather than reading all available input. 807 // rather than reading all available input.
802 bool process_single_input_frame_ = false; 808 bool process_single_input_frame_ = false;
803 }; 809 };
804 810
805 } // namespace net 811 } // namespace net
806 812
807 #endif // NET_SPDY_SPDY_FRAMER_H_ 813 #endif // NET_SPDY_SPDY_FRAMER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698