| 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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 packet_.encryption_level != ENCRYPTION_FORWARD_SECURE) { | 311 packet_.encryption_level != ENCRYPTION_FORWARD_SECURE) { |
| 312 packet_.encryption_level = retransmission.encryption_level; | 312 packet_.encryption_level = retransmission.encryption_level; |
| 313 } | 313 } |
| 314 | 314 |
| 315 // Serialize the packet and restore packet number length state. | 315 // Serialize the packet and restore packet number length state. |
| 316 for (const QuicFrame& frame : retransmission.retransmittable_frames) { | 316 for (const QuicFrame& frame : retransmission.retransmittable_frames) { |
| 317 bool success = AddFrame(frame, false); | 317 bool success = AddFrame(frame, false); |
| 318 DCHECK(success); | 318 DCHECK(success); |
| 319 } | 319 } |
| 320 SerializePacket(buffer, buffer_len); | 320 SerializePacket(buffer, buffer_len); |
| 321 packet_.original_path_id = retransmission.path_id; |
| 321 packet_.original_packet_number = retransmission.packet_number; | 322 packet_.original_packet_number = retransmission.packet_number; |
| 322 packet_.transmission_type = retransmission.transmission_type; | 323 packet_.transmission_type = retransmission.transmission_type; |
| 323 OnSerializedPacket(); | 324 OnSerializedPacket(); |
| 324 // Restore old values. | 325 // Restore old values. |
| 325 packet_.packet_number_length = saved_length; | 326 packet_.packet_number_length = saved_length; |
| 326 next_packet_number_length_ = saved_next_length; | 327 next_packet_number_length_ = saved_next_length; |
| 327 packet_.encryption_level = default_encryption_level; | 328 packet_.encryption_level = default_encryption_level; |
| 328 } | 329 } |
| 329 | 330 |
| 330 void QuicPacketCreator::Flush() { | 331 void QuicPacketCreator::Flush() { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 356 if (CanSetMaxPacketLength()) { | 357 if (CanSetMaxPacketLength()) { |
| 357 SetMaxPacketLength(max_packet_length_); | 358 SetMaxPacketLength(max_packet_length_); |
| 358 } | 359 } |
| 359 } | 360 } |
| 360 | 361 |
| 361 void QuicPacketCreator::ClearPacket() { | 362 void QuicPacketCreator::ClearPacket() { |
| 362 packet_.has_ack = false; | 363 packet_.has_ack = false; |
| 363 packet_.has_stop_waiting = false; | 364 packet_.has_stop_waiting = false; |
| 364 packet_.has_crypto_handshake = NOT_HANDSHAKE; | 365 packet_.has_crypto_handshake = NOT_HANDSHAKE; |
| 365 packet_.num_padding_bytes = 0; | 366 packet_.num_padding_bytes = 0; |
| 367 packet_.original_path_id = kInvalidPathId; |
| 366 packet_.original_packet_number = 0; | 368 packet_.original_packet_number = 0; |
| 367 packet_.transmission_type = NOT_RETRANSMISSION; | 369 packet_.transmission_type = NOT_RETRANSMISSION; |
| 368 packet_.encrypted_buffer = nullptr; | 370 packet_.encrypted_buffer = nullptr; |
| 369 packet_.encrypted_length = 0; | 371 packet_.encrypted_length = 0; |
| 370 DCHECK(packet_.retransmittable_frames.empty()); | 372 DCHECK(packet_.retransmittable_frames.empty()); |
| 371 packet_.listeners.clear(); | 373 packet_.listeners.clear(); |
| 372 } | 374 } |
| 373 | 375 |
| 374 bool QuicPacketCreator::HasPendingFrames() const { | 376 bool QuicPacketCreator::HasPendingFrames() const { |
| 375 return !queued_frames_.empty(); | 377 return !queued_frames_.empty(); |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 // Switching path needs to update packet number length. | 615 // Switching path needs to update packet number length. |
| 614 UpdatePacketNumberLength(least_packet_awaited_by_peer, max_packets_in_flight); | 616 UpdatePacketNumberLength(least_packet_awaited_by_peer, max_packets_in_flight); |
| 615 } | 617 } |
| 616 | 618 |
| 617 bool QuicPacketCreator::IncludeNonceInPublicHeader() { | 619 bool QuicPacketCreator::IncludeNonceInPublicHeader() { |
| 618 return have_diversification_nonce_ && | 620 return have_diversification_nonce_ && |
| 619 packet_.encryption_level == ENCRYPTION_INITIAL; | 621 packet_.encryption_level == ENCRYPTION_INITIAL; |
| 620 } | 622 } |
| 621 | 623 |
| 622 } // namespace net | 624 } // namespace net |
| OLD | NEW |