This source file includes following definitions.
- OnPacketAcked
- UpdateSequenceNumber
- OnSerializedPacket
#include "net/quic/quic_ack_notifier_manager.h"
#include <stddef.h>
#include <list>
#include <map>
#include <utility>
#include <vector>
#include "base/stl_util.h"
#include "net/quic/quic_ack_notifier.h"
#include "net/quic/quic_protocol.h"
namespace net {
AckNotifierManager::AckNotifierManager() {}
AckNotifierManager::~AckNotifierManager() {
STLDeleteElements(&ack_notifiers_);
}
void AckNotifierManager::OnPacketAcked(
QuicPacketSequenceNumber sequence_number) {
AckNotifierMap::iterator map_it = ack_notifier_map_.find(sequence_number);
if (map_it == ack_notifier_map_.end()) {
return;
}
for (AckNotifierSet::iterator set_it = map_it->second.begin();
set_it != map_it->second.end(); ++set_it) {
QuicAckNotifier* ack_notifier = *set_it;
ack_notifier->OnAck(sequence_number);
if (ack_notifier->IsEmpty()) {
delete ack_notifier;
ack_notifiers_.erase(ack_notifier);
}
}
ack_notifier_map_.erase(map_it);
}
void AckNotifierManager::UpdateSequenceNumber(
QuicPacketSequenceNumber old_sequence_number,
QuicPacketSequenceNumber new_sequence_number) {
AckNotifierMap::iterator map_it = ack_notifier_map_.find(old_sequence_number);
if (map_it != ack_notifier_map_.end()) {
AckNotifierSet new_set;
for (AckNotifierSet::iterator notifier_it = map_it->second.begin();
notifier_it != map_it->second.end(); ++notifier_it) {
(*notifier_it)
->UpdateSequenceNumber(old_sequence_number, new_sequence_number);
new_set.insert(*notifier_it);
}
ack_notifier_map_[new_sequence_number] = new_set;
ack_notifier_map_.erase(map_it);
}
}
void AckNotifierManager::OnSerializedPacket(
const SerializedPacket& serialized_packet) {
RetransmittableFrames* frames = serialized_packet.retransmittable_frames;
if (!frames) {
return;
}
for (QuicFrames::const_iterator it = frames->frames().begin();
it != frames->frames().end(); ++it) {
if (it->type == STREAM_FRAME && it->stream_frame->notifier != NULL) {
QuicAckNotifier* notifier = it->stream_frame->notifier;
notifier->AddSequenceNumber(serialized_packet.sequence_number,
serialized_packet.packet->length());
ack_notifier_map_[serialized_packet.sequence_number].insert(notifier);
ack_notifiers_.insert(notifier);
}
}
}
}