Delete unused downloads page asset.
[chromium-blink-merge.git] / net / quic / test_tools / quic_sent_packet_manager_peer.cc
blobbd30da3f817c7ad10a59830c834201b417095888
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"
13 namespace net {
14 namespace test {
16 // static
17 size_t QuicSentPacketManagerPeer::GetMaxTailLossProbes(
18 QuicSentPacketManager* sent_packet_manager) {
19 return sent_packet_manager->max_tail_loss_probes_;
22 // static
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;
28 // static
29 bool QuicSentPacketManagerPeer::GetEnableHalfRttTailLossProbe(
30 QuicSentPacketManager* sent_packet_manager) {
31 return sent_packet_manager->enable_half_rtt_tail_loss_probe_;
34 // static
35 bool QuicSentPacketManagerPeer::GetUseNewRto(
36 QuicSentPacketManager* sent_packet_manager) {
37 return sent_packet_manager->use_new_rto_;
40 // static
41 QuicByteCount QuicSentPacketManagerPeer::GetReceiveWindow(
42 QuicSentPacketManager* sent_packet_manager) {
43 return sent_packet_manager->receive_buffer_bytes_;
46 // static
47 void QuicSentPacketManagerPeer::SetPerspective(
48 QuicSentPacketManager* sent_packet_manager,
49 Perspective perspective) {
50 sent_packet_manager->perspective_ = perspective;
53 // static
54 const SendAlgorithmInterface*
55 QuicSentPacketManagerPeer::GetSendAlgorithm(
56 const QuicSentPacketManager& sent_packet_manager) {
57 return sent_packet_manager.send_algorithm_.get();
60 // static
61 void QuicSentPacketManagerPeer::SetSendAlgorithm(
62 QuicSentPacketManager* sent_packet_manager,
63 SendAlgorithmInterface* send_algorithm) {
64 sent_packet_manager->send_algorithm_.reset(send_algorithm);
67 // static
68 const LossDetectionInterface* QuicSentPacketManagerPeer::GetLossAlgorithm(
69 QuicSentPacketManager* sent_packet_manager) {
70 return sent_packet_manager->loss_algorithm_.get();
73 // static
74 void QuicSentPacketManagerPeer::SetLossAlgorithm(
75 QuicSentPacketManager* sent_packet_manager,
76 LossDetectionInterface* loss_detector) {
77 sent_packet_manager->loss_algorithm_.reset(loss_detector);
80 // static
81 RttStats* QuicSentPacketManagerPeer::GetRttStats(
82 QuicSentPacketManager* sent_packet_manager) {
83 return &sent_packet_manager->rtt_stats_;
86 // static
87 bool QuicSentPacketManagerPeer::HasPendingPackets(
88 const QuicSentPacketManager* sent_packet_manager) {
89 return sent_packet_manager->unacked_packets_.HasInFlightPackets();
92 // static
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(
99 packet_number)
100 .sent_time;
103 // static
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(
110 packet_number)
111 .all_transmissions != nullptr;
114 // static
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);
122 // static
123 QuicTime::Delta QuicSentPacketManagerPeer::GetRetransmissionDelay(
124 const QuicSentPacketManager* sent_packet_manager) {
125 return sent_packet_manager->GetRetransmissionDelay();
128 // static
129 bool QuicSentPacketManagerPeer::HasUnackedCryptoPackets(
130 const QuicSentPacketManager* sent_packet_manager) {
131 return sent_packet_manager->unacked_packets_.HasPendingCryptoPackets();
134 // static
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;
148 // static
149 QuicByteCount QuicSentPacketManagerPeer::GetBytesInFlight(
150 const QuicSentPacketManager* sent_packet_manager) {
151 return sent_packet_manager->unacked_packets_.bytes_in_flight();
154 // static
155 QuicSentPacketManager::NetworkChangeVisitor*
156 QuicSentPacketManagerPeer::GetNetworkChangeVisitor(
157 const QuicSentPacketManager* sent_packet_manager) {
158 return sent_packet_manager->network_change_visitor_;
161 // static
162 QuicSustainedBandwidthRecorder& QuicSentPacketManagerPeer::GetBandwidthRecorder(
163 QuicSentPacketManager* sent_packet_manager) {
164 return sent_packet_manager->sustained_bandwidth_recorder_;
167 } // namespace test
168 } // namespace net