chromium/net/third_party/quiche/src/quiche/http2/decoder/http2_frame_decoder_listener.h

// Copyright 2016 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_HTTP2_DECODER_HTTP2_FRAME_DECODER_LISTENER_H_
#define QUICHE_HTTP2_DECODER_HTTP2_FRAME_DECODER_LISTENER_H_

// Http2FrameDecoderListener is the interface which the HTTP/2 decoder uses
// to report the decoded frames to a listener.
//
// The general design is to assume that the listener will copy the data it needs
// (e.g. frame headers) and will keep track of the implicit state of the
// decoding process (i.e. the decoder maintains just the information it needs in
// order to perform the decoding). Therefore, the parameters are just those with
// (potentially) new data, not previously provided info about the current frame.
//
// The calls are described as if they are made in quick succession, i.e. one
// after another, but of course the decoder needs input to decode, and the
// decoder will only call the listener once the necessary input has been
// provided. For example: OnDataStart can only be called once the 9 bytes of
// of an HTTP/2 common frame header have been received. The decoder will call
// the listener methods as soon as possible to avoid almost all buffering.
//
// The listener interface is designed so that it is possible to exactly
// reconstruct the serialized frames, with the exception of reserved bits,
// including in the frame header's flags and stream_id fields, which will have
// been cleared before the methods below are called.

#include <stddef.h>

#include <cstdint>
#include <type_traits>

#include "quiche/http2/http2_constants.h"
#include "quiche/http2/http2_structures.h"
#include "quiche/common/platform/api/quiche_export.h"

namespace http2 {

// TODO(jamessynge): Consider sorting the methods by frequency of call, if that
// helps at all.
class QUICHE_EXPORT Http2FrameDecoderListener {};

// Do nothing for each call. Useful for ignoring a frame that is invalid.
class QUICHE_EXPORT Http2FrameDecoderNoOpListener
    : public Http2FrameDecoderListener {};

static_assert;

}  // namespace http2

#endif  // QUICHE_HTTP2_DECODER_HTTP2_FRAME_DECODER_LISTENER_H_