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_DECODER_DECODE_HTTP2_STRUCTURES_H_ | |
6 #define NET_HTTP2_DECODER_DECODE_HTTP2_STRUCTURES_H_ | |
7 | |
8 // Provides functions for decoding the fixed size structures in the HTTP/2 spec. | |
9 | |
10 // TODO(jamessynge): Consider whether the value of the SlowDecode methods is | |
11 // worth their complexity; in particular, dropping back to buffering at most | |
12 // 9 bytes (the largest fixed size structure) may actually be more efficient | |
13 // than using the SlowDecode methods, or at least worth the complexity | |
14 // reduction. | |
15 // See http2_structure_decoder.h et al for an experiment in removing all except | |
16 // DoDecode. | |
17 | |
18 #include "net/base/net_export.h" | |
19 #include "net/http2/decoder/decode_buffer.h" | |
20 #include "net/http2/http2_structures.h" | |
21 | |
22 namespace net { | |
23 | |
24 // DoDecode(STRUCTURE* out, DecodeBuffer* b) decodes the structure from start | |
25 // to end, advancing the cursor by STRUCTURE::EncodedSize(). The decoder buffer | |
26 // must be large enough (i.e. b->Remaining() >= STRUCTURE::EncodedSize()). | |
27 | |
28 NET_EXPORT_PRIVATE void DoDecode(Http2FrameHeader* out, DecodeBuffer* b); | |
29 NET_EXPORT_PRIVATE void DoDecode(Http2PriorityFields* out, DecodeBuffer* b); | |
30 NET_EXPORT_PRIVATE void DoDecode(Http2RstStreamFields* out, DecodeBuffer* b); | |
31 NET_EXPORT_PRIVATE void DoDecode(Http2SettingFields* out, DecodeBuffer* b); | |
32 NET_EXPORT_PRIVATE void DoDecode(Http2PushPromiseFields* out, DecodeBuffer* b); | |
33 NET_EXPORT_PRIVATE void DoDecode(Http2PingFields* out, DecodeBuffer* b); | |
34 NET_EXPORT_PRIVATE void DoDecode(Http2GoAwayFields* out, DecodeBuffer* b); | |
35 NET_EXPORT_PRIVATE void DoDecode(Http2WindowUpdateFields* out, DecodeBuffer* b); | |
36 NET_EXPORT_PRIVATE void DoDecode(Http2AltSvcFields* out, DecodeBuffer* b); | |
37 | |
38 // MaybeDecode(STRUCTURE* out, DecodeBuffer* b) decodes the structure from | |
39 // start to end if the decoder buffer is large enough, advancing the cursor | |
40 // by STRUCTURE::EncodedSize(), then returns true. | |
41 // If the decode buffer isn't large enough, does nothing and returns false. | |
42 // The buffer is large enough if b->Remaining() >= STRUCTURE::EncodedSize(). | |
43 | |
44 NET_EXPORT_PRIVATE bool MaybeDecode(Http2FrameHeader* out, DecodeBuffer* b); | |
45 NET_EXPORT_PRIVATE bool MaybeDecode(Http2PriorityFields* out, DecodeBuffer* b); | |
46 NET_EXPORT_PRIVATE bool MaybeDecode(Http2RstStreamFields* out, DecodeBuffer* b); | |
47 NET_EXPORT_PRIVATE bool MaybeDecode(Http2SettingFields* out, DecodeBuffer* b); | |
48 NET_EXPORT_PRIVATE bool MaybeDecode(Http2PushPromiseFields* out, | |
49 DecodeBuffer* b); | |
50 NET_EXPORT_PRIVATE bool MaybeDecode(Http2PingFields* out, DecodeBuffer* b); | |
51 NET_EXPORT_PRIVATE bool MaybeDecode(Http2GoAwayFields* out, DecodeBuffer* b); | |
52 NET_EXPORT_PRIVATE bool MaybeDecode(Http2WindowUpdateFields* out, | |
53 DecodeBuffer* b); | |
54 NET_EXPORT_PRIVATE bool MaybeDecode(Http2AltSvcFields* out, DecodeBuffer* b); | |
55 | |
56 // SlowDecode(STRUCTURE* out, DecodeBuffer* b, uint32_t* offset) provides | |
57 // incremental decoding of a structure, supporting cases where the structure | |
58 // is split across multiple input buffers. *offset represents the offset within | |
59 // the encoding of the structure, in the range [0, STRUCTURE::EncodedSize()]. | |
60 // Returns true when it is able to completely decode the structure, false | |
61 // before that. Updates *offset to record the progress decoding the structure; | |
62 // if false is returned, then b->Remaining() == 0 when SlowDecode returns. | |
63 | |
64 NET_EXPORT_PRIVATE bool SlowDecode(Http2FrameHeader* out, | |
65 DecodeBuffer* b, | |
66 uint32_t* offset); | |
67 NET_EXPORT_PRIVATE bool SlowDecode(Http2PriorityFields* out, | |
68 DecodeBuffer* b, | |
69 uint32_t* offset); | |
70 NET_EXPORT_PRIVATE bool SlowDecode(Http2RstStreamFields* out, | |
71 DecodeBuffer* b, | |
72 uint32_t* offset); | |
73 NET_EXPORT_PRIVATE bool SlowDecode(Http2SettingFields* out, | |
74 DecodeBuffer* b, | |
75 uint32_t* offset); | |
76 NET_EXPORT_PRIVATE bool SlowDecode(Http2PushPromiseFields* out, | |
77 DecodeBuffer* b, | |
78 uint32_t* offset); | |
79 NET_EXPORT_PRIVATE bool SlowDecode(Http2PingFields* out, | |
80 DecodeBuffer* b, | |
81 uint32_t* offset); | |
82 NET_EXPORT_PRIVATE bool SlowDecode(Http2GoAwayFields* out, | |
83 DecodeBuffer* b, | |
84 uint32_t* offset); | |
85 NET_EXPORT_PRIVATE bool SlowDecode(Http2WindowUpdateFields* out, | |
86 DecodeBuffer* b, | |
87 uint32_t* offset); | |
88 NET_EXPORT_PRIVATE bool SlowDecode(Http2AltSvcFields* out, | |
89 DecodeBuffer* b, | |
90 uint32_t* offset); | |
91 | |
92 } // namespace net | |
93 | |
94 #endif // NET_HTTP2_DECODER_DECODE_HTTP2_STRUCTURES_H_ | |
OLD | NEW |