| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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. | |
| 4 | |
| 5 #include "net/quic/test_tools/quic_connection_peer.h" | |
| 6 | |
| 7 #include "base/stl_util.h" | |
| 8 #include "net/quic/congestion_control/send_algorithm_interface.h" | |
| 9 #include "net/quic/quic_connection.h" | |
| 10 #include "net/quic/quic_packet_writer.h" | |
| 11 #include "net/quic/quic_received_packet_manager.h" | |
| 12 #include "net/quic/test_tools/quic_framer_peer.h" | |
| 13 #include "net/quic/test_tools/quic_packet_generator_peer.h" | |
| 14 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" | |
| 15 | |
| 16 namespace net { | |
| 17 namespace test { | |
| 18 | |
| 19 // static | |
| 20 void QuicConnectionPeer::SendAck(QuicConnection* connection) { | |
| 21 connection->SendAck(); | |
| 22 } | |
| 23 | |
| 24 // static | |
| 25 void QuicConnectionPeer::SetSendAlgorithm( | |
| 26 QuicConnection* connection, | |
| 27 SendAlgorithmInterface* send_algorithm) { | |
| 28 connection->sent_packet_manager_.send_algorithm_.reset(send_algorithm); | |
| 29 } | |
| 30 | |
| 31 // static | |
| 32 void QuicConnectionPeer::PopulateAckFrame(QuicConnection* connection, | |
| 33 QuicAckFrame* ack) { | |
| 34 connection->PopulateAckFrame(ack); | |
| 35 } | |
| 36 | |
| 37 // static | |
| 38 void QuicConnectionPeer::PopulateStopWaitingFrame( | |
| 39 QuicConnection* connection, | |
| 40 QuicStopWaitingFrame* stop_waiting) { | |
| 41 connection->PopulateStopWaitingFrame(stop_waiting); | |
| 42 } | |
| 43 | |
| 44 // static | |
| 45 QuicConnectionVisitorInterface* QuicConnectionPeer::GetVisitor( | |
| 46 QuicConnection* connection) { | |
| 47 return connection->visitor_; | |
| 48 } | |
| 49 | |
| 50 // static | |
| 51 QuicPacketCreator* QuicConnectionPeer::GetPacketCreator( | |
| 52 QuicConnection* connection) { | |
| 53 return QuicPacketGeneratorPeer::GetPacketCreator( | |
| 54 &connection->packet_generator_); | |
| 55 } | |
| 56 | |
| 57 // static | |
| 58 QuicPacketGenerator* QuicConnectionPeer::GetPacketGenerator( | |
| 59 QuicConnection* connection) { | |
| 60 return &connection->packet_generator_; | |
| 61 } | |
| 62 | |
| 63 // static | |
| 64 QuicSentPacketManager* QuicConnectionPeer::GetSentPacketManager( | |
| 65 QuicConnection* connection) { | |
| 66 return &connection->sent_packet_manager_; | |
| 67 } | |
| 68 | |
| 69 // static | |
| 70 QuicReceivedPacketManager* QuicConnectionPeer::GetReceivedPacketManager( | |
| 71 QuicConnection* connection) { | |
| 72 return &connection->received_packet_manager_; | |
| 73 } | |
| 74 | |
| 75 // static | |
| 76 QuicTime::Delta QuicConnectionPeer::GetNetworkTimeout( | |
| 77 QuicConnection* connection) { | |
| 78 return connection->idle_network_timeout_; | |
| 79 } | |
| 80 | |
| 81 // static | |
| 82 bool QuicConnectionPeer::IsSavedForRetransmission( | |
| 83 QuicConnection* connection, | |
| 84 QuicPacketSequenceNumber sequence_number) { | |
| 85 return connection->sent_packet_manager_.IsUnacked(sequence_number) && | |
| 86 connection->sent_packet_manager_.HasRetransmittableFrames( | |
| 87 sequence_number); | |
| 88 } | |
| 89 | |
| 90 // static | |
| 91 bool QuicConnectionPeer::IsRetransmission( | |
| 92 QuicConnection* connection, | |
| 93 QuicPacketSequenceNumber sequence_number) { | |
| 94 return QuicSentPacketManagerPeer::IsRetransmission( | |
| 95 &connection->sent_packet_manager_, sequence_number); | |
| 96 } | |
| 97 | |
| 98 // static | |
| 99 // TODO(ianswett): Create a GetSentEntropyHash which accepts an AckFrame. | |
| 100 QuicPacketEntropyHash QuicConnectionPeer::GetSentEntropyHash( | |
| 101 QuicConnection* connection, | |
| 102 QuicPacketSequenceNumber sequence_number) { | |
| 103 QuicSentEntropyManager::CumulativeEntropy last_entropy_copy = | |
| 104 connection->sent_entropy_manager_.last_cumulative_entropy_; | |
| 105 connection->sent_entropy_manager_.UpdateCumulativeEntropy(sequence_number, | |
| 106 &last_entropy_copy); | |
| 107 return last_entropy_copy.entropy; | |
| 108 } | |
| 109 | |
| 110 // static | |
| 111 QuicPacketEntropyHash QuicConnectionPeer::PacketEntropy( | |
| 112 QuicConnection* connection, | |
| 113 QuicPacketSequenceNumber sequence_number) { | |
| 114 return connection->sent_entropy_manager_.GetPacketEntropy(sequence_number); | |
| 115 } | |
| 116 | |
| 117 // static | |
| 118 QuicPacketEntropyHash QuicConnectionPeer::ReceivedEntropyHash( | |
| 119 QuicConnection* connection, | |
| 120 QuicPacketSequenceNumber sequence_number) { | |
| 121 return connection->received_packet_manager_.EntropyHash( | |
| 122 sequence_number); | |
| 123 } | |
| 124 | |
| 125 // static | |
| 126 bool QuicConnectionPeer::IsServer(QuicConnection* connection) { | |
| 127 return connection->is_server_; | |
| 128 } | |
| 129 | |
| 130 // static | |
| 131 void QuicConnectionPeer::SetIsServer(QuicConnection* connection, | |
| 132 bool is_server) { | |
| 133 connection->is_server_ = is_server; | |
| 134 QuicFramerPeer::SetIsServer(&connection->framer_, is_server); | |
| 135 } | |
| 136 | |
| 137 // static | |
| 138 void QuicConnectionPeer::SetSelfAddress(QuicConnection* connection, | |
| 139 const IPEndPoint& self_address) { | |
| 140 connection->self_address_ = self_address; | |
| 141 } | |
| 142 | |
| 143 // static | |
| 144 void QuicConnectionPeer::SetPeerAddress(QuicConnection* connection, | |
| 145 const IPEndPoint& peer_address) { | |
| 146 connection->peer_address_ = peer_address; | |
| 147 } | |
| 148 | |
| 149 // static | |
| 150 bool QuicConnectionPeer::IsSilentCloseEnabled(QuicConnection* connection) { | |
| 151 return connection->silent_close_enabled_; | |
| 152 } | |
| 153 | |
| 154 // static | |
| 155 void QuicConnectionPeer::SwapCrypters(QuicConnection* connection, | |
| 156 QuicFramer* framer) { | |
| 157 QuicFramerPeer::SwapCrypters(framer, &connection->framer_); | |
| 158 } | |
| 159 | |
| 160 // static | |
| 161 QuicConnectionHelperInterface* QuicConnectionPeer::GetHelper( | |
| 162 QuicConnection* connection) { | |
| 163 return connection->helper_; | |
| 164 } | |
| 165 | |
| 166 // static | |
| 167 QuicFramer* QuicConnectionPeer::GetFramer(QuicConnection* connection) { | |
| 168 return &connection->framer_; | |
| 169 } | |
| 170 | |
| 171 // static | |
| 172 QuicFecGroup* QuicConnectionPeer::GetFecGroup(QuicConnection* connection, | |
| 173 int fec_group) { | |
| 174 connection->last_header_.fec_group = fec_group; | |
| 175 return connection->GetFecGroup(); | |
| 176 } | |
| 177 | |
| 178 // static | |
| 179 QuicAlarm* QuicConnectionPeer::GetAckAlarm(QuicConnection* connection) { | |
| 180 return connection->ack_alarm_.get(); | |
| 181 } | |
| 182 | |
| 183 // static | |
| 184 QuicAlarm* QuicConnectionPeer::GetPingAlarm(QuicConnection* connection) { | |
| 185 return connection->ping_alarm_.get(); | |
| 186 } | |
| 187 | |
| 188 // static | |
| 189 QuicAlarm* QuicConnectionPeer::GetFecAlarm(QuicConnection* connection) { | |
| 190 return connection->fec_alarm_.get(); | |
| 191 } | |
| 192 | |
| 193 // static | |
| 194 QuicAlarm* QuicConnectionPeer::GetResumeWritesAlarm( | |
| 195 QuicConnection* connection) { | |
| 196 return connection->resume_writes_alarm_.get(); | |
| 197 } | |
| 198 | |
| 199 // static | |
| 200 QuicAlarm* QuicConnectionPeer::GetRetransmissionAlarm( | |
| 201 QuicConnection* connection) { | |
| 202 return connection->retransmission_alarm_.get(); | |
| 203 } | |
| 204 | |
| 205 // static | |
| 206 QuicAlarm* QuicConnectionPeer::GetSendAlarm(QuicConnection* connection) { | |
| 207 return connection->send_alarm_.get(); | |
| 208 } | |
| 209 | |
| 210 // static | |
| 211 QuicAlarm* QuicConnectionPeer::GetTimeoutAlarm(QuicConnection* connection) { | |
| 212 return connection->timeout_alarm_.get(); | |
| 213 } | |
| 214 | |
| 215 // static | |
| 216 QuicPacketWriter* QuicConnectionPeer::GetWriter(QuicConnection* connection) { | |
| 217 return connection->writer_; | |
| 218 } | |
| 219 | |
| 220 // static | |
| 221 void QuicConnectionPeer::SetWriter(QuicConnection* connection, | |
| 222 QuicPacketWriter* writer, | |
| 223 bool owns_writer) { | |
| 224 if (connection->owns_writer_) { | |
| 225 delete connection->writer_; | |
| 226 } | |
| 227 connection->writer_ = writer; | |
| 228 connection->owns_writer_ = owns_writer; | |
| 229 } | |
| 230 | |
| 231 // static | |
| 232 void QuicConnectionPeer::CloseConnection(QuicConnection* connection) { | |
| 233 connection->connected_ = false; | |
| 234 } | |
| 235 | |
| 236 // static | |
| 237 QuicEncryptedPacket* QuicConnectionPeer::GetConnectionClosePacket( | |
| 238 QuicConnection* connection) { | |
| 239 return connection->connection_close_packet_.get(); | |
| 240 } | |
| 241 | |
| 242 // static | |
| 243 void QuicConnectionPeer::SetSupportedVersions(QuicConnection* connection, | |
| 244 QuicVersionVector versions) { | |
| 245 connection->framer_.SetSupportedVersions(versions); | |
| 246 } | |
| 247 | |
| 248 // static | |
| 249 QuicPacketHeader* QuicConnectionPeer::GetLastHeader( | |
| 250 QuicConnection* connection) { | |
| 251 return &connection->last_header_; | |
| 252 } | |
| 253 | |
| 254 // static | |
| 255 void QuicConnectionPeer::SetSequenceNumberOfLastSentPacket( | |
| 256 QuicConnection* connection, QuicPacketSequenceNumber number) { | |
| 257 connection->sequence_number_of_last_sent_packet_ = number; | |
| 258 } | |
| 259 | |
| 260 // static | |
| 261 QuicConnectionStats* QuicConnectionPeer::GetStats(QuicConnection* connection) { | |
| 262 return &connection->stats_; | |
| 263 } | |
| 264 | |
| 265 } // namespace test | |
| 266 } // namespace net | |
| OLD | NEW |