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

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

Issue 885443002: Roll Chrome into Mojo. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebase to ToT mojo Created 5 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
« no previous file with comments | « net/quic/quic_ack_notifier_manager.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_manager.h" 5 #include "net/quic/quic_ack_notifier_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
(...skipping 16 matching lines...) Expand all
27 QuicTime::Delta delta_largest_observed) { 27 QuicTime::Delta delta_largest_observed) {
28 // Inform all the registered AckNotifiers of the new ACK. 28 // Inform all the registered AckNotifiers of the new ACK.
29 auto map_it = ack_notifier_map_.find(sequence_number); 29 auto map_it = ack_notifier_map_.find(sequence_number);
30 if (map_it == ack_notifier_map_.end()) { 30 if (map_it == ack_notifier_map_.end()) {
31 // No AckNotifier is interested in this sequence number. 31 // No AckNotifier is interested in this sequence number.
32 return; 32 return;
33 } 33 }
34 34
35 // One or more AckNotifiers are registered as interested in this sequence 35 // One or more AckNotifiers are registered as interested in this sequence
36 // number. Iterate through them and call OnAck on each. 36 // number. Iterate through them and call OnAck on each.
37 AckNotifierSet& ack_notifier_set = map_it->second; 37 AckNotifierList& ack_notifier_list = map_it->second;
38 for (QuicAckNotifier* ack_notifier : ack_notifier_set) { 38 for (QuicAckNotifier* ack_notifier : ack_notifier_list) {
39 ack_notifier->OnAck(sequence_number, delta_largest_observed); 39 ack_notifier->OnAck(sequence_number, delta_largest_observed);
40 40
41 // If this has resulted in an empty AckNotifer, erase it. 41 // If this has resulted in an empty AckNotifer, erase it.
42 if (ack_notifier->IsEmpty()) { 42 if (ack_notifier->IsEmpty()) {
43 delete ack_notifier; 43 delete ack_notifier;
44 ack_notifiers_.erase(ack_notifier); 44 ack_notifiers_.erase(ack_notifier);
45 } 45 }
46 } 46 }
47 47
48 // Remove the sequence number from the map as we have notified all the 48 // Remove the sequence number from the map as we have notified all the
49 // registered AckNotifiers, and we won't see it again. 49 // registered AckNotifiers, and we won't see it again.
50 ack_notifier_map_.erase(map_it); 50 ack_notifier_map_.erase(map_it);
51 } 51 }
52 52
53 void AckNotifierManager::UpdateSequenceNumber( 53 void AckNotifierManager::OnPacketRetransmitted(
54 QuicPacketSequenceNumber old_sequence_number, 54 QuicPacketSequenceNumber old_sequence_number,
55 QuicPacketSequenceNumber new_sequence_number) { 55 QuicPacketSequenceNumber new_sequence_number,
56 int packet_payload_size) {
56 auto map_it = ack_notifier_map_.find(old_sequence_number); 57 auto map_it = ack_notifier_map_.find(old_sequence_number);
57 if (map_it == ack_notifier_map_.end()) { 58 if (map_it == ack_notifier_map_.end()) {
58 // No AckNotifiers are interested in the old sequence number. 59 // No AckNotifiers are interested in the old sequence number.
59 return; 60 return;
60 } 61 }
61 62
62 // Update the existing QuicAckNotifiers to the new sequence number. 63 // Update the existing QuicAckNotifiers to the new sequence number.
63 AckNotifierSet& ack_notifier_set = map_it->second; 64 AckNotifierList& ack_notifier_list = map_it->second;
64 for (QuicAckNotifier* ack_notifier : ack_notifier_set) { 65 for (QuicAckNotifier* ack_notifier : ack_notifier_list) {
65 ack_notifier->UpdateSequenceNumber(old_sequence_number, 66 ack_notifier->OnPacketRetransmitted(packet_payload_size);
66 new_sequence_number);
67 } 67 }
68 68
69 // The old sequence number is no longer of interest, copy the updated 69 // The old sequence number is no longer of interest, copy the updated
70 // AckNotifiers to the new sequence number before deleting the old. 70 // AckNotifiers to the new sequence number before deleting the old.
71 ack_notifier_map_[new_sequence_number] = ack_notifier_set; 71 ack_notifier_map_[new_sequence_number] = ack_notifier_list;
72 ack_notifier_map_.erase(map_it); 72 ack_notifier_map_.erase(map_it);
73 } 73 }
74 74
75 void AckNotifierManager::OnSerializedPacket( 75 void AckNotifierManager::OnSerializedPacket(
76 const SerializedPacket& serialized_packet) { 76 const SerializedPacket& serialized_packet) {
77 if (FLAGS_quic_attach_ack_notifiers_to_packets) { 77 if (FLAGS_quic_attach_ack_notifiers_to_packets) {
78 // Inform each attached AckNotifier of the packet's sequence number. 78 // Inform each attached AckNotifier of the packet's sequence number.
79 for (QuicAckNotifier* notifier : serialized_packet.notifiers) { 79 for (QuicAckNotifier* notifier : serialized_packet.notifiers) {
80 if (notifier == nullptr) { 80 if (notifier == nullptr) {
81 LOG(DFATAL) << "AckNotifier should not be nullptr."; 81 LOG(DFATAL) << "AckNotifier should not be nullptr.";
82 continue; 82 continue;
83 } 83 }
84 notifier->AddSequenceNumber(serialized_packet.sequence_number, 84 notifier->AddSequenceNumber(serialized_packet.sequence_number,
85 serialized_packet.packet->length()); 85 serialized_packet.packet->length());
86 86
87 // Update the mapping in the other direction, from sequence number to 87 // Update the mapping in the other direction, from sequence number to
88 // AckNotifier. 88 // AckNotifier.
89 ack_notifier_map_[serialized_packet.sequence_number].insert(notifier); 89 ack_notifier_map_[serialized_packet.sequence_number].push_back(notifier);
90 90
91 // Take ownership of the AckNotifier. 91 // Take ownership of the AckNotifier.
92 ack_notifiers_.insert(notifier); 92 ack_notifiers_.insert(notifier);
93 } 93 }
94 } else { 94 } else {
95 // AckNotifiers can only be attached to retransmittable frames. 95 // AckNotifiers can only be attached to retransmittable frames.
96 RetransmittableFrames* frames = serialized_packet.retransmittable_frames; 96 RetransmittableFrames* frames = serialized_packet.retransmittable_frames;
97 if (frames == nullptr) { 97 if (frames == nullptr) {
98 return; 98 return;
99 } 99 }
100 100
101 // For each frame in |serialized_packet|, inform any attached AckNotifiers 101 // For each frame in |serialized_packet|, inform any attached AckNotifiers
102 // of the packet's sequence number. 102 // of the packet's sequence number.
103 for (const QuicFrame& quic_frame : frames->frames()) { 103 for (const QuicFrame& quic_frame : frames->frames()) {
104 if (quic_frame.type != STREAM_FRAME || 104 if (quic_frame.type != STREAM_FRAME ||
105 quic_frame.stream_frame->notifier == nullptr) { 105 quic_frame.stream_frame->notifier == nullptr) {
106 continue; 106 continue;
107 } 107 }
108 108
109 QuicAckNotifier* notifier = quic_frame.stream_frame->notifier; 109 QuicAckNotifier* notifier = quic_frame.stream_frame->notifier;
110 notifier->AddSequenceNumber(serialized_packet.sequence_number, 110 notifier->AddSequenceNumber(serialized_packet.sequence_number,
111 serialized_packet.packet->length()); 111 serialized_packet.packet->length());
112 112
113 // Update the mapping in the other direction, from sequence number to 113 // Update the mapping in the other direction, from sequence number to
114 // AckNotifier. 114 // AckNotifier.
115 ack_notifier_map_[serialized_packet.sequence_number].insert(notifier); 115 ack_notifier_map_[serialized_packet.sequence_number].push_back(notifier);
116 116
117 // Take ownership of the AckNotifier. 117 // Take ownership of the AckNotifier.
118 ack_notifiers_.insert(notifier); 118 ack_notifiers_.insert(notifier);
119 } 119 }
120 } 120 }
121 } 121 }
122 122
123 } // namespace net 123 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_ack_notifier_manager.h ('k') | net/quic/quic_ack_notifier_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698