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_STRING_DECODER_LISTENER_H_ | |
6 #define NET_HTTP2_HPACK_DECODER_HPACK_STRING_DECODER_LISTENER_H_ | |
7 | |
8 // Defines HpackStringDecoderListener which defines the methods required by an | |
9 // HpackStringDecoder. Also defines HpackStringDecoderVLoggingListener which | |
10 // logs before calling another HpackStringDecoderListener implementation. | |
11 // For now these are only used by tests, so placed in the test namespace. | |
12 | |
13 #include <stddef.h> | |
14 | |
15 #include "net/base/net_export.h" | |
16 | |
17 namespace net { | |
18 namespace test { | |
19 | |
20 // HpackStringDecoder methods require a listener that implements the methods | |
21 // below, but it is NOT necessary to extend this class because the methods | |
22 // are templates. | |
23 class NET_EXPORT_PRIVATE HpackStringDecoderListener { | |
24 public: | |
25 virtual ~HpackStringDecoderListener() {} | |
26 | |
27 // Called at the start of decoding an HPACK string. The encoded length of the | |
28 // string is |len| bytes, which may be zero. The string is Huffman encoded | |
29 // if huffman_encoded is true, else it is plain text (i.e. the encoded length | |
30 // is then the plain text length). | |
31 virtual void OnStringStart(bool huffman_encoded, size_t len) = 0; | |
32 | |
33 // Called when some data is available, or once when the string length is zero | |
34 // (to simplify the decoder, it doesn't have a special case for len==0). | |
35 virtual void OnStringData(const char* data, size_t len) = 0; | |
36 | |
37 // Called after OnStringData has provided all of the encoded bytes of the | |
38 // string. | |
39 virtual void OnStringEnd() = 0; | |
40 }; | |
41 | |
42 class NET_EXPORT_PRIVATE HpackStringDecoderVLoggingListener | |
43 : public HpackStringDecoderListener { | |
44 public: | |
45 HpackStringDecoderVLoggingListener() : wrapped_(nullptr) {} | |
46 explicit HpackStringDecoderVLoggingListener( | |
47 HpackStringDecoderListener* wrapped) | |
48 : wrapped_(wrapped) {} | |
49 ~HpackStringDecoderVLoggingListener() override {} | |
50 | |
51 void OnStringStart(bool huffman_encoded, size_t len) override; | |
52 void OnStringData(const char* data, size_t len) override; | |
53 void OnStringEnd() override; | |
54 | |
55 private: | |
56 HpackStringDecoderListener* const wrapped_; | |
57 }; | |
58 | |
59 } // namespace test | |
60 } // namespace net | |
61 | |
62 #endif // NET_HTTP2_HPACK_DECODER_HPACK_STRING_DECODER_LISTENER_H_ | |
OLD | NEW |