// 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_DECODE_BUFFER_H_ #define QUICHE_HTTP2_DECODER_DECODE_BUFFER_H_ // DecodeBuffer provides primitives for decoding various integer types found in // HTTP/2 frames. It wraps a byte array from which we can read and decode // serialized HTTP/2 frames, or parts thereof. DecodeBuffer is intended only for // stack allocation, where the caller is typically going to use the DecodeBuffer // instance as part of decoding the entire buffer before returning to its own // caller. #include <stddef.h> #include <algorithm> #include <cstdint> #include "absl/strings/string_view.h" #include "quiche/common/platform/api/quiche_export.h" #include "quiche/common/platform/api/quiche_logging.h" namespace http2 { class DecodeBufferSubset; class QUICHE_EXPORT DecodeBuffer { … }; // DecodeBufferSubset is used when decoding a known sized chunk of data, which // starts at base->cursor(), and continues for subset_len, which may be // entirely in |base|, or may extend beyond it (hence the MinLengthRemaining // in the constructor). // There are two benefits to using DecodeBufferSubset: it ensures that the // cursor of |base| is advanced when the subset's destructor runs, and it // ensures that the consumer of the subset can't go beyond the subset which // it is intended to decode. // There must be only a single DecodeBufferSubset at a time for a base // DecodeBuffer, though they can be nested (i.e. a DecodeBufferSubset's // base may itself be a DecodeBufferSubset). This avoids the AdvanceCursor // being called erroneously. class QUICHE_EXPORT DecodeBufferSubset : public DecodeBuffer { … }; } // namespace http2 #endif // QUICHE_HTTP2_DECODER_DECODE_BUFFER_H_