| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <sys/epoll.h> | 7 #include <sys/epoll.h> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "net/quic/quic_flags.h" | 21 #include "net/quic/quic_flags.h" |
| 22 #include "net/quic/quic_framer.h" | 22 #include "net/quic/quic_framer.h" |
| 23 #include "net/quic/quic_packet_creator.h" | 23 #include "net/quic/quic_packet_creator.h" |
| 24 #include "net/quic/quic_protocol.h" | 24 #include "net/quic/quic_protocol.h" |
| 25 #include "net/quic/quic_server_id.h" | 25 #include "net/quic/quic_server_id.h" |
| 26 #include "net/quic/quic_utils.h" | 26 #include "net/quic/quic_utils.h" |
| 27 #include "net/quic/test_tools/quic_connection_peer.h" | 27 #include "net/quic/test_tools/quic_connection_peer.h" |
| 28 #include "net/quic/test_tools/quic_flow_controller_peer.h" | 28 #include "net/quic/test_tools/quic_flow_controller_peer.h" |
| 29 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" | 29 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" |
| 30 #include "net/quic/test_tools/quic_session_peer.h" | 30 #include "net/quic/test_tools/quic_session_peer.h" |
| 31 #include "net/quic/test_tools/quic_spdy_session_peer.h" |
| 31 #include "net/quic/test_tools/quic_test_utils.h" | 32 #include "net/quic/test_tools/quic_test_utils.h" |
| 32 #include "net/quic/test_tools/reliable_quic_stream_peer.h" | 33 #include "net/quic/test_tools/reliable_quic_stream_peer.h" |
| 33 #include "net/test/gtest_util.h" | 34 #include "net/test/gtest_util.h" |
| 34 #include "net/tools/epoll_server/epoll_server.h" | 35 #include "net/tools/epoll_server/epoll_server.h" |
| 35 #include "net/tools/quic/quic_epoll_connection_helper.h" | 36 #include "net/tools/quic/quic_epoll_connection_helper.h" |
| 36 #include "net/tools/quic/quic_in_memory_cache.h" | 37 #include "net/tools/quic/quic_in_memory_cache.h" |
| 37 #include "net/tools/quic/quic_packet_writer_wrapper.h" | 38 #include "net/tools/quic/quic_packet_writer_wrapper.h" |
| 38 #include "net/tools/quic/quic_server.h" | 39 #include "net/tools/quic/quic_server.h" |
| 39 #include "net/tools/quic/quic_socket_utils.h" | 40 #include "net/tools/quic/quic_socket_utils.h" |
| 40 #include "net/tools/quic/quic_spdy_client_stream.h" | 41 #include "net/tools/quic/quic_spdy_client_stream.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 51 using base::StringPiece; | 52 using base::StringPiece; |
| 52 using base::WaitableEvent; | 53 using base::WaitableEvent; |
| 53 using net::EpollServer; | 54 using net::EpollServer; |
| 54 using net::test::ConstructEncryptedPacket; | 55 using net::test::ConstructEncryptedPacket; |
| 55 using net::test::GenerateBody; | 56 using net::test::GenerateBody; |
| 56 using net::test::MockQuicConnectionDebugVisitor; | 57 using net::test::MockQuicConnectionDebugVisitor; |
| 57 using net::test::QuicConnectionPeer; | 58 using net::test::QuicConnectionPeer; |
| 58 using net::test::QuicFlowControllerPeer; | 59 using net::test::QuicFlowControllerPeer; |
| 59 using net::test::QuicSentPacketManagerPeer; | 60 using net::test::QuicSentPacketManagerPeer; |
| 60 using net::test::QuicSessionPeer; | 61 using net::test::QuicSessionPeer; |
| 62 using net::test::QuicSpdySessionPeer; |
| 61 using net::test::ReliableQuicStreamPeer; | 63 using net::test::ReliableQuicStreamPeer; |
| 62 using net::test::ValueRestore; | 64 using net::test::ValueRestore; |
| 63 using net::test::kClientDataStreamId1; | 65 using net::test::kClientDataStreamId1; |
| 64 using net::tools::test::PacketDroppingTestWriter; | 66 using net::tools::test::PacketDroppingTestWriter; |
| 65 using net::tools::test::QuicDispatcherPeer; | 67 using net::tools::test::QuicDispatcherPeer; |
| 66 using net::tools::test::QuicServerPeer; | 68 using net::tools::test::QuicServerPeer; |
| 67 using std::ostream; | 69 using std::ostream; |
| 68 using std::string; | 70 using std::string; |
| 69 using std::vector; | 71 using std::vector; |
| 70 | 72 |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 server_thread_->WaitForCryptoHandshakeConfirmed(); | 694 server_thread_->WaitForCryptoHandshakeConfirmed(); |
| 693 | 695 |
| 694 FecPolicy expected_policy = | 696 FecPolicy expected_policy = |
| 695 GetParam().use_fec ? FEC_PROTECT_ALWAYS : FEC_PROTECT_OPTIONAL; | 697 GetParam().use_fec ? FEC_PROTECT_ALWAYS : FEC_PROTECT_OPTIONAL; |
| 696 | 698 |
| 697 // Verify that server's FEC configuration is correct. | 699 // Verify that server's FEC configuration is correct. |
| 698 server_thread_->Pause(); | 700 server_thread_->Pause(); |
| 699 QuicDispatcher* dispatcher = | 701 QuicDispatcher* dispatcher = |
| 700 QuicServerPeer::GetDispatcher(server_thread_->server()); | 702 QuicServerPeer::GetDispatcher(server_thread_->server()); |
| 701 ASSERT_EQ(1u, dispatcher->session_map().size()); | 703 ASSERT_EQ(1u, dispatcher->session_map().size()); |
| 702 QuicSession* session = dispatcher->session_map().begin()->second; | 704 QuicSpdySession* session = dispatcher->session_map().begin()->second; |
| 703 EXPECT_EQ(expected_policy, | 705 EXPECT_EQ(expected_policy, |
| 704 QuicSessionPeer::GetHeadersStream(session)->fec_policy()); | 706 QuicSpdySessionPeer::GetHeadersStream(session)->fec_policy()); |
| 705 server_thread_->Resume(); | 707 server_thread_->Resume(); |
| 706 | 708 |
| 707 // Verify that client's FEC configuration is correct. | 709 // Verify that client's FEC configuration is correct. |
| 708 EXPECT_EQ(expected_policy, | 710 EXPECT_EQ(expected_policy, QuicSpdySessionPeer::GetHeadersStream( |
| 709 QuicSessionPeer::GetHeadersStream( | 711 client_->client()->session())->fec_policy()); |
| 710 client_->client()->session())->fec_policy()); | |
| 711 EXPECT_EQ(expected_policy, | 712 EXPECT_EQ(expected_policy, |
| 712 client_->GetOrCreateStream()->fec_policy()); | 713 client_->GetOrCreateStream()->fec_policy()); |
| 713 } | 714 } |
| 714 | 715 |
| 715 TEST_P(EndToEndTest, LargePostSmallBandwidthLargeBuffer) { | 716 TEST_P(EndToEndTest, LargePostSmallBandwidthLargeBuffer) { |
| 716 ASSERT_TRUE(Initialize()); | 717 ASSERT_TRUE(Initialize()); |
| 717 SetPacketSendDelay(QuicTime::Delta::FromMicroseconds(1)); | 718 SetPacketSendDelay(QuicTime::Delta::FromMicroseconds(1)); |
| 718 // 256KB per second with a 256KB buffer from server to client. Wireless | 719 // 256KB per second with a 256KB buffer from server to client. Wireless |
| 719 // clients commonly have larger buffers, but our max CWND is 200. | 720 // clients commonly have larger buffers, but our max CWND is 200. |
| 720 server_writer_->set_max_bandwidth_and_buffer_size( | 721 server_writer_->set_max_bandwidth_and_buffer_size( |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1284 QuicFlowControllerPeer::SendWindowSize(crypto_stream->flow_controller()), | 1285 QuicFlowControllerPeer::SendWindowSize(crypto_stream->flow_controller()), |
| 1285 kStreamIFCW); | 1286 kStreamIFCW); |
| 1286 EXPECT_EQ(kSessionIFCW, QuicFlowControllerPeer::SendWindowSize( | 1287 EXPECT_EQ(kSessionIFCW, QuicFlowControllerPeer::SendWindowSize( |
| 1287 client_->client()->session()->flow_controller())); | 1288 client_->client()->session()->flow_controller())); |
| 1288 | 1289 |
| 1289 // Send a request with no body, and verify that the connection level window | 1290 // Send a request with no body, and verify that the connection level window |
| 1290 // has not been affected. | 1291 // has not been affected. |
| 1291 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 1292 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| 1292 | 1293 |
| 1293 QuicHeadersStream* headers_stream = | 1294 QuicHeadersStream* headers_stream = |
| 1294 QuicSessionPeer::GetHeadersStream(client_->client()->session()); | 1295 QuicSpdySessionPeer::GetHeadersStream(client_->client()->session()); |
| 1295 EXPECT_LT( | 1296 EXPECT_LT( |
| 1296 QuicFlowControllerPeer::SendWindowSize(headers_stream->flow_controller()), | 1297 QuicFlowControllerPeer::SendWindowSize(headers_stream->flow_controller()), |
| 1297 kStreamIFCW); | 1298 kStreamIFCW); |
| 1298 EXPECT_EQ(kSessionIFCW, QuicFlowControllerPeer::SendWindowSize( | 1299 EXPECT_EQ(kSessionIFCW, QuicFlowControllerPeer::SendWindowSize( |
| 1299 client_->client()->session()->flow_controller())); | 1300 client_->client()->session()->flow_controller())); |
| 1300 | 1301 |
| 1301 // Server should be in a similar state: connection flow control window should | 1302 // Server should be in a similar state: connection flow control window should |
| 1302 // not have any bytes marked as received. | 1303 // not have any bytes marked as received. |
| 1303 server_thread_->Pause(); | 1304 server_thread_->Pause(); |
| 1304 QuicDispatcher* dispatcher = | 1305 QuicDispatcher* dispatcher = |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1611 | 1612 |
| 1612 // The connection should not be terminated. | 1613 // The connection should not be terminated. |
| 1613 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 1614 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| 1614 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 1615 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 1615 } | 1616 } |
| 1616 | 1617 |
| 1617 } // namespace | 1618 } // namespace |
| 1618 } // namespace test | 1619 } // namespace test |
| 1619 } // namespace tools | 1620 } // namespace tools |
| 1620 } // namespace net | 1621 } // namespace net |
| OLD | NEW |