QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 1 | // 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> |
vasilvv | 872e7a3 | 2019-03-12 16:42:44 -0700 | [diff] [blame] | 9 | #include <string> |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 10 | |
| 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 team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 13 | |
| 14 | namespace quic { |
| 15 | |
renjietang | 8a2df8f | 2019-08-07 10:43:52 -0700 | [diff] [blame] | 16 | QpackDecoderStreamSender::QpackDecoderStreamSender() : delegate_(nullptr) {} |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 17 | |
| 18 | void QpackDecoderStreamSender::SendInsertCountIncrement(uint64_t increment) { |
bnc | 28bb06c | 2019-07-17 05:21:10 -0700 | [diff] [blame] | 19 | values_.varint = increment; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 20 | |
bnc | 28bb06c | 2019-07-17 05:21:10 -0700 | [diff] [blame] | 21 | instruction_encoder_.Encode(InsertCountIncrementInstruction(), values_, |
bnc | 6b1fc8a | 2019-10-11 17:17:14 -0700 | [diff] [blame] | 22 | &buffer_); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | void QpackDecoderStreamSender::SendHeaderAcknowledgement( |
| 26 | QuicStreamId stream_id) { |
bnc | 28bb06c | 2019-07-17 05:21:10 -0700 | [diff] [blame] | 27 | values_.varint = stream_id; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 28 | |
bnc | 28bb06c | 2019-07-17 05:21:10 -0700 | [diff] [blame] | 29 | instruction_encoder_.Encode(HeaderAcknowledgementInstruction(), values_, |
bnc | 6b1fc8a | 2019-10-11 17:17:14 -0700 | [diff] [blame] | 30 | &buffer_); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | void QpackDecoderStreamSender::SendStreamCancellation(QuicStreamId stream_id) { |
bnc | 28bb06c | 2019-07-17 05:21:10 -0700 | [diff] [blame] | 34 | values_.varint = stream_id; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 35 | |
bnc | 28bb06c | 2019-07-17 05:21:10 -0700 | [diff] [blame] | 36 | instruction_encoder_.Encode(StreamCancellationInstruction(), values_, |
bnc | 6b1fc8a | 2019-10-11 17:17:14 -0700 | [diff] [blame] | 37 | &buffer_); |
| 38 | } |
| 39 | |
| 40 | void QpackDecoderStreamSender::Flush() { |
| 41 | if (buffer_.empty()) { |
| 42 | return; |
| 43 | } |
| 44 | |
| 45 | delegate_->WriteStreamData(buffer_); |
| 46 | buffer_.clear(); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | } // namespace quic |