Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / net / quic / test_tools / quic_connection_peer.cc
blobdf7d9e78e2715f5f76f31dd4cb14789b3d652699
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.
5 #include "net/quic/test_tools/quic_connection_peer.h"
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"
16 namespace net {
17 namespace test {
19 // static
20 void QuicConnectionPeer::SendAck(QuicConnection* connection) {
21 connection->SendAck();
24 // static
25 void QuicConnectionPeer::SetSendAlgorithm(
26 QuicConnection* connection,
27 SendAlgorithmInterface* send_algorithm) {
28 connection->sent_packet_manager_.send_algorithm_.reset(send_algorithm);
31 // static
32 void QuicConnectionPeer::PopulateAckFrame(QuicConnection* connection,
33 QuicAckFrame* ack) {
34 connection->PopulateAckFrame(ack);
37 // static
38 void QuicConnectionPeer::PopulateStopWaitingFrame(
39 QuicConnection* connection,
40 QuicStopWaitingFrame* stop_waiting) {
41 connection->PopulateStopWaitingFrame(stop_waiting);
44 // static
45 QuicConnectionVisitorInterface* QuicConnectionPeer::GetVisitor(
46 QuicConnection* connection) {
47 return connection->visitor_;
50 // static
51 QuicPacketCreator* QuicConnectionPeer::GetPacketCreator(
52 QuicConnection* connection) {
53 return QuicPacketGeneratorPeer::GetPacketCreator(
54 &connection->packet_generator_);
57 // static
58 QuicPacketGenerator* QuicConnectionPeer::GetPacketGenerator(
59 QuicConnection* connection) {
60 return &connection->packet_generator_;
63 // static
64 QuicSentPacketManager* QuicConnectionPeer::GetSentPacketManager(
65 QuicConnection* connection) {
66 return &connection->sent_packet_manager_;
69 // static
70 QuicTime::Delta QuicConnectionPeer::GetNetworkTimeout(
71 QuicConnection* connection) {
72 return connection->idle_network_timeout_;
75 // static
76 // TODO(ianswett): Create a GetSentEntropyHash which accepts an AckFrame.
77 QuicPacketEntropyHash QuicConnectionPeer::GetSentEntropyHash(
78 QuicConnection* connection,
79 QuicPacketSequenceNumber sequence_number) {
80 QuicSentEntropyManager::CumulativeEntropy last_entropy_copy =
81 connection->sent_entropy_manager_.last_cumulative_entropy_;
82 connection->sent_entropy_manager_.UpdateCumulativeEntropy(sequence_number,
83 &last_entropy_copy);
84 return last_entropy_copy.entropy;
87 // static
88 QuicPacketEntropyHash QuicConnectionPeer::PacketEntropy(
89 QuicConnection* connection,
90 QuicPacketSequenceNumber sequence_number) {
91 return connection->sent_entropy_manager_.GetPacketEntropy(sequence_number);
94 // static
95 QuicPacketEntropyHash QuicConnectionPeer::ReceivedEntropyHash(
96 QuicConnection* connection,
97 QuicPacketSequenceNumber sequence_number) {
98 return connection->received_packet_manager_.EntropyHash(
99 sequence_number);
102 // static
103 void QuicConnectionPeer::SetPerspective(QuicConnection* connection,
104 Perspective perspective) {
105 connection->perspective_ = perspective;
106 QuicFramerPeer::SetPerspective(&connection->framer_, perspective);
109 // static
110 void QuicConnectionPeer::SetSelfAddress(QuicConnection* connection,
111 const IPEndPoint& self_address) {
112 connection->self_address_ = self_address;
115 // static
116 void QuicConnectionPeer::SetPeerAddress(QuicConnection* connection,
117 const IPEndPoint& peer_address) {
118 connection->peer_address_ = peer_address;
121 // static
122 bool QuicConnectionPeer::IsSilentCloseEnabled(QuicConnection* connection) {
123 return connection->silent_close_enabled_;
126 // static
127 void QuicConnectionPeer::SwapCrypters(QuicConnection* connection,
128 QuicFramer* framer) {
129 QuicFramerPeer::SwapCrypters(framer, &connection->framer_);
132 // static
133 QuicConnectionHelperInterface* QuicConnectionPeer::GetHelper(
134 QuicConnection* connection) {
135 return connection->helper_;
138 // static
139 QuicFramer* QuicConnectionPeer::GetFramer(QuicConnection* connection) {
140 return &connection->framer_;
143 // static
144 QuicFecGroup* QuicConnectionPeer::GetFecGroup(QuicConnection* connection,
145 int fec_group) {
146 connection->last_header_.fec_group = fec_group;
147 return connection->GetFecGroup();
150 // static
151 QuicAlarm* QuicConnectionPeer::GetAckAlarm(QuicConnection* connection) {
152 return connection->ack_alarm_.get();
155 // static
156 QuicAlarm* QuicConnectionPeer::GetPingAlarm(QuicConnection* connection) {
157 return connection->ping_alarm_.get();
160 // static
161 QuicAlarm* QuicConnectionPeer::GetFecAlarm(QuicConnection* connection) {
162 return connection->fec_alarm_.get();
165 // static
166 QuicAlarm* QuicConnectionPeer::GetResumeWritesAlarm(
167 QuicConnection* connection) {
168 return connection->resume_writes_alarm_.get();
171 // static
172 QuicAlarm* QuicConnectionPeer::GetRetransmissionAlarm(
173 QuicConnection* connection) {
174 return connection->retransmission_alarm_.get();
177 // static
178 QuicAlarm* QuicConnectionPeer::GetSendAlarm(QuicConnection* connection) {
179 return connection->send_alarm_.get();
182 // static
183 QuicAlarm* QuicConnectionPeer::GetTimeoutAlarm(QuicConnection* connection) {
184 return connection->timeout_alarm_.get();
187 // static
188 QuicAlarm* QuicConnectionPeer::GetMtuDiscoveryAlarm(
189 QuicConnection* connection) {
190 return connection->mtu_discovery_alarm_.get();
193 // static
194 QuicPacketWriter* QuicConnectionPeer::GetWriter(QuicConnection* connection) {
195 return connection->writer_;
198 // static
199 void QuicConnectionPeer::SetWriter(QuicConnection* connection,
200 QuicPacketWriter* writer,
201 bool owns_writer) {
202 if (connection->owns_writer_) {
203 delete connection->writer_;
205 connection->writer_ = writer;
206 connection->owns_writer_ = owns_writer;
209 // static
210 void QuicConnectionPeer::CloseConnection(QuicConnection* connection) {
211 connection->connected_ = false;
214 // static
215 QuicEncryptedPacket* QuicConnectionPeer::GetConnectionClosePacket(
216 QuicConnection* connection) {
217 return connection->connection_close_packet_.get();
220 // static
221 QuicPacketHeader* QuicConnectionPeer::GetLastHeader(
222 QuicConnection* connection) {
223 return &connection->last_header_;
226 // static
227 void QuicConnectionPeer::SetSequenceNumberOfLastSentPacket(
228 QuicConnection* connection, QuicPacketSequenceNumber number) {
229 connection->sequence_number_of_last_sent_packet_ = number;
232 // static
233 QuicConnectionStats* QuicConnectionPeer::GetStats(QuicConnection* connection) {
234 return &connection->stats_;
237 } // namespace test
238 } // namespace net