We started redesigning GpuMemoryBuffer interface to handle multiple buffers [0].
[chromium-blink-merge.git] / net / quic / test_tools / quic_sent_packet_manager_peer.cc
blobadd97bb9ddadeda997e31dcb2410ce4bd22caf4f
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::SetPerspective(
42 QuicSentPacketManager* sent_packet_manager,
43 Perspective perspective) {
44 sent_packet_manager->perspective_ = perspective;
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 bool QuicSentPacketManagerPeer::HasPendingPackets(
82 const QuicSentPacketManager* sent_packet_manager) {
83 return sent_packet_manager->unacked_packets_.HasInFlightPackets();
86 // static
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;
96 // static
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;
106 // static
107 void QuicSentPacketManagerPeer::MarkForRetransmission(
108 QuicSentPacketManager* sent_packet_manager,
109 QuicPacketSequenceNumber sequence_number,
110 TransmissionType transmission_type) {
111 sent_packet_manager->MarkForRetransmission(sequence_number,
112 transmission_type);
115 // static
116 QuicTime::Delta QuicSentPacketManagerPeer::GetRetransmissionDelay(
117 const QuicSentPacketManager* sent_packet_manager) {
118 return sent_packet_manager->GetRetransmissionDelay();
121 // static
122 bool QuicSentPacketManagerPeer::HasUnackedCryptoPackets(
123 const QuicSentPacketManager* sent_packet_manager) {
124 return sent_packet_manager->unacked_packets_.HasPendingCryptoPackets();
127 // static
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;
141 // static
142 QuicByteCount QuicSentPacketManagerPeer::GetBytesInFlight(
143 const QuicSentPacketManager* sent_packet_manager) {
144 return sent_packet_manager->unacked_packets_.bytes_in_flight();
147 // static
148 QuicSentPacketManager::NetworkChangeVisitor*
149 QuicSentPacketManagerPeer::GetNetworkChangeVisitor(
150 const QuicSentPacketManager* sent_packet_manager) {
151 return sent_packet_manager->network_change_visitor_;
154 // static
155 QuicSustainedBandwidthRecorder& QuicSentPacketManagerPeer::GetBandwidthRecorder(
156 QuicSentPacketManager* sent_packet_manager) {
157 return sent_packet_manager->sustained_bandwidth_recorder_;
160 } // namespace test
161 } // namespace net