| 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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 char* buffer, | 282 char* buffer, |
| 283 size_t buffer_len) { | 283 size_t buffer_len) { |
| 284 DCHECK(queued_frames_.empty()); | 284 DCHECK(queued_frames_.empty()); |
| 285 DCHECK(!packet_.needs_padding); | 285 DCHECK(!packet_.needs_padding); |
| 286 QUIC_BUG_IF(retransmission.retransmittable_frames.empty()) | 286 QUIC_BUG_IF(retransmission.retransmittable_frames.empty()) |
| 287 << "Attempt to serialize empty packet"; | 287 << "Attempt to serialize empty packet"; |
| 288 const QuicPacketNumberLength saved_length = packet_.packet_number_length; | 288 const QuicPacketNumberLength saved_length = packet_.packet_number_length; |
| 289 const QuicPacketNumberLength saved_next_length = next_packet_number_length_; | 289 const QuicPacketNumberLength saved_next_length = next_packet_number_length_; |
| 290 const EncryptionLevel default_encryption_level = packet_.encryption_level; | 290 const EncryptionLevel default_encryption_level = packet_.encryption_level; |
| 291 | 291 |
| 292 // Temporarily set the packet number length, stop FEC protection, | 292 // Temporarily set the packet number length and change the encryption level. |
| 293 // and change the encryption level. | |
| 294 packet_.packet_number_length = retransmission.packet_number_length; | 293 packet_.packet_number_length = retransmission.packet_number_length; |
| 295 next_packet_number_length_ = retransmission.packet_number_length; | 294 next_packet_number_length_ = retransmission.packet_number_length; |
| 296 packet_.needs_padding = retransmission.needs_padding; | 295 packet_.needs_padding = retransmission.needs_padding; |
| 297 // Only preserve the original encryption level if it's a handshake packet or | 296 // Only preserve the original encryption level if it's a handshake packet or |
| 298 // if we haven't gone forward secure. | 297 // if we haven't gone forward secure. |
| 299 if (retransmission.has_crypto_handshake || | 298 if (retransmission.has_crypto_handshake || |
| 300 packet_.encryption_level != ENCRYPTION_FORWARD_SECURE) { | 299 packet_.encryption_level != ENCRYPTION_FORWARD_SECURE) { |
| 301 packet_.encryption_level = retransmission.encryption_level; | 300 packet_.encryption_level = retransmission.encryption_level; |
| 302 } | 301 } |
| 303 | 302 |
| 304 // Serialize the packet and restore the FEC and packet number length state. | 303 // Serialize the packet and restore packet number length state. |
| 305 for (const QuicFrame& frame : retransmission.retransmittable_frames) { | 304 for (const QuicFrame& frame : retransmission.retransmittable_frames) { |
| 306 bool success = AddFrame(frame, false); | 305 bool success = AddFrame(frame, false); |
| 307 DCHECK(success); | 306 DCHECK(success); |
| 308 } | 307 } |
| 309 SerializePacket(buffer, buffer_len); | 308 SerializePacket(buffer, buffer_len); |
| 310 packet_.original_packet_number = retransmission.packet_number; | 309 packet_.original_packet_number = retransmission.packet_number; |
| 311 packet_.transmission_type = retransmission.transmission_type; | 310 packet_.transmission_type = retransmission.transmission_type; |
| 312 OnSerializedPacket(); | 311 OnSerializedPacket(); |
| 313 // Restore old values. | 312 // Restore old values. |
| 314 packet_.packet_number_length = saved_length; | 313 packet_.packet_number_length = saved_length; |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 packet_.packet_number = it == multipath_packet_number_.end() ? 0 : it->second; | 599 packet_.packet_number = it == multipath_packet_number_.end() ? 0 : it->second; |
| 601 packet_.path_id = path_id; | 600 packet_.path_id = path_id; |
| 602 DCHECK(packet_.path_id != kInvalidPathId); | 601 DCHECK(packet_.path_id != kInvalidPathId); |
| 603 // Send path in packet if current path is not the default path. | 602 // Send path in packet if current path is not the default path. |
| 604 send_path_id_in_packet_ = packet_.path_id != kDefaultPathId ? true : false; | 603 send_path_id_in_packet_ = packet_.path_id != kDefaultPathId ? true : false; |
| 605 // Switching path needs to update packet number length. | 604 // Switching path needs to update packet number length. |
| 606 UpdatePacketNumberLength(least_packet_awaited_by_peer, max_packets_in_flight); | 605 UpdatePacketNumberLength(least_packet_awaited_by_peer, max_packets_in_flight); |
| 607 } | 606 } |
| 608 | 607 |
| 609 } // namespace net | 608 } // namespace net |
| OLD | NEW |