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 size_t QuicSentPacketManagerPeer::GetMaxTailLossProbes(
18 QuicSentPacketManager
* sent_packet_manager
) {
19 return sent_packet_manager
->max_tail_loss_probes_
;
23 void QuicSentPacketManagerPeer::SetMaxTailLossProbes(
24 QuicSentPacketManager
* sent_packet_manager
,
25 size_t max_tail_loss_probes
) {
26 sent_packet_manager
->max_tail_loss_probes_
= max_tail_loss_probes
;
30 bool QuicSentPacketManagerPeer::GetEnableHalfRttTailLossProbe(
31 QuicSentPacketManager
* sent_packet_manager
) {
32 return sent_packet_manager
->enable_half_rtt_tail_loss_probe_
;
36 bool QuicSentPacketManagerPeer::GetUseNewRto(
37 QuicSentPacketManager
* sent_packet_manager
) {
38 return sent_packet_manager
->use_new_rto_
;
42 QuicByteCount
QuicSentPacketManagerPeer::GetReceiveWindow(
43 QuicSentPacketManager
* sent_packet_manager
) {
44 return sent_packet_manager
->receive_buffer_bytes_
;
48 void QuicSentPacketManagerPeer::SetPerspective(
49 QuicSentPacketManager
* sent_packet_manager
,
50 Perspective perspective
) {
51 sent_packet_manager
->perspective_
= perspective
;
55 const SendAlgorithmInterface
*
56 QuicSentPacketManagerPeer::GetSendAlgorithm(
57 const QuicSentPacketManager
& sent_packet_manager
) {
58 return sent_packet_manager
.send_algorithm_
.get();
62 void QuicSentPacketManagerPeer::SetSendAlgorithm(
63 QuicSentPacketManager
* sent_packet_manager
,
64 SendAlgorithmInterface
* send_algorithm
) {
65 sent_packet_manager
->send_algorithm_
.reset(send_algorithm
);
69 const LossDetectionInterface
* QuicSentPacketManagerPeer::GetLossAlgorithm(
70 QuicSentPacketManager
* sent_packet_manager
) {
71 return sent_packet_manager
->loss_algorithm_
.get();
75 void QuicSentPacketManagerPeer::SetLossAlgorithm(
76 QuicSentPacketManager
* sent_packet_manager
,
77 LossDetectionInterface
* loss_detector
) {
78 sent_packet_manager
->loss_algorithm_
.reset(loss_detector
);
82 RttStats
* QuicSentPacketManagerPeer::GetRttStats(
83 QuicSentPacketManager
* sent_packet_manager
) {
84 return &sent_packet_manager
->rtt_stats_
;
88 bool QuicSentPacketManagerPeer::HasPendingPackets(
89 const QuicSentPacketManager
* sent_packet_manager
) {
90 return sent_packet_manager
->unacked_packets_
.HasInFlightPackets();
94 QuicTime
QuicSentPacketManagerPeer::GetSentTime(
95 const QuicSentPacketManager
* sent_packet_manager
,
96 QuicPacketNumber packet_number
) {
97 DCHECK(sent_packet_manager
->unacked_packets_
.IsUnacked(packet_number
));
99 return sent_packet_manager
->unacked_packets_
.GetTransmissionInfo(
105 bool QuicSentPacketManagerPeer::IsRetransmission(
106 QuicSentPacketManager
* sent_packet_manager
,
107 QuicPacketNumber packet_number
) {
108 DCHECK(sent_packet_manager
->HasRetransmittableFrames(packet_number
));
109 return sent_packet_manager
->HasRetransmittableFrames(packet_number
) &&
110 sent_packet_manager
->unacked_packets_
.GetTransmissionInfo(
112 .all_transmissions
!= nullptr;
116 void QuicSentPacketManagerPeer::MarkForRetransmission(
117 QuicSentPacketManager
* sent_packet_manager
,
118 QuicPacketNumber packet_number
,
119 TransmissionType transmission_type
) {
120 sent_packet_manager
->MarkForRetransmission(packet_number
, transmission_type
);
124 QuicTime::Delta
QuicSentPacketManagerPeer::GetRetransmissionDelay(
125 const QuicSentPacketManager
* sent_packet_manager
) {
126 return sent_packet_manager
->GetRetransmissionDelay();
130 bool QuicSentPacketManagerPeer::HasUnackedCryptoPackets(
131 const QuicSentPacketManager
* sent_packet_manager
) {
132 return sent_packet_manager
->unacked_packets_
.HasPendingCryptoPackets();
136 size_t QuicSentPacketManagerPeer::GetNumRetransmittablePackets(
137 const QuicSentPacketManager
* sent_packet_manager
) {
138 size_t num_unacked_packets
= 0;
139 for (QuicUnackedPacketMap::const_iterator it
=
140 sent_packet_manager
->unacked_packets_
.begin();
141 it
!= sent_packet_manager
->unacked_packets_
.end(); ++it
) {
142 if (it
->retransmittable_frames
!= nullptr) {
143 ++num_unacked_packets
;
146 return num_unacked_packets
;
150 QuicByteCount
QuicSentPacketManagerPeer::GetBytesInFlight(
151 const QuicSentPacketManager
* sent_packet_manager
) {
152 return sent_packet_manager
->unacked_packets_
.bytes_in_flight();
156 QuicSentPacketManager::NetworkChangeVisitor
*
157 QuicSentPacketManagerPeer::GetNetworkChangeVisitor(
158 const QuicSentPacketManager
* sent_packet_manager
) {
159 return sent_packet_manager
->network_change_visitor_
;
163 QuicSustainedBandwidthRecorder
& QuicSentPacketManagerPeer::GetBandwidthRecorder(
164 QuicSentPacketManager
* sent_packet_manager
) {
165 return sent_packet_manager
->sustained_bandwidth_recorder_
;