Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(583)

Side by Side Diff: net/quic/quic_connection.cc

Issue 1666553002: Make QUIC's SerializedPacket contain QuicFrames, rather than a pointer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@113205205
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_connection.h" 5 #include "net/quic/quic_connection.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <sys/types.h> 8 #include <sys/types.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 // All data for streams which are reset with QUIC_STREAM_NO_ERROR must 1181 // All data for streams which are reset with QUIC_STREAM_NO_ERROR must
1182 // be received by the peer. 1182 // be received by the peer.
1183 return; 1183 return;
1184 } 1184 }
1185 1185
1186 sent_packet_manager_.CancelRetransmissionsForStream(id); 1186 sent_packet_manager_.CancelRetransmissionsForStream(id);
1187 // Remove all queued packets which only contain data for the reset stream. 1187 // Remove all queued packets which only contain data for the reset stream.
1188 QueuedPacketList::iterator packet_iterator = queued_packets_.begin(); 1188 QueuedPacketList::iterator packet_iterator = queued_packets_.begin();
1189 while (packet_iterator != queued_packets_.end()) { 1189 while (packet_iterator != queued_packets_.end()) {
1190 QuicFrames* retransmittable_frames = 1190 QuicFrames* retransmittable_frames =
1191 packet_iterator->retransmittable_frames; 1191 &packet_iterator->retransmittable_frames;
1192 if (retransmittable_frames == nullptr) { 1192 if (retransmittable_frames->empty()) {
1193 ++packet_iterator; 1193 ++packet_iterator;
1194 continue; 1194 continue;
1195 } 1195 }
1196 QuicUtils::RemoveFramesForStream(retransmittable_frames, id); 1196 QuicUtils::RemoveFramesForStream(retransmittable_frames, id);
1197 if (!retransmittable_frames->empty()) { 1197 if (!retransmittable_frames->empty()) {
1198 ++packet_iterator; 1198 ++packet_iterator;
1199 continue; 1199 continue;
1200 } 1200 }
1201 QuicUtils::ClearSerializedPacket(&(*packet_iterator)); 1201 QuicUtils::ClearSerializedPacket(&(*packet_iterator));
1202 packet_iterator = queued_packets_.erase(packet_iterator); 1202 packet_iterator = queued_packets_.erase(packet_iterator);
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
1818 packet->entropy_hash); 1818 packet->entropy_hash);
1819 // If there are already queued packets, queue this one immediately to ensure 1819 // If there are already queued packets, queue this one immediately to ensure
1820 // it's written in sequence number order. 1820 // it's written in sequence number order.
1821 if (!queued_packets_.empty() || !WritePacket(packet)) { 1821 if (!queued_packets_.empty() || !WritePacket(packet)) {
1822 // Take ownership of the underlying encrypted packet. 1822 // Take ownership of the underlying encrypted packet.
1823 if (!packet->packet->owns_buffer()) { 1823 if (!packet->packet->owns_buffer()) {
1824 scoped_ptr<QuicEncryptedPacket> encrypted_deleter(packet->packet); 1824 scoped_ptr<QuicEncryptedPacket> encrypted_deleter(packet->packet);
1825 packet->packet = packet->packet->Clone(); 1825 packet->packet = packet->packet->Clone();
1826 } 1826 }
1827 queued_packets_.push_back(*packet); 1827 queued_packets_.push_back(*packet);
1828 packet->retransmittable_frames.clear();
1828 } 1829 }
1829 1830
1830 // If a forward-secure encrypter is available but is not being used and the 1831 // If a forward-secure encrypter is available but is not being used and the
1831 // next packet number is the first packet which requires 1832 // next packet number is the first packet which requires
1832 // forward security, start using the forward-secure encrypter. 1833 // forward security, start using the forward-secure encrypter.
1833 if (encryption_level_ != ENCRYPTION_FORWARD_SECURE && 1834 if (encryption_level_ != ENCRYPTION_FORWARD_SECURE &&
1834 has_forward_secure_encrypter_ && 1835 has_forward_secure_encrypter_ &&
1835 packet->packet_number >= first_required_forward_secure_packet_ - 1) { 1836 packet->packet_number >= first_required_forward_secure_packet_ - 1) {
1836 SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); 1837 SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE);
1837 } 1838 }
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
2352 connection_->SetRetransmissionAlarm(); 2353 connection_->SetRetransmissionAlarm();
2353 connection_->pending_retransmission_alarm_ = false; 2354 connection_->pending_retransmission_alarm_ = false;
2354 } 2355 }
2355 } 2356 }
2356 2357
2357 HasRetransmittableData QuicConnection::IsRetransmittable( 2358 HasRetransmittableData QuicConnection::IsRetransmittable(
2358 const SerializedPacket& packet) { 2359 const SerializedPacket& packet) {
2359 // Retransmitted packets retransmittable frames are owned by the unacked 2360 // Retransmitted packets retransmittable frames are owned by the unacked
2360 // packet map, but are not present in the serialized packet. 2361 // packet map, but are not present in the serialized packet.
2361 if (packet.transmission_type != NOT_RETRANSMISSION || 2362 if (packet.transmission_type != NOT_RETRANSMISSION ||
2362 packet.retransmittable_frames != nullptr) { 2363 !packet.retransmittable_frames.empty()) {
2363 return HAS_RETRANSMITTABLE_DATA; 2364 return HAS_RETRANSMITTABLE_DATA;
2364 } else { 2365 } else {
2365 return NO_RETRANSMITTABLE_DATA; 2366 return NO_RETRANSMITTABLE_DATA;
2366 } 2367 }
2367 } 2368 }
2368 2369
2369 bool QuicConnection::IsTerminationPacket(const SerializedPacket& packet) { 2370 bool QuicConnection::IsTerminationPacket(const SerializedPacket& packet) {
2370 if (packet.retransmittable_frames == nullptr) { 2371 if (packet.retransmittable_frames.empty()) {
2371 return false; 2372 return false;
2372 } 2373 }
2373 for (const QuicFrame& frame : *packet.retransmittable_frames) { 2374 for (const QuicFrame& frame : packet.retransmittable_frames) {
2374 if (frame.type == CONNECTION_CLOSE_FRAME) { 2375 if (frame.type == CONNECTION_CLOSE_FRAME) {
2375 return true; 2376 return true;
2376 } 2377 }
2377 if (save_crypto_packets_as_termination_packets_ && 2378 if (save_crypto_packets_as_termination_packets_ &&
2378 frame.type == STREAM_FRAME && 2379 frame.type == STREAM_FRAME &&
2379 frame.stream_frame->stream_id == kCryptoStreamId) { 2380 frame.stream_frame->stream_id == kCryptoStreamId) {
2380 return true; 2381 return true;
2381 } 2382 }
2382 } 2383 }
2383 return false; 2384 return false;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2448 void QuicConnection::OnPathClosed(QuicPathId path_id) { 2449 void QuicConnection::OnPathClosed(QuicPathId path_id) {
2449 // Stop receiving packets on this path. 2450 // Stop receiving packets on this path.
2450 framer_.OnPathClosed(path_id); 2451 framer_.OnPathClosed(path_id);
2451 } 2452 }
2452 2453
2453 bool QuicConnection::ack_frame_updated() const { 2454 bool QuicConnection::ack_frame_updated() const {
2454 return received_packet_manager_.ack_frame_updated(); 2455 return received_packet_manager_.ack_frame_updated();
2455 } 2456 }
2456 2457
2457 } // namespace net 2458 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/general_loss_algorithm_test.cc ('k') | net/quic/quic_connection_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698