OLD | NEW |
(Empty) | |
| 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 NET_HTTP2_HPACK_DECODER_HPACK_BLOCK_DECODER_H_ |
| 6 #define NET_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 |
| 13 #include <string> |
| 14 |
| 15 #include "base/logging.h" |
| 16 #include "base/macros.h" |
| 17 #include "net/base/net_export.h" |
| 18 #include "net/http2/decoder/decode_buffer.h" |
| 19 #include "net/http2/decoder/decode_status.h" |
| 20 #include "net/http2/hpack/decoder/hpack_entry_decoder.h" |
| 21 #include "net/http2/hpack/decoder/hpack_entry_decoder_listener.h" |
| 22 |
| 23 namespace net { |
| 24 |
| 25 class NET_EXPORT_PRIVATE HpackBlockDecoder { |
| 26 public: |
| 27 explicit HpackBlockDecoder(HpackEntryDecoderListener* listener) |
| 28 : listener_(listener) { |
| 29 DCHECK_NE(listener_, nullptr); |
| 30 } |
| 31 ~HpackBlockDecoder() {} |
| 32 |
| 33 // The listener may be changed at any time. The change takes effect on the |
| 34 // next entry into the decode loop of the Decode() method below. |
| 35 void set_listener(HpackEntryDecoderListener* listener) { |
| 36 DCHECK_NE(nullptr, listener); |
| 37 listener_ = listener; |
| 38 } |
| 39 HpackEntryDecoderListener* listener() { return listener_; } |
| 40 |
| 41 // Prepares the decoder to start decoding a new HPACK block. Expected |
| 42 // to be called from an implementation of Http2FrameDecoderListener's |
| 43 // OnHeadersStart or OnPushPromiseStart methods. |
| 44 void Reset() { |
| 45 DVLOG(2) << "HpackBlockDecoder::Reset"; |
| 46 before_entry_ = true; |
| 47 } |
| 48 |
| 49 // Decode the fragment of the HPACK block contained in the decode buffer. |
| 50 // Expected to be called from an implementation of Http2FrameDecoderListener's |
| 51 // OnHpackFragment method. |
| 52 DecodeStatus Decode(DecodeBuffer* db); |
| 53 |
| 54 std::string DebugString() const; |
| 55 |
| 56 private: |
| 57 HpackEntryDecoder entry_decoder_; |
| 58 HpackEntryDecoderListener* listener_; |
| 59 bool before_entry_ = true; |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(HpackBlockDecoder); |
| 62 }; |
| 63 |
| 64 NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, |
| 65 const HpackBlockDecoder& v); |
| 66 |
| 67 } // namespace net |
| 68 |
| 69 #endif // NET_HTTP2_HPACK_DECODER_HPACK_BLOCK_DECODER_H_ |
OLD | NEW |