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/test_tools/quic_sent_packet_manager_peer.h"
7 #include "base/stl_util.h"
8 #include "net/quic/congestion_control/loss_detection_interface.h"
9 #include "net/quic/congestion_control/send_algorithm_interface.h"
10 #include "net/quic/quic_protocol.h"
11 #include "net/quic/quic_sent_packet_manager.h"
17 void QuicSentPacketManagerPeer::SetMaxTailLossProbes(
18 QuicSentPacketManager
* sent_packet_manager
, size_t max_tail_loss_probes
) {
19 sent_packet_manager
->max_tail_loss_probes_
= max_tail_loss_probes
;
23 void QuicSentPacketManagerPeer::SetSendAlgorithm(
24 QuicSentPacketManager
* sent_packet_manager
,
25 SendAlgorithmInterface
* send_algorithm
) {
26 sent_packet_manager
->send_algorithm_
.reset(send_algorithm
);
30 void QuicSentPacketManagerPeer::SetIsServer(
31 QuicSentPacketManager
* sent_packet_manager
,
33 sent_packet_manager
->is_server_
= is_server
;
37 const LossDetectionInterface
* QuicSentPacketManagerPeer::GetLossAlgorithm(
38 QuicSentPacketManager
* sent_packet_manager
) {
39 return sent_packet_manager
->loss_algorithm_
.get();
43 const SendAlgorithmInterface
*
44 QuicSentPacketManagerPeer::GetCongestionControlAlgorithm(
45 const QuicSentPacketManager
& sent_packet_manager
) {
46 return sent_packet_manager
.send_algorithm_
.get();
50 void QuicSentPacketManagerPeer::SetLossAlgorithm(
51 QuicSentPacketManager
* sent_packet_manager
,
52 LossDetectionInterface
* loss_detector
) {
53 sent_packet_manager
->loss_algorithm_
.reset(loss_detector
);
57 RttStats
* QuicSentPacketManagerPeer::GetRttStats(
58 QuicSentPacketManager
* sent_packet_manager
) {
59 return &sent_packet_manager
->rtt_stats_
;
63 size_t QuicSentPacketManagerPeer::GetNackCount(
64 const QuicSentPacketManager
* sent_packet_manager
,
65 QuicPacketSequenceNumber sequence_number
) {
66 return sent_packet_manager
->unacked_packets_
.
67 GetTransmissionInfo(sequence_number
).nack_count
;
71 size_t QuicSentPacketManagerPeer::GetPendingRetransmissionCount(
72 const QuicSentPacketManager
* sent_packet_manager
) {
73 return sent_packet_manager
->pending_retransmissions_
.size();
77 bool QuicSentPacketManagerPeer::HasPendingPackets(
78 const QuicSentPacketManager
* sent_packet_manager
) {
79 return sent_packet_manager
->unacked_packets_
.HasInFlightPackets();
83 QuicTime
QuicSentPacketManagerPeer::GetSentTime(
84 const QuicSentPacketManager
* sent_packet_manager
,
85 QuicPacketSequenceNumber sequence_number
) {
86 DCHECK(sent_packet_manager
->unacked_packets_
.IsUnacked(sequence_number
));
88 return sent_packet_manager
->unacked_packets_
.GetTransmissionInfo(
89 sequence_number
).sent_time
;
93 bool QuicSentPacketManagerPeer::IsRetransmission(
94 QuicSentPacketManager
* sent_packet_manager
,
95 QuicPacketSequenceNumber sequence_number
) {
96 DCHECK(sent_packet_manager
->HasRetransmittableFrames(sequence_number
));
97 return sent_packet_manager
->HasRetransmittableFrames(sequence_number
) &&
98 sent_packet_manager
->unacked_packets_
.GetTransmissionInfo(
99 sequence_number
).all_transmissions
!= nullptr;
103 void QuicSentPacketManagerPeer::MarkForRetransmission(
104 QuicSentPacketManager
* sent_packet_manager
,
105 QuicPacketSequenceNumber sequence_number
,
106 TransmissionType transmission_type
) {
107 sent_packet_manager
->MarkForRetransmission(sequence_number
,
112 QuicTime::Delta
QuicSentPacketManagerPeer::GetRetransmissionDelay(
113 const QuicSentPacketManager
* sent_packet_manager
) {
114 return sent_packet_manager
->GetRetransmissionDelay();
118 bool QuicSentPacketManagerPeer::HasUnackedCryptoPackets(
119 const QuicSentPacketManager
* sent_packet_manager
) {
120 return sent_packet_manager
->unacked_packets_
.HasPendingCryptoPackets();
124 size_t QuicSentPacketManagerPeer::GetNumRetransmittablePackets(
125 const QuicSentPacketManager
* sent_packet_manager
) {
126 size_t num_unacked_packets
= 0;
127 for (QuicUnackedPacketMap::const_iterator it
=
128 sent_packet_manager
->unacked_packets_
.begin();
129 it
!= sent_packet_manager
->unacked_packets_
.end(); ++it
) {
130 if (it
->retransmittable_frames
!= nullptr) {
131 ++num_unacked_packets
;
134 return num_unacked_packets
;
138 QuicByteCount
QuicSentPacketManagerPeer::GetBytesInFlight(
139 const QuicSentPacketManager
* sent_packet_manager
) {
140 return sent_packet_manager
->unacked_packets_
.bytes_in_flight();
144 QuicSentPacketManager::NetworkChangeVisitor
*
145 QuicSentPacketManagerPeer::GetNetworkChangeVisitor(
146 const QuicSentPacketManager
* sent_packet_manager
) {
147 return sent_packet_manager
->network_change_visitor_
;
151 QuicSustainedBandwidthRecorder
& QuicSentPacketManagerPeer::GetBandwidthRecorder(
152 QuicSentPacketManager
* sent_packet_manager
) {
153 return sent_packet_manager
->sustained_bandwidth_recorder_
;