Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / net / quic / test_tools / quic_sent_packet_manager_peer.cc
blob229f5287f4914c6071cc01a388ff20e50cfacd2b
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,
25 size_t max_tail_loss_probes) {
26 sent_packet_manager->max_tail_loss_probes_ = max_tail_loss_probes;
29 // static
30 bool QuicSentPacketManagerPeer::GetEnableHalfRttTailLossProbe(
31 QuicSentPacketManager* sent_packet_manager) {
32 return sent_packet_manager->enable_half_rtt_tail_loss_probe_;
35 // static
36 bool QuicSentPacketManagerPeer::GetUseNewRto(
37 QuicSentPacketManager* sent_packet_manager) {
38 return sent_packet_manager->use_new_rto_;
41 // static
42 QuicByteCount QuicSentPacketManagerPeer::GetReceiveWindow(
43 QuicSentPacketManager* sent_packet_manager) {
44 return sent_packet_manager->receive_buffer_bytes_;
47 // static
48 void QuicSentPacketManagerPeer::SetPerspective(
49 QuicSentPacketManager* sent_packet_manager,
50 Perspective perspective) {
51 sent_packet_manager->perspective_ = perspective;
54 // static
55 const SendAlgorithmInterface*
56 QuicSentPacketManagerPeer::GetSendAlgorithm(
57 const QuicSentPacketManager& sent_packet_manager) {
58 return sent_packet_manager.send_algorithm_.get();
61 // static
62 void QuicSentPacketManagerPeer::SetSendAlgorithm(
63 QuicSentPacketManager* sent_packet_manager,
64 SendAlgorithmInterface* send_algorithm) {
65 sent_packet_manager->send_algorithm_.reset(send_algorithm);
68 // static
69 const LossDetectionInterface* QuicSentPacketManagerPeer::GetLossAlgorithm(
70 QuicSentPacketManager* sent_packet_manager) {
71 return sent_packet_manager->loss_algorithm_.get();
74 // static
75 void QuicSentPacketManagerPeer::SetLossAlgorithm(
76 QuicSentPacketManager* sent_packet_manager,
77 LossDetectionInterface* loss_detector) {
78 sent_packet_manager->loss_algorithm_.reset(loss_detector);
81 // static
82 RttStats* QuicSentPacketManagerPeer::GetRttStats(
83 QuicSentPacketManager* sent_packet_manager) {
84 return &sent_packet_manager->rtt_stats_;
87 // static
88 bool QuicSentPacketManagerPeer::HasPendingPackets(
89 const QuicSentPacketManager* sent_packet_manager) {
90 return sent_packet_manager->unacked_packets_.HasInFlightPackets();
93 // static
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(
100 packet_number)
101 .sent_time;
104 // static
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(
111 packet_number)
112 .all_transmissions != nullptr;
115 // static
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);
123 // static
124 QuicTime::Delta QuicSentPacketManagerPeer::GetRetransmissionDelay(
125 const QuicSentPacketManager* sent_packet_manager) {
126 return sent_packet_manager->GetRetransmissionDelay();
129 // static
130 bool QuicSentPacketManagerPeer::HasUnackedCryptoPackets(
131 const QuicSentPacketManager* sent_packet_manager) {
132 return sent_packet_manager->unacked_packets_.HasPendingCryptoPackets();
135 // static
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;
149 // static
150 QuicByteCount QuicSentPacketManagerPeer::GetBytesInFlight(
151 const QuicSentPacketManager* sent_packet_manager) {
152 return sent_packet_manager->unacked_packets_.bytes_in_flight();
155 // static
156 QuicSentPacketManager::NetworkChangeVisitor*
157 QuicSentPacketManagerPeer::GetNetworkChangeVisitor(
158 const QuicSentPacketManager* sent_packet_manager) {
159 return sent_packet_manager->network_change_visitor_;
162 // static
163 QuicSustainedBandwidthRecorder& QuicSentPacketManagerPeer::GetBandwidthRecorder(
164 QuicSentPacketManager* sent_packet_manager) {
165 return sent_packet_manager->sustained_bandwidth_recorder_;
168 } // namespace test
169 } // namespace net