blob: f78fca94f164e5465c9eca1a8f5cf8b8d64f975f [file] [log] [blame]
// Copyright (c) 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <cstdint>
#include "absl/strings/string_view.h"
#include "quiche/quic/core/qpack/qpack_instruction_decoder.h"
#include "quiche/quic/core/qpack/qpack_stream_receiver.h"
#include "quiche/quic/core/quic_error_codes.h"
#include "quiche/quic/core/quic_types.h"
#include "quiche/quic/platform/api/quic_export.h"
namespace quic {
// This class decodes data received on the decoder stream,
// and passes it along to its Delegate.
class QUIC_EXPORT_PRIVATE QpackDecoderStreamReceiver
: public QpackInstructionDecoder::Delegate,
public QpackStreamReceiver {
// An interface for handling instructions decoded from the decoder stream, see
class QUIC_EXPORT_PRIVATE Delegate {
virtual ~Delegate() = default;
// 5.3.1 Insert Count Increment
virtual void OnInsertCountIncrement(uint64_t increment) = 0;
// 5.3.2 Header Acknowledgement
virtual void OnHeaderAcknowledgement(QuicStreamId stream_id) = 0;
// 5.3.3 Stream Cancellation
virtual void OnStreamCancellation(QuicStreamId stream_id) = 0;
// Decoding error
virtual void OnErrorDetected(QuicErrorCode error_code,
absl::string_view error_message) = 0;
explicit QpackDecoderStreamReceiver(Delegate* delegate);
QpackDecoderStreamReceiver() = delete;
QpackDecoderStreamReceiver(const QpackDecoderStreamReceiver&) = delete;
QpackDecoderStreamReceiver& operator=(const QpackDecoderStreamReceiver&) =
// Implements QpackStreamReceiver::Decode().
// Decode data and call appropriate Delegate method after each decoded
// instruction. Once an error occurs, Delegate::OnErrorDetected() is called,
// and all further data is ignored.
void Decode(absl::string_view data) override;
// QpackInstructionDecoder::Delegate implementation.
bool OnInstructionDecoded(const QpackInstruction* instruction) override;
void OnInstructionDecodingError(QpackInstructionDecoder::ErrorCode error_code,
absl::string_view error_message) override;
QpackInstructionDecoder instruction_decoder_;
Delegate* const delegate_;
// True if a decoding error has been detected.
bool error_detected_;
} // namespace quic