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::GetUseNewRto(
30 QuicSentPacketManager
* sent_packet_manager
) {
31 return sent_packet_manager
->use_new_rto_
;
35 QuicByteCount
QuicSentPacketManagerPeer::GetReceiveWindow(
36 QuicSentPacketManager
* sent_packet_manager
) {
37 return sent_packet_manager
->receive_buffer_bytes_
;
41 void QuicSentPacketManagerPeer::SetIsServer(
42 QuicSentPacketManager
* sent_packet_manager
,
44 sent_packet_manager
->is_server_
= is_server
;
48 const SendAlgorithmInterface
*
49 QuicSentPacketManagerPeer::GetSendAlgorithm(
50 const QuicSentPacketManager
& sent_packet_manager
) {
51 return sent_packet_manager
.send_algorithm_
.get();
55 void QuicSentPacketManagerPeer::SetSendAlgorithm(
56 QuicSentPacketManager
* sent_packet_manager
,
57 SendAlgorithmInterface
* send_algorithm
) {
58 sent_packet_manager
->send_algorithm_
.reset(send_algorithm
);
62 const LossDetectionInterface
* QuicSentPacketManagerPeer::GetLossAlgorithm(
63 QuicSentPacketManager
* sent_packet_manager
) {
64 return sent_packet_manager
->loss_algorithm_
.get();
68 void QuicSentPacketManagerPeer::SetLossAlgorithm(
69 QuicSentPacketManager
* sent_packet_manager
,
70 LossDetectionInterface
* loss_detector
) {
71 sent_packet_manager
->loss_algorithm_
.reset(loss_detector
);
75 RttStats
* QuicSentPacketManagerPeer::GetRttStats(
76 QuicSentPacketManager
* sent_packet_manager
) {
77 return &sent_packet_manager
->rtt_stats_
;
81 QuicPacketCount
QuicSentPacketManagerPeer::GetNackCount(
82 const QuicSentPacketManager
* sent_packet_manager
,
83 QuicPacketSequenceNumber sequence_number
) {
84 return sent_packet_manager
->unacked_packets_
.
85 GetTransmissionInfo(sequence_number
).nack_count
;
89 size_t QuicSentPacketManagerPeer::GetPendingRetransmissionCount(
90 const QuicSentPacketManager
* sent_packet_manager
) {
91 return sent_packet_manager
->pending_retransmissions_
.size();
95 bool QuicSentPacketManagerPeer::HasPendingPackets(
96 const QuicSentPacketManager
* sent_packet_manager
) {
97 return sent_packet_manager
->unacked_packets_
.HasInFlightPackets();
101 QuicTime
QuicSentPacketManagerPeer::GetSentTime(
102 const QuicSentPacketManager
* sent_packet_manager
,
103 QuicPacketSequenceNumber sequence_number
) {
104 DCHECK(sent_packet_manager
->unacked_packets_
.IsUnacked(sequence_number
));
106 return sent_packet_manager
->unacked_packets_
.GetTransmissionInfo(
107 sequence_number
).sent_time
;
111 bool QuicSentPacketManagerPeer::IsRetransmission(
112 QuicSentPacketManager
* sent_packet_manager
,
113 QuicPacketSequenceNumber sequence_number
) {
114 DCHECK(sent_packet_manager
->HasRetransmittableFrames(sequence_number
));
115 return sent_packet_manager
->HasRetransmittableFrames(sequence_number
) &&
116 sent_packet_manager
->unacked_packets_
.GetTransmissionInfo(
117 sequence_number
).all_transmissions
!= nullptr;
121 void QuicSentPacketManagerPeer::MarkForRetransmission(
122 QuicSentPacketManager
* sent_packet_manager
,
123 QuicPacketSequenceNumber sequence_number
,
124 TransmissionType transmission_type
) {
125 sent_packet_manager
->MarkForRetransmission(sequence_number
,
130 QuicTime::Delta
QuicSentPacketManagerPeer::GetRetransmissionDelay(
131 const QuicSentPacketManager
* sent_packet_manager
) {
132 return sent_packet_manager
->GetRetransmissionDelay();
136 bool QuicSentPacketManagerPeer::HasUnackedCryptoPackets(
137 const QuicSentPacketManager
* sent_packet_manager
) {
138 return sent_packet_manager
->unacked_packets_
.HasPendingCryptoPackets();
142 size_t QuicSentPacketManagerPeer::GetNumRetransmittablePackets(
143 const QuicSentPacketManager
* sent_packet_manager
) {
144 size_t num_unacked_packets
= 0;
145 for (QuicUnackedPacketMap::const_iterator it
=
146 sent_packet_manager
->unacked_packets_
.begin();
147 it
!= sent_packet_manager
->unacked_packets_
.end(); ++it
) {
148 if (it
->retransmittable_frames
!= nullptr) {
149 ++num_unacked_packets
;
152 return num_unacked_packets
;
156 QuicByteCount
QuicSentPacketManagerPeer::GetBytesInFlight(
157 const QuicSentPacketManager
* sent_packet_manager
) {
158 return sent_packet_manager
->unacked_packets_
.bytes_in_flight();
162 QuicSentPacketManager::NetworkChangeVisitor
*
163 QuicSentPacketManagerPeer::GetNetworkChangeVisitor(
164 const QuicSentPacketManager
* sent_packet_manager
) {
165 return sent_packet_manager
->network_change_visitor_
;
169 QuicSustainedBandwidthRecorder
& QuicSentPacketManagerPeer::GetBandwidthRecorder(
170 QuicSentPacketManager
* sent_packet_manager
) {
171 return sent_packet_manager
->sustained_bandwidth_recorder_
;