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

Side by Side Diff: net/http2/decoder/payload_decoders/window_update_payload_decoder.cc

Issue 2554683003: Revert of Add new HTTP/2 and HPACK decoder in net/http2/. (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
(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/window_update_payload_decoder.h"
6
7 #include "base/logging.h"
8 #include "net/http2/decoder/decode_buffer.h"
9 #include "net/http2/decoder/decode_http2_structures.h"
10 #include "net/http2/decoder/http2_frame_decoder_listener.h"
11 #include "net/http2/http2_constants.h"
12 #include "net/http2/http2_structures.h"
13
14 namespace net {
15
16 DecodeStatus WindowUpdatePayloadDecoder::StartDecodingPayload(
17 FrameDecoderState* state,
18 DecodeBuffer* db) {
19 const Http2FrameHeader& frame_header = state->frame_header();
20 const uint32_t total_length = frame_header.payload_length;
21
22 DVLOG(2) << "WindowUpdatePayloadDecoder::StartDecodingPayload: "
23 << frame_header;
24
25 DCHECK_EQ(Http2FrameType::WINDOW_UPDATE, frame_header.type);
26 DCHECK_LE(db->Remaining(), total_length);
27
28 // WINDOW_UPDATE frames have no flags.
29 DCHECK_EQ(0, frame_header.flags);
30
31 // Special case for when the payload is the correct size and entirely in
32 // the buffer.
33 if (db->Remaining() == Http2WindowUpdateFields::EncodedSize() &&
34 total_length == Http2WindowUpdateFields::EncodedSize()) {
35 DoDecode(&window_update_fields_, db);
36 state->listener()->OnWindowUpdate(
37 frame_header, window_update_fields_.window_size_increment);
38 return DecodeStatus::kDecodeDone;
39 }
40 state->InitializeRemainders();
41 return HandleStatus(state, state->StartDecodingStructureInPayload(
42 &window_update_fields_, db));
43 }
44
45 DecodeStatus WindowUpdatePayloadDecoder::ResumeDecodingPayload(
46 FrameDecoderState* state,
47 DecodeBuffer* db) {
48 DVLOG(2) << "ResumeDecodingPayload: remaining_payload="
49 << state->remaining_payload()
50 << "; db->Remaining=" << db->Remaining();
51 DCHECK_EQ(Http2FrameType::WINDOW_UPDATE, state->frame_header().type);
52 DCHECK_LE(db->Remaining(), state->frame_header().payload_length);
53 return HandleStatus(state, state->ResumeDecodingStructureInPayload(
54 &window_update_fields_, db));
55 }
56
57 DecodeStatus WindowUpdatePayloadDecoder::HandleStatus(FrameDecoderState* state,
58 DecodeStatus status) {
59 DVLOG(2) << "HandleStatus: status=" << status
60 << "; remaining_payload=" << state->remaining_payload();
61 if (status == DecodeStatus::kDecodeDone) {
62 if (state->remaining_payload() == 0) {
63 state->listener()->OnWindowUpdate(
64 state->frame_header(), window_update_fields_.window_size_increment);
65 return DecodeStatus::kDecodeDone;
66 }
67 // Payload is too long.
68 return state->ReportFrameSizeError();
69 }
70 // Not done decoding the structure. Either we've got more payload to decode,
71 // or we've run out because the payload is too short, in which case
72 // OnFrameSizeError will have already been called.
73 DCHECK(
74 (status == DecodeStatus::kDecodeInProgress &&
75 state->remaining_payload() > 0) ||
76 (status == DecodeStatus::kDecodeError && state->remaining_payload() == 0))
77 << "\n status=" << status
78 << "; remaining_payload=" << state->remaining_payload();
79 return status;
80 }
81
82 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698