blob: 9474d6cdf9369dd8a9449ecaa9b4d71b72ce2719 [file] [log] [blame]
QUICHE teama6ef0a62019-03-07 20:34:33 -05001// Copyright (c) 2018 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/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender.h"
6
7#include <cstddef>
8#include <limits>
vasilvv872e7a32019-03-12 16:42:44 -07009#include <string>
QUICHE teama6ef0a62019-03-07 20:34:33 -050010
11#include "net/third_party/quiche/src/quic/core/qpack/qpack_constants.h"
12#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
QUICHE teama6ef0a62019-03-07 20:34:33 -050013
14namespace quic {
15
16QpackDecoderStreamSender::QpackDecoderStreamSender(Delegate* delegate)
17 : delegate_(delegate) {
18 DCHECK(delegate_);
19}
20
21void QpackDecoderStreamSender::SendInsertCountIncrement(uint64_t increment) {
22 instruction_encoder_.set_varint(increment);
23
24 instruction_encoder_.Encode(InsertCountIncrementInstruction());
25
vasilvvc48c8712019-03-11 13:38:16 -070026 std::string output;
QUICHE teama6ef0a62019-03-07 20:34:33 -050027
28 instruction_encoder_.Next(std::numeric_limits<size_t>::max(), &output);
29 DCHECK(!instruction_encoder_.HasNext());
30
31 delegate_->WriteDecoderStreamData(output);
32}
33
34void QpackDecoderStreamSender::SendHeaderAcknowledgement(
35 QuicStreamId stream_id) {
36 instruction_encoder_.set_varint(stream_id);
37
38 instruction_encoder_.Encode(HeaderAcknowledgementInstruction());
39
vasilvvc48c8712019-03-11 13:38:16 -070040 std::string output;
QUICHE teama6ef0a62019-03-07 20:34:33 -050041
42 instruction_encoder_.Next(std::numeric_limits<size_t>::max(), &output);
43 DCHECK(!instruction_encoder_.HasNext());
44
45 delegate_->WriteDecoderStreamData(output);
46}
47
48void QpackDecoderStreamSender::SendStreamCancellation(QuicStreamId stream_id) {
49 instruction_encoder_.set_varint(stream_id);
50
51 instruction_encoder_.Encode(StreamCancellationInstruction());
52
vasilvvc48c8712019-03-11 13:38:16 -070053 std::string output;
QUICHE teama6ef0a62019-03-07 20:34:33 -050054
55 instruction_encoder_.Next(std::numeric_limits<size_t>::max(), &output);
56 DCHECK(!instruction_encoder_.HasNext());
57
58 delegate_->WriteDecoderStreamData(output);
59}
60
61} // namespace quic