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

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

Issue 188333003: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compilation error - added NET_EXPORT_PRIVATE to QuicFixedUint32 Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_unacked_packet_map.h ('k') | net/quic/reliable_quic_stream_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_unacked_packet_map.h" 5 #include "net/quic/quic_unacked_packet_map.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "net/quic/quic_connection_stats.h" 9 #include "net/quic/quic_connection_stats.h"
10 #include "net/quic/quic_utils_chromium.h" 10 #include "net/quic/quic_utils_chromium.h"
11 11
12 using std::max; 12 using std::max;
13 13
14 namespace net { 14 namespace net {
15 15
16 #define ENDPOINT (is_server_ ? "Server: " : " Client: ")
17
18 QuicUnackedPacketMap::TransmissionInfo::TransmissionInfo() 16 QuicUnackedPacketMap::TransmissionInfo::TransmissionInfo()
19 : retransmittable_frames(NULL), 17 : retransmittable_frames(NULL),
20 sequence_number_length(PACKET_1BYTE_SEQUENCE_NUMBER), 18 sequence_number_length(PACKET_1BYTE_SEQUENCE_NUMBER),
21 sent_time(QuicTime::Zero()), 19 sent_time(QuicTime::Zero()),
22 bytes_sent(0), 20 bytes_sent(0),
23 nack_count(0), 21 nack_count(0),
24 all_transmissions(NULL), 22 all_transmissions(NULL),
25 pending(false) { } 23 pending(false) { }
26 24
27 QuicUnackedPacketMap::TransmissionInfo::TransmissionInfo( 25 QuicUnackedPacketMap::TransmissionInfo::TransmissionInfo(
(...skipping 18 matching lines...) Expand all
46 : retransmittable_frames(retransmittable_frames), 44 : retransmittable_frames(retransmittable_frames),
47 sequence_number_length(sequence_number_length), 45 sequence_number_length(sequence_number_length),
48 sent_time(QuicTime::Zero()), 46 sent_time(QuicTime::Zero()),
49 bytes_sent(0), 47 bytes_sent(0),
50 nack_count(0), 48 nack_count(0),
51 all_transmissions(all_transmissions), 49 all_transmissions(all_transmissions),
52 pending(false) { 50 pending(false) {
53 all_transmissions->insert(sequence_number); 51 all_transmissions->insert(sequence_number);
54 } 52 }
55 53
56 QuicUnackedPacketMap::QuicUnackedPacketMap(bool is_server) 54 QuicUnackedPacketMap::QuicUnackedPacketMap()
57 : largest_sent_packet_(0), 55 : largest_sent_packet_(0),
58 bytes_in_flight_(0), 56 bytes_in_flight_(0),
59 is_server_(is_server) { 57 pending_crypto_packet_count_(0) {
60 } 58 }
61 59
62 QuicUnackedPacketMap::~QuicUnackedPacketMap() { 60 QuicUnackedPacketMap::~QuicUnackedPacketMap() {
63 for (UnackedPacketMap::iterator it = unacked_packets_.begin(); 61 for (UnackedPacketMap::iterator it = unacked_packets_.begin();
64 it != unacked_packets_.end(); ++it) { 62 it != unacked_packets_.end(); ++it) {
65 delete it->second.retransmittable_frames; 63 delete it->second.retransmittable_frames;
66 // Only delete all_transmissions once, for the newest packet. 64 // Only delete all_transmissions once, for the newest packet.
67 if (it->first == *it->second.all_transmissions->rbegin()) { 65 if (it->first == *it->second.all_transmissions->rbegin()) {
68 delete it->second.all_transmissions; 66 delete it->second.all_transmissions;
69 } 67 }
(...skipping 10 matching lines...) Expand all
80 LOG_IF(DFATAL, is_old_packet) << "Old packet serialized: " 78 LOG_IF(DFATAL, is_old_packet) << "Old packet serialized: "
81 << serialized_packet.sequence_number 79 << serialized_packet.sequence_number
82 << " vs: " 80 << " vs: "
83 << unacked_packets_.rbegin()->first; 81 << unacked_packets_.rbegin()->first;
84 } 82 }
85 83
86 unacked_packets_[serialized_packet.sequence_number] = 84 unacked_packets_[serialized_packet.sequence_number] =
87 TransmissionInfo(serialized_packet.retransmittable_frames, 85 TransmissionInfo(serialized_packet.retransmittable_frames,
88 serialized_packet.sequence_number, 86 serialized_packet.sequence_number,
89 serialized_packet.sequence_number_length); 87 serialized_packet.sequence_number_length);
88 if (serialized_packet.retransmittable_frames != NULL &&
89 serialized_packet.retransmittable_frames->HasCryptoHandshake()
90 == IS_HANDSHAKE) {
91 ++pending_crypto_packet_count_;
92 }
90 } 93 }
91 94
92 void QuicUnackedPacketMap::OnRetransmittedPacket( 95 void QuicUnackedPacketMap::OnRetransmittedPacket(
93 QuicPacketSequenceNumber old_sequence_number, 96 QuicPacketSequenceNumber old_sequence_number,
94 QuicPacketSequenceNumber new_sequence_number) { 97 QuicPacketSequenceNumber new_sequence_number) {
95 DCHECK(ContainsKey(unacked_packets_, old_sequence_number)); 98 DCHECK(ContainsKey(unacked_packets_, old_sequence_number));
96 DCHECK(unacked_packets_.empty() || 99 DCHECK(unacked_packets_.empty() ||
97 unacked_packets_.rbegin()->first < new_sequence_number); 100 unacked_packets_.rbegin()->first < new_sequence_number);
98 101
99 // TODO(ianswett): Discard and lose the packet lazily instead of immediately. 102 // TODO(ianswett): Discard and lose the packet lazily instead of immediately.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 if (it == unacked_packets_.end()) { 163 if (it == unacked_packets_.end()) {
161 LOG(DFATAL) << "packet is not unacked: " << sequence_number; 164 LOG(DFATAL) << "packet is not unacked: " << sequence_number;
162 return; 165 return;
163 } 166 }
164 const TransmissionInfo& transmission_info = it->second; 167 const TransmissionInfo& transmission_info = it->second;
165 transmission_info.all_transmissions->erase(sequence_number); 168 transmission_info.all_transmissions->erase(sequence_number);
166 if (transmission_info.all_transmissions->empty()) { 169 if (transmission_info.all_transmissions->empty()) {
167 delete transmission_info.all_transmissions; 170 delete transmission_info.all_transmissions;
168 } 171 }
169 if (transmission_info.retransmittable_frames != NULL) { 172 if (transmission_info.retransmittable_frames != NULL) {
173 if (transmission_info.retransmittable_frames->HasCryptoHandshake()
174 == IS_HANDSHAKE) {
175 --pending_crypto_packet_count_;
176 }
170 delete transmission_info.retransmittable_frames; 177 delete transmission_info.retransmittable_frames;
171 } 178 }
172 unacked_packets_.erase(it); 179 unacked_packets_.erase(it);
173 } 180 }
174 181
175 void QuicUnackedPacketMap::NeuterPacket( 182 void QuicUnackedPacketMap::NeuterPacket(
176 QuicPacketSequenceNumber sequence_number) { 183 QuicPacketSequenceNumber sequence_number) {
177 UnackedPacketMap::iterator it = unacked_packets_.find(sequence_number); 184 UnackedPacketMap::iterator it = unacked_packets_.find(sequence_number);
178 if (it == unacked_packets_.end()) { 185 if (it == unacked_packets_.end()) {
179 LOG(DFATAL) << "packet is not unacked: " << sequence_number; 186 LOG(DFATAL) << "packet is not unacked: " << sequence_number;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 if (it->second.pending) { 282 if (it->second.pending) {
276 ++num_pending; 283 ++num_pending;
277 } 284 }
278 if (num_pending > 1) { 285 if (num_pending > 1) {
279 return true; 286 return true;
280 } 287 }
281 } 288 }
282 return false; 289 return false;
283 } 290 }
284 291
292 bool QuicUnackedPacketMap::HasPendingCryptoPackets() const {
293 return pending_crypto_packet_count_ > 0;
294 }
295
285 bool QuicUnackedPacketMap::HasUnackedRetransmittableFrames() const { 296 bool QuicUnackedPacketMap::HasUnackedRetransmittableFrames() const {
286 for (UnackedPacketMap::const_reverse_iterator it = 297 for (UnackedPacketMap::const_reverse_iterator it =
287 unacked_packets_.rbegin(); it != unacked_packets_.rend(); ++it) { 298 unacked_packets_.rbegin(); it != unacked_packets_.rend(); ++it) {
288 if (it->second.pending && it->second.retransmittable_frames) { 299 if (it->second.pending && it->second.retransmittable_frames) {
289 return true; 300 return true;
290 } 301 }
291 } 302 }
292 return false; 303 return false;
293 } 304 }
294 305
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 DCHECK(!it->second.pending); 346 DCHECK(!it->second.pending);
336 347
337 largest_sent_packet_ = max(sequence_number, largest_sent_packet_); 348 largest_sent_packet_ = max(sequence_number, largest_sent_packet_);
338 bytes_in_flight_ += bytes_sent; 349 bytes_in_flight_ += bytes_sent;
339 it->second.sent_time = sent_time; 350 it->second.sent_time = sent_time;
340 it->second.bytes_sent = bytes_sent; 351 it->second.bytes_sent = bytes_sent;
341 it->second.pending = true; 352 it->second.pending = true;
342 } 353 }
343 354
344 } // namespace net 355 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_unacked_packet_map.h ('k') | net/quic/reliable_quic_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698