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

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

Issue 1858093002: Alt-Svc 8: Change Supports SPDY list using SHP as the key. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@alt_svc_7
Patch Set: server pref changes 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') | url/scheme_host_port.h » ('j') | 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_host_port_pair_(HostPortPair::FromURL(test_url_)),
139 test_scheme_origin_(test_url_),
139 key_(test_host_port_pair_, 140 key_(test_host_port_pair_,
140 ProxyServer::Direct(), 141 ProxyServer::Direct(),
141 PRIVACY_MODE_DISABLED) { 142 PRIVACY_MODE_DISABLED) {
142 session_deps_.enable_priority_dependencies = GetDependenciesFromPriority(); 143 session_deps_.enable_priority_dependencies = GetDependenciesFromPriority();
143 } 144 }
144 145
145 virtual ~SpdySessionTest() { 146 virtual ~SpdySessionTest() {
146 // Important to restore the per-pool limit first, since the pool limit must 147 // 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. 148 // always be greater than group limit, and the tests reduce both limits.
148 ClientSocketPoolManager::set_max_sockets_per_pool( 149 ClientSocketPoolManager::set_max_sockets_per_pool(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 int old_max_group_sockets_; 205 int old_max_group_sockets_;
205 int old_max_pool_sockets_; 206 int old_max_pool_sockets_;
206 207
207 SpdyTestUtil spdy_util_; 208 SpdyTestUtil spdy_util_;
208 SpdySessionDependencies session_deps_; 209 SpdySessionDependencies session_deps_;
209 scoped_ptr<HttpNetworkSession> http_session_; 210 scoped_ptr<HttpNetworkSession> http_session_;
210 base::WeakPtr<SpdySession> session_; 211 base::WeakPtr<SpdySession> session_;
211 SpdySessionPool* spdy_session_pool_; 212 SpdySessionPool* spdy_session_pool_;
212 GURL test_url_; 213 GURL test_url_;
213 HostPortPair test_host_port_pair_; 214 HostPortPair test_host_port_pair_;
215 url::SchemeHostPort test_scheme_origin_;
214 SpdySessionKey key_; 216 SpdySessionKey key_;
215 BoundTestNetLog log_; 217 BoundTestNetLog log_;
216 }; 218 };
217 219
218 INSTANTIATE_TEST_CASE_P(ProtoPlusDepend, 220 INSTANTIATE_TEST_CASE_P(ProtoPlusDepend,
219 SpdySessionTest, 221 SpdySessionTest,
220 testing::Values(kTestCaseSPDY31, 222 testing::Values(kTestCaseSPDY31,
221 kTestCaseHTTP2NoPriorityDependencies, 223 kTestCaseHTTP2NoPriorityDependencies,
222 kTestCaseHTTP2PriorityDependencies)); 224 kTestCaseHTTP2PriorityDependencies));
223 225
(...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 MockRead(ASYNC, 0, 2), 1522 MockRead(ASYNC, 0, 2),
1521 }; 1523 };
1522 1524
1523 SequencedSocketData data(reads, arraysize(reads), nullptr, 0); 1525 SequencedSocketData data(reads, arraysize(reads), nullptr, 0);
1524 session_deps_.socket_factory->AddSocketDataProvider(&data); 1526 session_deps_.socket_factory->AddSocketDataProvider(&data);
1525 1527
1526 CreateNetworkSession(); 1528 CreateNetworkSession();
1527 1529
1528 // Initialize the SpdySetting with the default. 1530 // Initialize the SpdySetting with the default.
1529 spdy_session_pool_->http_server_properties()->SetSpdySetting( 1531 spdy_session_pool_->http_server_properties()->SetSpdySetting(
1530 test_host_port_pair_, 1532 test_scheme_origin_, SETTINGS_MAX_CONCURRENT_STREAMS,
1531 SETTINGS_MAX_CONCURRENT_STREAMS, 1533 SETTINGS_FLAG_PLEASE_PERSIST, kInitialMaxConcurrentStreams);
1532 SETTINGS_FLAG_PLEASE_PERSIST,
1533 kInitialMaxConcurrentStreams);
1534 1534
1535 EXPECT_FALSE( 1535 EXPECT_FALSE(spdy_session_pool_->http_server_properties()
1536 spdy_session_pool_->http_server_properties()->GetSpdySettings( 1536 ->GetSpdySettings(test_scheme_origin_)
1537 test_host_port_pair_).empty()); 1537 .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(spdy_session_pool_->http_server_properties()
1562 spdy_session_pool_->http_server_properties()->GetSpdySettings( 1562 ->GetSpdySettings(test_scheme_origin_)
1563 test_host_port_pair_).empty()); 1563 .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_scheme_origin_, SETTINGS_MAX_CONCURRENT_STREAMS,
1594 SETTINGS_MAX_CONCURRENT_STREAMS, 1594 SETTINGS_FLAG_PLEASE_PERSIST, 1);
1595 SETTINGS_FLAG_PLEASE_PERSIST,
1596 1);
1597 1595
1598 CreateInsecureSpdySession(); 1596 CreateInsecureSpdySession();
1599 1597
1600 // Leave room for only one more stream to be created. 1598 // Leave room for only one more stream to be created.
1601 for (size_t i = 0; i < kInitialMaxConcurrentStreams - 1; ++i) { 1599 for (size_t i = 0; i < kInitialMaxConcurrentStreams - 1; ++i) {
1602 base::WeakPtr<SpdyStream> spdy_stream = CreateStreamSynchronously( 1600 base::WeakPtr<SpdyStream> spdy_stream = CreateStreamSynchronously(
1603 SPDY_BIDIRECTIONAL_STREAM, session_, test_url_, MEDIUM, BoundNetLog()); 1601 SPDY_BIDIRECTIONAL_STREAM, session_, test_url_, MEDIUM, BoundNetLog());
1604 ASSERT_TRUE(spdy_stream != nullptr); 1602 ASSERT_TRUE(spdy_stream != nullptr);
1605 } 1603 }
1606 1604
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1661 writes.push_back(CreateMockWrite(*server_settings_frame)); 1659 writes.push_back(CreateMockWrite(*server_settings_frame));
1662 } 1660 }
1663 1661
1664 StaticSocketDataProvider data(reads, arraysize(reads), writes.data(), 1662 StaticSocketDataProvider data(reads, arraysize(reads), writes.data(),
1665 writes.size()); 1663 writes.size());
1666 session_deps_.socket_factory->AddSocketDataProvider(&data); 1664 session_deps_.socket_factory->AddSocketDataProvider(&data);
1667 1665
1668 CreateNetworkSession(); 1666 CreateNetworkSession();
1669 1667
1670 spdy_session_pool_->http_server_properties()->SetSpdySetting( 1668 spdy_session_pool_->http_server_properties()->SetSpdySetting(
1671 test_host_port_pair_, 1669 test_scheme_origin_, SETTINGS_MAX_CONCURRENT_STREAMS,
1672 SETTINGS_MAX_CONCURRENT_STREAMS, 1670 SETTINGS_FLAG_PLEASE_PERSIST, initial_max_concurrent_streams);
1673 SETTINGS_FLAG_PLEASE_PERSIST,
1674 initial_max_concurrent_streams);
1675 1671
1676 SpdySessionPoolPeer pool_peer(spdy_session_pool_); 1672 SpdySessionPoolPeer pool_peer(spdy_session_pool_);
1677 pool_peer.SetEnableSendingInitialData(true); 1673 pool_peer.SetEnableSendingInitialData(true);
1678 1674
1679 CreateInsecureSpdySession(); 1675 CreateInsecureSpdySession();
1680 1676
1681 base::RunLoop().RunUntilIdle(); 1677 base::RunLoop().RunUntilIdle();
1682 EXPECT_TRUE(data.AllWriteDataConsumed()); 1678 EXPECT_TRUE(data.AllWriteDataConsumed());
1683 } 1679 }
1684 1680
1685 TEST_P(SpdySessionTest, ClearSettingsStorageOnIPAddressChanged) { 1681 TEST_P(SpdySessionTest, ClearSettingsStorageOnIPAddressChanged) {
1686 CreateNetworkSession(); 1682 CreateNetworkSession();
1687 1683
1688 base::WeakPtr<HttpServerProperties> test_http_server_properties = 1684 base::WeakPtr<HttpServerProperties> test_http_server_properties =
1689 spdy_session_pool_->http_server_properties(); 1685 spdy_session_pool_->http_server_properties();
1690 SettingsFlagsAndValue flags_and_value1(SETTINGS_FLAG_PLEASE_PERSIST, 2); 1686 SettingsFlagsAndValue flags_and_value1(SETTINGS_FLAG_PLEASE_PERSIST, 2);
1691 test_http_server_properties->SetSpdySetting( 1687 test_http_server_properties->SetSpdySetting(test_scheme_origin_,
1692 test_host_port_pair_, 1688 SETTINGS_MAX_CONCURRENT_STREAMS,
1693 SETTINGS_MAX_CONCURRENT_STREAMS, 1689 SETTINGS_FLAG_PLEASE_PERSIST, 2);
1694 SETTINGS_FLAG_PLEASE_PERSIST, 1690 EXPECT_NE(
1695 2); 1691 0u,
1696 EXPECT_NE(0u, test_http_server_properties->GetSpdySettings( 1692 test_http_server_properties->GetSpdySettings(test_scheme_origin_).size());
1697 test_host_port_pair_).size());
1698 spdy_session_pool_->OnIPAddressChanged(); 1693 spdy_session_pool_->OnIPAddressChanged();
1699 EXPECT_EQ(0u, test_http_server_properties->GetSpdySettings( 1694 EXPECT_EQ(
1700 test_host_port_pair_).size()); 1695 0u,
1696 test_http_server_properties->GetSpdySettings(test_scheme_origin_).size());
1701 } 1697 }
1702 1698
1703 TEST_P(SpdySessionTest, Initialize) { 1699 TEST_P(SpdySessionTest, Initialize) {
1704 session_deps_.host_resolver->set_synchronous_mode(true); 1700 session_deps_.host_resolver->set_synchronous_mode(true);
1705 1701
1706 MockRead reads[] = { 1702 MockRead reads[] = {
1707 MockRead(ASYNC, 0, 0) // EOF 1703 MockRead(ASYNC, 0, 0) // EOF
1708 }; 1704 };
1709 1705
1710 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0); 1706 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(), 5437 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(),
5442 "spdy_pooling.pem"); 5438 "spdy_pooling.pem");
5443 ssl_info.is_issued_by_known_root = true; 5439 ssl_info.is_issued_by_known_root = true;
5444 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); 5440 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin));
5445 5441
5446 EXPECT_TRUE(SpdySession::CanPool( 5442 EXPECT_TRUE(SpdySession::CanPool(
5447 &tss, ssl_info, "www.example.org", "mail.example.org")); 5443 &tss, ssl_info, "www.example.org", "mail.example.org"));
5448 } 5444 }
5449 5445
5450 } // namespace net 5446 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session.cc ('k') | url/scheme_host_port.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698