Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(735)

Unified Diff: net/http2/decoder/decode_http2_structures.h

Issue 2293613002: Add new HTTP/2 and HPACK decoder in net/http2/. (Closed)
Patch Set: Replace LOG(INFO) by VLOG(2) in DecodeBufferTest.SlowDecodeTestStruct so that trybots do not fail. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http2/decoder/decode_buffer_test.cc ('k') | net/http2/decoder/decode_http2_structures.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http2/decoder/decode_http2_structures.h
diff --git a/net/http2/decoder/decode_http2_structures.h b/net/http2/decoder/decode_http2_structures.h
new file mode 100644
index 0000000000000000000000000000000000000000..7cee46f26a69865344cabdff6bfd495889ac1117
--- /dev/null
+++ b/net/http2/decoder/decode_http2_structures.h
@@ -0,0 +1,94 @@
+// 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_DECODER_DECODE_HTTP2_STRUCTURES_H_
+#define NET_HTTP2_DECODER_DECODE_HTTP2_STRUCTURES_H_
+
+// Provides functions for decoding the fixed size structures in the HTTP/2 spec.
+
+// TODO(jamessynge): Consider whether the value of the SlowDecode methods is
+// worth their complexity; in particular, dropping back to buffering at most
+// 9 bytes (the largest fixed size structure) may actually be more efficient
+// than using the SlowDecode methods, or at least worth the complexity
+// reduction.
+// See http2_structure_decoder.h et al for an experiment in removing all except
+// DoDecode.
+
+#include "net/base/net_export.h"
+#include "net/http2/decoder/decode_buffer.h"
+#include "net/http2/http2_structures.h"
+
+namespace net {
+
+// DoDecode(STRUCTURE* out, DecodeBuffer* b) decodes the structure from start
+// to end, advancing the cursor by STRUCTURE::EncodedSize(). The decoder buffer
+// must be large enough (i.e. b->Remaining() >= STRUCTURE::EncodedSize()).
+
+NET_EXPORT_PRIVATE void DoDecode(Http2FrameHeader* out, DecodeBuffer* b);
+NET_EXPORT_PRIVATE void DoDecode(Http2PriorityFields* out, DecodeBuffer* b);
+NET_EXPORT_PRIVATE void DoDecode(Http2RstStreamFields* out, DecodeBuffer* b);
+NET_EXPORT_PRIVATE void DoDecode(Http2SettingFields* out, DecodeBuffer* b);
+NET_EXPORT_PRIVATE void DoDecode(Http2PushPromiseFields* out, DecodeBuffer* b);
+NET_EXPORT_PRIVATE void DoDecode(Http2PingFields* out, DecodeBuffer* b);
+NET_EXPORT_PRIVATE void DoDecode(Http2GoAwayFields* out, DecodeBuffer* b);
+NET_EXPORT_PRIVATE void DoDecode(Http2WindowUpdateFields* out, DecodeBuffer* b);
+NET_EXPORT_PRIVATE void DoDecode(Http2AltSvcFields* out, DecodeBuffer* b);
+
+// MaybeDecode(STRUCTURE* out, DecodeBuffer* b) decodes the structure from
+// start to end if the decoder buffer is large enough, advancing the cursor
+// by STRUCTURE::EncodedSize(), then returns true.
+// If the decode buffer isn't large enough, does nothing and returns false.
+// The buffer is large enough if b->Remaining() >= STRUCTURE::EncodedSize().
+
+NET_EXPORT_PRIVATE bool MaybeDecode(Http2FrameHeader* out, DecodeBuffer* b);
+NET_EXPORT_PRIVATE bool MaybeDecode(Http2PriorityFields* out, DecodeBuffer* b);
+NET_EXPORT_PRIVATE bool MaybeDecode(Http2RstStreamFields* out, DecodeBuffer* b);
+NET_EXPORT_PRIVATE bool MaybeDecode(Http2SettingFields* out, DecodeBuffer* b);
+NET_EXPORT_PRIVATE bool MaybeDecode(Http2PushPromiseFields* out,
+ DecodeBuffer* b);
+NET_EXPORT_PRIVATE bool MaybeDecode(Http2PingFields* out, DecodeBuffer* b);
+NET_EXPORT_PRIVATE bool MaybeDecode(Http2GoAwayFields* out, DecodeBuffer* b);
+NET_EXPORT_PRIVATE bool MaybeDecode(Http2WindowUpdateFields* out,
+ DecodeBuffer* b);
+NET_EXPORT_PRIVATE bool MaybeDecode(Http2AltSvcFields* out, DecodeBuffer* b);
+
+// SlowDecode(STRUCTURE* out, DecodeBuffer* b, uint32_t* offset) provides
+// incremental decoding of a structure, supporting cases where the structure
+// is split across multiple input buffers. *offset represents the offset within
+// the encoding of the structure, in the range [0, STRUCTURE::EncodedSize()].
+// Returns true when it is able to completely decode the structure, false
+// before that. Updates *offset to record the progress decoding the structure;
+// if false is returned, then b->Remaining() == 0 when SlowDecode returns.
+
+NET_EXPORT_PRIVATE bool SlowDecode(Http2FrameHeader* out,
+ DecodeBuffer* b,
+ uint32_t* offset);
+NET_EXPORT_PRIVATE bool SlowDecode(Http2PriorityFields* out,
+ DecodeBuffer* b,
+ uint32_t* offset);
+NET_EXPORT_PRIVATE bool SlowDecode(Http2RstStreamFields* out,
+ DecodeBuffer* b,
+ uint32_t* offset);
+NET_EXPORT_PRIVATE bool SlowDecode(Http2SettingFields* out,
+ DecodeBuffer* b,
+ uint32_t* offset);
+NET_EXPORT_PRIVATE bool SlowDecode(Http2PushPromiseFields* out,
+ DecodeBuffer* b,
+ uint32_t* offset);
+NET_EXPORT_PRIVATE bool SlowDecode(Http2PingFields* out,
+ DecodeBuffer* b,
+ uint32_t* offset);
+NET_EXPORT_PRIVATE bool SlowDecode(Http2GoAwayFields* out,
+ DecodeBuffer* b,
+ uint32_t* offset);
+NET_EXPORT_PRIVATE bool SlowDecode(Http2WindowUpdateFields* out,
+ DecodeBuffer* b,
+ uint32_t* offset);
+NET_EXPORT_PRIVATE bool SlowDecode(Http2AltSvcFields* out,
+ DecodeBuffer* b,
+ uint32_t* offset);
+
+} // namespace net
+
+#endif // NET_HTTP2_DECODER_DECODE_HTTP2_STRUCTURES_H_
« no previous file with comments | « net/http2/decoder/decode_buffer_test.cc ('k') | net/http2/decoder/decode_http2_structures.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698