blob: 187e3a8501afdd3b382965af1d7f08a9048a66b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/quic/quic_ack_notifier.h"
#include <set>
#include "base/logging.h"
#include "base/stl_util.h"
using base::hash_map;
using std::make_pair;
namespace net {
QuicAckNotifier::DelegateInterface::DelegateInterface() {}
QuicAckNotifier::DelegateInterface::~DelegateInterface() {}
QuicAckNotifier::QuicAckNotifier(DelegateInterface* delegate)
: delegate_(delegate),
unacked_packets_(0),
retransmitted_packet_count_(0),
retransmitted_byte_count_(0) {
DCHECK(delegate);
}
QuicAckNotifier::~QuicAckNotifier() {
}
void QuicAckNotifier::OnSerializedPacket() {
++unacked_packets_;
}
bool QuicAckNotifier::OnAck(QuicTime::Delta delta_largest_observed) {
if (unacked_packets_ <= 0) {
LOG(DFATAL) << "Acked more packets than were tracked."
<< " unacked_packets:" << unacked_packets_;
return true;
}
--unacked_packets_;
if (!HasUnackedPackets()) {
// We have seen all the packet numbers we were waiting for, trigger
// callback notification.
delegate_->OnAckNotification(retransmitted_packet_count_,
retransmitted_byte_count_,
delta_largest_observed);
return true;
}
return false;
}
bool QuicAckNotifier::OnPacketAbandoned() {
if (unacked_packets_ <= 0) {
LOG(DFATAL) << "Abandoned more packets than were tracked."
<< " unacked_packets:" << unacked_packets_;
return true;
}
--unacked_packets_;
return unacked_packets_ == 0;
}
void QuicAckNotifier::OnPacketRetransmitted(int packet_payload_size) {
++retransmitted_packet_count_;
retransmitted_byte_count_ += packet_payload_size;
}
} // namespace net
|