| 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 #include "net/http2/decoder/payload_decoders/continuation_payload_decoder.h" | |
| 6 | |
| 7 #include <stddef.h> | |
| 8 | |
| 9 #include "base/logging.h" | |
| 10 #include "net/http2/decoder/decode_buffer.h" | |
| 11 #include "net/http2/decoder/http2_frame_decoder_listener.h" | |
| 12 #include "net/http2/http2_constants.h" | |
| 13 #include "net/http2/http2_structures.h" | |
| 14 | |
| 15 namespace net { | |
| 16 | |
| 17 DecodeStatus ContinuationPayloadDecoder::StartDecodingPayload( | |
| 18 FrameDecoderState* state, | |
| 19 DecodeBuffer* db) { | |
| 20 const Http2FrameHeader& frame_header = state->frame_header(); | |
| 21 const uint32_t total_length = frame_header.payload_length; | |
| 22 | |
| 23 DVLOG(2) << "ContinuationPayloadDecoder::StartDecodingPayload: " | |
| 24 << frame_header; | |
| 25 DCHECK_EQ(Http2FrameType::CONTINUATION, frame_header.type); | |
| 26 DCHECK_LE(db->Remaining(), total_length); | |
| 27 DCHECK_EQ(0, frame_header.flags & ~(Http2FrameFlag::FLAG_END_HEADERS)); | |
| 28 | |
| 29 state->InitializeRemainders(); | |
| 30 state->listener()->OnContinuationStart(frame_header); | |
| 31 return ResumeDecodingPayload(state, db); | |
| 32 } | |
| 33 | |
| 34 DecodeStatus ContinuationPayloadDecoder::ResumeDecodingPayload( | |
| 35 FrameDecoderState* state, | |
| 36 DecodeBuffer* db) { | |
| 37 DVLOG(2) << "ContinuationPayloadDecoder::ResumeDecodingPayload" | |
| 38 << " remaining_payload=" << state->remaining_payload() | |
| 39 << " db->Remaining=" << db->Remaining(); | |
| 40 DCHECK_EQ(Http2FrameType::CONTINUATION, state->frame_header().type); | |
| 41 DCHECK_LE(state->remaining_payload(), state->frame_header().payload_length); | |
| 42 DCHECK_LE(db->Remaining(), state->remaining_payload()); | |
| 43 | |
| 44 size_t avail = db->Remaining(); | |
| 45 DCHECK_LE(avail, state->remaining_payload()); | |
| 46 if (avail > 0) { | |
| 47 state->listener()->OnHpackFragment(db->cursor(), avail); | |
| 48 db->AdvanceCursor(avail); | |
| 49 state->ConsumePayload(avail); | |
| 50 } | |
| 51 if (state->remaining_payload() == 0) { | |
| 52 state->listener()->OnContinuationEnd(); | |
| 53 return DecodeStatus::kDecodeDone; | |
| 54 } | |
| 55 return DecodeStatus::kDecodeInProgress; | |
| 56 } | |
| 57 | |
| 58 } // namespace net | |
| OLD | NEW |