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/rst_stream_payload_decoder.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "net/http2/decoder/decode_buffer.h" | |
9 #include "net/http2/decoder/http2_frame_decoder_listener.h" | |
10 #include "net/http2/http2_constants.h" | |
11 #include "net/http2/http2_structures.h" | |
12 | |
13 namespace net { | |
14 | |
15 DecodeStatus RstStreamPayloadDecoder::StartDecodingPayload( | |
16 FrameDecoderState* state, | |
17 DecodeBuffer* db) { | |
18 DVLOG(2) << "RstStreamPayloadDecoder::StartDecodingPayload: " | |
19 << state->frame_header(); | |
20 DCHECK_EQ(Http2FrameType::RST_STREAM, state->frame_header().type); | |
21 DCHECK_LE(db->Remaining(), state->frame_header().payload_length); | |
22 // RST_STREAM has no flags. | |
23 DCHECK_EQ(0, state->frame_header().flags); | |
24 state->InitializeRemainders(); | |
25 return HandleStatus( | |
26 state, state->StartDecodingStructureInPayload(&rst_stream_fields_, db)); | |
27 } | |
28 | |
29 DecodeStatus RstStreamPayloadDecoder::ResumeDecodingPayload( | |
30 FrameDecoderState* state, | |
31 DecodeBuffer* db) { | |
32 DVLOG(2) << "RstStreamPayloadDecoder::ResumeDecodingPayload" | |
33 << " remaining_payload=" << state->remaining_payload() | |
34 << " db->Remaining=" << db->Remaining(); | |
35 DCHECK_EQ(Http2FrameType::RST_STREAM, state->frame_header().type); | |
36 DCHECK_LE(db->Remaining(), state->frame_header().payload_length); | |
37 return HandleStatus( | |
38 state, state->ResumeDecodingStructureInPayload(&rst_stream_fields_, db)); | |
39 } | |
40 | |
41 DecodeStatus RstStreamPayloadDecoder::HandleStatus(FrameDecoderState* state, | |
42 DecodeStatus status) { | |
43 DVLOG(2) << "HandleStatus: status=" << status | |
44 << "; remaining_payload=" << state->remaining_payload(); | |
45 if (status == DecodeStatus::kDecodeDone) { | |
46 if (state->remaining_payload() == 0) { | |
47 state->listener()->OnRstStream(state->frame_header(), | |
48 rst_stream_fields_.error_code); | |
49 return DecodeStatus::kDecodeDone; | |
50 } | |
51 // Payload is too long. | |
52 return state->ReportFrameSizeError(); | |
53 } | |
54 // Not done decoding the structure. Either we've got more payload to decode, | |
55 // or we've run out because the payload is too short, in which case | |
56 // OnFrameSizeError will have already been called by the FrameDecoderState. | |
57 DCHECK( | |
58 (status == DecodeStatus::kDecodeInProgress && | |
59 state->remaining_payload() > 0) || | |
60 (status == DecodeStatus::kDecodeError && state->remaining_payload() == 0)) | |
61 << "\n status=" << status | |
62 << "; remaining_payload=" << state->remaining_payload(); | |
63 return status; | |
64 } | |
65 | |
66 } // namespace net | |
OLD | NEW |