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_ENTRY_TYPE_DECODER_H_ |
| 6 #define NET_HTTP2_HPACK_DECODER_HPACK_ENTRY_TYPE_DECODER_H_ |
| 7 |
| 8 // Decodes the type of an HPACK entry, and the variable length integer whose |
| 9 // prefix is in the low-order bits of the same byte, "below" the type bits. |
| 10 // The integer represents an index into static or dynamic table, which may be |
| 11 // zero, or is the new size limit of the dynamic table. |
| 12 |
| 13 #include <string> |
| 14 |
| 15 #include "base/logging.h" |
| 16 #include "net/base/net_export.h" |
| 17 #include "net/http2/decoder/decode_buffer.h" |
| 18 #include "net/http2/decoder/decode_status.h" |
| 19 #include "net/http2/hpack/decoder/hpack_varint_decoder.h" |
| 20 #include "net/http2/hpack/http2_hpack_constants.h" |
| 21 |
| 22 namespace net { |
| 23 |
| 24 class NET_EXPORT_PRIVATE HpackEntryTypeDecoder { |
| 25 public: |
| 26 // Only call when the decode buffer has data (i.e. HpackEntryDecoder must |
| 27 // not call until there is data). |
| 28 DecodeStatus Start(DecodeBuffer* db); |
| 29 |
| 30 // Only call Resume if the previous call (Start or Resume) returned |
| 31 // DecodeStatus::kDecodeInProgress. |
| 32 DecodeStatus Resume(DecodeBuffer* db) { return varint_decoder_.Resume(db); } |
| 33 |
| 34 // Returns the decoded entry type. Only call if the preceding call to Start |
| 35 // or Resume returned kDecodeDone. |
| 36 HpackEntryType entry_type() const { return entry_type_; } |
| 37 |
| 38 // Returns the decoded variable length integer. Only call if the |
| 39 // preceding call to Start or Resume returned kDecodeDone. |
| 40 uint32_t varint() const { return varint_decoder_.value(); } |
| 41 |
| 42 std::string DebugString() const; |
| 43 |
| 44 private: |
| 45 HpackVarintDecoder varint_decoder_; |
| 46 |
| 47 // This field is initialized just to keep ASAN happy about reading it |
| 48 // from DebugString(). |
| 49 HpackEntryType entry_type_ = HpackEntryType::kIndexedHeader; |
| 50 }; |
| 51 |
| 52 NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, |
| 53 const HpackEntryTypeDecoder& v); |
| 54 |
| 55 } // namespace net |
| 56 #endif // NET_HTTP2_HPACK_DECODER_HPACK_ENTRY_TYPE_DECODER_H_ |
OLD | NEW |