Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: net/spdy/spdy_session_unittest.cc

Issue 1904483004: Change SupportsSpdy dict, SpdySettingsMap, ServerNetworkStatsMap, AlternativeServiceMap and disk da… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile after sync code, introduced by commit 388755 Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/spdy/spdy_session.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 SpdySessionTest() 129 SpdySessionTest()
130 : old_max_group_sockets_(ClientSocketPoolManager::max_sockets_per_group( 130 : old_max_group_sockets_(ClientSocketPoolManager::max_sockets_per_group(
131 HttpNetworkSession::NORMAL_SOCKET_POOL)), 131 HttpNetworkSession::NORMAL_SOCKET_POOL)),
132 old_max_pool_sockets_(ClientSocketPoolManager::max_sockets_per_pool( 132 old_max_pool_sockets_(ClientSocketPoolManager::max_sockets_per_pool(
133 HttpNetworkSession::NORMAL_SOCKET_POOL)), 133 HttpNetworkSession::NORMAL_SOCKET_POOL)),
134 spdy_util_(GetProtocol(), GetDependenciesFromPriority()), 134 spdy_util_(GetProtocol(), GetDependenciesFromPriority()),
135 session_deps_(GetProtocol()), 135 session_deps_(GetProtocol()),
136 spdy_session_pool_(nullptr), 136 spdy_session_pool_(nullptr),
137 test_url_(kDefaultURL), 137 test_url_(kDefaultURL),
138 test_host_port_pair_(HostPortPair::FromURL(test_url_)), 138 test_server_(test_url_),
139 key_(test_host_port_pair_, 139 key_(HostPortPair::FromURL(test_url_),
140 ProxyServer::Direct(), 140 ProxyServer::Direct(),
141 PRIVACY_MODE_DISABLED) { 141 PRIVACY_MODE_DISABLED) {
142 session_deps_.enable_priority_dependencies = GetDependenciesFromPriority(); 142 session_deps_.enable_priority_dependencies = GetDependenciesFromPriority();
143 } 143 }
144 144
145 virtual ~SpdySessionTest() { 145 virtual ~SpdySessionTest() {
146 // Important to restore the per-pool limit first, since the pool limit must 146 // Important to restore the per-pool limit first, since the pool limit must
147 // always be greater than group limit, and the tests reduce both limits. 147 // always be greater than group limit, and the tests reduce both limits.
148 ClientSocketPoolManager::set_max_sockets_per_pool( 148 ClientSocketPoolManager::set_max_sockets_per_pool(
149 HttpNetworkSession::NORMAL_SOCKET_POOL, old_max_pool_sockets_); 149 HttpNetworkSession::NORMAL_SOCKET_POOL, old_max_pool_sockets_);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 // them once each test has been run. 203 // them once each test has been run.
204 int old_max_group_sockets_; 204 int old_max_group_sockets_;
205 int old_max_pool_sockets_; 205 int old_max_pool_sockets_;
206 206
207 SpdyTestUtil spdy_util_; 207 SpdyTestUtil spdy_util_;
208 SpdySessionDependencies session_deps_; 208 SpdySessionDependencies session_deps_;
209 std::unique_ptr<HttpNetworkSession> http_session_; 209 std::unique_ptr<HttpNetworkSession> http_session_;
210 base::WeakPtr<SpdySession> session_; 210 base::WeakPtr<SpdySession> session_;
211 SpdySessionPool* spdy_session_pool_; 211 SpdySessionPool* spdy_session_pool_;
212 GURL test_url_; 212 GURL test_url_;
213 HostPortPair test_host_port_pair_; 213 url::SchemeHostPort test_server_;
214 SpdySessionKey key_; 214 SpdySessionKey key_;
215 BoundTestNetLog log_; 215 BoundTestNetLog log_;
216 }; 216 };
217 217
218 INSTANTIATE_TEST_CASE_P(ProtoPlusDepend, 218 INSTANTIATE_TEST_CASE_P(ProtoPlusDepend,
219 SpdySessionTest, 219 SpdySessionTest,
220 testing::Values(kTestCaseSPDY31, 220 testing::Values(kTestCaseSPDY31,
221 kTestCaseHTTP2NoPriorityDependencies, 221 kTestCaseHTTP2NoPriorityDependencies,
222 kTestCaseHTTP2PriorityDependencies)); 222 kTestCaseHTTP2PriorityDependencies));
223 223
(...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1539 MockRead(ASYNC, 0, 2), 1539 MockRead(ASYNC, 0, 2),
1540 }; 1540 };
1541 1541
1542 SequencedSocketData data(reads, arraysize(reads), nullptr, 0); 1542 SequencedSocketData data(reads, arraysize(reads), nullptr, 0);
1543 session_deps_.socket_factory->AddSocketDataProvider(&data); 1543 session_deps_.socket_factory->AddSocketDataProvider(&data);
1544 1544
1545 CreateNetworkSession(); 1545 CreateNetworkSession();
1546 1546
1547 // Initialize the SpdySetting with the default. 1547 // Initialize the SpdySetting with the default.
1548 spdy_session_pool_->http_server_properties()->SetSpdySetting( 1548 spdy_session_pool_->http_server_properties()->SetSpdySetting(
1549 test_host_port_pair_, 1549 test_server_, SETTINGS_MAX_CONCURRENT_STREAMS,
1550 SETTINGS_MAX_CONCURRENT_STREAMS, 1550 SETTINGS_FLAG_PLEASE_PERSIST, kInitialMaxConcurrentStreams);
1551 SETTINGS_FLAG_PLEASE_PERSIST,
1552 kInitialMaxConcurrentStreams);
1553 1551
1554 EXPECT_FALSE( 1552 EXPECT_FALSE(spdy_session_pool_->http_server_properties()
1555 spdy_session_pool_->http_server_properties()->GetSpdySettings( 1553 ->GetSpdySettings(test_server_)
1556 test_host_port_pair_).empty()); 1554 .empty());
1557 1555
1558 CreateInsecureSpdySession(); 1556 CreateInsecureSpdySession();
1559 1557
1560 // Create the maximum number of concurrent streams. 1558 // Create the maximum number of concurrent streams.
1561 for (size_t i = 0; i < kInitialMaxConcurrentStreams; ++i) { 1559 for (size_t i = 0; i < kInitialMaxConcurrentStreams; ++i) {
1562 base::WeakPtr<SpdyStream> spdy_stream = CreateStreamSynchronously( 1560 base::WeakPtr<SpdyStream> spdy_stream = CreateStreamSynchronously(
1563 SPDY_BIDIRECTIONAL_STREAM, session_, test_url_, MEDIUM, BoundNetLog()); 1561 SPDY_BIDIRECTIONAL_STREAM, session_, test_url_, MEDIUM, BoundNetLog());
1564 ASSERT_TRUE(spdy_stream != nullptr); 1562 ASSERT_TRUE(spdy_stream != nullptr);
1565 } 1563 }
1566 1564
1567 StreamReleaserCallback stream_releaser; 1565 StreamReleaserCallback stream_releaser;
1568 1566
1569 SpdyStreamRequest request; 1567 SpdyStreamRequest request;
1570 ASSERT_EQ(ERR_IO_PENDING, 1568 ASSERT_EQ(ERR_IO_PENDING,
1571 request.StartRequest(SPDY_BIDIRECTIONAL_STREAM, session_, test_url_, 1569 request.StartRequest(SPDY_BIDIRECTIONAL_STREAM, session_, test_url_,
1572 MEDIUM, BoundNetLog(), 1570 MEDIUM, BoundNetLog(),
1573 stream_releaser.MakeCallback(&request))); 1571 stream_releaser.MakeCallback(&request)));
1574 1572
1575 base::RunLoop().RunUntilIdle(); 1573 base::RunLoop().RunUntilIdle();
1576 1574
1577 EXPECT_EQ(OK, stream_releaser.WaitForResult()); 1575 EXPECT_EQ(OK, stream_releaser.WaitForResult());
1578 1576
1579 // Make sure that persisted data is cleared. 1577 // Make sure that persisted data is cleared.
1580 EXPECT_TRUE( 1578 EXPECT_TRUE(spdy_session_pool_->http_server_properties()
1581 spdy_session_pool_->http_server_properties()->GetSpdySettings( 1579 ->GetSpdySettings(test_server_)
1582 test_host_port_pair_).empty()); 1580 .empty());
1583 1581
1584 // Make sure session's max_concurrent_streams is correct. 1582 // Make sure session's max_concurrent_streams is correct.
1585 EXPECT_EQ(kInitialMaxConcurrentStreams + 1, 1583 EXPECT_EQ(kInitialMaxConcurrentStreams + 1,
1586 session_->max_concurrent_streams_); 1584 session_->max_concurrent_streams_);
1587 1585
1588 data.Resume(); 1586 data.Resume();
1589 base::RunLoop().RunUntilIdle(); 1587 base::RunLoop().RunUntilIdle();
1590 EXPECT_FALSE(session_); 1588 EXPECT_FALSE(session_);
1591 } 1589 }
1592 1590
1593 // Start with max concurrent streams set to 1. Request two streams. 1591 // Start with max concurrent streams set to 1. Request two streams.
1594 // When the first completes, have the callback close its stream, which 1592 // When the first completes, have the callback close its stream, which
1595 // should trigger the second stream creation. Then cancel that one 1593 // should trigger the second stream creation. Then cancel that one
1596 // immediately. Don't crash. This is a regression test for 1594 // immediately. Don't crash. This is a regression test for
1597 // http://crbug.com/63532 . 1595 // http://crbug.com/63532 .
1598 TEST_P(SpdySessionTest, CancelPendingCreateStream) { 1596 TEST_P(SpdySessionTest, CancelPendingCreateStream) {
1599 session_deps_.host_resolver->set_synchronous_mode(true); 1597 session_deps_.host_resolver->set_synchronous_mode(true);
1600 1598
1601 MockRead reads[] = { 1599 MockRead reads[] = {
1602 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever. 1600 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever.
1603 }; 1601 };
1604 1602
1605 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0); 1603 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0);
1606 session_deps_.socket_factory->AddSocketDataProvider(&data); 1604 session_deps_.socket_factory->AddSocketDataProvider(&data);
1607 1605
1608 CreateNetworkSession(); 1606 CreateNetworkSession();
1609 1607
1610 // Initialize the SpdySetting with 1 max concurrent streams. 1608 // Initialize the SpdySetting with 1 max concurrent streams.
1611 spdy_session_pool_->http_server_properties()->SetSpdySetting( 1609 spdy_session_pool_->http_server_properties()->SetSpdySetting(
1612 test_host_port_pair_, 1610 test_server_, SETTINGS_MAX_CONCURRENT_STREAMS,
1613 SETTINGS_MAX_CONCURRENT_STREAMS, 1611 SETTINGS_FLAG_PLEASE_PERSIST, 1);
1614 SETTINGS_FLAG_PLEASE_PERSIST,
1615 1);
1616 1612
1617 CreateInsecureSpdySession(); 1613 CreateInsecureSpdySession();
1618 1614
1619 // Leave room for only one more stream to be created. 1615 // Leave room for only one more stream to be created.
1620 for (size_t i = 0; i < kInitialMaxConcurrentStreams - 1; ++i) { 1616 for (size_t i = 0; i < kInitialMaxConcurrentStreams - 1; ++i) {
1621 base::WeakPtr<SpdyStream> spdy_stream = CreateStreamSynchronously( 1617 base::WeakPtr<SpdyStream> spdy_stream = CreateStreamSynchronously(
1622 SPDY_BIDIRECTIONAL_STREAM, session_, test_url_, MEDIUM, BoundNetLog()); 1618 SPDY_BIDIRECTIONAL_STREAM, session_, test_url_, MEDIUM, BoundNetLog());
1623 ASSERT_TRUE(spdy_stream != nullptr); 1619 ASSERT_TRUE(spdy_stream != nullptr);
1624 } 1620 }
1625 1621
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1680 writes.push_back(CreateMockWrite(*server_settings_frame)); 1676 writes.push_back(CreateMockWrite(*server_settings_frame));
1681 } 1677 }
1682 1678
1683 StaticSocketDataProvider data(reads, arraysize(reads), writes.data(), 1679 StaticSocketDataProvider data(reads, arraysize(reads), writes.data(),
1684 writes.size()); 1680 writes.size());
1685 session_deps_.socket_factory->AddSocketDataProvider(&data); 1681 session_deps_.socket_factory->AddSocketDataProvider(&data);
1686 1682
1687 CreateNetworkSession(); 1683 CreateNetworkSession();
1688 1684
1689 spdy_session_pool_->http_server_properties()->SetSpdySetting( 1685 spdy_session_pool_->http_server_properties()->SetSpdySetting(
1690 test_host_port_pair_, 1686 test_server_, SETTINGS_MAX_CONCURRENT_STREAMS,
1691 SETTINGS_MAX_CONCURRENT_STREAMS, 1687 SETTINGS_FLAG_PLEASE_PERSIST, initial_max_concurrent_streams);
1692 SETTINGS_FLAG_PLEASE_PERSIST,
1693 initial_max_concurrent_streams);
1694 1688
1695 SpdySessionPoolPeer pool_peer(spdy_session_pool_); 1689 SpdySessionPoolPeer pool_peer(spdy_session_pool_);
1696 pool_peer.SetEnableSendingInitialData(true); 1690 pool_peer.SetEnableSendingInitialData(true);
1697 1691
1698 CreateInsecureSpdySession(); 1692 CreateInsecureSpdySession();
1699 1693
1700 base::RunLoop().RunUntilIdle(); 1694 base::RunLoop().RunUntilIdle();
1701 EXPECT_TRUE(data.AllWriteDataConsumed()); 1695 EXPECT_TRUE(data.AllWriteDataConsumed());
1702 } 1696 }
1703 1697
1704 TEST_P(SpdySessionTest, ClearSettingsStorageOnIPAddressChanged) { 1698 TEST_P(SpdySessionTest, ClearSettingsStorageOnIPAddressChanged) {
1705 CreateNetworkSession(); 1699 CreateNetworkSession();
1706 1700
1707 base::WeakPtr<HttpServerProperties> test_http_server_properties = 1701 base::WeakPtr<HttpServerProperties> test_http_server_properties =
1708 spdy_session_pool_->http_server_properties(); 1702 spdy_session_pool_->http_server_properties();
1709 SettingsFlagsAndValue flags_and_value1(SETTINGS_FLAG_PLEASE_PERSIST, 2); 1703 SettingsFlagsAndValue flags_and_value1(SETTINGS_FLAG_PLEASE_PERSIST, 2);
1710 test_http_server_properties->SetSpdySetting( 1704 test_http_server_properties->SetSpdySetting(test_server_,
1711 test_host_port_pair_, 1705 SETTINGS_MAX_CONCURRENT_STREAMS,
1712 SETTINGS_MAX_CONCURRENT_STREAMS, 1706 SETTINGS_FLAG_PLEASE_PERSIST, 2);
1713 SETTINGS_FLAG_PLEASE_PERSIST, 1707 EXPECT_NE(0u,
1714 2); 1708 test_http_server_properties->GetSpdySettings(test_server_).size());
1715 EXPECT_NE(0u, test_http_server_properties->GetSpdySettings(
1716 test_host_port_pair_).size());
1717 spdy_session_pool_->OnIPAddressChanged(); 1709 spdy_session_pool_->OnIPAddressChanged();
1718 EXPECT_EQ(0u, test_http_server_properties->GetSpdySettings( 1710 EXPECT_EQ(0u,
1719 test_host_port_pair_).size()); 1711 test_http_server_properties->GetSpdySettings(test_server_).size());
1720 } 1712 }
1721 1713
1722 TEST_P(SpdySessionTest, Initialize) { 1714 TEST_P(SpdySessionTest, Initialize) {
1723 session_deps_.host_resolver->set_synchronous_mode(true); 1715 session_deps_.host_resolver->set_synchronous_mode(true);
1724 1716
1725 MockRead reads[] = { 1717 MockRead reads[] = {
1726 MockRead(ASYNC, 0, 0) // EOF 1718 MockRead(ASYNC, 0, 0) // EOF
1727 }; 1719 };
1728 1720
1729 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0); 1721 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0);
(...skipping 3748 matching lines...) Expand 10 before | Expand all | Expand 10 after
5478 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), 5470 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(),
5479 "spdy_pooling.pem"); 5471 "spdy_pooling.pem");
5480 ssl_info.is_issued_by_known_root = true; 5472 ssl_info.is_issued_by_known_root = true;
5481 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); 5473 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin));
5482 5474
5483 EXPECT_TRUE(SpdySession::CanPool( 5475 EXPECT_TRUE(SpdySession::CanPool(
5484 &tss, ssl_info, "www.example.org", "mail.example.org")); 5476 &tss, ssl_info, "www.example.org", "mail.example.org"));
5485 } 5477 }
5486 5478
5487 } // namespace net 5479 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698