Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / net / quic / test_tools / quic_sent_packet_manager_peer.cc
blob94e46077addb69223de24ba4785e51d6a1f86849
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 const LossDetectionInterface* QuicSentPacketManagerPeer::GetLossAlgorithm(
31 QuicSentPacketManager* sent_packet_manager) {
32 return sent_packet_manager->loss_algorithm_.get();
35 // static
36 const SendAlgorithmInterface*
37 QuicSentPacketManagerPeer::GetCongestionControlAlgorithm(
38 const QuicSentPacketManager& sent_packet_manager) {
39 return sent_packet_manager.send_algorithm_.get();
42 // static
43 void QuicSentPacketManagerPeer::SetLossAlgorithm(
44 QuicSentPacketManager* sent_packet_manager,
45 LossDetectionInterface* loss_detector) {
46 sent_packet_manager->loss_algorithm_.reset(loss_detector);
49 // static
50 RttStats* QuicSentPacketManagerPeer::GetRttStats(
51 QuicSentPacketManager* sent_packet_manager) {
52 return &sent_packet_manager->rtt_stats_;
55 // static
56 size_t QuicSentPacketManagerPeer::GetNackCount(
57 const QuicSentPacketManager* sent_packet_manager,
58 QuicPacketSequenceNumber sequence_number) {
59 return sent_packet_manager->unacked_packets_.
60 GetTransmissionInfo(sequence_number).nack_count;
63 // static
64 size_t QuicSentPacketManagerPeer::GetPendingRetransmissionCount(
65 const QuicSentPacketManager* sent_packet_manager) {
66 return sent_packet_manager->pending_retransmissions_.size();
69 // static
70 bool QuicSentPacketManagerPeer::HasPendingPackets(
71 const QuicSentPacketManager* sent_packet_manager) {
72 return sent_packet_manager->unacked_packets_.HasInFlightPackets();
75 // static
76 QuicTime QuicSentPacketManagerPeer::GetSentTime(
77 const QuicSentPacketManager* sent_packet_manager,
78 QuicPacketSequenceNumber sequence_number) {
79 DCHECK(sent_packet_manager->unacked_packets_.IsUnacked(sequence_number));
81 return sent_packet_manager->unacked_packets_.GetTransmissionInfo(
82 sequence_number).sent_time;
85 // static
86 bool QuicSentPacketManagerPeer::IsRetransmission(
87 QuicSentPacketManager* sent_packet_manager,
88 QuicPacketSequenceNumber sequence_number) {
89 DCHECK(sent_packet_manager->HasRetransmittableFrames(sequence_number));
90 return sent_packet_manager->HasRetransmittableFrames(sequence_number) &&
91 sent_packet_manager->unacked_packets_.GetTransmissionInfo(
92 sequence_number).all_transmissions->size() > 1;
95 // static
96 void QuicSentPacketManagerPeer::MarkForRetransmission(
97 QuicSentPacketManager* sent_packet_manager,
98 QuicPacketSequenceNumber sequence_number,
99 TransmissionType transmission_type) {
100 sent_packet_manager->MarkForRetransmission(sequence_number,
101 transmission_type);
104 // static
105 QuicTime::Delta QuicSentPacketManagerPeer::GetRetransmissionDelay(
106 const QuicSentPacketManager* sent_packet_manager) {
107 return sent_packet_manager->GetRetransmissionDelay();
110 // static
111 bool QuicSentPacketManagerPeer::HasUnackedCryptoPackets(
112 const QuicSentPacketManager* sent_packet_manager) {
113 return sent_packet_manager->unacked_packets_.HasPendingCryptoPackets();
116 // static
117 size_t QuicSentPacketManagerPeer::GetNumRetransmittablePackets(
118 const QuicSentPacketManager* sent_packet_manager) {
119 size_t num_unacked_packets = 0;
120 for (QuicUnackedPacketMap::const_iterator it =
121 sent_packet_manager->unacked_packets_.begin();
122 it != sent_packet_manager->unacked_packets_.end(); ++it) {
123 if (it->second.retransmittable_frames != NULL) {
124 ++num_unacked_packets;
127 return num_unacked_packets;
130 // static
131 QuicByteCount QuicSentPacketManagerPeer::GetBytesInFlight(
132 const QuicSentPacketManager* sent_packet_manager) {
133 return sent_packet_manager->unacked_packets_.bytes_in_flight();
136 // static
137 QuicSentPacketManager::NetworkChangeVisitor*
138 QuicSentPacketManagerPeer::GetNetworkChangeVisitor(
139 const QuicSentPacketManager* sent_packet_manager) {
140 return sent_packet_manager->network_change_visitor_;
143 // static
144 QuicSustainedBandwidthRecorder& QuicSentPacketManagerPeer::GetBandwidthRecorder(
145 QuicSentPacketManager* sent_packet_manager) {
146 return sent_packet_manager->sustained_bandwidth_recorder_;
149 } // namespace test
150 } // namespace net