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/quic/quic_stream_factory.h" | 5 #include "net/quic/quic_stream_factory.h" |
6 | 6 |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "net/base/test_data_directory.h" | 9 #include "net/base/test_data_directory.h" |
10 #include "net/cert/cert_verifier.h" | 10 #include "net/cert/cert_verifier.h" |
(...skipping 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1739 "GET", net_log_, callback_.callback())); | 1739 "GET", net_log_, callback_.callback())); |
1740 | 1740 |
1741 QuicClientSession* session = QuicStreamFactoryPeer::GetActiveSession( | 1741 QuicClientSession* session = QuicStreamFactoryPeer::GetActiveSession( |
1742 &factory_, host_port_pair_, is_https_); | 1742 &factory_, host_port_pair_, is_https_); |
1743 | 1743 |
1744 DVLOG(1) << "Create 1st session and test packet loss"; | 1744 DVLOG(1) << "Create 1st session and test packet loss"; |
1745 | 1745 |
1746 // Set packet_loss_rate to a lower value than packet_loss_threshold. | 1746 // Set packet_loss_rate to a lower value than packet_loss_threshold. |
1747 EXPECT_FALSE( | 1747 EXPECT_FALSE( |
1748 factory_.OnHandshakeConfirmed(session, /*packet_loss_rate=*/0.9f)); | 1748 factory_.OnHandshakeConfirmed(session, /*packet_loss_rate=*/0.9f)); |
| 1749 EXPECT_TRUE(session->connection()->connected()); |
1749 EXPECT_TRUE(QuicStreamFactoryPeer::HasActiveSession( | 1750 EXPECT_TRUE(QuicStreamFactoryPeer::HasActiveSession( |
1750 &factory_, host_port_pair_, is_https_)); | 1751 &factory_, host_port_pair_, is_https_)); |
1751 EXPECT_FALSE( | 1752 EXPECT_FALSE( |
1752 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); | 1753 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); |
1753 EXPECT_EQ(0, QuicStreamFactoryPeer::GetNumberOfLossyConnections( | 1754 EXPECT_EQ(0, QuicStreamFactoryPeer::GetNumberOfLossyConnections( |
1754 &factory_, host_port_pair_.port())); | 1755 &factory_, host_port_pair_.port())); |
1755 | 1756 |
1756 // Set packet_loss_rate to a higher value than packet_loss_threshold only once | 1757 // Set packet_loss_rate to a higher value than packet_loss_threshold only once |
1757 // and that should close the session, but shouldn't disable QUIC. | 1758 // and that should close the session, but shouldn't disable QUIC. |
1758 EXPECT_TRUE( | 1759 EXPECT_TRUE( |
(...skipping 27 matching lines...) Expand all Loading... |
1786 &factory_, server2.port())); | 1787 &factory_, server2.port())); |
1787 EXPECT_FALSE( | 1788 EXPECT_FALSE( |
1788 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, server2.port())); | 1789 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, server2.port())); |
1789 | 1790 |
1790 // Set packet_loss_rate to a higher value than packet_loss_threshold only once | 1791 // Set packet_loss_rate to a higher value than packet_loss_threshold only once |
1791 // and that should close the session, but shouldn't disable QUIC. | 1792 // and that should close the session, but shouldn't disable QUIC. |
1792 EXPECT_TRUE( | 1793 EXPECT_TRUE( |
1793 factory_.OnHandshakeConfirmed(session2, /*packet_loss_rate=*/1.0f)); | 1794 factory_.OnHandshakeConfirmed(session2, /*packet_loss_rate=*/1.0f)); |
1794 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumberOfLossyConnections( | 1795 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumberOfLossyConnections( |
1795 &factory_, server2.port())); | 1796 &factory_, server2.port())); |
| 1797 EXPECT_FALSE(session2->connection()->connected()); |
1796 EXPECT_FALSE( | 1798 EXPECT_FALSE( |
1797 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, server2.port())); | 1799 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, server2.port())); |
1798 EXPECT_FALSE( | 1800 EXPECT_FALSE( |
1799 QuicStreamFactoryPeer::HasActiveSession(&factory_, server2, is_https_)); | 1801 QuicStreamFactoryPeer::HasActiveSession(&factory_, server2, is_https_)); |
1800 EXPECT_EQ(nullptr, CreateIfSessionExists(server2, net_log_).get()); | 1802 EXPECT_EQ(nullptr, CreateIfSessionExists(server2, net_log_).get()); |
1801 | 1803 |
1802 DVLOG(1) << "Create 3rd session which also has packet loss"; | 1804 DVLOG(1) << "Create 3rd session which also has packet loss"; |
1803 | 1805 |
1804 TestCompletionCallback callback3; | 1806 TestCompletionCallback callback3; |
1805 QuicStreamRequest request3(&factory_); | 1807 QuicStreamRequest request3(&factory_); |
1806 EXPECT_EQ(OK, request3.Request(server3, is_https_, privacy_mode_, "GET", | 1808 EXPECT_EQ(OK, request3.Request(server3, is_https_, privacy_mode_, "GET", |
1807 net_log_, callback3.callback())); | 1809 net_log_, callback3.callback())); |
1808 QuicClientSession* session3 = | 1810 QuicClientSession* session3 = |
1809 QuicStreamFactoryPeer::GetActiveSession(&factory_, server3, is_https_); | 1811 QuicStreamFactoryPeer::GetActiveSession(&factory_, server3, is_https_); |
1810 | 1812 |
1811 // Set packet_loss_rate to higher value than packet_loss_threshold 2nd time in | 1813 // Set packet_loss_rate to higher value than packet_loss_threshold 2nd time in |
1812 // a row and that should close the session and disable QUIC. | 1814 // a row and that should close the session and disable QUIC. |
1813 EXPECT_TRUE( | 1815 EXPECT_TRUE( |
1814 factory_.OnHandshakeConfirmed(session3, /*packet_loss_rate=*/1.0f)); | 1816 factory_.OnHandshakeConfirmed(session3, /*packet_loss_rate=*/1.0f)); |
1815 EXPECT_EQ(2, QuicStreamFactoryPeer::GetNumberOfLossyConnections( | 1817 EXPECT_EQ(2, QuicStreamFactoryPeer::GetNumberOfLossyConnections( |
1816 &factory_, server3.port())); | 1818 &factory_, server3.port())); |
| 1819 EXPECT_FALSE(session2->connection()->connected()); |
1817 EXPECT_TRUE(QuicStreamFactoryPeer::IsQuicDisabled(&factory_, server3.port())); | 1820 EXPECT_TRUE(QuicStreamFactoryPeer::IsQuicDisabled(&factory_, server3.port())); |
1818 EXPECT_FALSE( | 1821 EXPECT_FALSE( |
1819 QuicStreamFactoryPeer::HasActiveSession(&factory_, server3, is_https_)); | 1822 QuicStreamFactoryPeer::HasActiveSession(&factory_, server3, is_https_)); |
1820 EXPECT_EQ(nullptr, CreateIfSessionExists(server3, net_log_).get()); | 1823 EXPECT_EQ(nullptr, CreateIfSessionExists(server3, net_log_).get()); |
1821 | 1824 |
1822 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1825 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
1823 EXPECT_TRUE(stream.get()); | 1826 EXPECT_TRUE(stream.get()); |
1824 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 1827 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
1825 EXPECT_TRUE(stream2.get()); | 1828 EXPECT_TRUE(stream2.get()); |
1826 scoped_ptr<QuicHttpStream> stream3 = request3.ReleaseStream(); | 1829 scoped_ptr<QuicHttpStream> stream3 = request3.ReleaseStream(); |
1827 EXPECT_TRUE(stream3.get()); | 1830 EXPECT_TRUE(stream3.get()); |
1828 EXPECT_TRUE(socket_data.at_read_eof()); | 1831 EXPECT_TRUE(socket_data.at_read_eof()); |
1829 EXPECT_TRUE(socket_data.at_write_eof()); | 1832 EXPECT_TRUE(socket_data.at_write_eof()); |
1830 EXPECT_TRUE(socket_data2.at_read_eof()); | 1833 EXPECT_TRUE(socket_data2.at_read_eof()); |
1831 EXPECT_TRUE(socket_data2.at_write_eof()); | 1834 EXPECT_TRUE(socket_data2.at_write_eof()); |
1832 EXPECT_TRUE(socket_data3.at_read_eof()); | 1835 EXPECT_TRUE(socket_data3.at_read_eof()); |
1833 EXPECT_TRUE(socket_data3.at_write_eof()); | 1836 EXPECT_TRUE(socket_data3.at_write_eof()); |
1834 } | 1837 } |
1835 | 1838 |
1836 } // namespace test | 1839 } // namespace test |
1837 } // namespace net | 1840 } // namespace net |
OLD | NEW |