| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_dispatcher.h" | 5 #include "net/tools/quic/quic_dispatcher.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <ostream> | 8 #include <ostream> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1367 while (store->HasChlosBuffered()) { | 1367 while (store->HasChlosBuffered()) { |
| 1368 dispatcher_->ProcessBufferedChlos(kMaxNumSessionsToCreate); | 1368 dispatcher_->ProcessBufferedChlos(kMaxNumSessionsToCreate); |
| 1369 } | 1369 } |
| 1370 | 1370 |
| 1371 EXPECT_EQ(static_cast<size_t>(kMaxNumSessionsToCreate) + | 1371 EXPECT_EQ(static_cast<size_t>(kMaxNumSessionsToCreate) + |
| 1372 kDefaultMaxConnectionsInStore, | 1372 kDefaultMaxConnectionsInStore, |
| 1373 session1_->connection_id()); | 1373 session1_->connection_id()); |
| 1374 } | 1374 } |
| 1375 | 1375 |
| 1376 // Duplicated CHLO shouldn't be buffered. | 1376 // Duplicated CHLO shouldn't be buffered. |
| 1377 TEST_P(BufferedPacketStoreTest, DropDuplicatedCHLO) { | 1377 TEST_P(BufferedPacketStoreTest, BufferDuplicatedCHLO) { |
| 1378 FLAGS_quic_limit_num_new_sessions_per_epoll_loop = true; | 1378 FLAGS_quic_limit_num_new_sessions_per_epoll_loop = true; |
| 1379 for (QuicConnectionId conn_id = 1; conn_id <= kMaxNumSessionsToCreate + 1; | 1379 for (QuicConnectionId conn_id = 1; conn_id <= kMaxNumSessionsToCreate + 1; |
| 1380 ++conn_id) { | 1380 ++conn_id) { |
| 1381 // Last CHLO will be buffered. Others will create connection right away. | 1381 // Last CHLO will be buffered. Others will create connection right away. |
| 1382 if (conn_id <= kMaxNumSessionsToCreate) { | 1382 if (conn_id <= kMaxNumSessionsToCreate) { |
| 1383 EXPECT_CALL(*dispatcher_, CreateQuicSession(conn_id, client_addr_)) | 1383 EXPECT_CALL(*dispatcher_, CreateQuicSession(conn_id, client_addr_)) |
| 1384 .WillOnce(testing::Return(CreateSession( | 1384 .WillOnce(testing::Return(CreateSession( |
| 1385 dispatcher_.get(), config_, conn_id, client_addr_, &mock_helper_, | 1385 dispatcher_.get(), config_, conn_id, client_addr_, &mock_helper_, |
| 1386 &mock_alarm_factory_, &crypto_config_, | 1386 &mock_alarm_factory_, &crypto_config_, |
| 1387 QuicDispatcherPeer::GetCache(dispatcher_.get()), &session1_))); | 1387 QuicDispatcherPeer::GetCache(dispatcher_.get()), &session1_))); |
| 1388 EXPECT_CALL( | 1388 EXPECT_CALL( |
| 1389 *reinterpret_cast<MockQuicConnection*>(session1_->connection()), | 1389 *reinterpret_cast<MockQuicConnection*>(session1_->connection()), |
| 1390 ProcessUdpPacket(_, _, _)) | 1390 ProcessUdpPacket(_, _, _)) |
| 1391 .WillOnce(testing::WithArg<2>( | 1391 .WillOnce(testing::WithArg<2>( |
| 1392 Invoke(CreateFunctor(&QuicDispatcherTest::ValidatePacket, | 1392 Invoke(CreateFunctor(&QuicDispatcherTest::ValidatePacket, |
| 1393 base::Unretained(this), conn_id)))); | 1393 base::Unretained(this), conn_id)))); |
| 1394 } | 1394 } |
| 1395 ProcessPacket(client_addr_, conn_id, true, false, SerializeFullCHLO()); | 1395 ProcessPacket(client_addr_, conn_id, true, false, SerializeFullCHLO()); |
| 1396 } | 1396 } |
| 1397 // Retransmit CHLO on last connection should be dropped. | 1397 // Retransmit CHLO on last connection should be dropped. |
| 1398 QuicConnectionId last_connection = kMaxNumSessionsToCreate + 1; | 1398 QuicConnectionId last_connection = kMaxNumSessionsToCreate + 1; |
| 1399 ProcessPacket(client_addr_, last_connection, true, false, | 1399 ProcessPacket(client_addr_, last_connection, true, false, |
| 1400 SerializeFullCHLO()); | 1400 SerializeFullCHLO()); |
| 1401 | 1401 |
| 1402 size_t packets_buffered = 2; |
| 1403 if (!FLAGS_quic_buffer_packets_after_chlo) { |
| 1404 // The packet sent above is dropped when flag is off. |
| 1405 packets_buffered = 1; |
| 1406 } |
| 1407 |
| 1402 // Reset counter and process buffered CHLO. | 1408 // Reset counter and process buffered CHLO. |
| 1403 EXPECT_CALL(*dispatcher_, CreateQuicSession(last_connection, client_addr_)) | 1409 EXPECT_CALL(*dispatcher_, CreateQuicSession(last_connection, client_addr_)) |
| 1404 .WillOnce(testing::Return(CreateSession( | 1410 .WillOnce(testing::Return(CreateSession( |
| 1405 dispatcher_.get(), config_, last_connection, client_addr_, | 1411 dispatcher_.get(), config_, last_connection, client_addr_, |
| 1406 &mock_helper_, &mock_alarm_factory_, &crypto_config_, | 1412 &mock_helper_, &mock_alarm_factory_, &crypto_config_, |
| 1407 QuicDispatcherPeer::GetCache(dispatcher_.get()), &session1_))); | 1413 QuicDispatcherPeer::GetCache(dispatcher_.get()), &session1_))); |
| 1408 // Only one packet(CHLO) should be process. | 1414 // Only one packet(CHLO) should be process. |
| 1409 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()), | 1415 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()), |
| 1410 ProcessUdpPacket(_, _, _)) | 1416 ProcessUdpPacket(_, _, _)) |
| 1411 .WillOnce(testing::WithArg<2>( | 1417 .Times(packets_buffered) |
| 1418 .WillRepeatedly(testing::WithArg<2>( |
| 1412 Invoke(CreateFunctor(&QuicDispatcherTest::ValidatePacket, | 1419 Invoke(CreateFunctor(&QuicDispatcherTest::ValidatePacket, |
| 1413 base::Unretained(this), last_connection)))); | 1420 base::Unretained(this), last_connection)))); |
| 1414 dispatcher_->ProcessBufferedChlos(kMaxNumSessionsToCreate); | 1421 dispatcher_->ProcessBufferedChlos(kMaxNumSessionsToCreate); |
| 1415 } | 1422 } |
| 1416 | 1423 |
| 1417 TEST_P(BufferedPacketStoreTest, BufferNonChloPacketsUptoLimitWithChloBuffered) { | 1424 TEST_P(BufferedPacketStoreTest, BufferNonChloPacketsUptoLimitWithChloBuffered) { |
| 1418 FLAGS_quic_limit_num_new_sessions_per_epoll_loop = true; | 1425 FLAGS_quic_limit_num_new_sessions_per_epoll_loop = true; |
| 1419 QuicConnectionId last_connection_id = kMaxNumSessionsToCreate + 1; | 1426 QuicConnectionId last_connection_id = kMaxNumSessionsToCreate + 1; |
| 1420 for (QuicConnectionId conn_id = 1; conn_id <= last_connection_id; ++conn_id) { | 1427 for (QuicConnectionId conn_id = 1; conn_id <= last_connection_id; ++conn_id) { |
| 1421 // Last CHLO will be buffered. Others will create connection right away. | 1428 // Last CHLO will be buffered. Others will create connection right away. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1496 | 1503 |
| 1497 // CHLO on connection 1 should still be buffered. | 1504 // CHLO on connection 1 should still be buffered. |
| 1498 ProcessPacket(client_addr_, /*connection_id=*/1, true, false, | 1505 ProcessPacket(client_addr_, /*connection_id=*/1, true, false, |
| 1499 SerializeFullCHLO()); | 1506 SerializeFullCHLO()); |
| 1500 EXPECT_TRUE(store->HasChloForConnection(/*connection_id=*/1)); | 1507 EXPECT_TRUE(store->HasChloForConnection(/*connection_id=*/1)); |
| 1501 } | 1508 } |
| 1502 | 1509 |
| 1503 } // namespace | 1510 } // namespace |
| 1504 } // namespace test | 1511 } // namespace test |
| 1505 } // namespace net | 1512 } // namespace net |
| OLD | NEW |