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

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

Issue 849123003: Land Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed extra blank line Created 5 years, 11 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
« no previous file with comments | « net/quic/quic_ack_notifier.h ('k') | net/quic/quic_ack_notifier_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_ack_notifier.h" 5 #include "net/quic/quic_ack_notifier.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 11
12 using base::hash_map; 12 using base::hash_map;
13 using std::make_pair; 13 using std::make_pair;
14 14
15 namespace net { 15 namespace net {
16 16
17 QuicAckNotifier::PacketInfo::PacketInfo() : packet_payload_size(0) { 17 QuicAckNotifier::PacketInfo::PacketInfo() : packet_payload_size(0) {
18 } 18 }
19 19
20 QuicAckNotifier::PacketInfo::PacketInfo(int payload_size) 20 QuicAckNotifier::PacketInfo::PacketInfo(int payload_size)
21 : packet_payload_size(payload_size) { 21 : packet_payload_size(payload_size) {
22 } 22 }
23 23
24 QuicAckNotifier::DelegateInterface::DelegateInterface() {} 24 QuicAckNotifier::DelegateInterface::DelegateInterface() {}
25 25
26 QuicAckNotifier::DelegateInterface::~DelegateInterface() {} 26 QuicAckNotifier::DelegateInterface::~DelegateInterface() {}
27 27
28 QuicAckNotifier::QuicAckNotifier(DelegateInterface* delegate) 28 QuicAckNotifier::QuicAckNotifier(DelegateInterface* delegate)
29 : delegate_(delegate), 29 : delegate_(delegate),
30 original_packet_count_(0),
31 original_byte_count_(0),
32 retransmitted_packet_count_(0), 30 retransmitted_packet_count_(0),
33 retransmitted_byte_count_(0) { 31 retransmitted_byte_count_(0) {
34 DCHECK(delegate); 32 DCHECK(delegate);
35 } 33 }
36 34
37 QuicAckNotifier::~QuicAckNotifier() { 35 QuicAckNotifier::~QuicAckNotifier() {
38 } 36 }
39 37
40 void QuicAckNotifier::AddSequenceNumber( 38 void QuicAckNotifier::AddSequenceNumber(
41 const QuicPacketSequenceNumber& sequence_number, 39 const QuicPacketSequenceNumber& sequence_number,
42 int packet_payload_size) { 40 int packet_payload_size) {
43 sequence_numbers_.insert(make_pair(sequence_number, 41 sequence_numbers_.insert(make_pair(sequence_number,
44 PacketInfo(packet_payload_size))); 42 PacketInfo(packet_payload_size)));
45 ++original_packet_count_;
46 original_byte_count_ += packet_payload_size;
47 43
48 DVLOG(1) << "AckNotifier waiting for packet: " << sequence_number; 44 DVLOG(1) << "AckNotifier waiting for packet: " << sequence_number;
49 } 45 }
50 46
51 bool QuicAckNotifier::OnAck(QuicPacketSequenceNumber sequence_number, 47 bool QuicAckNotifier::OnAck(QuicPacketSequenceNumber sequence_number,
52 QuicTime::Delta delta_largest_observed) { 48 QuicTime::Delta delta_largest_observed) {
53 DCHECK(ContainsKey(sequence_numbers_, sequence_number)); 49 DCHECK(ContainsKey(sequence_numbers_, sequence_number));
54 sequence_numbers_.erase(sequence_number); 50 sequence_numbers_.erase(sequence_number);
55 if (IsEmpty()) { 51 if (IsEmpty()) {
56 // We have seen all the sequence numbers we were waiting for, trigger 52 // We have seen all the sequence numbers we were waiting for, trigger
57 // callback notification. 53 // callback notification.
58 delegate_->OnAckNotification( 54 delegate_->OnAckNotification(retransmitted_packet_count_,
59 original_packet_count_, original_byte_count_, 55 retransmitted_byte_count_,
60 retransmitted_packet_count_, retransmitted_byte_count_, 56 delta_largest_observed);
61 delta_largest_observed);
62 return true; 57 return true;
63 } 58 }
64 return false; 59 return false;
65 } 60 }
66 61
67 void QuicAckNotifier::UpdateSequenceNumber( 62 void QuicAckNotifier::UpdateSequenceNumber(
68 QuicPacketSequenceNumber old_sequence_number, 63 QuicPacketSequenceNumber old_sequence_number,
69 QuicPacketSequenceNumber new_sequence_number) { 64 QuicPacketSequenceNumber new_sequence_number) {
70 DCHECK(!ContainsKey(sequence_numbers_, new_sequence_number)); 65 DCHECK(!ContainsKey(sequence_numbers_, new_sequence_number));
71 66
72 PacketInfo packet_info; 67 PacketInfo packet_info;
73 auto it = sequence_numbers_.find(old_sequence_number); 68 auto it = sequence_numbers_.find(old_sequence_number);
74 if (it != sequence_numbers_.end()) { 69 if (it != sequence_numbers_.end()) {
75 packet_info = it->second; 70 packet_info = it->second;
76 sequence_numbers_.erase(it); 71 sequence_numbers_.erase(it);
77 } else { 72 } else {
78 DLOG(DFATAL) << "Old sequence number not found."; 73 DLOG(DFATAL) << "Old sequence number not found.";
79 } 74 }
80 75
81 ++retransmitted_packet_count_; 76 ++retransmitted_packet_count_;
82 retransmitted_byte_count_ += packet_info.packet_payload_size; 77 retransmitted_byte_count_ += packet_info.packet_payload_size;
83 sequence_numbers_.insert(make_pair(new_sequence_number, packet_info)); 78 sequence_numbers_.insert(make_pair(new_sequence_number, packet_info));
84 79
85 DVLOG(1) << "AckNotifier waiting for packet: " << new_sequence_number 80 DVLOG(1) << "AckNotifier waiting for packet: " << new_sequence_number
86 << " (retransmitted " << old_sequence_number << ")."; 81 << " (retransmitted " << old_sequence_number << ").";
87 } 82 }
88 83
89 }; // namespace net 84 }; // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_ack_notifier.h ('k') | net/quic/quic_ack_notifier_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698