| OLD | NEW |
| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 } | 69 } |
| 70 | 70 |
| 71 // The old sequence number is no longer of interest, copy the updated | 71 // The old sequence number is no longer of interest, copy the updated |
| 72 // AckNotifiers to the new sequence number before deleting the old. | 72 // AckNotifiers to the new sequence number before deleting the old. |
| 73 ack_notifier_map_[new_sequence_number] = ack_notifier_list; | 73 ack_notifier_map_[new_sequence_number] = ack_notifier_list; |
| 74 ack_notifier_map_.erase(map_it); | 74 ack_notifier_map_.erase(map_it); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void AckNotifierManager::OnSerializedPacket( | 77 void AckNotifierManager::OnSerializedPacket( |
| 78 const SerializedPacket& serialized_packet) { | 78 const SerializedPacket& serialized_packet) { |
| 79 if (FLAGS_quic_attach_ack_notifiers_to_packets) { | 79 // Inform each attached AckNotifier of the packet's serialization. |
| 80 // Inform each attached AckNotifier of the packet's serialization. | 80 AckNotifierList& notifier_list = |
| 81 AckNotifierList& notifier_list = | 81 ack_notifier_map_[serialized_packet.sequence_number]; |
| 82 ack_notifier_map_[serialized_packet.sequence_number]; | 82 for (QuicAckNotifier* notifier : serialized_packet.notifiers) { |
| 83 for (QuicAckNotifier* notifier : serialized_packet.notifiers) { | 83 if (notifier == nullptr) { |
| 84 if (notifier == nullptr) { | 84 LOG(DFATAL) << "AckNotifier should not be nullptr."; |
| 85 LOG(DFATAL) << "AckNotifier should not be nullptr."; | 85 continue; |
| 86 continue; | |
| 87 } | |
| 88 notifier->OnSerializedPacket(); | |
| 89 | |
| 90 // Update the mapping in the other direction, from sequence number to | |
| 91 // AckNotifier. | |
| 92 notifier_list.push_back(notifier); | |
| 93 } | 86 } |
| 94 } else { | 87 notifier->OnSerializedPacket(); |
| 95 // AckNotifiers can only be attached to retransmittable frames. | 88 notifier_list.push_back(notifier); |
| 96 RetransmittableFrames* frames = serialized_packet.retransmittable_frames; | |
| 97 if (frames == nullptr) { | |
| 98 return; | |
| 99 } | |
| 100 | |
| 101 // For each frame in |serialized_packet|, inform any attached AckNotifiers | |
| 102 // of the packet's sequence number. | |
| 103 for (const QuicFrame& quic_frame : frames->frames()) { | |
| 104 if (quic_frame.type != STREAM_FRAME || | |
| 105 quic_frame.stream_frame->notifier == nullptr) { | |
| 106 continue; | |
| 107 } | |
| 108 | |
| 109 QuicAckNotifier* notifier = quic_frame.stream_frame->notifier; | |
| 110 notifier->OnSerializedPacket(); | |
| 111 | |
| 112 // Update the mapping in the other direction, from sequence number to | |
| 113 // AckNotifier. | |
| 114 ack_notifier_map_[serialized_packet.sequence_number].push_back(notifier); | |
| 115 } | |
| 116 } | 89 } |
| 117 } | 90 } |
| 118 | 91 |
| 119 } // namespace net | 92 } // namespace net |
| OLD | NEW |