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
3 // found in the LICENSE file.
5 #include "net/quic/quic_ack_notifier.h"
9 #include "base/logging.h"
10 #include "base/stl_util.h"
17 QuicAckNotifier::DelegateInterface::DelegateInterface() {}
19 QuicAckNotifier::DelegateInterface::~DelegateInterface() {}
21 QuicAckNotifier::QuicAckNotifier(DelegateInterface
* delegate
)
22 : delegate_(delegate
),
24 retransmitted_packet_count_(0),
25 retransmitted_byte_count_(0) {
29 QuicAckNotifier::~QuicAckNotifier() {
32 void QuicAckNotifier::OnSerializedPacket() {
36 bool QuicAckNotifier::OnAck(QuicTime::Delta delta_largest_observed
) {
37 if (unacked_packets_
<= 0) {
38 LOG(DFATAL
) << "Acked more packets than were tracked."
39 << " unacked_packets:" << unacked_packets_
;
43 if (!HasUnackedPackets()) {
44 // We have seen all the packet numbers we were waiting for, trigger
45 // callback notification.
46 delegate_
->OnAckNotification(retransmitted_packet_count_
,
47 retransmitted_byte_count_
,
48 delta_largest_observed
);
54 bool QuicAckNotifier::OnPacketAbandoned() {
55 if (unacked_packets_
<= 0) {
56 LOG(DFATAL
) << "Abandoned more packets than were tracked."
57 << " unacked_packets:" << unacked_packets_
;
61 return unacked_packets_
== 0;
64 void QuicAckNotifier::OnPacketRetransmitted(int packet_payload_size
) {
65 ++retransmitted_packet_count_
;
66 retransmitted_byte_count_
+= packet_payload_size
;