1 // Copyright 2020 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_PRIORITY_UPDATE_PAYLOAD_DECODER_H_ 6 #define QUICHE_HTTP2_DECODER_PAYLOAD_DECODERS_PRIORITY_UPDATE_PAYLOAD_DECODER_H_ 7 8 // Decodes the payload of a PRIORITY_UPDATE 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/http2/http2_structures.h" 14 #include "quiche/common/platform/api/quiche_export.h" 15 16 namespace http2 { 17 namespace test { 18 class PriorityUpdatePayloadDecoderPeer; 19 } // namespace test 20 21 class QUICHE_EXPORT PriorityUpdatePayloadDecoder { 22 public: 23 // States during decoding of a PRIORITY_UPDATE frame. 24 enum class PayloadState { 25 // At the start of the PRIORITY_UPDATE frame payload, ready to start 26 // decoding the fixed size fields into priority_update_fields_. 27 kStartDecodingFixedFields, 28 29 // The fixed size fields weren't all available when the decoder first 30 // tried to decode them; this state resumes the decoding when 31 // ResumeDecodingPayload is called later. 32 kResumeDecodingFixedFields, 33 34 // Handle the DecodeStatus returned from starting or resuming the decoding 35 // of Http2PriorityUpdateFields into priority_update_fields_. If complete, 36 // calls OnPriorityUpdateStart. 37 kHandleFixedFieldsStatus, 38 39 // Report the Priority Field Value portion of the payload to the listener's 40 // OnPriorityUpdatePayload method, and call OnPriorityUpdateEnd when the end 41 // of the payload is reached. 42 kReadPriorityFieldValue, 43 }; 44 45 // Starts the decoding of a PRIORITY_UPDATE frame's payload, and completes it 46 // if the entire payload is in the provided decode buffer. 47 DecodeStatus StartDecodingPayload(FrameDecoderState* state, DecodeBuffer* db); 48 49 // Resumes decoding a PRIORITY_UPDATE frame that has been split across decode 50 // buffers. 51 DecodeStatus ResumeDecodingPayload(FrameDecoderState* state, 52 DecodeBuffer* db); 53 54 private: 55 friend class test::PriorityUpdatePayloadDecoderPeer; 56 57 Http2PriorityUpdateFields priority_update_fields_; 58 PayloadState payload_state_; 59 }; 60 61 } // namespace http2 62 63 #endif // QUICHE_HTTP2_DECODER_PAYLOAD_DECODERS_PRIORITY_UPDATE_PAYLOAD_DECODER_H_ 64