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

Unified Diff: net/http2/decoder/payload_decoders/rst_stream_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/rst_stream_payload_decoder.cc
diff --git a/net/http2/decoder/payload_decoders/rst_stream_payload_decoder.cc b/net/http2/decoder/payload_decoders/rst_stream_payload_decoder.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e9d86fb7385d48b49668f85aa625e2a7165556ae
--- /dev/null
+++ b/net/http2/decoder/payload_decoders/rst_stream_payload_decoder.cc
@@ -0,0 +1,66 @@
+// 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/rst_stream_payload_decoder.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 RstStreamPayloadDecoder::StartDecodingPayload(
+ FrameDecoderState* state,
+ DecodeBuffer* db) {
+ DVLOG(2) << "RstStreamPayloadDecoder::StartDecodingPayload: "
+ << state->frame_header();
+ DCHECK_EQ(Http2FrameType::RST_STREAM, state->frame_header().type);
+ DCHECK_LE(db->Remaining(), state->frame_header().payload_length);
+ // RST_STREAM has no flags.
+ DCHECK_EQ(0, state->frame_header().flags);
+ state->InitializeRemainders();
+ return HandleStatus(
+ state, state->StartDecodingStructureInPayload(&rst_stream_fields_, db));
+}
+
+DecodeStatus RstStreamPayloadDecoder::ResumeDecodingPayload(
+ FrameDecoderState* state,
+ DecodeBuffer* db) {
+ DVLOG(2) << "RstStreamPayloadDecoder::ResumeDecodingPayload"
+ << " remaining_payload=" << state->remaining_payload()
+ << " db->Remaining=" << db->Remaining();
+ DCHECK_EQ(Http2FrameType::RST_STREAM, state->frame_header().type);
+ DCHECK_LE(db->Remaining(), state->frame_header().payload_length);
+ return HandleStatus(
+ state, state->ResumeDecodingStructureInPayload(&rst_stream_fields_, db));
+}
+
+DecodeStatus RstStreamPayloadDecoder::HandleStatus(FrameDecoderState* state,
+ DecodeStatus status) {
+ DVLOG(2) << "HandleStatus: status=" << status
+ << "; remaining_payload=" << state->remaining_payload();
+ if (status == DecodeStatus::kDecodeDone) {
+ if (state->remaining_payload() == 0) {
+ state->listener()->OnRstStream(state->frame_header(),
+ rst_stream_fields_.error_code);
+ return DecodeStatus::kDecodeDone;
+ }
+ // Payload is too long.
+ return state->ReportFrameSizeError();
+ }
+ // Not done decoding the structure. Either we've got more payload to decode,
+ // or we've run out because the payload is too short, in which case
+ // OnFrameSizeError will have already been called by the FrameDecoderState.
+ DCHECK(
+ (status == DecodeStatus::kDecodeInProgress &&
+ state->remaining_payload() > 0) ||
+ (status == DecodeStatus::kDecodeError && state->remaining_payload() == 0))
+ << "\n status=" << status
+ << "; remaining_payload=" << state->remaining_payload();
+ return status;
+}
+
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698