| OLD | NEW |
| 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 | 8 |
| 9 #include "net/quic/crypto/crypto_protocol.h" | 9 #include "net/quic/crypto/crypto_protocol.h" |
| 10 #include "net/quic/crypto/null_encrypter.h" | 10 #include "net/quic/crypto/null_encrypter.h" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 212 |
| 213 TEST_F(QuicTimeWaitListManagerTest, CheckStatelessConnectionIdInTimeWait) { | 213 TEST_F(QuicTimeWaitListManagerTest, CheckStatelessConnectionIdInTimeWait) { |
| 214 EXPECT_FALSE(IsConnectionIdInTimeWait(connection_id_)); | 214 EXPECT_FALSE(IsConnectionIdInTimeWait(connection_id_)); |
| 215 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id_)); | 215 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id_)); |
| 216 AddStatelessConnectionId(connection_id_); | 216 AddStatelessConnectionId(connection_id_); |
| 217 EXPECT_EQ(1u, time_wait_list_manager_.num_connections()); | 217 EXPECT_EQ(1u, time_wait_list_manager_.num_connections()); |
| 218 EXPECT_TRUE(IsConnectionIdInTimeWait(connection_id_)); | 218 EXPECT_TRUE(IsConnectionIdInTimeWait(connection_id_)); |
| 219 } | 219 } |
| 220 | 220 |
| 221 TEST_F(QuicTimeWaitListManagerTest, SendVersionNegotiationPacket) { | 221 TEST_F(QuicTimeWaitListManagerTest, SendVersionNegotiationPacket) { |
| 222 scoped_ptr<QuicEncryptedPacket> packet( | 222 std::unique_ptr<QuicEncryptedPacket> packet( |
| 223 QuicFramer::BuildVersionNegotiationPacket(connection_id_, | 223 QuicFramer::BuildVersionNegotiationPacket(connection_id_, |
| 224 QuicSupportedVersions())); | 224 QuicSupportedVersions())); |
| 225 EXPECT_CALL(writer_, | 225 EXPECT_CALL(writer_, |
| 226 WritePacket(_, packet->length(), server_address_.address(), | 226 WritePacket(_, packet->length(), server_address_.address(), |
| 227 client_address_, _)) | 227 client_address_, _)) |
| 228 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 1))); | 228 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 1))); |
| 229 | 229 |
| 230 time_wait_list_manager_.SendVersionNegotiationPacket( | 230 time_wait_list_manager_.SendVersionNegotiationPacket( |
| 231 connection_id_, QuicSupportedVersions(), server_address_, | 231 connection_id_, QuicSupportedVersions(), server_address_, |
| 232 client_address_); | 232 client_address_); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 } | 367 } |
| 368 EXPECT_EQ(kConnectionIdCount - kOldConnectionIdCount, | 368 EXPECT_EQ(kConnectionIdCount - kOldConnectionIdCount, |
| 369 time_wait_list_manager_.num_connections()); | 369 time_wait_list_manager_.num_connections()); |
| 370 } | 370 } |
| 371 | 371 |
| 372 TEST_F(QuicTimeWaitListManagerTest, SendQueuedPackets) { | 372 TEST_F(QuicTimeWaitListManagerTest, SendQueuedPackets) { |
| 373 QuicConnectionId connection_id = 1; | 373 QuicConnectionId connection_id = 1; |
| 374 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id)); | 374 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id)); |
| 375 AddConnectionId(connection_id); | 375 AddConnectionId(connection_id); |
| 376 QuicPacketNumber packet_number = 234; | 376 QuicPacketNumber packet_number = 234; |
| 377 scoped_ptr<QuicEncryptedPacket> packet( | 377 std::unique_ptr<QuicEncryptedPacket> packet( |
| 378 ConstructEncryptedPacket(connection_id, packet_number)); | 378 ConstructEncryptedPacket(connection_id, packet_number)); |
| 379 // Let first write through. | 379 // Let first write through. |
| 380 EXPECT_CALL(writer_, | 380 EXPECT_CALL(writer_, |
| 381 WritePacket(_, _, server_address_.address(), client_address_, _)) | 381 WritePacket(_, _, server_address_.address(), client_address_, _)) |
| 382 .With(Args<0, 1>(PublicResetPacketEq(connection_id, 0))) | 382 .With(Args<0, 1>(PublicResetPacketEq(connection_id, 0))) |
| 383 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, packet->length()))); | 383 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, packet->length()))); |
| 384 ProcessPacket(connection_id, packet_number); | 384 ProcessPacket(connection_id, packet_number); |
| 385 | 385 |
| 386 // write block for the next packet. | 386 // write block for the next packet. |
| 387 EXPECT_CALL(writer_, | 387 EXPECT_CALL(writer_, |
| 388 WritePacket(_, _, server_address_.address(), client_address_, _)) | 388 WritePacket(_, _, server_address_.address(), client_address_, _)) |
| 389 .With(Args<0, 1>(PublicResetPacketEq(connection_id, 0))) | 389 .With(Args<0, 1>(PublicResetPacketEq(connection_id, 0))) |
| 390 .WillOnce(DoAll(Assign(&writer_is_blocked_, true), | 390 .WillOnce(DoAll(Assign(&writer_is_blocked_, true), |
| 391 Return(WriteResult(WRITE_STATUS_BLOCKED, EAGAIN)))); | 391 Return(WriteResult(WRITE_STATUS_BLOCKED, EAGAIN)))); |
| 392 EXPECT_CALL(visitor_, OnWriteBlocked(&time_wait_list_manager_)); | 392 EXPECT_CALL(visitor_, OnWriteBlocked(&time_wait_list_manager_)); |
| 393 ProcessPacket(connection_id, packet_number); | 393 ProcessPacket(connection_id, packet_number); |
| 394 // 3rd packet. No public reset should be sent; | 394 // 3rd packet. No public reset should be sent; |
| 395 ProcessPacket(connection_id, packet_number); | 395 ProcessPacket(connection_id, packet_number); |
| 396 | 396 |
| 397 // write packet should not be called since we are write blocked but the | 397 // write packet should not be called since we are write blocked but the |
| 398 // should be queued. | 398 // should be queued. |
| 399 QuicConnectionId other_connection_id = 2; | 399 QuicConnectionId other_connection_id = 2; |
| 400 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(other_connection_id)); | 400 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(other_connection_id)); |
| 401 AddConnectionId(other_connection_id); | 401 AddConnectionId(other_connection_id); |
| 402 QuicPacketNumber other_packet_number = 23423; | 402 QuicPacketNumber other_packet_number = 23423; |
| 403 scoped_ptr<QuicEncryptedPacket> other_packet( | 403 std::unique_ptr<QuicEncryptedPacket> other_packet( |
| 404 ConstructEncryptedPacket(other_connection_id, other_packet_number)); | 404 ConstructEncryptedPacket(other_connection_id, other_packet_number)); |
| 405 EXPECT_CALL(writer_, WritePacket(_, _, _, _, _)).Times(0); | 405 EXPECT_CALL(writer_, WritePacket(_, _, _, _, _)).Times(0); |
| 406 EXPECT_CALL(visitor_, OnWriteBlocked(&time_wait_list_manager_)); | 406 EXPECT_CALL(visitor_, OnWriteBlocked(&time_wait_list_manager_)); |
| 407 ProcessPacket(other_connection_id, other_packet_number); | 407 ProcessPacket(other_connection_id, other_packet_number); |
| 408 EXPECT_EQ(2u, time_wait_list_manager_.num_connections()); | 408 EXPECT_EQ(2u, time_wait_list_manager_.num_connections()); |
| 409 | 409 |
| 410 // Now expect all the write blocked public reset packets to be sent again. | 410 // Now expect all the write blocked public reset packets to be sent again. |
| 411 writer_is_blocked_ = false; | 411 writer_is_blocked_ = false; |
| 412 EXPECT_CALL(writer_, | 412 EXPECT_CALL(writer_, |
| 413 WritePacket(_, _, server_address_.address(), client_address_, _)) | 413 WritePacket(_, _, server_address_.address(), client_address_, _)) |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 EXPECT_EQ(static_cast<size_t>(FLAGS_quic_time_wait_list_max_connections), | 551 EXPECT_EQ(static_cast<size_t>(FLAGS_quic_time_wait_list_max_connections), |
| 552 time_wait_list_manager_.num_connections()); | 552 time_wait_list_manager_.num_connections()); |
| 553 EXPECT_FALSE(IsConnectionIdInTimeWait(id_to_evict)); | 553 EXPECT_FALSE(IsConnectionIdInTimeWait(id_to_evict)); |
| 554 EXPECT_TRUE(IsConnectionIdInTimeWait(current_connection_id)); | 554 EXPECT_TRUE(IsConnectionIdInTimeWait(current_connection_id)); |
| 555 } | 555 } |
| 556 } | 556 } |
| 557 | 557 |
| 558 } // namespace | 558 } // namespace |
| 559 } // namespace test | 559 } // namespace test |
| 560 } // namespace net | 560 } // namespace net |
| OLD | NEW |