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/base64.h" | 7 #include "base/base64.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "base/test/histogram_tester.h" | 12 #include "base/test/histogram_tester.h" |
13 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
14 #include "net/base/ip_endpoint.h" | 14 #include "net/base/ip_endpoint.h" |
15 #include "net/base/request_priority.h" | 15 #include "net/base/request_priority.h" |
16 #include "net/base/test_data_directory.h" | 16 #include "net/base/test_data_directory.h" |
17 #include "net/base/test_data_stream.h" | 17 #include "net/base/test_data_stream.h" |
| 18 #include "net/log/captured_net_log_entry.h" |
18 #include "net/log/net_log_unittest.h" | 19 #include "net/log/net_log_unittest.h" |
| 20 #include "net/log/test_net_log.h" |
19 #include "net/socket/client_socket_pool_manager.h" | 21 #include "net/socket/client_socket_pool_manager.h" |
20 #include "net/socket/next_proto.h" | 22 #include "net/socket/next_proto.h" |
21 #include "net/socket/socket_test_util.h" | 23 #include "net/socket/socket_test_util.h" |
22 #include "net/spdy/spdy_http_utils.h" | 24 #include "net/spdy/spdy_http_utils.h" |
23 #include "net/spdy/spdy_session_pool.h" | 25 #include "net/spdy/spdy_session_pool.h" |
24 #include "net/spdy/spdy_session_test_util.h" | 26 #include "net/spdy/spdy_session_test_util.h" |
25 #include "net/spdy/spdy_stream.h" | 27 #include "net/spdy/spdy_stream.h" |
26 #include "net/spdy/spdy_stream_test_util.h" | 28 #include "net/spdy/spdy_stream_test_util.h" |
27 #include "net/spdy/spdy_test_util_common.h" | 29 #include "net/spdy/spdy_test_util_common.h" |
28 #include "net/spdy/spdy_test_utils.h" | 30 #include "net/spdy/spdy_test_utils.h" |
(...skipping 1596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1625 | 1627 |
1626 CreateNetworkSession(); | 1628 CreateNetworkSession(); |
1627 | 1629 |
1628 base::WeakPtr<SpdySession> session = | 1630 base::WeakPtr<SpdySession> session = |
1629 CreateInsecureSpdySession(http_session_, key_, log.bound()); | 1631 CreateInsecureSpdySession(http_session_, key_, log.bound()); |
1630 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_)); | 1632 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_)); |
1631 | 1633 |
1632 // Flush the read completion task. | 1634 // Flush the read completion task. |
1633 base::MessageLoop::current()->RunUntilIdle(); | 1635 base::MessageLoop::current()->RunUntilIdle(); |
1634 | 1636 |
1635 TestNetLog::CapturedEntryList entries; | 1637 CapturedNetLogEntry::List entries; |
1636 log.GetEntries(&entries); | 1638 log.GetEntries(&entries); |
1637 EXPECT_LT(0u, entries.size()); | 1639 EXPECT_LT(0u, entries.size()); |
1638 | 1640 |
1639 // Check that we logged TYPE_HTTP2_SESSION_INITIALIZED correctly. | 1641 // Check that we logged TYPE_HTTP2_SESSION_INITIALIZED correctly. |
1640 int pos = ExpectLogContainsSomewhere( | 1642 int pos = ExpectLogContainsSomewhere( |
1641 entries, 0, NetLog::TYPE_HTTP2_SESSION_INITIALIZED, NetLog::PHASE_NONE); | 1643 entries, 0, NetLog::TYPE_HTTP2_SESSION_INITIALIZED, NetLog::PHASE_NONE); |
1642 EXPECT_LT(0, pos); | 1644 EXPECT_LT(0, pos); |
1643 | 1645 |
1644 TestNetLog::CapturedEntry entry = entries[pos]; | 1646 CapturedNetLogEntry entry = entries[pos]; |
1645 NetLog::Source socket_source; | 1647 NetLog::Source socket_source; |
1646 EXPECT_TRUE(NetLog::Source::FromEventParameters(entry.params.get(), | 1648 EXPECT_TRUE(NetLog::Source::FromEventParameters(entry.params.get(), |
1647 &socket_source)); | 1649 &socket_source)); |
1648 EXPECT_TRUE(socket_source.IsValid()); | 1650 EXPECT_TRUE(socket_source.IsValid()); |
1649 EXPECT_NE(log.bound().source().id, socket_source.id); | 1651 EXPECT_NE(log.bound().source().id, socket_source.id); |
1650 } | 1652 } |
1651 | 1653 |
1652 TEST_P(SpdySessionTest, NetLogOnSessionGoaway) { | 1654 TEST_P(SpdySessionTest, NetLogOnSessionGoaway) { |
1653 session_deps_.host_resolver->set_synchronous_mode(true); | 1655 session_deps_.host_resolver->set_synchronous_mode(true); |
1654 | 1656 |
(...skipping 15 matching lines...) Expand all Loading... |
1670 CreateInsecureSpdySession(http_session_, key_, log.bound()); | 1672 CreateInsecureSpdySession(http_session_, key_, log.bound()); |
1671 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_)); | 1673 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_)); |
1672 | 1674 |
1673 // Flush the read completion task. | 1675 // Flush the read completion task. |
1674 base::MessageLoop::current()->RunUntilIdle(); | 1676 base::MessageLoop::current()->RunUntilIdle(); |
1675 | 1677 |
1676 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_)); | 1678 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_)); |
1677 EXPECT_TRUE(session == NULL); | 1679 EXPECT_TRUE(session == NULL); |
1678 | 1680 |
1679 // Check that the NetLog was filled reasonably. | 1681 // Check that the NetLog was filled reasonably. |
1680 TestNetLog::CapturedEntryList entries; | 1682 CapturedNetLogEntry::List entries; |
1681 log.GetEntries(&entries); | 1683 log.GetEntries(&entries); |
1682 EXPECT_LT(0u, entries.size()); | 1684 EXPECT_LT(0u, entries.size()); |
1683 | 1685 |
1684 // Check that we logged SPDY_SESSION_CLOSE correctly. | 1686 // Check that we logged SPDY_SESSION_CLOSE correctly. |
1685 int pos = ExpectLogContainsSomewhere( | 1687 int pos = ExpectLogContainsSomewhere( |
1686 entries, 0, NetLog::TYPE_HTTP2_SESSION_CLOSE, NetLog::PHASE_NONE); | 1688 entries, 0, NetLog::TYPE_HTTP2_SESSION_CLOSE, NetLog::PHASE_NONE); |
1687 | 1689 |
1688 if (pos < static_cast<int>(entries.size())) { | 1690 if (pos < static_cast<int>(entries.size())) { |
1689 TestNetLog::CapturedEntry entry = entries[pos]; | 1691 CapturedNetLogEntry entry = entries[pos]; |
1690 int error_code = 0; | 1692 int error_code = 0; |
1691 ASSERT_TRUE(entry.GetNetErrorCode(&error_code)); | 1693 ASSERT_TRUE(entry.GetNetErrorCode(&error_code)); |
1692 EXPECT_EQ(OK, error_code); | 1694 EXPECT_EQ(OK, error_code); |
1693 } else { | 1695 } else { |
1694 ADD_FAILURE(); | 1696 ADD_FAILURE(); |
1695 } | 1697 } |
1696 } | 1698 } |
1697 | 1699 |
1698 TEST_P(SpdySessionTest, NetLogOnSessionEOF) { | 1700 TEST_P(SpdySessionTest, NetLogOnSessionEOF) { |
1699 session_deps_.host_resolver->set_synchronous_mode(true); | 1701 session_deps_.host_resolver->set_synchronous_mode(true); |
(...skipping 14 matching lines...) Expand all Loading... |
1714 CreateInsecureSpdySession(http_session_, key_, log.bound()); | 1716 CreateInsecureSpdySession(http_session_, key_, log.bound()); |
1715 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_)); | 1717 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_)); |
1716 | 1718 |
1717 // Flush the read completion task. | 1719 // Flush the read completion task. |
1718 base::MessageLoop::current()->RunUntilIdle(); | 1720 base::MessageLoop::current()->RunUntilIdle(); |
1719 | 1721 |
1720 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_)); | 1722 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_)); |
1721 EXPECT_TRUE(session == NULL); | 1723 EXPECT_TRUE(session == NULL); |
1722 | 1724 |
1723 // Check that the NetLog was filled reasonably. | 1725 // Check that the NetLog was filled reasonably. |
1724 TestNetLog::CapturedEntryList entries; | 1726 CapturedNetLogEntry::List entries; |
1725 log.GetEntries(&entries); | 1727 log.GetEntries(&entries); |
1726 EXPECT_LT(0u, entries.size()); | 1728 EXPECT_LT(0u, entries.size()); |
1727 | 1729 |
1728 // Check that we logged SPDY_SESSION_CLOSE correctly. | 1730 // Check that we logged SPDY_SESSION_CLOSE correctly. |
1729 int pos = ExpectLogContainsSomewhere( | 1731 int pos = ExpectLogContainsSomewhere( |
1730 entries, 0, NetLog::TYPE_HTTP2_SESSION_CLOSE, NetLog::PHASE_NONE); | 1732 entries, 0, NetLog::TYPE_HTTP2_SESSION_CLOSE, NetLog::PHASE_NONE); |
1731 | 1733 |
1732 if (pos < static_cast<int>(entries.size())) { | 1734 if (pos < static_cast<int>(entries.size())) { |
1733 TestNetLog::CapturedEntry entry = entries[pos]; | 1735 CapturedNetLogEntry entry = entries[pos]; |
1734 int error_code = 0; | 1736 int error_code = 0; |
1735 ASSERT_TRUE(entry.GetNetErrorCode(&error_code)); | 1737 ASSERT_TRUE(entry.GetNetErrorCode(&error_code)); |
1736 EXPECT_EQ(ERR_CONNECTION_CLOSED, error_code); | 1738 EXPECT_EQ(ERR_CONNECTION_CLOSED, error_code); |
1737 } else { | 1739 } else { |
1738 ADD_FAILURE(); | 1740 ADD_FAILURE(); |
1739 } | 1741 } |
1740 } | 1742 } |
1741 | 1743 |
1742 TEST_P(SpdySessionTest, SynCompressionHistograms) { | 1744 TEST_P(SpdySessionTest, SynCompressionHistograms) { |
1743 session_deps_.enable_compression = true; | 1745 session_deps_.enable_compression = true; |
(...skipping 3454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5198 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), | 5200 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), |
5199 "spdy_pooling.pem"); | 5201 "spdy_pooling.pem"); |
5200 ssl_info.is_issued_by_known_root = true; | 5202 ssl_info.is_issued_by_known_root = true; |
5201 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); | 5203 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); |
5202 | 5204 |
5203 EXPECT_TRUE(SpdySession::CanPool( | 5205 EXPECT_TRUE(SpdySession::CanPool( |
5204 &tss, ssl_info, "www.example.org", "mail.example.org")); | 5206 &tss, ssl_info, "www.example.org", "mail.example.org")); |
5205 } | 5207 } |
5206 | 5208 |
5207 } // namespace net | 5209 } // namespace net |
OLD | NEW |