| 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/quic_packet_creator.h" | 5 #include "net/quic/quic_packet_creator.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 const QuicPacketNumberLength saved_next_length = next_packet_number_length_; | 409 const QuicPacketNumberLength saved_next_length = next_packet_number_length_; |
| 410 const bool saved_should_fec_protect = fec_protect_; | 410 const bool saved_should_fec_protect = fec_protect_; |
| 411 const bool needs_padding = needs_padding_; | 411 const bool needs_padding = needs_padding_; |
| 412 const EncryptionLevel default_encryption_level = encryption_level_; | 412 const EncryptionLevel default_encryption_level = encryption_level_; |
| 413 | 413 |
| 414 // Temporarily set the packet number length, stop FEC protection, | 414 // Temporarily set the packet number length, stop FEC protection, |
| 415 // and change the encryption level. | 415 // and change the encryption level. |
| 416 packet_number_length_ = original_length; | 416 packet_number_length_ = original_length; |
| 417 next_packet_number_length_ = original_length; | 417 next_packet_number_length_ = original_length; |
| 418 fec_protect_ = false; | 418 fec_protect_ = false; |
| 419 encryption_level_ = original_encryption_level; | |
| 420 needs_padding_ = frames.needs_padding(); | 419 needs_padding_ = frames.needs_padding(); |
| 420 // Only preserve the original encryption level if it's a handshake packet or |
| 421 // if we haven't gone forward secure. |
| 422 if (frames.HasCryptoHandshake() || |
| 423 encryption_level_ != ENCRYPTION_FORWARD_SECURE) { |
| 424 encryption_level_ = original_encryption_level; |
| 425 } |
| 421 | 426 |
| 422 // Serialize the packet and restore the FEC and packet number length state. | 427 // Serialize the packet and restore the FEC and packet number length state. |
| 423 SerializedPacket serialized_packet = | 428 SerializedPacket serialized_packet = |
| 424 SerializeAllFrames(frames.frames(), buffer, buffer_len); | 429 SerializeAllFrames(frames.frames(), buffer, buffer_len); |
| 425 packet_number_length_ = saved_length; | 430 packet_number_length_ = saved_length; |
| 426 next_packet_number_length_ = saved_next_length; | 431 next_packet_number_length_ = saved_next_length; |
| 427 fec_protect_ = saved_should_fec_protect; | 432 fec_protect_ = saved_should_fec_protect; |
| 428 needs_padding_ = needs_padding; | 433 needs_padding_ = needs_padding; |
| 429 encryption_level_ = default_encryption_level; | 434 encryption_level_ = default_encryption_level; |
| 430 | 435 |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 QuicPacketCount max_packets_in_flight) { | 792 QuicPacketCount max_packets_in_flight) { |
| 788 set_max_packets_per_fec_group(static_cast<size_t>( | 793 set_max_packets_per_fec_group(static_cast<size_t>( |
| 789 kMaxPacketsInFlightMultiplierForFecGroupSize * max_packets_in_flight)); | 794 kMaxPacketsInFlightMultiplierForFecGroupSize * max_packets_in_flight)); |
| 790 } | 795 } |
| 791 | 796 |
| 792 void QuicPacketCreator::OnRttChange(QuicTime::Delta rtt) { | 797 void QuicPacketCreator::OnRttChange(QuicTime::Delta rtt) { |
| 793 fec_timeout_ = rtt.Multiply(rtt_multiplier_for_fec_timeout_); | 798 fec_timeout_ = rtt.Multiply(rtt_multiplier_for_fec_timeout_); |
| 794 } | 799 } |
| 795 | 800 |
| 796 } // namespace net | 801 } // namespace net |
| OLD | NEW |