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

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

Issue 1866983006: SHP 2: Change SpdySettingsMap to use SchemeHostPort as the key. No change to Pref data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@SHP_1
Patch Set: 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
« net/spdy/spdy_session.h ('K') | « 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 <utility> 7 #include <utility>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.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 scoped_ptr<HttpNetworkSession> http_session_; 209 scoped_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 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 MockRead(ASYNC, 0, 2), 1520 MockRead(ASYNC, 0, 2),
1521 }; 1521 };
1522 1522
1523 SequencedSocketData data(reads, arraysize(reads), nullptr, 0); 1523 SequencedSocketData data(reads, arraysize(reads), nullptr, 0);
1524 session_deps_.socket_factory->AddSocketDataProvider(&data); 1524 session_deps_.socket_factory->AddSocketDataProvider(&data);
1525 1525
1526 CreateNetworkSession(); 1526 CreateNetworkSession();
1527 1527
1528 // Initialize the SpdySetting with the default. 1528 // Initialize the SpdySetting with the default.
1529 spdy_session_pool_->http_server_properties()->SetSpdySetting( 1529 spdy_session_pool_->http_server_properties()->SetSpdySetting(
1530 test_host_port_pair_, 1530 test_server_,
1531 SETTINGS_MAX_CONCURRENT_STREAMS, 1531 SETTINGS_MAX_CONCURRENT_STREAMS,
1532 SETTINGS_FLAG_PLEASE_PERSIST, 1532 SETTINGS_FLAG_PLEASE_PERSIST,
1533 kInitialMaxConcurrentStreams); 1533 kInitialMaxConcurrentStreams);
1534 1534
1535 EXPECT_FALSE( 1535 EXPECT_FALSE(
1536 spdy_session_pool_->http_server_properties()->GetSpdySettings( 1536 spdy_session_pool_->http_server_properties()->GetSpdySettings(
1537 test_host_port_pair_).empty()); 1537 test_server_).empty());
1538 1538
1539 CreateInsecureSpdySession(); 1539 CreateInsecureSpdySession();
1540 1540
1541 // Create the maximum number of concurrent streams. 1541 // Create the maximum number of concurrent streams.
1542 for (size_t i = 0; i < kInitialMaxConcurrentStreams; ++i) { 1542 for (size_t i = 0; i < kInitialMaxConcurrentStreams; ++i) {
1543 base::WeakPtr<SpdyStream> spdy_stream = CreateStreamSynchronously( 1543 base::WeakPtr<SpdyStream> spdy_stream = CreateStreamSynchronously(
1544 SPDY_BIDIRECTIONAL_STREAM, session_, test_url_, MEDIUM, BoundNetLog()); 1544 SPDY_BIDIRECTIONAL_STREAM, session_, test_url_, MEDIUM, BoundNetLog());
1545 ASSERT_TRUE(spdy_stream != nullptr); 1545 ASSERT_TRUE(spdy_stream != nullptr);
1546 } 1546 }
1547 1547
1548 StreamReleaserCallback stream_releaser; 1548 StreamReleaserCallback stream_releaser;
1549 1549
1550 SpdyStreamRequest request; 1550 SpdyStreamRequest request;
1551 ASSERT_EQ(ERR_IO_PENDING, 1551 ASSERT_EQ(ERR_IO_PENDING,
1552 request.StartRequest(SPDY_BIDIRECTIONAL_STREAM, session_, test_url_, 1552 request.StartRequest(SPDY_BIDIRECTIONAL_STREAM, session_, test_url_,
1553 MEDIUM, BoundNetLog(), 1553 MEDIUM, BoundNetLog(),
1554 stream_releaser.MakeCallback(&request))); 1554 stream_releaser.MakeCallback(&request)));
1555 1555
1556 base::RunLoop().RunUntilIdle(); 1556 base::RunLoop().RunUntilIdle();
1557 1557
1558 EXPECT_EQ(OK, stream_releaser.WaitForResult()); 1558 EXPECT_EQ(OK, stream_releaser.WaitForResult());
1559 1559
1560 // Make sure that persisted data is cleared. 1560 // Make sure that persisted data is cleared.
1561 EXPECT_TRUE( 1561 EXPECT_TRUE(
1562 spdy_session_pool_->http_server_properties()->GetSpdySettings( 1562 spdy_session_pool_->http_server_properties()->GetSpdySettings(
1563 test_host_port_pair_).empty()); 1563 test_server_).empty());
1564 1564
1565 // Make sure session's max_concurrent_streams is correct. 1565 // Make sure session's max_concurrent_streams is correct.
1566 EXPECT_EQ(kInitialMaxConcurrentStreams + 1, 1566 EXPECT_EQ(kInitialMaxConcurrentStreams + 1,
1567 session_->max_concurrent_streams_); 1567 session_->max_concurrent_streams_);
1568 1568
1569 data.Resume(); 1569 data.Resume();
1570 base::RunLoop().RunUntilIdle(); 1570 base::RunLoop().RunUntilIdle();
1571 EXPECT_FALSE(session_); 1571 EXPECT_FALSE(session_);
1572 } 1572 }
1573 1573
1574 // Start with max concurrent streams set to 1. Request two streams. 1574 // Start with max concurrent streams set to 1. Request two streams.
1575 // When the first completes, have the callback close its stream, which 1575 // When the first completes, have the callback close its stream, which
1576 // should trigger the second stream creation. Then cancel that one 1576 // should trigger the second stream creation. Then cancel that one
1577 // immediately. Don't crash. This is a regression test for 1577 // immediately. Don't crash. This is a regression test for
1578 // http://crbug.com/63532 . 1578 // http://crbug.com/63532 .
1579 TEST_P(SpdySessionTest, CancelPendingCreateStream) { 1579 TEST_P(SpdySessionTest, CancelPendingCreateStream) {
1580 session_deps_.host_resolver->set_synchronous_mode(true); 1580 session_deps_.host_resolver->set_synchronous_mode(true);
1581 1581
1582 MockRead reads[] = { 1582 MockRead reads[] = {
1583 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever. 1583 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever.
1584 }; 1584 };
1585 1585
1586 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0); 1586 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0);
1587 session_deps_.socket_factory->AddSocketDataProvider(&data); 1587 session_deps_.socket_factory->AddSocketDataProvider(&data);
1588 1588
1589 CreateNetworkSession(); 1589 CreateNetworkSession();
1590 1590
1591 // Initialize the SpdySetting with 1 max concurrent streams. 1591 // Initialize the SpdySetting with 1 max concurrent streams.
1592 spdy_session_pool_->http_server_properties()->SetSpdySetting( 1592 spdy_session_pool_->http_server_properties()->SetSpdySetting(
1593 test_host_port_pair_, 1593 test_server_,
1594 SETTINGS_MAX_CONCURRENT_STREAMS, 1594 SETTINGS_MAX_CONCURRENT_STREAMS,
1595 SETTINGS_FLAG_PLEASE_PERSIST, 1595 SETTINGS_FLAG_PLEASE_PERSIST,
1596 1); 1596 1);
1597 1597
1598 CreateInsecureSpdySession(); 1598 CreateInsecureSpdySession();
1599 1599
1600 // Leave room for only one more stream to be created. 1600 // Leave room for only one more stream to be created.
1601 for (size_t i = 0; i < kInitialMaxConcurrentStreams - 1; ++i) { 1601 for (size_t i = 0; i < kInitialMaxConcurrentStreams - 1; ++i) {
1602 base::WeakPtr<SpdyStream> spdy_stream = CreateStreamSynchronously( 1602 base::WeakPtr<SpdyStream> spdy_stream = CreateStreamSynchronously(
1603 SPDY_BIDIRECTIONAL_STREAM, session_, test_url_, MEDIUM, BoundNetLog()); 1603 SPDY_BIDIRECTIONAL_STREAM, session_, test_url_, MEDIUM, BoundNetLog());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1661 writes.push_back(CreateMockWrite(*server_settings_frame)); 1661 writes.push_back(CreateMockWrite(*server_settings_frame));
1662 } 1662 }
1663 1663
1664 StaticSocketDataProvider data(reads, arraysize(reads), writes.data(), 1664 StaticSocketDataProvider data(reads, arraysize(reads), writes.data(),
1665 writes.size()); 1665 writes.size());
1666 session_deps_.socket_factory->AddSocketDataProvider(&data); 1666 session_deps_.socket_factory->AddSocketDataProvider(&data);
1667 1667
1668 CreateNetworkSession(); 1668 CreateNetworkSession();
1669 1669
1670 spdy_session_pool_->http_server_properties()->SetSpdySetting( 1670 spdy_session_pool_->http_server_properties()->SetSpdySetting(
1671 test_host_port_pair_, 1671 test_server_,
1672 SETTINGS_MAX_CONCURRENT_STREAMS, 1672 SETTINGS_MAX_CONCURRENT_STREAMS,
1673 SETTINGS_FLAG_PLEASE_PERSIST, 1673 SETTINGS_FLAG_PLEASE_PERSIST,
1674 initial_max_concurrent_streams); 1674 initial_max_concurrent_streams);
1675 1675
1676 SpdySessionPoolPeer pool_peer(spdy_session_pool_); 1676 SpdySessionPoolPeer pool_peer(spdy_session_pool_);
1677 pool_peer.SetEnableSendingInitialData(true); 1677 pool_peer.SetEnableSendingInitialData(true);
1678 1678
1679 CreateInsecureSpdySession(); 1679 CreateInsecureSpdySession();
1680 1680
1681 base::RunLoop().RunUntilIdle(); 1681 base::RunLoop().RunUntilIdle();
1682 EXPECT_TRUE(data.AllWriteDataConsumed()); 1682 EXPECT_TRUE(data.AllWriteDataConsumed());
1683 } 1683 }
1684 1684
1685 TEST_P(SpdySessionTest, ClearSettingsStorageOnIPAddressChanged) { 1685 TEST_P(SpdySessionTest, ClearSettingsStorageOnIPAddressChanged) {
1686 CreateNetworkSession(); 1686 CreateNetworkSession();
1687 1687
1688 base::WeakPtr<HttpServerProperties> test_http_server_properties = 1688 base::WeakPtr<HttpServerProperties> test_http_server_properties =
1689 spdy_session_pool_->http_server_properties(); 1689 spdy_session_pool_->http_server_properties();
1690 SettingsFlagsAndValue flags_and_value1(SETTINGS_FLAG_PLEASE_PERSIST, 2); 1690 SettingsFlagsAndValue flags_and_value1(SETTINGS_FLAG_PLEASE_PERSIST, 2);
1691 test_http_server_properties->SetSpdySetting( 1691 test_http_server_properties->SetSpdySetting(
1692 test_host_port_pair_, 1692 test_server_,
1693 SETTINGS_MAX_CONCURRENT_STREAMS, 1693 SETTINGS_MAX_CONCURRENT_STREAMS,
1694 SETTINGS_FLAG_PLEASE_PERSIST, 1694 SETTINGS_FLAG_PLEASE_PERSIST,
1695 2); 1695 2);
1696 EXPECT_NE(0u, test_http_server_properties->GetSpdySettings( 1696 EXPECT_NE(0u, test_http_server_properties->GetSpdySettings(
1697 test_host_port_pair_).size()); 1697 test_server_).size());
1698 spdy_session_pool_->OnIPAddressChanged(); 1698 spdy_session_pool_->OnIPAddressChanged();
1699 EXPECT_EQ(0u, test_http_server_properties->GetSpdySettings( 1699 EXPECT_EQ(0u, test_http_server_properties->GetSpdySettings(
1700 test_host_port_pair_).size()); 1700 test_server_).size());
1701 } 1701 }
1702 1702
1703 TEST_P(SpdySessionTest, Initialize) { 1703 TEST_P(SpdySessionTest, Initialize) {
1704 session_deps_.host_resolver->set_synchronous_mode(true); 1704 session_deps_.host_resolver->set_synchronous_mode(true);
1705 1705
1706 MockRead reads[] = { 1706 MockRead reads[] = {
1707 MockRead(ASYNC, 0, 0) // EOF 1707 MockRead(ASYNC, 0, 0) // EOF
1708 }; 1708 };
1709 1709
1710 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0); 1710 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0);
(...skipping 3730 matching lines...) Expand 10 before | Expand all | Expand 10 after
5441 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), 5441 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(),
5442 "spdy_pooling.pem"); 5442 "spdy_pooling.pem");
5443 ssl_info.is_issued_by_known_root = true; 5443 ssl_info.is_issued_by_known_root = true;
5444 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); 5444 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin));
5445 5445
5446 EXPECT_TRUE(SpdySession::CanPool( 5446 EXPECT_TRUE(SpdySession::CanPool(
5447 &tss, ssl_info, "www.example.org", "mail.example.org")); 5447 &tss, ssl_info, "www.example.org", "mail.example.org"));
5448 } 5448 }
5449 5449
5450 } // namespace net 5450 } // namespace net
OLDNEW
« net/spdy/spdy_session.h ('K') | « net/spdy/spdy_session.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698