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