MacViews: Get c/b/ui/views/tabs to build on Mac
[chromium-blink-merge.git] / net / quic / test_tools / quic_sent_packet_manager_peer.cc
blobbebd5545170add9f54c2e6e4cc7f681acc2fa765
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 void QuicSentPacketManagerPeer::SetMaxTailLossProbes(
18 QuicSentPacketManager* sent_packet_manager, size_t max_tail_loss_probes) {
19 sent_packet_manager->max_tail_loss_probes_ = max_tail_loss_probes;
22 // static
23 void QuicSentPacketManagerPeer::SetSendAlgorithm(
24 QuicSentPacketManager* sent_packet_manager,
25 SendAlgorithmInterface* send_algorithm) {
26 sent_packet_manager->send_algorithm_.reset(send_algorithm);
29 // static
30 void QuicSentPacketManagerPeer::SetIsServer(
31 QuicSentPacketManager* sent_packet_manager,
32 bool is_server) {
33 sent_packet_manager->is_server_ = is_server;
36 // static
37 const LossDetectionInterface* QuicSentPacketManagerPeer::GetLossAlgorithm(
38 QuicSentPacketManager* sent_packet_manager) {
39 return sent_packet_manager->loss_algorithm_.get();
42 // static
43 const SendAlgorithmInterface*
44 QuicSentPacketManagerPeer::GetCongestionControlAlgorithm(
45 const QuicSentPacketManager& sent_packet_manager) {
46 return sent_packet_manager.send_algorithm_.get();
49 // static
50 void QuicSentPacketManagerPeer::SetLossAlgorithm(
51 QuicSentPacketManager* sent_packet_manager,
52 LossDetectionInterface* loss_detector) {
53 sent_packet_manager->loss_algorithm_.reset(loss_detector);
56 // static
57 RttStats* QuicSentPacketManagerPeer::GetRttStats(
58 QuicSentPacketManager* sent_packet_manager) {
59 return &sent_packet_manager->rtt_stats_;
62 // static
63 size_t QuicSentPacketManagerPeer::GetNackCount(
64 const QuicSentPacketManager* sent_packet_manager,
65 QuicPacketSequenceNumber sequence_number) {
66 return sent_packet_manager->unacked_packets_.
67 GetTransmissionInfo(sequence_number).nack_count;
70 // static
71 size_t QuicSentPacketManagerPeer::GetPendingRetransmissionCount(
72 const QuicSentPacketManager* sent_packet_manager) {
73 return sent_packet_manager->pending_retransmissions_.size();
76 // static
77 bool QuicSentPacketManagerPeer::HasPendingPackets(
78 const QuicSentPacketManager* sent_packet_manager) {
79 return sent_packet_manager->unacked_packets_.HasInFlightPackets();
82 // static
83 QuicTime QuicSentPacketManagerPeer::GetSentTime(
84 const QuicSentPacketManager* sent_packet_manager,
85 QuicPacketSequenceNumber sequence_number) {
86 DCHECK(sent_packet_manager->unacked_packets_.IsUnacked(sequence_number));
88 return sent_packet_manager->unacked_packets_.GetTransmissionInfo(
89 sequence_number).sent_time;
92 // static
93 bool QuicSentPacketManagerPeer::IsRetransmission(
94 QuicSentPacketManager* sent_packet_manager,
95 QuicPacketSequenceNumber sequence_number) {
96 DCHECK(sent_packet_manager->HasRetransmittableFrames(sequence_number));
97 return sent_packet_manager->HasRetransmittableFrames(sequence_number) &&
98 sent_packet_manager->unacked_packets_.GetTransmissionInfo(
99 sequence_number).all_transmissions != nullptr;
102 // static
103 void QuicSentPacketManagerPeer::MarkForRetransmission(
104 QuicSentPacketManager* sent_packet_manager,
105 QuicPacketSequenceNumber sequence_number,
106 TransmissionType transmission_type) {
107 sent_packet_manager->MarkForRetransmission(sequence_number,
108 transmission_type);
111 // static
112 QuicTime::Delta QuicSentPacketManagerPeer::GetRetransmissionDelay(
113 const QuicSentPacketManager* sent_packet_manager) {
114 return sent_packet_manager->GetRetransmissionDelay();
117 // static
118 bool QuicSentPacketManagerPeer::HasUnackedCryptoPackets(
119 const QuicSentPacketManager* sent_packet_manager) {
120 return sent_packet_manager->unacked_packets_.HasPendingCryptoPackets();
123 // static
124 size_t QuicSentPacketManagerPeer::GetNumRetransmittablePackets(
125 const QuicSentPacketManager* sent_packet_manager) {
126 size_t num_unacked_packets = 0;
127 for (QuicUnackedPacketMap::const_iterator it =
128 sent_packet_manager->unacked_packets_.begin();
129 it != sent_packet_manager->unacked_packets_.end(); ++it) {
130 if (it->retransmittable_frames != nullptr) {
131 ++num_unacked_packets;
134 return num_unacked_packets;
137 // static
138 QuicByteCount QuicSentPacketManagerPeer::GetBytesInFlight(
139 const QuicSentPacketManager* sent_packet_manager) {
140 return sent_packet_manager->unacked_packets_.bytes_in_flight();
143 // static
144 QuicSentPacketManager::NetworkChangeVisitor*
145 QuicSentPacketManagerPeer::GetNetworkChangeVisitor(
146 const QuicSentPacketManager* sent_packet_manager) {
147 return sent_packet_manager->network_change_visitor_;
150 // static
151 QuicSustainedBandwidthRecorder& QuicSentPacketManagerPeer::GetBandwidthRecorder(
152 QuicSentPacketManager* sent_packet_manager) {
153 return sent_packet_manager->sustained_bandwidth_recorder_;
156 } // namespace test
157 } // namespace net