Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: net/quic/quic_sent_packet_manager_test.cc

Issue 1667003002: Replace QuicEncryptedPacket's fields with equivalents in SerializedPacket. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@113395732
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_protocol.cc ('k') | net/quic/quic_unacked_packet_map_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/quic_sent_packet_manager.h" 5 #include "net/quic/quic_sent_packet_manager.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "net/quic/quic_flags.h" 8 #include "net/quic/quic_flags.h"
9 #include "net/quic/test_tools/quic_config_peer.h" 9 #include "net/quic/test_tools/quic_config_peer.h"
10 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" 10 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 EXPECT_TRUE(QuicSentPacketManagerPeer::IsRetransmission(&manager_, 187 EXPECT_TRUE(QuicSentPacketManagerPeer::IsRetransmission(&manager_,
188 new_packet_number)); 188 new_packet_number));
189 } 189 }
190 190
191 SerializedPacket CreateDataPacket(QuicPacketNumber packet_number) { 191 SerializedPacket CreateDataPacket(QuicPacketNumber packet_number) {
192 return CreatePacket(packet_number, true); 192 return CreatePacket(packet_number, true);
193 } 193 }
194 194
195 SerializedPacket CreatePacket(QuicPacketNumber packet_number, 195 SerializedPacket CreatePacket(QuicPacketNumber packet_number,
196 bool retransmittable) { 196 bool retransmittable) {
197 packets_.push_back(new QuicEncryptedPacket(nullptr, kDefaultLength));
198 SerializedPacket packet(kDefaultPathId, packet_number, 197 SerializedPacket packet(kDefaultPathId, packet_number,
199 PACKET_6BYTE_PACKET_NUMBER, packets_.back(), 0u, 198 PACKET_6BYTE_PACKET_NUMBER, nullptr, kDefaultLength,
200 false, false); 199 0u, false, false);
201 if (retransmittable) { 200 if (retransmittable) {
202 packet.retransmittable_frames.push_back( 201 packet.retransmittable_frames.push_back(
203 QuicFrame(new QuicStreamFrame(kStreamId, false, 0, StringPiece()))); 202 QuicFrame(new QuicStreamFrame(kStreamId, false, 0, StringPiece())));
204 } 203 }
205 return packet; 204 return packet;
206 } 205 }
207 206
208 SerializedPacket CreateFecPacket(QuicPacketNumber packet_number) { 207 SerializedPacket CreateFecPacket(QuicPacketNumber packet_number) {
209 packets_.push_back(new QuicEncryptedPacket(nullptr, kDefaultLength));
210 SerializedPacket serialized(kDefaultPathId, packet_number, 208 SerializedPacket serialized(kDefaultPathId, packet_number,
211 PACKET_6BYTE_PACKET_NUMBER, packets_.back(), 0u, 209 PACKET_6BYTE_PACKET_NUMBER, nullptr,
212 false, false); 210 kDefaultLength, 0u, false, false);
213 serialized.is_fec_packet = true; 211 serialized.is_fec_packet = true;
214 return serialized; 212 return serialized;
215 } 213 }
216 214
217 void SendDataPacket(QuicPacketNumber packet_number) { 215 void SendDataPacket(QuicPacketNumber packet_number) {
218 EXPECT_CALL(*send_algorithm_, 216 EXPECT_CALL(*send_algorithm_,
219 OnPacketSent(_, BytesInFlight(), packet_number, _, _)) 217 OnPacketSent(_, BytesInFlight(), packet_number, _, _))
220 .Times(1) 218 .Times(1)
221 .WillOnce(Return(true)); 219 .WillOnce(Return(true));
222 SerializedPacket packet(CreateDataPacket(packet_number)); 220 SerializedPacket packet(CreateDataPacket(packet_number));
223 manager_.OnPacketSent(&packet, 0, clock_.Now(), packet.packet->length(), 221 manager_.OnPacketSent(&packet, 0, clock_.Now(), packet.encrypted_length,
224 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA); 222 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA);
225 } 223 }
226 224
227 void SendCryptoPacket(QuicPacketNumber packet_number) { 225 void SendCryptoPacket(QuicPacketNumber packet_number) {
228 EXPECT_CALL(*send_algorithm_, 226 EXPECT_CALL(*send_algorithm_,
229 OnPacketSent(_, BytesInFlight(), packet_number, kDefaultLength, 227 OnPacketSent(_, BytesInFlight(), packet_number, kDefaultLength,
230 HAS_RETRANSMITTABLE_DATA)) 228 HAS_RETRANSMITTABLE_DATA))
231 .Times(1) 229 .Times(1)
232 .WillOnce(Return(true)); 230 .WillOnce(Return(true));
233 SerializedPacket packet(CreateDataPacket(packet_number)); 231 SerializedPacket packet(CreateDataPacket(packet_number));
234 packet.retransmittable_frames.push_back( 232 packet.retransmittable_frames.push_back(
235 QuicFrame(new QuicStreamFrame(1, false, 0, StringPiece()))); 233 QuicFrame(new QuicStreamFrame(1, false, 0, StringPiece())));
236 packet.has_crypto_handshake = IS_HANDSHAKE; 234 packet.has_crypto_handshake = IS_HANDSHAKE;
237 manager_.OnPacketSent(&packet, 0, clock_.Now(), packet.packet->length(), 235 manager_.OnPacketSent(&packet, 0, clock_.Now(), packet.encrypted_length,
238 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA); 236 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA);
239 } 237 }
240 238
241 void SendFecPacket(QuicPacketNumber packet_number) { 239 void SendFecPacket(QuicPacketNumber packet_number) {
242 EXPECT_CALL(*send_algorithm_, 240 EXPECT_CALL(*send_algorithm_,
243 OnPacketSent(_, BytesInFlight(), packet_number, kDefaultLength, 241 OnPacketSent(_, BytesInFlight(), packet_number, kDefaultLength,
244 HAS_RETRANSMITTABLE_DATA)) 242 HAS_RETRANSMITTABLE_DATA))
245 .Times(1) 243 .Times(1)
246 .WillOnce(Return(true)); 244 .WillOnce(Return(true));
247 SerializedPacket packet(CreateFecPacket(packet_number)); 245 SerializedPacket packet(CreateFecPacket(packet_number));
248 manager_.OnPacketSent(&packet, 0, clock_.Now(), packet.packet->length(), 246 manager_.OnPacketSent(&packet, 0, clock_.Now(), packet.encrypted_length,
249 NOT_RETRANSMISSION, NO_RETRANSMITTABLE_DATA); 247 NOT_RETRANSMISSION, NO_RETRANSMITTABLE_DATA);
250 } 248 }
251 249
252 void SendAckPacket(QuicPacketNumber packet_number) { 250 void SendAckPacket(QuicPacketNumber packet_number) {
253 EXPECT_CALL(*send_algorithm_, 251 EXPECT_CALL(*send_algorithm_,
254 OnPacketSent(_, BytesInFlight(), packet_number, kDefaultLength, 252 OnPacketSent(_, BytesInFlight(), packet_number, kDefaultLength,
255 NO_RETRANSMITTABLE_DATA)) 253 NO_RETRANSMITTABLE_DATA))
256 .Times(1) 254 .Times(1)
257 .WillOnce(Return(false)); 255 .WillOnce(Return(false));
258 SerializedPacket packet(CreatePacket(packet_number, false)); 256 SerializedPacket packet(CreatePacket(packet_number, false));
259 manager_.OnPacketSent(&packet, 0, clock_.Now(), packet.packet->length(), 257 manager_.OnPacketSent(&packet, 0, clock_.Now(), packet.encrypted_length,
260 NOT_RETRANSMISSION, NO_RETRANSMITTABLE_DATA); 258 NOT_RETRANSMISSION, NO_RETRANSMITTABLE_DATA);
261 } 259 }
262 260
263 // Based on QuicConnection's WritePendingRetransmissions. 261 // Based on QuicConnection's WritePendingRetransmissions.
264 void RetransmitNextPacket(QuicPacketNumber retransmission_packet_number) { 262 void RetransmitNextPacket(QuicPacketNumber retransmission_packet_number) {
265 EXPECT_TRUE(manager_.HasPendingRetransmissions()); 263 EXPECT_TRUE(manager_.HasPendingRetransmissions());
266 EXPECT_CALL(*send_algorithm_, 264 EXPECT_CALL(*send_algorithm_,
267 OnPacketSent(_, _, retransmission_packet_number, kDefaultLength, 265 OnPacketSent(_, _, retransmission_packet_number, kDefaultLength,
268 HAS_RETRANSMITTABLE_DATA)) 266 HAS_RETRANSMITTABLE_DATA))
269 .Times(1) 267 .Times(1)
(...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 1693
1696 EXPECT_CALL(*send_algorithm_, ResumeConnectionState(_, false)); 1694 EXPECT_CALL(*send_algorithm_, ResumeConnectionState(_, false));
1697 manager_.ResumeConnectionState(cached_network_params, false); 1695 manager_.ResumeConnectionState(cached_network_params, false);
1698 EXPECT_EQ(kRttMs * kNumMicrosPerMilli, 1696 EXPECT_EQ(kRttMs * kNumMicrosPerMilli,
1699 static_cast<uint64_t>(manager_.GetRttStats()->initial_rtt_us())); 1697 static_cast<uint64_t>(manager_.GetRttStats()->initial_rtt_us()));
1700 } 1698 }
1701 1699
1702 } // namespace 1700 } // namespace
1703 } // namespace test 1701 } // namespace test
1704 } // namespace net 1702 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_protocol.cc ('k') | net/quic/quic_unacked_packet_map_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698