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