| 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" |
| (...skipping 1614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1625 | 1625 |
| 1626 CreateNetworkSession(); | 1626 CreateNetworkSession(); |
| 1627 | 1627 |
| 1628 base::WeakPtr<SpdySession> session = | 1628 base::WeakPtr<SpdySession> session = |
| 1629 CreateInsecureSpdySession(http_session_, key_, log.bound()); | 1629 CreateInsecureSpdySession(http_session_, key_, log.bound()); |
| 1630 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_)); | 1630 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_)); |
| 1631 | 1631 |
| 1632 // Flush the read completion task. | 1632 // Flush the read completion task. |
| 1633 base::MessageLoop::current()->RunUntilIdle(); | 1633 base::MessageLoop::current()->RunUntilIdle(); |
| 1634 | 1634 |
| 1635 net::CapturingNetLog::CapturedEntryList entries; | 1635 net::TestNetLog::CapturedEntryList entries; |
| 1636 log.GetEntries(&entries); | 1636 log.GetEntries(&entries); |
| 1637 EXPECT_LT(0u, entries.size()); | 1637 EXPECT_LT(0u, entries.size()); |
| 1638 | 1638 |
| 1639 // Check that we logged TYPE_HTTP2_SESSION_INITIALIZED correctly. | 1639 // Check that we logged TYPE_HTTP2_SESSION_INITIALIZED correctly. |
| 1640 int pos = net::ExpectLogContainsSomewhere( | 1640 int pos = net::ExpectLogContainsSomewhere( |
| 1641 entries, 0, net::NetLog::TYPE_HTTP2_SESSION_INITIALIZED, | 1641 entries, 0, net::NetLog::TYPE_HTTP2_SESSION_INITIALIZED, |
| 1642 net::NetLog::PHASE_NONE); | 1642 net::NetLog::PHASE_NONE); |
| 1643 EXPECT_LT(0, pos); | 1643 EXPECT_LT(0, pos); |
| 1644 | 1644 |
| 1645 CapturingNetLog::CapturedEntry entry = entries[pos]; | 1645 TestNetLog::CapturedEntry entry = entries[pos]; |
| 1646 NetLog::Source socket_source; | 1646 NetLog::Source socket_source; |
| 1647 EXPECT_TRUE(NetLog::Source::FromEventParameters(entry.params.get(), | 1647 EXPECT_TRUE(NetLog::Source::FromEventParameters(entry.params.get(), |
| 1648 &socket_source)); | 1648 &socket_source)); |
| 1649 EXPECT_TRUE(socket_source.IsValid()); | 1649 EXPECT_TRUE(socket_source.IsValid()); |
| 1650 EXPECT_NE(log.bound().source().id, socket_source.id); | 1650 EXPECT_NE(log.bound().source().id, socket_source.id); |
| 1651 } | 1651 } |
| 1652 | 1652 |
| 1653 TEST_P(SpdySessionTest, NetLogOnSessionGoaway) { | 1653 TEST_P(SpdySessionTest, NetLogOnSessionGoaway) { |
| 1654 session_deps_.host_resolver->set_synchronous_mode(true); | 1654 session_deps_.host_resolver->set_synchronous_mode(true); |
| 1655 | 1655 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1671 CreateInsecureSpdySession(http_session_, key_, log.bound()); | 1671 CreateInsecureSpdySession(http_session_, key_, log.bound()); |
| 1672 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_)); | 1672 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_)); |
| 1673 | 1673 |
| 1674 // Flush the read completion task. | 1674 // Flush the read completion task. |
| 1675 base::MessageLoop::current()->RunUntilIdle(); | 1675 base::MessageLoop::current()->RunUntilIdle(); |
| 1676 | 1676 |
| 1677 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_)); | 1677 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_)); |
| 1678 EXPECT_TRUE(session == NULL); | 1678 EXPECT_TRUE(session == NULL); |
| 1679 | 1679 |
| 1680 // Check that the NetLog was filled reasonably. | 1680 // Check that the NetLog was filled reasonably. |
| 1681 net::CapturingNetLog::CapturedEntryList entries; | 1681 net::TestNetLog::CapturedEntryList entries; |
| 1682 log.GetEntries(&entries); | 1682 log.GetEntries(&entries); |
| 1683 EXPECT_LT(0u, entries.size()); | 1683 EXPECT_LT(0u, entries.size()); |
| 1684 | 1684 |
| 1685 // Check that we logged SPDY_SESSION_CLOSE correctly. | 1685 // Check that we logged SPDY_SESSION_CLOSE correctly. |
| 1686 int pos = net::ExpectLogContainsSomewhere( | 1686 int pos = net::ExpectLogContainsSomewhere( |
| 1687 entries, 0, net::NetLog::TYPE_HTTP2_SESSION_CLOSE, | 1687 entries, 0, net::NetLog::TYPE_HTTP2_SESSION_CLOSE, |
| 1688 net::NetLog::PHASE_NONE); | 1688 net::NetLog::PHASE_NONE); |
| 1689 | 1689 |
| 1690 if (pos < static_cast<int>(entries.size())) { | 1690 if (pos < static_cast<int>(entries.size())) { |
| 1691 CapturingNetLog::CapturedEntry entry = entries[pos]; | 1691 TestNetLog::CapturedEntry entry = entries[pos]; |
| 1692 int error_code = 0; | 1692 int error_code = 0; |
| 1693 ASSERT_TRUE(entry.GetNetErrorCode(&error_code)); | 1693 ASSERT_TRUE(entry.GetNetErrorCode(&error_code)); |
| 1694 EXPECT_EQ(OK, error_code); | 1694 EXPECT_EQ(OK, error_code); |
| 1695 } else { | 1695 } else { |
| 1696 ADD_FAILURE(); | 1696 ADD_FAILURE(); |
| 1697 } | 1697 } |
| 1698 } | 1698 } |
| 1699 | 1699 |
| 1700 TEST_P(SpdySessionTest, NetLogOnSessionEOF) { | 1700 TEST_P(SpdySessionTest, NetLogOnSessionEOF) { |
| 1701 session_deps_.host_resolver->set_synchronous_mode(true); | 1701 session_deps_.host_resolver->set_synchronous_mode(true); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1716 CreateInsecureSpdySession(http_session_, key_, log.bound()); | 1716 CreateInsecureSpdySession(http_session_, key_, log.bound()); |
| 1717 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_)); | 1717 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_)); |
| 1718 | 1718 |
| 1719 // Flush the read completion task. | 1719 // Flush the read completion task. |
| 1720 base::MessageLoop::current()->RunUntilIdle(); | 1720 base::MessageLoop::current()->RunUntilIdle(); |
| 1721 | 1721 |
| 1722 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_)); | 1722 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_)); |
| 1723 EXPECT_TRUE(session == NULL); | 1723 EXPECT_TRUE(session == NULL); |
| 1724 | 1724 |
| 1725 // Check that the NetLog was filled reasonably. | 1725 // Check that the NetLog was filled reasonably. |
| 1726 net::CapturingNetLog::CapturedEntryList entries; | 1726 net::TestNetLog::CapturedEntryList entries; |
| 1727 log.GetEntries(&entries); | 1727 log.GetEntries(&entries); |
| 1728 EXPECT_LT(0u, entries.size()); | 1728 EXPECT_LT(0u, entries.size()); |
| 1729 | 1729 |
| 1730 // Check that we logged SPDY_SESSION_CLOSE correctly. | 1730 // Check that we logged SPDY_SESSION_CLOSE correctly. |
| 1731 int pos = net::ExpectLogContainsSomewhere( | 1731 int pos = net::ExpectLogContainsSomewhere( |
| 1732 entries, 0, net::NetLog::TYPE_HTTP2_SESSION_CLOSE, | 1732 entries, 0, net::NetLog::TYPE_HTTP2_SESSION_CLOSE, |
| 1733 net::NetLog::PHASE_NONE); | 1733 net::NetLog::PHASE_NONE); |
| 1734 | 1734 |
| 1735 if (pos < static_cast<int>(entries.size())) { | 1735 if (pos < static_cast<int>(entries.size())) { |
| 1736 CapturingNetLog::CapturedEntry entry = entries[pos]; | 1736 TestNetLog::CapturedEntry entry = entries[pos]; |
| 1737 int error_code = 0; | 1737 int error_code = 0; |
| 1738 ASSERT_TRUE(entry.GetNetErrorCode(&error_code)); | 1738 ASSERT_TRUE(entry.GetNetErrorCode(&error_code)); |
| 1739 EXPECT_EQ(ERR_CONNECTION_CLOSED, error_code); | 1739 EXPECT_EQ(ERR_CONNECTION_CLOSED, error_code); |
| 1740 } else { | 1740 } else { |
| 1741 ADD_FAILURE(); | 1741 ADD_FAILURE(); |
| 1742 } | 1742 } |
| 1743 } | 1743 } |
| 1744 | 1744 |
| 1745 TEST_P(SpdySessionTest, SynCompressionHistograms) { | 1745 TEST_P(SpdySessionTest, SynCompressionHistograms) { |
| 1746 session_deps_.enable_compression = true; | 1746 session_deps_.enable_compression = true; |
| (...skipping 3401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5148 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), | 5148 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), |
| 5149 "spdy_pooling.pem"); | 5149 "spdy_pooling.pem"); |
| 5150 ssl_info.is_issued_by_known_root = true; | 5150 ssl_info.is_issued_by_known_root = true; |
| 5151 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); | 5151 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); |
| 5152 | 5152 |
| 5153 EXPECT_TRUE(SpdySession::CanPool( | 5153 EXPECT_TRUE(SpdySession::CanPool( |
| 5154 &tss, ssl_info, "www.example.org", "mail.example.org")); | 5154 &tss, ssl_info, "www.example.org", "mail.example.org")); |
| 5155 } | 5155 } |
| 5156 | 5156 |
| 5157 } // namespace net | 5157 } // namespace net |
| OLD | NEW |