Index: net/http2/decoder/payload_decoders/continuation_payload_decoder.cc |
diff --git a/net/http2/decoder/payload_decoders/continuation_payload_decoder.cc b/net/http2/decoder/payload_decoders/continuation_payload_decoder.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ac5371c056f9c91ffdd87d81b627c08fc61c251a |
--- /dev/null |
+++ b/net/http2/decoder/payload_decoders/continuation_payload_decoder.cc |
@@ -0,0 +1,58 @@ |
+// 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/continuation_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 ContinuationPayloadDecoder::StartDecodingPayload( |
+ FrameDecoderState* state, |
+ DecodeBuffer* db) { |
+ const Http2FrameHeader& frame_header = state->frame_header(); |
+ const uint32_t total_length = frame_header.payload_length; |
+ |
+ DVLOG(2) << "ContinuationPayloadDecoder::StartDecodingPayload: " |
+ << frame_header; |
+ DCHECK_EQ(Http2FrameType::CONTINUATION, frame_header.type); |
+ DCHECK_LE(db->Remaining(), total_length); |
+ DCHECK_EQ(0, frame_header.flags & ~(Http2FrameFlag::FLAG_END_HEADERS)); |
+ |
+ state->InitializeRemainders(); |
+ state->listener()->OnContinuationStart(frame_header); |
+ return ResumeDecodingPayload(state, db); |
+} |
+ |
+DecodeStatus ContinuationPayloadDecoder::ResumeDecodingPayload( |
+ FrameDecoderState* state, |
+ DecodeBuffer* db) { |
+ DVLOG(2) << "ContinuationPayloadDecoder::ResumeDecodingPayload" |
+ << " remaining_payload=" << state->remaining_payload() |
+ << " db->Remaining=" << db->Remaining(); |
+ DCHECK_EQ(Http2FrameType::CONTINUATION, state->frame_header().type); |
+ DCHECK_LE(state->remaining_payload(), state->frame_header().payload_length); |
+ DCHECK_LE(db->Remaining(), state->remaining_payload()); |
+ |
+ size_t avail = db->Remaining(); |
+ DCHECK_LE(avail, state->remaining_payload()); |
+ if (avail > 0) { |
+ state->listener()->OnHpackFragment(db->cursor(), avail); |
+ db->AdvanceCursor(avail); |
+ state->ConsumePayload(avail); |
+ } |
+ if (state->remaining_payload() == 0) { |
+ state->listener()->OnContinuationEnd(); |
+ return DecodeStatus::kDecodeDone; |
+ } |
+ return DecodeStatus::kDecodeInProgress; |
+} |
+ |
+} // namespace net |