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
, size_t max_tail_loss_probes
) {
25 sent_packet_manager
->max_tail_loss_probes_
= max_tail_loss_probes
;
29 bool QuicSentPacketManagerPeer::GetEnableHalfRttTailLossProbe(
30 QuicSentPacketManager
* sent_packet_manager
) {
31 return sent_packet_manager
->enable_half_rtt_tail_loss_probe_
;
35 bool QuicSentPacketManagerPeer::GetUseNewRto(
36 QuicSentPacketManager
* sent_packet_manager
) {
37 return sent_packet_manager
->use_new_rto_
;
41 QuicByteCount
QuicSentPacketManagerPeer::GetReceiveWindow(
42 QuicSentPacketManager
* sent_packet_manager
) {
43 return sent_packet_manager
->receive_buffer_bytes_
;
47 void QuicSentPacketManagerPeer::SetPerspective(
48 QuicSentPacketManager
* sent_packet_manager
,
49 Perspective perspective
) {
50 sent_packet_manager
->perspective_
= perspective
;
54 const SendAlgorithmInterface
*
55 QuicSentPacketManagerPeer::GetSendAlgorithm(
56 const QuicSentPacketManager
& sent_packet_manager
) {
57 return sent_packet_manager
.send_algorithm_
.get();
61 void QuicSentPacketManagerPeer::SetSendAlgorithm(
62 QuicSentPacketManager
* sent_packet_manager
,
63 SendAlgorithmInterface
* send_algorithm
) {
64 sent_packet_manager
->send_algorithm_
.reset(send_algorithm
);
68 const LossDetectionInterface
* QuicSentPacketManagerPeer::GetLossAlgorithm(
69 QuicSentPacketManager
* sent_packet_manager
) {
70 return sent_packet_manager
->loss_algorithm_
.get();
74 void QuicSentPacketManagerPeer::SetLossAlgorithm(
75 QuicSentPacketManager
* sent_packet_manager
,
76 LossDetectionInterface
* loss_detector
) {
77 sent_packet_manager
->loss_algorithm_
.reset(loss_detector
);
81 RttStats
* QuicSentPacketManagerPeer::GetRttStats(
82 QuicSentPacketManager
* sent_packet_manager
) {
83 return &sent_packet_manager
->rtt_stats_
;
87 bool QuicSentPacketManagerPeer::HasPendingPackets(
88 const QuicSentPacketManager
* sent_packet_manager
) {
89 return sent_packet_manager
->unacked_packets_
.HasInFlightPackets();
93 QuicTime
QuicSentPacketManagerPeer::GetSentTime(
94 const QuicSentPacketManager
* sent_packet_manager
,
95 QuicPacketNumber packet_number
) {
96 DCHECK(sent_packet_manager
->unacked_packets_
.IsUnacked(packet_number
));
98 return sent_packet_manager
->unacked_packets_
.GetTransmissionInfo(
104 bool QuicSentPacketManagerPeer::IsRetransmission(
105 QuicSentPacketManager
* sent_packet_manager
,
106 QuicPacketNumber packet_number
) {
107 DCHECK(sent_packet_manager
->HasRetransmittableFrames(packet_number
));
108 return sent_packet_manager
->HasRetransmittableFrames(packet_number
) &&
109 sent_packet_manager
->unacked_packets_
.GetTransmissionInfo(
111 .all_transmissions
!= nullptr;
115 void QuicSentPacketManagerPeer::MarkForRetransmission(
116 QuicSentPacketManager
* sent_packet_manager
,
117 QuicPacketNumber packet_number
,
118 TransmissionType transmission_type
) {
119 sent_packet_manager
->MarkForRetransmission(packet_number
, transmission_type
);
123 QuicTime::Delta
QuicSentPacketManagerPeer::GetRetransmissionDelay(
124 const QuicSentPacketManager
* sent_packet_manager
) {
125 return sent_packet_manager
->GetRetransmissionDelay();
129 bool QuicSentPacketManagerPeer::HasUnackedCryptoPackets(
130 const QuicSentPacketManager
* sent_packet_manager
) {
131 return sent_packet_manager
->unacked_packets_
.HasPendingCryptoPackets();
135 size_t QuicSentPacketManagerPeer::GetNumRetransmittablePackets(
136 const QuicSentPacketManager
* sent_packet_manager
) {
137 size_t num_unacked_packets
= 0;
138 for (QuicUnackedPacketMap::const_iterator it
=
139 sent_packet_manager
->unacked_packets_
.begin();
140 it
!= sent_packet_manager
->unacked_packets_
.end(); ++it
) {
141 if (it
->retransmittable_frames
!= nullptr) {
142 ++num_unacked_packets
;
145 return num_unacked_packets
;
149 QuicByteCount
QuicSentPacketManagerPeer::GetBytesInFlight(
150 const QuicSentPacketManager
* sent_packet_manager
) {
151 return sent_packet_manager
->unacked_packets_
.bytes_in_flight();
155 QuicSentPacketManager::NetworkChangeVisitor
*
156 QuicSentPacketManagerPeer::GetNetworkChangeVisitor(
157 const QuicSentPacketManager
* sent_packet_manager
) {
158 return sent_packet_manager
->network_change_visitor_
;
162 QuicSustainedBandwidthRecorder
& QuicSentPacketManagerPeer::GetBandwidthRecorder(
163 QuicSentPacketManager
* sent_packet_manager
) {
164 return sent_packet_manager
->sustained_bandwidth_recorder_
;