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

Side by Side Diff: net/tools/quic/quic_time_wait_list_manager_test.cc

Issue 1901173003: Cleanup: Migrate references from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@119568788
Patch Set: Created 4 years, 8 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/tools/quic/quic_simple_server_session_test.cc ('k') | no next file » | 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/tools/quic/quic_time_wait_list_manager.h" 5 #include "net/tools/quic/quic_time_wait_list_manager.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <memory>
8 9
9 #include "net/quic/crypto/crypto_protocol.h" 10 #include "net/quic/crypto/crypto_protocol.h"
10 #include "net/quic/crypto/null_encrypter.h" 11 #include "net/quic/crypto/null_encrypter.h"
11 #include "net/quic/crypto/quic_decrypter.h" 12 #include "net/quic/crypto/quic_decrypter.h"
12 #include "net/quic/crypto/quic_encrypter.h" 13 #include "net/quic/crypto/quic_encrypter.h"
13 #include "net/quic/quic_chromium_alarm_factory.h" 14 #include "net/quic/quic_chromium_alarm_factory.h"
14 #include "net/quic/quic_chromium_connection_helper.h" 15 #include "net/quic/quic_chromium_connection_helper.h"
15 #include "net/quic/quic_data_reader.h" 16 #include "net/quic/quic_data_reader.h"
16 #include "net/quic/quic_flags.h" 17 #include "net/quic/quic_flags.h"
17 #include "net/quic/quic_framer.h" 18 #include "net/quic/quic_framer.h"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 217
217 TEST_F(QuicTimeWaitListManagerTest, CheckStatelessConnectionIdInTimeWait) { 218 TEST_F(QuicTimeWaitListManagerTest, CheckStatelessConnectionIdInTimeWait) {
218 EXPECT_FALSE(IsConnectionIdInTimeWait(connection_id_)); 219 EXPECT_FALSE(IsConnectionIdInTimeWait(connection_id_));
219 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id_)); 220 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id_));
220 AddStatelessConnectionId(connection_id_); 221 AddStatelessConnectionId(connection_id_);
221 EXPECT_EQ(1u, time_wait_list_manager_.num_connections()); 222 EXPECT_EQ(1u, time_wait_list_manager_.num_connections());
222 EXPECT_TRUE(IsConnectionIdInTimeWait(connection_id_)); 223 EXPECT_TRUE(IsConnectionIdInTimeWait(connection_id_));
223 } 224 }
224 225
225 TEST_F(QuicTimeWaitListManagerTest, SendVersionNegotiationPacket) { 226 TEST_F(QuicTimeWaitListManagerTest, SendVersionNegotiationPacket) {
226 scoped_ptr<QuicEncryptedPacket> packet( 227 std::unique_ptr<QuicEncryptedPacket> packet(
227 QuicFramer::BuildVersionNegotiationPacket(connection_id_, 228 QuicFramer::BuildVersionNegotiationPacket(connection_id_,
228 QuicSupportedVersions())); 229 QuicSupportedVersions()));
229 EXPECT_CALL(writer_, 230 EXPECT_CALL(writer_,
230 WritePacket(_, packet->length(), server_address_.address(), 231 WritePacket(_, packet->length(), server_address_.address(),
231 client_address_, _)) 232 client_address_, _))
232 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 1))); 233 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 1)));
233 234
234 time_wait_list_manager_.SendVersionNegotiationPacket( 235 time_wait_list_manager_.SendVersionNegotiationPacket(
235 connection_id_, QuicSupportedVersions(), server_address_, 236 connection_id_, QuicSupportedVersions(), server_address_,
236 client_address_); 237 client_address_);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 } 372 }
372 EXPECT_EQ(kConnectionIdCount - kOldConnectionIdCount, 373 EXPECT_EQ(kConnectionIdCount - kOldConnectionIdCount,
373 time_wait_list_manager_.num_connections()); 374 time_wait_list_manager_.num_connections());
374 } 375 }
375 376
376 TEST_F(QuicTimeWaitListManagerTest, SendQueuedPackets) { 377 TEST_F(QuicTimeWaitListManagerTest, SendQueuedPackets) {
377 QuicConnectionId connection_id = 1; 378 QuicConnectionId connection_id = 1;
378 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id)); 379 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id));
379 AddConnectionId(connection_id); 380 AddConnectionId(connection_id);
380 QuicPacketNumber packet_number = 234; 381 QuicPacketNumber packet_number = 234;
381 scoped_ptr<QuicEncryptedPacket> packet( 382 std::unique_ptr<QuicEncryptedPacket> packet(
382 ConstructEncryptedPacket(connection_id, packet_number)); 383 ConstructEncryptedPacket(connection_id, packet_number));
383 // Let first write through. 384 // Let first write through.
384 EXPECT_CALL(writer_, 385 EXPECT_CALL(writer_,
385 WritePacket(_, _, server_address_.address(), client_address_, _)) 386 WritePacket(_, _, server_address_.address(), client_address_, _))
386 .With(Args<0, 1>(PublicResetPacketEq(connection_id, 0))) 387 .With(Args<0, 1>(PublicResetPacketEq(connection_id, 0)))
387 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, packet->length()))); 388 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, packet->length())));
388 ProcessPacket(connection_id, packet_number); 389 ProcessPacket(connection_id, packet_number);
389 390
390 // write block for the next packet. 391 // write block for the next packet.
391 EXPECT_CALL(writer_, 392 EXPECT_CALL(writer_,
392 WritePacket(_, _, server_address_.address(), client_address_, _)) 393 WritePacket(_, _, server_address_.address(), client_address_, _))
393 .With(Args<0, 1>(PublicResetPacketEq(connection_id, 0))) 394 .With(Args<0, 1>(PublicResetPacketEq(connection_id, 0)))
394 .WillOnce(DoAll(Assign(&writer_is_blocked_, true), 395 .WillOnce(DoAll(Assign(&writer_is_blocked_, true),
395 Return(WriteResult(WRITE_STATUS_BLOCKED, EAGAIN)))); 396 Return(WriteResult(WRITE_STATUS_BLOCKED, EAGAIN))));
396 EXPECT_CALL(visitor_, OnWriteBlocked(&time_wait_list_manager_)); 397 EXPECT_CALL(visitor_, OnWriteBlocked(&time_wait_list_manager_));
397 ProcessPacket(connection_id, packet_number); 398 ProcessPacket(connection_id, packet_number);
398 // 3rd packet. No public reset should be sent; 399 // 3rd packet. No public reset should be sent;
399 ProcessPacket(connection_id, packet_number); 400 ProcessPacket(connection_id, packet_number);
400 401
401 // write packet should not be called since we are write blocked but the 402 // write packet should not be called since we are write blocked but the
402 // should be queued. 403 // should be queued.
403 QuicConnectionId other_connection_id = 2; 404 QuicConnectionId other_connection_id = 2;
404 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(other_connection_id)); 405 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(other_connection_id));
405 AddConnectionId(other_connection_id); 406 AddConnectionId(other_connection_id);
406 QuicPacketNumber other_packet_number = 23423; 407 QuicPacketNumber other_packet_number = 23423;
407 scoped_ptr<QuicEncryptedPacket> other_packet( 408 std::unique_ptr<QuicEncryptedPacket> other_packet(
408 ConstructEncryptedPacket(other_connection_id, other_packet_number)); 409 ConstructEncryptedPacket(other_connection_id, other_packet_number));
409 EXPECT_CALL(writer_, WritePacket(_, _, _, _, _)).Times(0); 410 EXPECT_CALL(writer_, WritePacket(_, _, _, _, _)).Times(0);
410 EXPECT_CALL(visitor_, OnWriteBlocked(&time_wait_list_manager_)); 411 EXPECT_CALL(visitor_, OnWriteBlocked(&time_wait_list_manager_));
411 ProcessPacket(other_connection_id, other_packet_number); 412 ProcessPacket(other_connection_id, other_packet_number);
412 EXPECT_EQ(2u, time_wait_list_manager_.num_connections()); 413 EXPECT_EQ(2u, time_wait_list_manager_.num_connections());
413 414
414 // Now expect all the write blocked public reset packets to be sent again. 415 // Now expect all the write blocked public reset packets to be sent again.
415 writer_is_blocked_ = false; 416 writer_is_blocked_ = false;
416 EXPECT_CALL(writer_, 417 EXPECT_CALL(writer_,
417 WritePacket(_, _, server_address_.address(), client_address_, _)) 418 WritePacket(_, _, server_address_.address(), client_address_, _))
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 EXPECT_EQ(static_cast<size_t>(FLAGS_quic_time_wait_list_max_connections), 556 EXPECT_EQ(static_cast<size_t>(FLAGS_quic_time_wait_list_max_connections),
556 time_wait_list_manager_.num_connections()); 557 time_wait_list_manager_.num_connections());
557 EXPECT_FALSE(IsConnectionIdInTimeWait(id_to_evict)); 558 EXPECT_FALSE(IsConnectionIdInTimeWait(id_to_evict));
558 EXPECT_TRUE(IsConnectionIdInTimeWait(current_connection_id)); 559 EXPECT_TRUE(IsConnectionIdInTimeWait(current_connection_id));
559 } 560 }
560 } 561 }
561 562
562 } // namespace 563 } // namespace
563 } // namespace test 564 } // namespace test
564 } // namespace net 565 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_simple_server_session_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698