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