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/spdy/spdy_session.h" | 5 #include "net/spdy/spdy_session.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | |
8 #include "base/memory/scoped_vector.h" | |
9 #include "net/base/host_cache.h" | 7 #include "net/base/host_cache.h" |
10 #include "net/base/io_buffer.h" | |
11 #include "net/base/ip_endpoint.h" | 8 #include "net/base/ip_endpoint.h" |
12 #include "net/base/net_log_unittest.h" | 9 #include "net/base/net_log_unittest.h" |
13 #include "net/base/request_priority.h" | 10 #include "net/base/request_priority.h" |
14 #include "net/base/test_data_directory.h" | 11 #include "net/base/test_data_directory.h" |
15 #include "net/base/test_data_stream.h" | |
16 #include "net/spdy/spdy_io_buffer.h" | 12 #include "net/spdy/spdy_io_buffer.h" |
17 #include "net/spdy/spdy_session_pool.h" | 13 #include "net/spdy/spdy_session_pool.h" |
18 #include "net/spdy/spdy_session_test_util.h" | |
19 #include "net/spdy/spdy_stream.h" | 14 #include "net/spdy/spdy_stream.h" |
20 #include "net/spdy/spdy_stream_test_util.h" | 15 #include "net/spdy/spdy_stream_test_util.h" |
21 #include "net/spdy/spdy_test_util_common.h" | 16 #include "net/spdy/spdy_test_util_common.h" |
22 #include "net/spdy/spdy_test_util_spdy2.h" | 17 #include "net/spdy/spdy_test_util_spdy2.h" |
23 #include "net/test/cert_test_util.h" | 18 #include "net/test/cert_test_util.h" |
24 #include "testing/platform_test.h" | 19 #include "testing/platform_test.h" |
25 | 20 |
26 using namespace net::test_spdy2; | 21 using namespace net::test_spdy2; |
27 | 22 |
28 namespace net { | 23 namespace net { |
(...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1578 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), true, OK)); | 1573 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), true, OK)); |
1579 | 1574 |
1580 EXPECT_FALSE(session->NeedsCredentials()); | 1575 EXPECT_FALSE(session->NeedsCredentials()); |
1581 | 1576 |
1582 // Flush the SpdySession::OnReadComplete() task. | 1577 // Flush the SpdySession::OnReadComplete() task. |
1583 MessageLoop::current()->RunUntilIdle(); | 1578 MessageLoop::current()->RunUntilIdle(); |
1584 | 1579 |
1585 spdy_session_pool_->Remove(session); | 1580 spdy_session_pool_->Remove(session); |
1586 } | 1581 } |
1587 | 1582 |
1588 // Test that SpdySession::DoRead reads data from the socket without yielding. | |
1589 // This test makes 32k - 1 bytes of data available on the socket for reading. It | |
1590 // then verifies that it has read all the available data without yielding. | |
1591 TEST_F(SpdySessionSpdy2Test, ReadDataWithoutYielding) { | |
1592 MockConnect connect_data(SYNCHRONOUS, OK); | |
1593 BufferedSpdyFramer framer(2, false); | |
1594 | |
1595 scoped_ptr<SpdyFrame> req1(ConstructSpdyGet(NULL, 0, false, 1, MEDIUM)); | |
1596 MockWrite writes[] = { | |
1597 CreateMockWrite(*req1, 0), | |
1598 }; | |
1599 | |
1600 // Build buffer of size kMaxReadBytes / 4 (-spdy_data_frame_size). | |
1601 ASSERT_EQ(32 * 1024, kMaxReadBytes); | |
1602 const int kPayloadSize = | |
1603 kMaxReadBytes / 4 - framer.GetControlFrameHeaderSize(); | |
1604 TestDataStream test_stream; | |
1605 scoped_refptr<net::IOBuffer> payload(new net::IOBuffer(kPayloadSize)); | |
1606 char* payload_data = payload->data(); | |
1607 test_stream.GetBytes(payload_data, kPayloadSize); | |
1608 | |
1609 scoped_ptr<SpdyFrame> partial_data_frame( | |
1610 framer.CreateDataFrame(1, payload_data, kPayloadSize, DATA_FLAG_NONE)); | |
1611 scoped_ptr<SpdyFrame> finish_data_frame( | |
1612 framer.CreateDataFrame(1, payload_data, kPayloadSize - 1, DATA_FLAG_FIN)); | |
1613 | |
1614 scoped_ptr<SpdyFrame> resp1(ConstructSpdyGetSynReply(NULL, 0, 1)); | |
1615 | |
1616 // Write 1 byte less than kMaxReadBytes to check that DoRead reads up to 32k | |
1617 // bytes. | |
1618 MockRead reads[] = { | |
1619 CreateMockRead(*resp1, 1), | |
1620 CreateMockRead(*partial_data_frame, 2), | |
1621 CreateMockRead(*partial_data_frame, 3, SYNCHRONOUS), | |
1622 CreateMockRead(*partial_data_frame, 4, SYNCHRONOUS), | |
1623 CreateMockRead(*finish_data_frame, 5, SYNCHRONOUS), | |
1624 MockRead(ASYNC, 0, 6) // EOF | |
1625 }; | |
1626 | |
1627 // Create SpdySession and SpdyStream and send the request. | |
1628 DeterministicSocketData data(reads, arraysize(reads), | |
1629 writes, arraysize(writes)); | |
1630 data.set_connect_data(connect_data); | |
1631 session_deps_.host_resolver->set_synchronous_mode(true); | |
1632 session_deps_.deterministic_socket_factory->AddSocketDataProvider(&data); | |
1633 | |
1634 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); | |
1635 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl); | |
1636 | |
1637 CreateDeterministicNetworkSession(); | |
1638 | |
1639 scoped_refptr<SpdySession> session = CreateInitializedSession(); | |
1640 | |
1641 GURL url1("http://www.google.com"); | |
1642 scoped_refptr<SpdyStream> spdy_stream1 = | |
1643 CreateStreamSynchronously(session, url1, MEDIUM, BoundNetLog()); | |
1644 ASSERT_TRUE(spdy_stream1.get() != NULL); | |
1645 EXPECT_EQ(0u, spdy_stream1->stream_id()); | |
1646 | |
1647 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); | |
1648 (*headers)["method"] = "GET"; | |
1649 (*headers)["scheme"] = url1.scheme(); | |
1650 (*headers)["host"] = url1.host(); | |
1651 (*headers)["url"] = url1.path(); | |
1652 (*headers)["version"] = "HTTP/1.1"; | |
1653 | |
1654 spdy_stream1->set_spdy_headers(headers.Pass()); | |
1655 EXPECT_TRUE(spdy_stream1->HasUrl()); | |
1656 spdy_stream1->SendRequest(false); | |
1657 | |
1658 // Set up the TaskObserver to verify SpdySession::DoRead doesn't post a task. | |
1659 SpdySessionTestTaskObserver observer("spdy_session.cc", "DoRead"); | |
1660 | |
1661 // Run until 1st read. | |
1662 EXPECT_EQ(0u, spdy_stream1->stream_id()); | |
1663 data.RunFor(2); | |
1664 EXPECT_EQ(1u, spdy_stream1->stream_id()); | |
1665 EXPECT_EQ(0u, observer.executed_count()); | |
1666 | |
1667 // Read all the data and verify SpdySession::DoRead has not posted a task. | |
1668 data.RunFor(4); | |
1669 | |
1670 // Verify task observer's executed_count is zero, which indicates DoRead read | |
1671 // all the available data. | |
1672 EXPECT_EQ(0u, observer.executed_count()); | |
1673 EXPECT_TRUE(data.at_write_eof()); | |
1674 EXPECT_TRUE(data.at_read_eof()); | |
1675 } | |
1676 | |
1677 // Test that SpdySession::DoRead yields while reading the data. This test makes | |
1678 // 32k + 1 bytes of data available on the socket for reading. It then verifies | |
1679 // that DoRead has yielded even though there is data available for it to read | |
1680 // (i.e, socket()->Read didn't return ERR_IO_PENDING during socket reads). | |
1681 TEST_F(SpdySessionSpdy2Test, TestYieldingDuringReadData) { | |
1682 MockConnect connect_data(SYNCHRONOUS, OK); | |
1683 BufferedSpdyFramer framer(2, false); | |
1684 | |
1685 scoped_ptr<SpdyFrame> req1(ConstructSpdyGet(NULL, 0, false, 1, MEDIUM)); | |
1686 MockWrite writes[] = { | |
1687 CreateMockWrite(*req1, 0), | |
1688 }; | |
1689 | |
1690 // Build buffer of size kMaxReadBytes / 4 (-spdy_data_frame_size). | |
1691 ASSERT_EQ(32 * 1024, kMaxReadBytes); | |
1692 const int kPayloadSize = | |
1693 kMaxReadBytes / 4 - framer.GetControlFrameHeaderSize(); | |
1694 TestDataStream test_stream; | |
1695 scoped_refptr<net::IOBuffer> payload(new net::IOBuffer(kPayloadSize)); | |
1696 char* payload_data = payload->data(); | |
1697 test_stream.GetBytes(payload_data, kPayloadSize); | |
1698 | |
1699 scoped_ptr<SpdyFrame> partial_data_frame( | |
1700 framer.CreateDataFrame(1, payload_data, kPayloadSize, DATA_FLAG_NONE)); | |
1701 scoped_ptr<SpdyFrame> finish_data_frame( | |
1702 framer.CreateDataFrame(1, "h", 1, DATA_FLAG_FIN)); | |
1703 | |
1704 scoped_ptr<SpdyFrame> resp1(ConstructSpdyGetSynReply(NULL, 0, 1)); | |
1705 | |
1706 // Write 1 byte more than kMaxReadBytes to check that DoRead yields. | |
1707 MockRead reads[] = { | |
1708 CreateMockRead(*resp1, 1), | |
1709 CreateMockRead(*partial_data_frame, 2), | |
1710 CreateMockRead(*partial_data_frame, 3, SYNCHRONOUS), | |
1711 CreateMockRead(*partial_data_frame, 4, SYNCHRONOUS), | |
1712 CreateMockRead(*partial_data_frame, 5, SYNCHRONOUS), | |
1713 CreateMockRead(*finish_data_frame, 6, SYNCHRONOUS), | |
1714 MockRead(ASYNC, 0, 7) // EOF | |
1715 }; | |
1716 | |
1717 // Create SpdySession and SpdyStream and send the request. | |
1718 DeterministicSocketData data(reads, arraysize(reads), | |
1719 writes, arraysize(writes)); | |
1720 data.set_connect_data(connect_data); | |
1721 session_deps_.host_resolver->set_synchronous_mode(true); | |
1722 session_deps_.deterministic_socket_factory->AddSocketDataProvider(&data); | |
1723 | |
1724 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); | |
1725 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl); | |
1726 | |
1727 CreateDeterministicNetworkSession(); | |
1728 | |
1729 scoped_refptr<SpdySession> session = CreateInitializedSession(); | |
1730 | |
1731 GURL url1("http://www.google.com"); | |
1732 scoped_refptr<SpdyStream> spdy_stream1 = | |
1733 CreateStreamSynchronously(session, url1, MEDIUM, BoundNetLog()); | |
1734 ASSERT_TRUE(spdy_stream1.get() != NULL); | |
1735 EXPECT_EQ(0u, spdy_stream1->stream_id()); | |
1736 | |
1737 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); | |
1738 (*headers)["method"] = "GET"; | |
1739 (*headers)["scheme"] = url1.scheme(); | |
1740 (*headers)["host"] = url1.host(); | |
1741 (*headers)["url"] = url1.path(); | |
1742 (*headers)["version"] = "HTTP/1.1"; | |
1743 | |
1744 spdy_stream1->set_spdy_headers(headers.Pass()); | |
1745 EXPECT_TRUE(spdy_stream1->HasUrl()); | |
1746 spdy_stream1->SendRequest(false); | |
1747 | |
1748 // Set up the TaskObserver to verify SpdySession::DoRead posts a task. | |
1749 SpdySessionTestTaskObserver observer("spdy_session.cc", "DoRead"); | |
1750 | |
1751 // Run until 1st read. | |
1752 EXPECT_EQ(0u, spdy_stream1->stream_id()); | |
1753 data.RunFor(2); | |
1754 EXPECT_EQ(1u, spdy_stream1->stream_id()); | |
1755 EXPECT_EQ(0u, observer.executed_count()); | |
1756 | |
1757 // Read all the data and verify SpdySession::DoRead has posted a task. | |
1758 data.RunFor(6); | |
1759 | |
1760 // Verify task observer's executed_count is 1, which indicates DoRead has | |
1761 // posted only one task and thus yielded though there is data available for it | |
1762 // to read. | |
1763 EXPECT_EQ(1u, observer.executed_count()); | |
1764 EXPECT_TRUE(data.at_write_eof()); | |
1765 EXPECT_TRUE(data.at_read_eof()); | |
1766 } | |
1767 | |
1768 // Test that SpdySession::DoRead() tests interactions of yielding + async, | |
1769 // by doing the following MockReads. | |
1770 // | |
1771 // MockRead of SYNCHRONOUS 8K, SYNCHRONOUS 8K, SYNCHRONOUS 8K, SYNCHRONOUS 2K | |
1772 // ASYNC 8K, SYNCHRONOUS 8K, SYNCHRONOUS 8K, SYNCHRONOUS 8K, SYNCHRONOUS 2K. | |
1773 // | |
1774 // The above reads 26K synchronously. Since that is less that 32K, we will | |
1775 // attempt to read again. However, that DoRead() will return ERR_IO_PENDING | |
1776 // (because of async read), so DoRead() will yield. When we come back, DoRead() | |
1777 // will read the results from the async read, and rest of the data | |
1778 // synchronously. | |
1779 TEST_F(SpdySessionSpdy2Test, TestYieldingDuringAsyncReadData) { | |
1780 MockConnect connect_data(SYNCHRONOUS, OK); | |
1781 BufferedSpdyFramer framer(2, false); | |
1782 | |
1783 scoped_ptr<SpdyFrame> req1(ConstructSpdyGet(NULL, 0, false, 1, MEDIUM)); | |
1784 MockWrite writes[] = { | |
1785 CreateMockWrite(*req1, 0), | |
1786 }; | |
1787 | |
1788 // Build buffer of size kMaxReadBytes / 4 (-spdy_data_frame_size). | |
1789 ASSERT_EQ(32 * 1024, kMaxReadBytes); | |
1790 TestDataStream test_stream; | |
1791 const int kEightKPayloadSize = | |
1792 kMaxReadBytes / 4 - framer.GetControlFrameHeaderSize(); | |
1793 scoped_refptr<net::IOBuffer> eightk_payload( | |
1794 new net::IOBuffer(kEightKPayloadSize)); | |
1795 char* eightk_payload_data = eightk_payload->data(); | |
1796 test_stream.GetBytes(eightk_payload_data, kEightKPayloadSize); | |
1797 | |
1798 // Build buffer of 2k size. | |
1799 TestDataStream test_stream2; | |
1800 const int kTwoKPayloadSize = kEightKPayloadSize - 6 * 1024; | |
1801 scoped_refptr<net::IOBuffer> twok_payload( | |
1802 new net::IOBuffer(kTwoKPayloadSize)); | |
1803 char* twok_payload_data = twok_payload->data(); | |
1804 test_stream2.GetBytes(twok_payload_data, kTwoKPayloadSize); | |
1805 | |
1806 scoped_ptr<SpdyFrame> eightk_data_frame(framer.CreateDataFrame( | |
1807 1, eightk_payload_data, kEightKPayloadSize, DATA_FLAG_NONE)); | |
1808 scoped_ptr<SpdyFrame> twok_data_frame(framer.CreateDataFrame( | |
1809 1, twok_payload_data, kTwoKPayloadSize, DATA_FLAG_NONE)); | |
1810 scoped_ptr<SpdyFrame> finish_data_frame(framer.CreateDataFrame( | |
1811 1, "h", 1, DATA_FLAG_FIN)); | |
1812 | |
1813 scoped_ptr<SpdyFrame> resp1(ConstructSpdyGetSynReply(NULL, 0, 1)); | |
1814 | |
1815 MockRead reads[] = { | |
1816 CreateMockRead(*resp1, 1), | |
1817 CreateMockRead(*eightk_data_frame, 2), | |
1818 CreateMockRead(*eightk_data_frame, 3, SYNCHRONOUS), | |
1819 CreateMockRead(*eightk_data_frame, 4, SYNCHRONOUS), | |
1820 CreateMockRead(*twok_data_frame, 5, SYNCHRONOUS), | |
1821 CreateMockRead(*eightk_data_frame, 6, ASYNC), | |
1822 CreateMockRead(*eightk_data_frame, 7, SYNCHRONOUS), | |
1823 CreateMockRead(*eightk_data_frame, 8, SYNCHRONOUS), | |
1824 CreateMockRead(*eightk_data_frame, 9, SYNCHRONOUS), | |
1825 CreateMockRead(*twok_data_frame, 10, SYNCHRONOUS), | |
1826 CreateMockRead(*finish_data_frame, 11, SYNCHRONOUS), | |
1827 MockRead(ASYNC, 0, 12) // EOF | |
1828 }; | |
1829 | |
1830 // Create SpdySession and SpdyStream and send the request. | |
1831 DeterministicSocketData data(reads, arraysize(reads), | |
1832 writes, arraysize(writes)); | |
1833 data.set_connect_data(connect_data); | |
1834 session_deps_.host_resolver->set_synchronous_mode(true); | |
1835 session_deps_.deterministic_socket_factory->AddSocketDataProvider(&data); | |
1836 | |
1837 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); | |
1838 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl); | |
1839 | |
1840 CreateDeterministicNetworkSession(); | |
1841 | |
1842 scoped_refptr<SpdySession> session = CreateInitializedSession(); | |
1843 | |
1844 GURL url1("http://www.google.com"); | |
1845 scoped_refptr<SpdyStream> spdy_stream1 = | |
1846 CreateStreamSynchronously(session, url1, MEDIUM, BoundNetLog()); | |
1847 ASSERT_TRUE(spdy_stream1.get() != NULL); | |
1848 EXPECT_EQ(0u, spdy_stream1->stream_id()); | |
1849 | |
1850 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); | |
1851 (*headers)["method"] = "GET"; | |
1852 (*headers)["scheme"] = url1.scheme(); | |
1853 (*headers)["host"] = url1.host(); | |
1854 (*headers)["url"] = url1.path(); | |
1855 (*headers)["version"] = "HTTP/1.1"; | |
1856 | |
1857 spdy_stream1->set_spdy_headers(headers.Pass()); | |
1858 EXPECT_TRUE(spdy_stream1->HasUrl()); | |
1859 spdy_stream1->SendRequest(false); | |
1860 | |
1861 // Set up the TaskObserver to monitor SpdySession::DoRead posting of tasks. | |
1862 SpdySessionTestTaskObserver observer("spdy_session.cc", "DoRead"); | |
1863 | |
1864 // Run until 1st read. | |
1865 EXPECT_EQ(0u, spdy_stream1->stream_id()); | |
1866 data.RunFor(2); | |
1867 EXPECT_EQ(1u, spdy_stream1->stream_id()); | |
1868 EXPECT_EQ(0u, observer.executed_count()); | |
1869 | |
1870 // Read all the data and verify SpdySession::DoRead has posted a task. | |
1871 data.RunFor(12); | |
1872 | |
1873 // Verify task observer's executed_count is 1, which indicates DoRead has | |
1874 // posted only one task and thus yielded though there is data available for | |
1875 // it to read. | |
1876 EXPECT_EQ(1u, observer.executed_count()); | |
1877 EXPECT_TRUE(data.at_write_eof()); | |
1878 EXPECT_TRUE(data.at_read_eof()); | |
1879 } | |
1880 | |
1881 // Send a GoAway frame when SpdySession is in DoLoop. If scoped_refptr to | |
1882 // <SpdySession> is deleted from SpdySession::DoLoop(), we get a crash because | |
1883 // GoAway could delete the SpdySession from the SpdySessionPool and the last | |
1884 // reference to SpdySession. | |
1885 TEST_F(SpdySessionSpdy2Test, GoAwayWhileInDoLoop) { | |
1886 MockConnect connect_data(SYNCHRONOUS, OK); | |
1887 BufferedSpdyFramer framer(2, false); | |
1888 | |
1889 scoped_ptr<SpdyFrame> req1(ConstructSpdyGet(NULL, 0, false, 1, MEDIUM)); | |
1890 MockWrite writes[] = { | |
1891 CreateMockWrite(*req1, 0), | |
1892 }; | |
1893 | |
1894 scoped_ptr<SpdyFrame> resp1(ConstructSpdyGetSynReply(NULL, 0, 1)); | |
1895 scoped_ptr<SpdyFrame> body1(ConstructSpdyBodyFrame(1, true)); | |
1896 scoped_ptr<SpdyFrame> goaway(ConstructSpdyGoAway()); | |
1897 | |
1898 MockRead reads[] = { | |
1899 CreateMockRead(*resp1, 1), | |
1900 CreateMockRead(*body1, 2), | |
1901 CreateMockRead(*goaway, 3), | |
1902 MockRead(ASYNC, 0, 4) // EOF | |
1903 }; | |
1904 | |
1905 // Create SpdySession and SpdyStream and send the request. | |
1906 DeterministicSocketData data(reads, arraysize(reads), | |
1907 writes, arraysize(writes)); | |
1908 data.set_connect_data(connect_data); | |
1909 session_deps_.host_resolver->set_synchronous_mode(true); | |
1910 session_deps_.deterministic_socket_factory->AddSocketDataProvider(&data); | |
1911 | |
1912 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); | |
1913 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl); | |
1914 | |
1915 CreateDeterministicNetworkSession(); | |
1916 | |
1917 scoped_refptr<SpdySession> session = CreateInitializedSession(); | |
1918 | |
1919 GURL url1("http://www.google.com"); | |
1920 scoped_refptr<SpdyStream> spdy_stream1 = | |
1921 CreateStreamSynchronously(session, url1, MEDIUM, BoundNetLog()); | |
1922 ASSERT_TRUE(spdy_stream1.get() != NULL); | |
1923 EXPECT_EQ(0u, spdy_stream1->stream_id()); | |
1924 | |
1925 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); | |
1926 (*headers)["method"] = "GET"; | |
1927 (*headers)["scheme"] = url1.scheme(); | |
1928 (*headers)["host"] = url1.host(); | |
1929 (*headers)["url"] = url1.path(); | |
1930 (*headers)["version"] = "HTTP/1.1"; | |
1931 | |
1932 spdy_stream1->set_spdy_headers(headers.Pass()); | |
1933 EXPECT_TRUE(spdy_stream1->HasUrl()); | |
1934 spdy_stream1->SendRequest(false); | |
1935 | |
1936 // Run until 1st read. | |
1937 EXPECT_EQ(0u, spdy_stream1->stream_id()); | |
1938 data.RunFor(1); | |
1939 EXPECT_EQ(1u, spdy_stream1->stream_id()); | |
1940 | |
1941 // Drop the reference to the session. | |
1942 session = NULL; | |
1943 | |
1944 // Run until GoAway. | |
1945 data.RunFor(2); | |
1946 | |
1947 // Drop the reference to the stream which deletes its reference to the | |
1948 // SpdySession. Only references to SpdySession are held by DoLoop and | |
1949 // SpdySessionPool. If DoLoop doesn't hold the reference, we get a crash if | |
1950 // SpdySession is deleted from the SpdySessionPool. | |
1951 spdy_stream1 = NULL; | |
1952 | |
1953 data.RunFor(2); | |
1954 EXPECT_TRUE(data.at_write_eof()); | |
1955 EXPECT_TRUE(data.at_read_eof()); | |
1956 } | |
1957 | |
1958 // Within this framework, a SpdySession should be initialized with | 1583 // Within this framework, a SpdySession should be initialized with |
1959 // flow control disabled and with protocol version 2. | 1584 // flow control disabled and with protocol version 2. |
1960 TEST_F(SpdySessionSpdy2Test, ProtocolNegotiation) { | 1585 TEST_F(SpdySessionSpdy2Test, ProtocolNegotiation) { |
1961 session_deps_.host_resolver->set_synchronous_mode(true); | 1586 session_deps_.host_resolver->set_synchronous_mode(true); |
1962 | 1587 |
1963 MockConnect connect_data(SYNCHRONOUS, OK); | 1588 MockConnect connect_data(SYNCHRONOUS, OK); |
1964 MockRead reads[] = { | 1589 MockRead reads[] = { |
1965 MockRead(SYNCHRONOUS, 0, 0) // EOF | 1590 MockRead(SYNCHRONOUS, 0, 0) // EOF |
1966 }; | 1591 }; |
1967 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); | 1592 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); |
(...skipping 13 matching lines...) Expand all Loading... |
1981 http_session_.get(), session.get(), test_host_port_pair_); | 1606 http_session_.get(), session.get(), test_host_port_pair_); |
1982 | 1607 |
1983 EXPECT_EQ(SpdySession::FLOW_CONTROL_NONE, session->flow_control_state()); | 1608 EXPECT_EQ(SpdySession::FLOW_CONTROL_NONE, session->flow_control_state()); |
1984 EXPECT_EQ(kSpdyVersion2, session->buffered_spdy_framer_->protocol_version()); | 1609 EXPECT_EQ(kSpdyVersion2, session->buffered_spdy_framer_->protocol_version()); |
1985 EXPECT_EQ(0, session->session_send_window_size_); | 1610 EXPECT_EQ(0, session->session_send_window_size_); |
1986 EXPECT_EQ(0, session->session_recv_window_size_); | 1611 EXPECT_EQ(0, session->session_recv_window_size_); |
1987 EXPECT_EQ(0, session->session_unacked_recv_window_bytes_); | 1612 EXPECT_EQ(0, session->session_unacked_recv_window_bytes_); |
1988 } | 1613 } |
1989 | 1614 |
1990 } // namespace net | 1615 } // namespace net |
OLD | NEW |