Rewrite AndroidSyncSettings to be significantly simpler.
[chromium-blink-merge.git] / net / quic / test_tools / quic_sent_packet_manager_peer.cc
blob4e182abfdbd49e8c1c82112f3302a839ea4397d7
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::GetUseNewRto(
30 QuicSentPacketManager* sent_packet_manager) {
31 return sent_packet_manager->use_new_rto_;
34 // static
35 QuicByteCount QuicSentPacketManagerPeer::GetReceiveWindow(
36 QuicSentPacketManager* sent_packet_manager) {
37 return sent_packet_manager->receive_buffer_bytes_;
40 // static
41 void QuicSentPacketManagerPeer::SetIsServer(
42 QuicSentPacketManager* sent_packet_manager,
43 bool is_server) {
44 sent_packet_manager->is_server_ = is_server;
47 // static
48 const SendAlgorithmInterface*
49 QuicSentPacketManagerPeer::GetSendAlgorithm(
50 const QuicSentPacketManager& sent_packet_manager) {
51 return sent_packet_manager.send_algorithm_.get();
54 // static
55 void QuicSentPacketManagerPeer::SetSendAlgorithm(
56 QuicSentPacketManager* sent_packet_manager,
57 SendAlgorithmInterface* send_algorithm) {
58 sent_packet_manager->send_algorithm_.reset(send_algorithm);
61 // static
62 const LossDetectionInterface* QuicSentPacketManagerPeer::GetLossAlgorithm(
63 QuicSentPacketManager* sent_packet_manager) {
64 return sent_packet_manager->loss_algorithm_.get();
67 // static
68 void QuicSentPacketManagerPeer::SetLossAlgorithm(
69 QuicSentPacketManager* sent_packet_manager,
70 LossDetectionInterface* loss_detector) {
71 sent_packet_manager->loss_algorithm_.reset(loss_detector);
74 // static
75 RttStats* QuicSentPacketManagerPeer::GetRttStats(
76 QuicSentPacketManager* sent_packet_manager) {
77 return &sent_packet_manager->rtt_stats_;
80 // static
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;
88 // static
89 size_t QuicSentPacketManagerPeer::GetPendingRetransmissionCount(
90 const QuicSentPacketManager* sent_packet_manager) {
91 return sent_packet_manager->pending_retransmissions_.size();
94 // static
95 bool QuicSentPacketManagerPeer::HasPendingPackets(
96 const QuicSentPacketManager* sent_packet_manager) {
97 return sent_packet_manager->unacked_packets_.HasInFlightPackets();
100 // static
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;
110 // static
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;
120 // static
121 void QuicSentPacketManagerPeer::MarkForRetransmission(
122 QuicSentPacketManager* sent_packet_manager,
123 QuicPacketSequenceNumber sequence_number,
124 TransmissionType transmission_type) {
125 sent_packet_manager->MarkForRetransmission(sequence_number,
126 transmission_type);
129 // static
130 QuicTime::Delta QuicSentPacketManagerPeer::GetRetransmissionDelay(
131 const QuicSentPacketManager* sent_packet_manager) {
132 return sent_packet_manager->GetRetransmissionDelay();
135 // static
136 bool QuicSentPacketManagerPeer::HasUnackedCryptoPackets(
137 const QuicSentPacketManager* sent_packet_manager) {
138 return sent_packet_manager->unacked_packets_.HasPendingCryptoPackets();
141 // static
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;
155 // static
156 QuicByteCount QuicSentPacketManagerPeer::GetBytesInFlight(
157 const QuicSentPacketManager* sent_packet_manager) {
158 return sent_packet_manager->unacked_packets_.bytes_in_flight();
161 // static
162 QuicSentPacketManager::NetworkChangeVisitor*
163 QuicSentPacketManagerPeer::GetNetworkChangeVisitor(
164 const QuicSentPacketManager* sent_packet_manager) {
165 return sent_packet_manager->network_change_visitor_;
168 // static
169 QuicSustainedBandwidthRecorder& QuicSentPacketManagerPeer::GetBandwidthRecorder(
170 QuicSentPacketManager* sent_packet_manager) {
171 return sent_packet_manager->sustained_bandwidth_recorder_;
174 } // namespace test
175 } // namespace net