QUICHE team | fd50a40 | 2018-12-07 22:54:05 -0500 | [diff] [blame] | 1 | // Copyright 2016 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_HTTP2_HPACK_DECODER_HPACK_BLOCK_DECODER_H_ |
| 6 | #define QUICHE_HTTP2_HPACK_DECODER_HPACK_BLOCK_DECODER_H_ |
| 7 | |
| 8 | // HpackBlockDecoder decodes an entire HPACK block (or the available portion |
| 9 | // thereof in the DecodeBuffer) into entries, but doesn't include HPACK static |
| 10 | // or dynamic table support, so table indices remain indices at this level. |
| 11 | // Reports the entries to an HpackEntryDecoderListener. |
| 12 | |
QUICHE team | fd50a40 | 2018-12-07 22:54:05 -0500 | [diff] [blame] | 13 | #include "net/third_party/quiche/src/http2/decoder/decode_buffer.h" |
| 14 | #include "net/third_party/quiche/src/http2/decoder/decode_status.h" |
| 15 | #include "net/third_party/quiche/src/http2/hpack/decoder/hpack_entry_decoder.h" |
| 16 | #include "net/third_party/quiche/src/http2/hpack/decoder/hpack_entry_decoder_listener.h" |
| 17 | #include "net/third_party/quiche/src/http2/platform/api/http2_export.h" |
QUICHE team | 61940b4 | 2019-03-07 23:32:27 -0500 | [diff] [blame] | 18 | #include "net/third_party/quiche/src/http2/platform/api/http2_logging.h" |
QUICHE team | fd50a40 | 2018-12-07 22:54:05 -0500 | [diff] [blame] | 19 | #include "net/third_party/quiche/src/http2/platform/api/http2_string.h" |
| 20 | |
| 21 | namespace http2 { |
| 22 | |
| 23 | class HTTP2_EXPORT_PRIVATE HpackBlockDecoder { |
| 24 | public: |
| 25 | explicit HpackBlockDecoder(HpackEntryDecoderListener* listener) |
| 26 | : listener_(listener) { |
| 27 | DCHECK_NE(listener_, nullptr); |
| 28 | } |
| 29 | ~HpackBlockDecoder() {} |
| 30 | |
| 31 | HpackBlockDecoder(const HpackBlockDecoder&) = delete; |
| 32 | HpackBlockDecoder& operator=(const HpackBlockDecoder&) = delete; |
| 33 | |
| 34 | // Prepares the decoder to start decoding a new HPACK block. Expected |
| 35 | // to be called from an implementation of Http2FrameDecoderListener's |
| 36 | // OnHeadersStart or OnPushPromiseStart methods. |
| 37 | void Reset() { |
QUICHE team | 61940b4 | 2019-03-07 23:32:27 -0500 | [diff] [blame] | 38 | HTTP2_DVLOG(2) << "HpackBlockDecoder::Reset"; |
QUICHE team | fd50a40 | 2018-12-07 22:54:05 -0500 | [diff] [blame] | 39 | before_entry_ = true; |
| 40 | } |
| 41 | |
| 42 | // Decode the fragment of the HPACK block contained in the decode buffer. |
| 43 | // Expected to be called from an implementation of Http2FrameDecoderListener's |
| 44 | // OnHpackFragment method. |
| 45 | DecodeStatus Decode(DecodeBuffer* db); |
| 46 | |
| 47 | // Is the decoding process between entries (i.e. would the next byte be the |
| 48 | // first byte of a new HPACK entry)? |
| 49 | bool before_entry() const { return before_entry_; } |
| 50 | |
| 51 | Http2String DebugString() const; |
| 52 | |
| 53 | private: |
| 54 | HpackEntryDecoder entry_decoder_; |
| 55 | HpackEntryDecoderListener* const listener_; |
| 56 | bool before_entry_ = true; |
| 57 | }; |
| 58 | |
| 59 | HTTP2_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, |
| 60 | const HpackBlockDecoder& v); |
| 61 | |
| 62 | } // namespace http2 |
| 63 | |
| 64 | #endif // QUICHE_HTTP2_HPACK_DECODER_HPACK_BLOCK_DECODER_H_ |