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

Unified Diff: net/http2/decoder/payload_decoders/unknown_payload_decoder.cc

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
Index: net/http2/decoder/payload_decoders/unknown_payload_decoder.cc
diff --git a/net/http2/decoder/payload_decoders/unknown_payload_decoder.cc b/net/http2/decoder/payload_decoders/unknown_payload_decoder.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ec020c1617ab17f8ae43667b44598f51c780a783
--- /dev/null
+++ b/net/http2/decoder/payload_decoders/unknown_payload_decoder.cc
@@ -0,0 +1,55 @@
+// 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.
+
+#include "net/http2/decoder/payload_decoders/unknown_payload_decoder.h"
+
+#include <stddef.h>
+
+#include "base/logging.h"
+#include "net/http2/decoder/decode_buffer.h"
+#include "net/http2/decoder/http2_frame_decoder_listener.h"
+#include "net/http2/http2_constants.h"
+#include "net/http2/http2_structures.h"
+
+namespace net {
+
+DecodeStatus UnknownPayloadDecoder::StartDecodingPayload(
+ FrameDecoderState* state,
+ DecodeBuffer* db) {
+ const Http2FrameHeader& frame_header = state->frame_header();
+
+ DVLOG(2) << "UnknownPayloadDecoder::StartDecodingPayload: " << frame_header;
+ DCHECK(!IsSupportedHttp2FrameType(frame_header.type)) << frame_header;
+ DCHECK_LE(db->Remaining(), frame_header.payload_length);
+
+ state->InitializeRemainders();
+ state->listener()->OnUnknownStart(frame_header);
+ return ResumeDecodingPayload(state, db);
+}
+
+DecodeStatus UnknownPayloadDecoder::ResumeDecodingPayload(
+ FrameDecoderState* state,
+ DecodeBuffer* db) {
+ DVLOG(2) << "UnknownPayloadDecoder::ResumeDecodingPayload "
+ << "remaining_payload=" << state->remaining_payload()
+ << "; db->Remaining=" << db->Remaining();
+ DCHECK(!IsSupportedHttp2FrameType(state->frame_header().type))
+ << state->frame_header();
+ DCHECK_LE(state->remaining_payload(), state->frame_header().payload_length);
+ DCHECK_LE(db->Remaining(), state->remaining_payload());
+
+ size_t avail = db->Remaining();
+ if (avail > 0) {
+ state->listener()->OnUnknownPayload(db->cursor(), avail);
+ db->AdvanceCursor(avail);
+ state->ConsumePayload(avail);
+ }
+ if (state->remaining_payload() == 0) {
+ state->listener()->OnUnknownEnd();
+ return DecodeStatus::kDecodeDone;
+ }
+ return DecodeStatus::kDecodeInProgress;
+}
+
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698