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::SetPerspective(
42 QuicSentPacketManager
* sent_packet_manager
,
43 Perspective perspective
) {
44 sent_packet_manager
->perspective_
= perspective
;
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 bool QuicSentPacketManagerPeer::HasPendingPackets(
82 const QuicSentPacketManager
* sent_packet_manager
) {
83 return sent_packet_manager
->unacked_packets_
.HasInFlightPackets();
87 QuicTime
QuicSentPacketManagerPeer::GetSentTime(
88 const QuicSentPacketManager
* sent_packet_manager
,
89 QuicPacketSequenceNumber sequence_number
) {
90 DCHECK(sent_packet_manager
->unacked_packets_
.IsUnacked(sequence_number
));
92 return sent_packet_manager
->unacked_packets_
.GetTransmissionInfo(
93 sequence_number
).sent_time
;
97 bool QuicSentPacketManagerPeer::IsRetransmission(
98 QuicSentPacketManager
* sent_packet_manager
,
99 QuicPacketSequenceNumber sequence_number
) {
100 DCHECK(sent_packet_manager
->HasRetransmittableFrames(sequence_number
));
101 return sent_packet_manager
->HasRetransmittableFrames(sequence_number
) &&
102 sent_packet_manager
->unacked_packets_
.GetTransmissionInfo(
103 sequence_number
).all_transmissions
!= nullptr;
107 void QuicSentPacketManagerPeer::MarkForRetransmission(
108 QuicSentPacketManager
* sent_packet_manager
,
109 QuicPacketSequenceNumber sequence_number
,
110 TransmissionType transmission_type
) {
111 sent_packet_manager
->MarkForRetransmission(sequence_number
,
116 QuicTime::Delta
QuicSentPacketManagerPeer::GetRetransmissionDelay(
117 const QuicSentPacketManager
* sent_packet_manager
) {
118 return sent_packet_manager
->GetRetransmissionDelay();
122 bool QuicSentPacketManagerPeer::HasUnackedCryptoPackets(
123 const QuicSentPacketManager
* sent_packet_manager
) {
124 return sent_packet_manager
->unacked_packets_
.HasPendingCryptoPackets();
128 size_t QuicSentPacketManagerPeer::GetNumRetransmittablePackets(
129 const QuicSentPacketManager
* sent_packet_manager
) {
130 size_t num_unacked_packets
= 0;
131 for (QuicUnackedPacketMap::const_iterator it
=
132 sent_packet_manager
->unacked_packets_
.begin();
133 it
!= sent_packet_manager
->unacked_packets_
.end(); ++it
) {
134 if (it
->retransmittable_frames
!= nullptr) {
135 ++num_unacked_packets
;
138 return num_unacked_packets
;
142 QuicByteCount
QuicSentPacketManagerPeer::GetBytesInFlight(
143 const QuicSentPacketManager
* sent_packet_manager
) {
144 return sent_packet_manager
->unacked_packets_
.bytes_in_flight();
148 QuicSentPacketManager::NetworkChangeVisitor
*
149 QuicSentPacketManagerPeer::GetNetworkChangeVisitor(
150 const QuicSentPacketManager
* sent_packet_manager
) {
151 return sent_packet_manager
->network_change_visitor_
;
155 QuicSustainedBandwidthRecorder
& QuicSentPacketManagerPeer::GetBandwidthRecorder(
156 QuicSentPacketManager
* sent_packet_manager
) {
157 return sent_packet_manager
->sustained_bandwidth_recorder_
;