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

Side by Side Diff: net/http2/decoder/payload_decoders/priority_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/priority_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 PriorityPayloadDecoder::StartDecodingPayload(
16 FrameDecoderState* state,
17 DecodeBuffer* db) {
18 DVLOG(2) << "PriorityPayloadDecoder::StartDecodingPayload: "
19 << state->frame_header();
20 DCHECK_EQ(Http2FrameType::PRIORITY, state->frame_header().type);
21 DCHECK_LE(db->Remaining(), state->frame_header().payload_length);
22 // PRIORITY frames have no flags.
23 DCHECK_EQ(0, state->frame_header().flags);
24 state->InitializeRemainders();
25 return HandleStatus(
26 state, state->StartDecodingStructureInPayload(&priority_fields_, db));
27 }
28
29 DecodeStatus PriorityPayloadDecoder::ResumeDecodingPayload(
30 FrameDecoderState* state,
31 DecodeBuffer* db) {
32 DVLOG(2) << "PriorityPayloadDecoder::ResumeDecodingPayload"
33 << " remaining_payload=" << state->remaining_payload()
34 << " db->Remaining=" << db->Remaining();
35 DCHECK_EQ(Http2FrameType::PRIORITY, state->frame_header().type);
36 DCHECK_LE(db->Remaining(), state->frame_header().payload_length);
37 return HandleStatus(
38 state, state->ResumeDecodingStructureInPayload(&priority_fields_, db));
39 }
40
41 DecodeStatus PriorityPayloadDecoder::HandleStatus(FrameDecoderState* state,
42 DecodeStatus status) {
43 if (status == DecodeStatus::kDecodeDone) {
44 if (state->remaining_payload() == 0) {
45 state->listener()->OnPriorityFrame(state->frame_header(),
46 priority_fields_);
47 return DecodeStatus::kDecodeDone;
48 }
49 // Payload is too long.
50 return state->ReportFrameSizeError();
51 }
52 // Not done decoding the structure. Either we've got more payload to decode,
53 // or we've run out because the payload is too short, in which case
54 // OnFrameSizeError will have already been called.
55 DCHECK(
56 (status == DecodeStatus::kDecodeInProgress &&
57 state->remaining_payload() > 0) ||
58 (status == DecodeStatus::kDecodeError && state->remaining_payload() == 0))
59 << "\n status=" << status
60 << "; remaining_payload=" << state->remaining_payload();
61 return status;
62 }
63
64 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698