OLD | NEW |
| (Empty) |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef NET_HTTP2_DECODER_PAYLOAD_DECODERS_HEADERS_PAYLOAD_DECODER_H_ | |
6 #define NET_HTTP2_DECODER_PAYLOAD_DECODERS_HEADERS_PAYLOAD_DECODER_H_ | |
7 | |
8 // Decodes the payload of a HEADERS frame. | |
9 | |
10 #include "net/base/net_export.h" | |
11 #include "net/http2/decoder/decode_buffer.h" | |
12 #include "net/http2/decoder/decode_status.h" | |
13 #include "net/http2/decoder/frame_decoder_state.h" | |
14 #include "net/http2/http2_structures.h" | |
15 | |
16 namespace net { | |
17 namespace test { | |
18 class HeadersPayloadDecoderPeer; | |
19 } // namespace test | |
20 | |
21 class NET_EXPORT_PRIVATE HeadersPayloadDecoder { | |
22 public: | |
23 // States during decoding of a HEADERS frame, unless the fast path kicks | |
24 // in, in which case the state machine will be bypassed. | |
25 enum class PayloadState { | |
26 // The PADDED flag is set, and we now need to read the Pad Length field | |
27 // (the first byte of the payload, after the common frame header). | |
28 kReadPadLength, | |
29 | |
30 // The PRIORITY flag is set, and we now need to read the fixed size priority | |
31 // fields (E, Stream Dependency, Weight) into priority_fields_. Calls on | |
32 // OnHeadersPriority if completely decodes those fields. | |
33 kStartDecodingPriorityFields, | |
34 | |
35 // The decoder passes the non-padding portion of the remaining payload | |
36 // (i.e. the HPACK block fragment) to the listener's OnHpackFragment method. | |
37 kReadPayload, | |
38 | |
39 // The decoder has finished with the HPACK block fragment, and is now | |
40 // ready to skip the trailing padding, if the frame has any. | |
41 kSkipPadding, | |
42 | |
43 // The fixed size fields weren't all available when the decoder first tried | |
44 // to decode them (state kStartDecodingPriorityFields); this state resumes | |
45 // the decoding when ResumeDecodingPayload is called later. | |
46 kResumeDecodingPriorityFields, | |
47 }; | |
48 | |
49 // Starts the decoding of a HEADERS frame's payload, and completes it if | |
50 // the entire payload is in the provided decode buffer. | |
51 DecodeStatus StartDecodingPayload(FrameDecoderState* state, DecodeBuffer* db); | |
52 | |
53 // Resumes decoding a HEADERS frame's payload that has been split across | |
54 // decode buffers. | |
55 DecodeStatus ResumeDecodingPayload(FrameDecoderState* state, | |
56 DecodeBuffer* db); | |
57 | |
58 private: | |
59 friend class test::HeadersPayloadDecoderPeer; | |
60 | |
61 PayloadState payload_state_; | |
62 Http2PriorityFields priority_fields_; | |
63 }; | |
64 | |
65 } // namespace net | |
66 | |
67 #endif // NET_HTTP2_DECODER_PAYLOAD_DECODERS_HEADERS_PAYLOAD_DECODER_H_ | |
OLD | NEW |