Index: net/quic/quic_ack_notifier_manager.cc |
diff --git a/net/quic/quic_ack_notifier_manager.cc b/net/quic/quic_ack_notifier_manager.cc |
index 73e3c8e1c2ac87692fb8dc1e4256d95c67d7d9f8..0d37752e211ab130f4ffcb9243ecf486e8f9ec1d 100644 |
--- a/net/quic/quic_ack_notifier_manager.cc |
+++ b/net/quic/quic_ack_notifier_manager.cc |
@@ -20,13 +20,7 @@ |
AckNotifierManager::AckNotifierManager() {} |
AckNotifierManager::~AckNotifierManager() { |
- for (const auto& pair : ack_notifier_map_) { |
- for (QuicAckNotifier* notifier : pair.second) { |
- if (notifier->OnPacketAbandoned()) { |
- delete notifier; |
- } |
- } |
- } |
+ STLDeleteElements(&ack_notifiers_); |
} |
void AckNotifierManager::OnPacketAcked(QuicPacketSequenceNumber sequence_number, |
@@ -40,10 +34,14 @@ |
// One or more AckNotifiers are registered as interested in this sequence |
// number. Iterate through them and call OnAck on each. |
- for (QuicAckNotifier* ack_notifier : map_it->second) { |
- if (ack_notifier->OnAck(delta_largest_observed)) { |
- // If this has resulted in an empty AckNotifer, erase it. |
+ AckNotifierList& ack_notifier_list = map_it->second; |
+ for (QuicAckNotifier* ack_notifier : ack_notifier_list) { |
+ ack_notifier->OnAck(sequence_number, delta_largest_observed); |
+ |
+ // If this has resulted in an empty AckNotifer, erase it. |
+ if (ack_notifier->IsEmpty()) { |
delete ack_notifier; |
+ ack_notifiers_.erase(ack_notifier); |
} |
} |
@@ -77,19 +75,21 @@ |
void AckNotifierManager::OnSerializedPacket( |
const SerializedPacket& serialized_packet) { |
if (FLAGS_quic_attach_ack_notifiers_to_packets) { |
- // Inform each attached AckNotifier of the packet's serialization. |
- AckNotifierList& notifier_list = |
- ack_notifier_map_[serialized_packet.sequence_number]; |
+ // Inform each attached AckNotifier of the packet's sequence number. |
for (QuicAckNotifier* notifier : serialized_packet.notifiers) { |
if (notifier == nullptr) { |
LOG(DFATAL) << "AckNotifier should not be nullptr."; |
continue; |
} |
- notifier->OnSerializedPacket(); |
+ notifier->AddSequenceNumber(serialized_packet.sequence_number, |
+ serialized_packet.packet->length()); |
// Update the mapping in the other direction, from sequence number to |
// AckNotifier. |
- notifier_list.push_back(notifier); |
+ ack_notifier_map_[serialized_packet.sequence_number].push_back(notifier); |
+ |
+ // Take ownership of the AckNotifier. |
+ ack_notifiers_.insert(notifier); |
} |
} else { |
// AckNotifiers can only be attached to retransmittable frames. |
@@ -107,11 +107,15 @@ |
} |
QuicAckNotifier* notifier = quic_frame.stream_frame->notifier; |
- notifier->OnSerializedPacket(); |
+ notifier->AddSequenceNumber(serialized_packet.sequence_number, |
+ serialized_packet.packet->length()); |
// Update the mapping in the other direction, from sequence number to |
// AckNotifier. |
ack_notifier_map_[serialized_packet.sequence_number].push_back(notifier); |
+ |
+ // Take ownership of the AckNotifier. |
+ ack_notifiers_.insert(notifier); |
} |
} |
} |