Create a new interface called QpackStreamReceiver and make Qpack(Decoder/Encoder)StreamReceiver derive from it. The new interface will be used in QpackReceiveStream to decode data. gfe-relnote: v99 only, not used in prod. PiperOrigin-RevId: 255638066 Change-Id: I6bf86f356e49f2846e63b2fa422a7e1e59e7a800
diff --git a/quic/core/qpack/qpack_decoder_stream_receiver.h b/quic/core/qpack/qpack_decoder_stream_receiver.h index 61c2773..6071939 100644 --- a/quic/core/qpack/qpack_decoder_stream_receiver.h +++ b/quic/core/qpack/qpack_decoder_stream_receiver.h
@@ -8,6 +8,7 @@ #include <cstdint> #include "net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.h" +#include "net/third_party/quiche/src/quic/core/qpack/qpack_stream_receiver.h" #include "net/third_party/quiche/src/quic/core/quic_types.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" #include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" @@ -17,7 +18,8 @@ // 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 QpackInstructionDecoder::Delegate, + public QpackStreamReceiver { public: // An interface for handling instructions decoded from the decoder stream, see // https://quicwg.org/base-drafts/draft-ietf-quic-qpack.html#rfc.section.5.3 @@ -41,10 +43,11 @@ QpackDecoderStreamReceiver& operator=(const QpackDecoderStreamReceiver&) = delete; + // 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(QuicStringPiece data); + void Decode(QuicStringPiece data) override; // QpackInstructionDecoder::Delegate implementation. bool OnInstructionDecoded(const QpackInstruction* instruction) override;
diff --git a/quic/core/qpack/qpack_encoder_stream_receiver.h b/quic/core/qpack/qpack_encoder_stream_receiver.h index 5519b4c..8da3147 100644 --- a/quic/core/qpack/qpack_encoder_stream_receiver.h +++ b/quic/core/qpack/qpack_encoder_stream_receiver.h
@@ -9,6 +9,7 @@ #include <string> #include "net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.h" +#include "net/third_party/quiche/src/quic/core/qpack/qpack_stream_receiver.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" #include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" @@ -16,7 +17,8 @@ // This class decodes data received on the encoder stream. class QUIC_EXPORT_PRIVATE QpackEncoderStreamReceiver - : public QpackInstructionDecoder::Delegate { + : public QpackInstructionDecoder::Delegate, + public QpackStreamReceiver { public: // An interface for handling instructions decoded from the encoder stream, see // https://quicwg.org/base-drafts/draft-ietf-quic-qpack.html#rfc.section.5.2 @@ -46,10 +48,11 @@ delete; ~QpackEncoderStreamReceiver() override = default; + // 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(QuicStringPiece data); + void Decode(QuicStringPiece data) override; // QpackInstructionDecoder::Delegate implementation. bool OnInstructionDecoded(const QpackInstruction* instruction) override;
diff --git a/quic/core/qpack/qpack_stream_receiver.h b/quic/core/qpack/qpack_stream_receiver.h new file mode 100644 index 0000000..48f5aa30 --- /dev/null +++ b/quic/core/qpack/qpack_stream_receiver.h
@@ -0,0 +1,24 @@ +// Copyright (c) 2019 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. + +#ifndef QUICHE_QUIC_CORE_QPACK_QPACK_STREAM_RECEIVER_H_ +#define QUICHE_QUIC_CORE_QPACK_QPACK_STREAM_RECEIVER_H_ + +#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" + +namespace quic { + +// This interface decodes QPACK data that are received on a QpackReceiveStream. +class QUIC_EXPORT_PRIVATE QpackStreamReceiver { + public: + virtual ~QpackStreamReceiver() = default; + + // Decode data. + virtual void Decode(QuicStringPiece data) = 0; +}; + +} // namespace quic + +#endif // QUICHE_QUIC_CORE_QPACK_QPACK_STREAM_RECEIVER_H_