| 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_PUSH_PROMISE_PAYLOAD_DECODER_H_ | |
| 6 #define NET_HTTP2_DECODER_PAYLOAD_DECODERS_PUSH_PROMISE_PAYLOAD_DECODER_H_ | |
| 7 | |
| 8 // Decodes the payload of a PUSH_PROMISE 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 PushPromisePayloadDecoderPeer; | |
| 19 } // namespace test | |
| 20 | |
| 21 class NET_EXPORT_PRIVATE PushPromisePayloadDecoder { | |
| 22 public: | |
| 23 // States during decoding of a PUSH_PROMISE frame. | |
| 24 enum class PayloadState { | |
| 25 // The frame is padded and we need to read the PAD_LENGTH field (1 byte). | |
| 26 kReadPadLength, | |
| 27 | |
| 28 // Ready to start decoding the fixed size fields of the PUSH_PROMISE | |
| 29 // frame into push_promise_fields_. | |
| 30 kStartDecodingPushPromiseFields, | |
| 31 | |
| 32 // The decoder has already called OnPushPromiseStart, and is now reporting | |
| 33 // the HPACK block fragment to the listener's OnHpackFragment method. | |
| 34 kReadPayload, | |
| 35 | |
| 36 // The decoder has finished with the HPACK block fragment, and is now | |
| 37 // ready to skip the trailing padding, if the frame has any. | |
| 38 kSkipPadding, | |
| 39 | |
| 40 // The fixed size fields weren't all available when the decoder first tried | |
| 41 // to decode them (state kStartDecodingPushPromiseFields); this state | |
| 42 // resumes the decoding when ResumeDecodingPayload is called later. | |
| 43 kResumeDecodingPushPromiseFields, | |
| 44 }; | |
| 45 | |
| 46 // Starts the decoding of a PUSH_PROMISE frame's payload, and completes it if | |
| 47 // the entire payload is in the provided decode buffer. | |
| 48 DecodeStatus StartDecodingPayload(FrameDecoderState* state, DecodeBuffer* db); | |
| 49 | |
| 50 // Resumes decoding a PUSH_PROMISE frame's payload that has been split across | |
| 51 // decode buffers. | |
| 52 DecodeStatus ResumeDecodingPayload(FrameDecoderState* state, | |
| 53 DecodeBuffer* db); | |
| 54 | |
| 55 private: | |
| 56 friend class test::PushPromisePayloadDecoderPeer; | |
| 57 | |
| 58 void ReportPushPromise(FrameDecoderState* state); | |
| 59 | |
| 60 PayloadState payload_state_; | |
| 61 Http2PushPromiseFields push_promise_fields_; | |
| 62 }; | |
| 63 | |
| 64 } // namespace net | |
| 65 | |
| 66 #endif // NET_HTTP2_DECODER_PAYLOAD_DECODERS_PUSH_PROMISE_PAYLOAD_DECODER_H_ | |
| OLD | NEW |