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

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: remove commented line 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.cc ('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 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 MockRead(ASYNC, 0, 2), 1529 MockRead(ASYNC, 0, 2),
1530 }; 1530 };
1531 1531
1532 SequencedSocketData data(reads, arraysize(reads), nullptr, 0); 1532 SequencedSocketData data(reads, arraysize(reads), nullptr, 0);
1533 session_deps_.socket_factory->AddSocketDataProvider(&data); 1533 session_deps_.socket_factory->AddSocketDataProvider(&data);
1534 1534
1535 CreateNetworkSession(); 1535 CreateNetworkSession();
1536 1536
1537 // Initialize the SpdySetting with the default. 1537 // Initialize the SpdySetting with the default.
1538 spdy_session_pool_->http_server_properties()->SetSpdySetting( 1538 spdy_session_pool_->http_server_properties()->SetSpdySetting(
1539 test_host_port_pair_, 1539 test_server_,
1540 SETTINGS_MAX_CONCURRENT_STREAMS, 1540 SETTINGS_MAX_CONCURRENT_STREAMS,
1541 SETTINGS_FLAG_PLEASE_PERSIST, 1541 SETTINGS_FLAG_PLEASE_PERSIST,
1542 kInitialMaxConcurrentStreams); 1542 kInitialMaxConcurrentStreams);
1543 1543
1544 EXPECT_FALSE( 1544 EXPECT_FALSE(
1545 spdy_session_pool_->http_server_properties()->GetSpdySettings( 1545 spdy_session_pool_->http_server_properties()->GetSpdySettings(
1546 test_host_port_pair_).empty()); 1546 test_server_).empty());
1547 1547
1548 CreateInsecureSpdySession(); 1548 CreateInsecureSpdySession();
1549 1549
1550 // Create the maximum number of concurrent streams. 1550 // Create the maximum number of concurrent streams.
1551 for (size_t i = 0; i < kInitialMaxConcurrentStreams; ++i) { 1551 for (size_t i = 0; i < kInitialMaxConcurrentStreams; ++i) {
1552 base::WeakPtr<SpdyStream> spdy_stream = CreateStreamSynchronously( 1552 base::WeakPtr<SpdyStream> spdy_stream = CreateStreamSynchronously(
1553 SPDY_BIDIRECTIONAL_STREAM, session_, test_url_, MEDIUM, BoundNetLog()); 1553 SPDY_BIDIRECTIONAL_STREAM, session_, test_url_, MEDIUM, BoundNetLog());
1554 ASSERT_TRUE(spdy_stream != nullptr); 1554 ASSERT_TRUE(spdy_stream != nullptr);
1555 } 1555 }
1556 1556
1557 StreamReleaserCallback stream_releaser; 1557 StreamReleaserCallback stream_releaser;
1558 1558
1559 SpdyStreamRequest request; 1559 SpdyStreamRequest request;
1560 ASSERT_EQ(ERR_IO_PENDING, 1560 ASSERT_EQ(ERR_IO_PENDING,
1561 request.StartRequest(SPDY_BIDIRECTIONAL_STREAM, session_, test_url_, 1561 request.StartRequest(SPDY_BIDIRECTIONAL_STREAM, session_, test_url_,
1562 MEDIUM, BoundNetLog(), 1562 MEDIUM, BoundNetLog(),
1563 stream_releaser.MakeCallback(&request))); 1563 stream_releaser.MakeCallback(&request)));
1564 1564
1565 base::RunLoop().RunUntilIdle(); 1565 base::RunLoop().RunUntilIdle();
1566 1566
1567 EXPECT_EQ(OK, stream_releaser.WaitForResult()); 1567 EXPECT_EQ(OK, stream_releaser.WaitForResult());
1568 1568
1569 // Make sure that persisted data is cleared. 1569 // Make sure that persisted data is cleared.
1570 EXPECT_TRUE( 1570 EXPECT_TRUE(
1571 spdy_session_pool_->http_server_properties()->GetSpdySettings( 1571 spdy_session_pool_->http_server_properties()->GetSpdySettings(
1572 test_host_port_pair_).empty()); 1572 test_server_).empty());
1573 1573
1574 // Make sure session's max_concurrent_streams is correct. 1574 // Make sure session's max_concurrent_streams is correct.
1575 EXPECT_EQ(kInitialMaxConcurrentStreams + 1, 1575 EXPECT_EQ(kInitialMaxConcurrentStreams + 1,
1576 session_->max_concurrent_streams_); 1576 session_->max_concurrent_streams_);
1577 1577
1578 data.Resume(); 1578 data.Resume();
1579 base::RunLoop().RunUntilIdle(); 1579 base::RunLoop().RunUntilIdle();
1580 EXPECT_FALSE(session_); 1580 EXPECT_FALSE(session_);
1581 } 1581 }
1582 1582
1583 // Start with max concurrent streams set to 1. Request two streams. 1583 // Start with max concurrent streams set to 1. Request two streams.
1584 // When the first completes, have the callback close its stream, which 1584 // When the first completes, have the callback close its stream, which
1585 // should trigger the second stream creation. Then cancel that one 1585 // should trigger the second stream creation. Then cancel that one
1586 // immediately. Don't crash. This is a regression test for 1586 // immediately. Don't crash. This is a regression test for
1587 // http://crbug.com/63532 . 1587 // http://crbug.com/63532 .
1588 TEST_P(SpdySessionTest, CancelPendingCreateStream) { 1588 TEST_P(SpdySessionTest, CancelPendingCreateStream) {
1589 session_deps_.host_resolver->set_synchronous_mode(true); 1589 session_deps_.host_resolver->set_synchronous_mode(true);
1590 1590
1591 MockRead reads[] = { 1591 MockRead reads[] = {
1592 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever. 1592 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever.
1593 }; 1593 };
1594 1594
1595 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0); 1595 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0);
1596 session_deps_.socket_factory->AddSocketDataProvider(&data); 1596 session_deps_.socket_factory->AddSocketDataProvider(&data);
1597 1597
1598 CreateNetworkSession(); 1598 CreateNetworkSession();
1599 1599
1600 // Initialize the SpdySetting with 1 max concurrent streams. 1600 // Initialize the SpdySetting with 1 max concurrent streams.
1601 spdy_session_pool_->http_server_properties()->SetSpdySetting( 1601 spdy_session_pool_->http_server_properties()->SetSpdySetting(
1602 test_host_port_pair_, 1602 test_server_,
1603 SETTINGS_MAX_CONCURRENT_STREAMS, 1603 SETTINGS_MAX_CONCURRENT_STREAMS,
1604 SETTINGS_FLAG_PLEASE_PERSIST, 1604 SETTINGS_FLAG_PLEASE_PERSIST,
1605 1); 1605 1);
1606 1606
1607 CreateInsecureSpdySession(); 1607 CreateInsecureSpdySession();
1608 1608
1609 // Leave room for only one more stream to be created. 1609 // Leave room for only one more stream to be created.
1610 for (size_t i = 0; i < kInitialMaxConcurrentStreams - 1; ++i) { 1610 for (size_t i = 0; i < kInitialMaxConcurrentStreams - 1; ++i) {
1611 base::WeakPtr<SpdyStream> spdy_stream = CreateStreamSynchronously( 1611 base::WeakPtr<SpdyStream> spdy_stream = CreateStreamSynchronously(
1612 SPDY_BIDIRECTIONAL_STREAM, session_, test_url_, MEDIUM, BoundNetLog()); 1612 SPDY_BIDIRECTIONAL_STREAM, session_, test_url_, MEDIUM, BoundNetLog());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 writes.push_back(CreateMockWrite(*server_settings_frame)); 1670 writes.push_back(CreateMockWrite(*server_settings_frame));
1671 } 1671 }
1672 1672
1673 StaticSocketDataProvider data(reads, arraysize(reads), writes.data(), 1673 StaticSocketDataProvider data(reads, arraysize(reads), writes.data(),
1674 writes.size()); 1674 writes.size());
1675 session_deps_.socket_factory->AddSocketDataProvider(&data); 1675 session_deps_.socket_factory->AddSocketDataProvider(&data);
1676 1676
1677 CreateNetworkSession(); 1677 CreateNetworkSession();
1678 1678
1679 spdy_session_pool_->http_server_properties()->SetSpdySetting( 1679 spdy_session_pool_->http_server_properties()->SetSpdySetting(
1680 test_host_port_pair_, 1680 test_server_,
1681 SETTINGS_MAX_CONCURRENT_STREAMS, 1681 SETTINGS_MAX_CONCURRENT_STREAMS,
1682 SETTINGS_FLAG_PLEASE_PERSIST, 1682 SETTINGS_FLAG_PLEASE_PERSIST,
1683 initial_max_concurrent_streams); 1683 initial_max_concurrent_streams);
1684 1684
1685 SpdySessionPoolPeer pool_peer(spdy_session_pool_); 1685 SpdySessionPoolPeer pool_peer(spdy_session_pool_);
1686 pool_peer.SetEnableSendingInitialData(true); 1686 pool_peer.SetEnableSendingInitialData(true);
1687 1687
1688 CreateInsecureSpdySession(); 1688 CreateInsecureSpdySession();
1689 1689
1690 base::RunLoop().RunUntilIdle(); 1690 base::RunLoop().RunUntilIdle();
1691 EXPECT_TRUE(data.AllWriteDataConsumed()); 1691 EXPECT_TRUE(data.AllWriteDataConsumed());
1692 } 1692 }
1693 1693
1694 TEST_P(SpdySessionTest, ClearSettingsStorageOnIPAddressChanged) { 1694 TEST_P(SpdySessionTest, ClearSettingsStorageOnIPAddressChanged) {
1695 CreateNetworkSession(); 1695 CreateNetworkSession();
1696 1696
1697 base::WeakPtr<HttpServerProperties> test_http_server_properties = 1697 base::WeakPtr<HttpServerProperties> test_http_server_properties =
1698 spdy_session_pool_->http_server_properties(); 1698 spdy_session_pool_->http_server_properties();
1699 SettingsFlagsAndValue flags_and_value1(SETTINGS_FLAG_PLEASE_PERSIST, 2); 1699 SettingsFlagsAndValue flags_and_value1(SETTINGS_FLAG_PLEASE_PERSIST, 2);
1700 test_http_server_properties->SetSpdySetting( 1700 test_http_server_properties->SetSpdySetting(
1701 test_host_port_pair_, 1701 test_server_,
1702 SETTINGS_MAX_CONCURRENT_STREAMS, 1702 SETTINGS_MAX_CONCURRENT_STREAMS,
1703 SETTINGS_FLAG_PLEASE_PERSIST, 1703 SETTINGS_FLAG_PLEASE_PERSIST,
1704 2); 1704 2);
1705 EXPECT_NE(0u, test_http_server_properties->GetSpdySettings( 1705 EXPECT_NE(0u, test_http_server_properties->GetSpdySettings(
1706 test_host_port_pair_).size()); 1706 test_server_).size());
1707 spdy_session_pool_->OnIPAddressChanged(); 1707 spdy_session_pool_->OnIPAddressChanged();
1708 EXPECT_EQ(0u, test_http_server_properties->GetSpdySettings( 1708 EXPECT_EQ(0u, test_http_server_properties->GetSpdySettings(
1709 test_host_port_pair_).size()); 1709 test_server_).size());
1710 } 1710 }
1711 1711
1712 TEST_P(SpdySessionTest, Initialize) { 1712 TEST_P(SpdySessionTest, Initialize) {
1713 session_deps_.host_resolver->set_synchronous_mode(true); 1713 session_deps_.host_resolver->set_synchronous_mode(true);
1714 1714
1715 MockRead reads[] = { 1715 MockRead reads[] = {
1716 MockRead(ASYNC, 0, 0) // EOF 1716 MockRead(ASYNC, 0, 0) // EOF
1717 }; 1717 };
1718 1718
1719 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0); 1719 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0);
(...skipping 3747 matching lines...) Expand 10 before | Expand all | Expand 10 after
5467 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), 5467 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(),
5468 "spdy_pooling.pem"); 5468 "spdy_pooling.pem");
5469 ssl_info.is_issued_by_known_root = true; 5469 ssl_info.is_issued_by_known_root = true;
5470 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); 5470 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin));
5471 5471
5472 EXPECT_TRUE(SpdySession::CanPool( 5472 EXPECT_TRUE(SpdySession::CanPool(
5473 &tss, ssl_info, "www.example.org", "mail.example.org")); 5473 &tss, ssl_info, "www.example.org", "mail.example.org"));
5474 } 5474 }
5475 5475
5476 } // namespace net 5476 } // namespace net
OLDNEW
« net/spdy/spdy_session.cc ('K') | « net/spdy/spdy_session.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698