| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/quic/core/quic_packet_creator.h" | 5 #include "net/quic/core/quic_packet_creator.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstdint> | 8 #include <cstdint> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "net/quic/core/crypto/crypto_protocol.h" | 11 #include "net/quic/core/crypto/crypto_protocol.h" |
| 12 #include "net/quic/core/quic_data_writer.h" | 12 #include "net/quic/core/quic_data_writer.h" |
| 13 #include "net/quic/core/quic_flags.h" | 13 #include "net/quic/core/quic_flags.h" |
| 14 #include "net/quic/core/quic_utils.h" | 14 #include "net/quic/core/quic_utils.h" |
| 15 #include "net/quic/platform/api/quic_aligned.h" | 15 #include "net/quic/platform/api/quic_aligned.h" |
| 16 #include "net/quic/platform/api/quic_bug_tracker.h" | 16 #include "net/quic/platform/api/quic_bug_tracker.h" |
| 17 #include "net/quic/platform/api/quic_flag_utils.h" |
| 17 #include "net/quic/platform/api/quic_logging.h" | 18 #include "net/quic/platform/api/quic_logging.h" |
| 18 #include "net/quic/platform/api/quic_string_piece.h" | 19 #include "net/quic/platform/api/quic_string_piece.h" |
| 19 | 20 |
| 20 using std::string; | 21 using std::string; |
| 21 | 22 |
| 22 // If true, enforce that QUIC CHLOs fit in one packet. | 23 // If true, enforce that QUIC CHLOs fit in one packet. |
| 23 bool FLAGS_quic_enforce_single_packet_chlo = true; | 24 bool FLAGS_quic_enforce_single_packet_chlo = true; |
| 24 | 25 |
| 25 namespace net { | 26 namespace net { |
| 26 | 27 |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 return; | 639 return; |
| 639 } | 640 } |
| 640 | 641 |
| 641 if (needs_full_padding_) { | 642 if (needs_full_padding_) { |
| 642 // Full padding does not consume pending padding bytes. | 643 // Full padding does not consume pending padding bytes. |
| 643 packet_.num_padding_bytes = -1; | 644 packet_.num_padding_bytes = -1; |
| 644 } else { | 645 } else { |
| 645 packet_.num_padding_bytes = | 646 packet_.num_padding_bytes = |
| 646 std::min<int16_t>(pending_padding_bytes_, BytesFree()); | 647 std::min<int16_t>(pending_padding_bytes_, BytesFree()); |
| 647 pending_padding_bytes_ -= packet_.num_padding_bytes; | 648 pending_padding_bytes_ -= packet_.num_padding_bytes; |
| 649 QUIC_FLAG_COUNT(quic_reloadable_flag_quic_enable_random_padding); |
| 648 } | 650 } |
| 649 | 651 |
| 650 bool success = | 652 bool success = |
| 651 AddFrame(QuicFrame(QuicPaddingFrame(packet_.num_padding_bytes)), false); | 653 AddFrame(QuicFrame(QuicPaddingFrame(packet_.num_padding_bytes)), false); |
| 652 DCHECK(success); | 654 DCHECK(success); |
| 653 } | 655 } |
| 654 | 656 |
| 655 bool QuicPacketCreator::IncludeNonceInPublicHeader() { | 657 bool QuicPacketCreator::IncludeNonceInPublicHeader() { |
| 656 return have_diversification_nonce_ && | 658 return have_diversification_nonce_ && |
| 657 packet_.encryption_level == ENCRYPTION_INITIAL; | 659 packet_.encryption_level == ENCRYPTION_INITIAL; |
| 658 } | 660 } |
| 659 | 661 |
| 660 void QuicPacketCreator::AddPendingPadding(QuicByteCount size) { | 662 void QuicPacketCreator::AddPendingPadding(QuicByteCount size) { |
| 661 pending_padding_bytes_ += size; | 663 pending_padding_bytes_ += size; |
| 662 } | 664 } |
| 663 | 665 |
| 664 } // namespace net | 666 } // namespace net |
| OLD | NEW |