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 QUICHE_HTTP2_DECODER_PAYLOAD_DECODERS_DATA_PAYLOAD_DECODER_H_ 6 #define QUICHE_HTTP2_DECODER_PAYLOAD_DECODERS_DATA_PAYLOAD_DECODER_H_ 7 8 // Decodes the payload of a DATA frame. 9 10 #include "quiche/http2/decoder/decode_buffer.h" 11 #include "quiche/http2/decoder/decode_status.h" 12 #include "quiche/http2/decoder/frame_decoder_state.h" 13 #include "quiche/common/platform/api/quiche_export.h" 14 15 namespace http2 { 16 namespace test { 17 class DataPayloadDecoderPeer; 18 } // namespace test 19 20 class QUICHE_EXPORT DataPayloadDecoder { 21 public: 22 // States during decoding of a DATA frame. 23 enum class PayloadState { 24 // The frame is padded and we need to read the PAD_LENGTH field (1 byte), 25 // and then call OnPadLength 26 kReadPadLength, 27 28 // Report the non-padding portion of the payload to the listener's 29 // OnDataPayload method. 30 kReadPayload, 31 32 // The decoder has finished with the non-padding portion of the payload, 33 // and is now ready to skip the trailing padding, if the frame has any. 34 kSkipPadding, 35 }; 36 37 // Starts decoding a DATA frame's payload, and completes it if 38 // the entire payload is in the provided decode buffer. 39 DecodeStatus StartDecodingPayload(FrameDecoderState* state, DecodeBuffer* db); 40 41 // Resumes decoding a DATA frame's payload that has been split across 42 // decode buffers. 43 DecodeStatus ResumeDecodingPayload(FrameDecoderState* state, 44 DecodeBuffer* db); 45 46 private: 47 friend class test::DataPayloadDecoderPeer; 48 49 PayloadState payload_state_; 50 }; 51 52 } // namespace http2 53 54 #endif // QUICHE_HTTP2_DECODER_PAYLOAD_DECODERS_DATA_PAYLOAD_DECODER_H_ 55