blob: 68e4d67816c19aafd9b87b6c1f502524409fe93f [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
renjietang8a2df8f2019-08-07 10:43:52 -070016QpackDecoderStreamSender::QpackDecoderStreamSender() : delegate_(nullptr) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -050017
18void QpackDecoderStreamSender::SendInsertCountIncrement(uint64_t increment) {
bnc28bb06c2019-07-17 05:21:10 -070019 values_.varint = increment;
QUICHE teama6ef0a62019-03-07 20:34:33 -050020
bnc28bb06c2019-07-17 05:21:10 -070021 instruction_encoder_.Encode(InsertCountIncrementInstruction(), values_,
bnc6b1fc8a2019-10-11 17:17:14 -070022 &buffer_);
QUICHE teama6ef0a62019-03-07 20:34:33 -050023}
24
25void QpackDecoderStreamSender::SendHeaderAcknowledgement(
26 QuicStreamId stream_id) {
bnc28bb06c2019-07-17 05:21:10 -070027 values_.varint = stream_id;
QUICHE teama6ef0a62019-03-07 20:34:33 -050028
bnc28bb06c2019-07-17 05:21:10 -070029 instruction_encoder_.Encode(HeaderAcknowledgementInstruction(), values_,
bnc6b1fc8a2019-10-11 17:17:14 -070030 &buffer_);
QUICHE teama6ef0a62019-03-07 20:34:33 -050031}
32
33void QpackDecoderStreamSender::SendStreamCancellation(QuicStreamId stream_id) {
bnc28bb06c2019-07-17 05:21:10 -070034 values_.varint = stream_id;
QUICHE teama6ef0a62019-03-07 20:34:33 -050035
bnc28bb06c2019-07-17 05:21:10 -070036 instruction_encoder_.Encode(StreamCancellationInstruction(), values_,
bnc6b1fc8a2019-10-11 17:17:14 -070037 &buffer_);
38}
39
40void QpackDecoderStreamSender::Flush() {
41 if (buffer_.empty()) {
42 return;
43 }
44
45 delegate_->WriteStreamData(buffer_);
46 buffer_.clear();
QUICHE teama6ef0a62019-03-07 20:34:33 -050047}
48
49} // namespace quic