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 | |
| 16 | QpackDecoderStreamSender::QpackDecoderStreamSender(Delegate* delegate) |
| 17 | : delegate_(delegate) { |
| 18 | DCHECK(delegate_); |
| 19 | } |
| 20 | |
| 21 | void QpackDecoderStreamSender::SendInsertCountIncrement(uint64_t increment) { |
| 22 | instruction_encoder_.set_varint(increment); |
| 23 | |
| 24 | instruction_encoder_.Encode(InsertCountIncrementInstruction()); |
| 25 | |
vasilvv | c48c871 | 2019-03-11 13:38:16 -0700 | [diff] [blame] | 26 | std::string output; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 27 | |
| 28 | instruction_encoder_.Next(std::numeric_limits<size_t>::max(), &output); |
| 29 | DCHECK(!instruction_encoder_.HasNext()); |
| 30 | |
| 31 | delegate_->WriteDecoderStreamData(output); |
| 32 | } |
| 33 | |
| 34 | void QpackDecoderStreamSender::SendHeaderAcknowledgement( |
| 35 | QuicStreamId stream_id) { |
| 36 | instruction_encoder_.set_varint(stream_id); |
| 37 | |
| 38 | instruction_encoder_.Encode(HeaderAcknowledgementInstruction()); |
| 39 | |
vasilvv | c48c871 | 2019-03-11 13:38:16 -0700 | [diff] [blame] | 40 | std::string output; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 41 | |
| 42 | instruction_encoder_.Next(std::numeric_limits<size_t>::max(), &output); |
| 43 | DCHECK(!instruction_encoder_.HasNext()); |
| 44 | |
| 45 | delegate_->WriteDecoderStreamData(output); |
| 46 | } |
| 47 | |
| 48 | void QpackDecoderStreamSender::SendStreamCancellation(QuicStreamId stream_id) { |
| 49 | instruction_encoder_.set_varint(stream_id); |
| 50 | |
| 51 | instruction_encoder_.Encode(StreamCancellationInstruction()); |
| 52 | |
vasilvv | c48c871 | 2019-03-11 13:38:16 -0700 | [diff] [blame] | 53 | std::string output; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 54 | |
| 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 |