1 // Copyright (c) 2018 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_QUIC_CORE_QPACK_QPACK_DECODER_STREAM_SENDER_H_ 6 #define QUICHE_QUIC_CORE_QPACK_QPACK_DECODER_STREAM_SENDER_H_ 7 8 #include <cstdint> 9 10 #include "quiche/quic/core/qpack/qpack_instruction_encoder.h" 11 #include "quiche/quic/core/qpack/qpack_stream_sender_delegate.h" 12 #include "quiche/quic/core/quic_types.h" 13 #include "quiche/quic/platform/api/quic_export.h" 14 15 namespace quic { 16 17 // This class serializes instructions for transmission on the decoder stream. 18 // Serialized instructions are buffered until Flush() is called. 19 class QUICHE_EXPORT QpackDecoderStreamSender { 20 public: 21 QpackDecoderStreamSender(); 22 QpackDecoderStreamSender(const QpackDecoderStreamSender&) = delete; 23 QpackDecoderStreamSender& operator=(const QpackDecoderStreamSender&) = delete; 24 25 // Methods for serializing and buffering instructions, see 26 // https://quicwg.org/base-drafts/draft-ietf-quic-qpack.html#rfc.section.5.3 27 28 // 5.3.1 Insert Count Increment 29 void SendInsertCountIncrement(uint64_t increment); 30 // 5.3.2 Header Acknowledgement 31 void SendHeaderAcknowledgement(QuicStreamId stream_id); 32 // 5.3.3 Stream Cancellation 33 void SendStreamCancellation(QuicStreamId stream_id); 34 35 // Writes all buffered instructions on the decoder stream. 36 void Flush(); 37 38 // delegate must be set if dynamic table capacity is not zero. set_qpack_stream_sender_delegate(QpackStreamSenderDelegate * delegate)39 void set_qpack_stream_sender_delegate(QpackStreamSenderDelegate* delegate) { 40 delegate_ = delegate; 41 } 42 43 private: 44 QpackStreamSenderDelegate* delegate_; 45 QpackInstructionEncoder instruction_encoder_; 46 std::string buffer_; 47 }; 48 49 } // namespace quic 50 51 #endif // QUICHE_QUIC_CORE_QPACK_QPACK_DECODER_STREAM_SENDER_H_ 52