Complete SyncMessageFilter initialization after SyncChannel initialization
[chromium-blink-merge.git] / net / quic / quic_ack_notifier.cc
blob48ee23df1a45bac5c7ce4876489feb930fabfc36
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"
7 #include <set>
9 #include "base/logging.h"
10 #include "base/stl_util.h"
12 using base::hash_map;
13 using std::make_pair;
15 namespace net {
17 QuicAckNotifier::DelegateInterface::DelegateInterface() {}
19 QuicAckNotifier::DelegateInterface::~DelegateInterface() {}
21 QuicAckNotifier::QuicAckNotifier(DelegateInterface* delegate)
22 : delegate_(delegate),
23 unacked_packets_(0),
24 retransmitted_packet_count_(0),
25 retransmitted_byte_count_(0) {
26 DCHECK(delegate);
29 QuicAckNotifier::~QuicAckNotifier() {
32 void QuicAckNotifier::OnSerializedPacket() {
33 ++unacked_packets_;
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_;
40 return true;
42 --unacked_packets_;
43 if (!HasUnackedPackets()) {
44 // We have seen all the sequence numbers we were waiting for, trigger
45 // callback notification.
46 delegate_->OnAckNotification(retransmitted_packet_count_,
47 retransmitted_byte_count_,
48 delta_largest_observed);
49 return true;
51 return false;
54 bool QuicAckNotifier::OnPacketAbandoned() {
55 if (unacked_packets_ <= 0) {
56 LOG(DFATAL) << "Abandoned more packets than were tracked."
57 << " unacked_packets:" << unacked_packets_;
58 return true;
60 --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;
69 }; // namespace net