OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "net/base/ip_endpoint.h" | 7 #include "net/base/ip_endpoint.h" |
8 #include "net/spdy/spdy_io_buffer.h" | 8 #include "net/spdy/spdy_io_buffer.h" |
9 #include "net/spdy/spdy_session_pool.h" | 9 #include "net/spdy/spdy_session_pool.h" |
10 #include "net/spdy/spdy_stream.h" | 10 #include "net/spdy/spdy_stream.h" |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 const std::string kTestHost("www.foo.com"); | 531 const std::string kTestHost("www.foo.com"); |
532 const int kTestPort = 80; | 532 const int kTestPort = 80; |
533 HostPortPair test_host_port_pair(kTestHost, kTestPort); | 533 HostPortPair test_host_port_pair(kTestHost, kTestPort); |
534 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); | 534 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); |
535 | 535 |
536 // Initialize the SpdySettingsStorage with 1 max concurrent streams. | 536 // Initialize the SpdySettingsStorage with 1 max concurrent streams. |
537 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); | 537 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); |
538 spdy::SpdySettings old_settings; | 538 spdy::SpdySettings old_settings; |
539 id.set_flags(spdy::SETTINGS_FLAG_PLEASE_PERSIST); | 539 id.set_flags(spdy::SETTINGS_FLAG_PLEASE_PERSIST); |
540 old_settings.push_back(spdy::SpdySetting(id, 1)); | 540 old_settings.push_back(spdy::SpdySetting(id, 1)); |
541 spdy_session_pool->mutable_spdy_settings()->Set( | 541 spdy_session_pool->http_server_properties()->SetSpdySettings( |
542 test_host_port_pair, old_settings); | 542 test_host_port_pair, old_settings); |
543 | 543 |
544 // Create a session. | 544 // Create a session. |
545 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); | 545 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); |
546 scoped_refptr<SpdySession> session = | 546 scoped_refptr<SpdySession> session = |
547 spdy_session_pool->Get(pair, BoundNetLog()); | 547 spdy_session_pool->Get(pair, BoundNetLog()); |
548 ASSERT_TRUE(spdy_session_pool->HasSession(pair)); | 548 ASSERT_TRUE(spdy_session_pool->HasSession(pair)); |
549 | 549 |
550 scoped_refptr<TransportSocketParams> transport_params( | 550 scoped_refptr<TransportSocketParams> transport_params( |
551 new TransportSocketParams(test_host_port_pair, | 551 new TransportSocketParams(test_host_port_pair, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 HostPortPair test_host_port_pair(kTestHost, kTestPort); | 617 HostPortPair test_host_port_pair(kTestHost, kTestPort); |
618 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); | 618 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); |
619 | 619 |
620 // Initialize the SpdySettingsStorage with 1 max concurrent streams. | 620 // Initialize the SpdySettingsStorage with 1 max concurrent streams. |
621 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); | 621 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); |
622 spdy::SpdySettings settings; | 622 spdy::SpdySettings settings; |
623 spdy::SettingsFlagsAndId id(0); | 623 spdy::SettingsFlagsAndId id(0); |
624 id.set_id(spdy::SETTINGS_MAX_CONCURRENT_STREAMS); | 624 id.set_id(spdy::SETTINGS_MAX_CONCURRENT_STREAMS); |
625 id.set_flags(spdy::SETTINGS_FLAG_PLEASE_PERSIST); | 625 id.set_flags(spdy::SETTINGS_FLAG_PLEASE_PERSIST); |
626 settings.push_back(spdy::SpdySetting(id, 1)); | 626 settings.push_back(spdy::SpdySetting(id, 1)); |
627 spdy_session_pool->mutable_spdy_settings()->Set( | 627 spdy_session_pool->http_server_properties()->SetSpdySettings( |
628 test_host_port_pair, settings); | 628 test_host_port_pair, settings); |
629 | 629 |
630 // Create a session. | 630 // Create a session. |
631 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); | 631 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); |
632 scoped_refptr<SpdySession> session = | 632 scoped_refptr<SpdySession> session = |
633 spdy_session_pool->Get(pair, BoundNetLog()); | 633 spdy_session_pool->Get(pair, BoundNetLog()); |
634 ASSERT_TRUE(spdy_session_pool->HasSession(pair)); | 634 ASSERT_TRUE(spdy_session_pool->HasSession(pair)); |
635 | 635 |
636 scoped_refptr<TransportSocketParams> transport_params( | 636 scoped_refptr<TransportSocketParams> transport_params( |
637 new TransportSocketParams(test_host_port_pair, | 637 new TransportSocketParams(test_host_port_pair, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 | 719 |
720 const std::string kTestHost("www.foo.com"); | 720 const std::string kTestHost("www.foo.com"); |
721 const int kTestPort = 80; | 721 const int kTestPort = 80; |
722 HostPortPair test_host_port_pair(kTestHost, kTestPort); | 722 HostPortPair test_host_port_pair(kTestHost, kTestPort); |
723 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); | 723 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); |
724 | 724 |
725 id.set_flags(spdy::SETTINGS_FLAG_PLEASE_PERSIST); | 725 id.set_flags(spdy::SETTINGS_FLAG_PLEASE_PERSIST); |
726 settings.clear(); | 726 settings.clear(); |
727 settings.push_back(spdy::SpdySetting(id, kBogusSettingValue)); | 727 settings.push_back(spdy::SpdySetting(id, kBogusSettingValue)); |
728 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); | 728 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); |
729 spdy_session_pool->mutable_spdy_settings()->Set( | 729 spdy_session_pool->http_server_properties()->SetSpdySettings( |
730 test_host_port_pair, settings); | 730 test_host_port_pair, settings); |
731 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); | 731 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); |
732 scoped_refptr<SpdySession> session = | 732 scoped_refptr<SpdySession> session = |
733 spdy_session_pool->Get(pair, BoundNetLog()); | 733 spdy_session_pool->Get(pair, BoundNetLog()); |
734 EXPECT_TRUE(spdy_session_pool->HasSession(pair)); | 734 EXPECT_TRUE(spdy_session_pool->HasSession(pair)); |
735 | 735 |
736 scoped_refptr<TransportSocketParams> transport_params( | 736 scoped_refptr<TransportSocketParams> transport_params( |
737 new TransportSocketParams(test_host_port_pair, | 737 new TransportSocketParams(test_host_port_pair, |
738 MEDIUM, | 738 MEDIUM, |
739 GURL(), | 739 GURL(), |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 TEST_F(SpdySessionTest, ClearSettingsStorageOnIPAddressChanged) { | 898 TEST_F(SpdySessionTest, ClearSettingsStorageOnIPAddressChanged) { |
899 const std::string kTestHost("www.foo.com"); | 899 const std::string kTestHost("www.foo.com"); |
900 const int kTestPort = 80; | 900 const int kTestPort = 80; |
901 HostPortPair test_host_port_pair(kTestHost, kTestPort); | 901 HostPortPair test_host_port_pair(kTestHost, kTestPort); |
902 | 902 |
903 SpdySessionDependencies session_deps; | 903 SpdySessionDependencies session_deps; |
904 scoped_refptr<HttpNetworkSession> http_session( | 904 scoped_refptr<HttpNetworkSession> http_session( |
905 SpdySessionDependencies::SpdyCreateSession(&session_deps)); | 905 SpdySessionDependencies::SpdyCreateSession(&session_deps)); |
906 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); | 906 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); |
907 | 907 |
908 SpdySettingsStorage* test_settings_storage = | 908 HttpServerProperties* test_http_server_properties = |
909 spdy_session_pool->mutable_spdy_settings(); | 909 spdy_session_pool->http_server_properties(); |
910 spdy::SettingsFlagsAndId id(0); | 910 spdy::SettingsFlagsAndId id(0); |
911 id.set_id(spdy::SETTINGS_MAX_CONCURRENT_STREAMS); | 911 id.set_id(spdy::SETTINGS_MAX_CONCURRENT_STREAMS); |
912 id.set_flags(spdy::SETTINGS_FLAG_PLEASE_PERSIST); | 912 id.set_flags(spdy::SETTINGS_FLAG_PLEASE_PERSIST); |
913 const size_t max_concurrent_streams = 2; | 913 const size_t max_concurrent_streams = 2; |
914 spdy::SpdySettings test_settings; | 914 spdy::SpdySettings test_settings; |
915 test_settings.push_back(spdy::SpdySetting(id, max_concurrent_streams)); | 915 test_settings.push_back(spdy::SpdySetting(id, max_concurrent_streams)); |
916 | 916 |
917 test_settings_storage->Set(test_host_port_pair, test_settings); | 917 test_http_server_properties->SetSpdySettings(test_host_port_pair, |
918 EXPECT_NE(0u, test_settings_storage->Get(test_host_port_pair).size()); | 918 test_settings); |
| 919 EXPECT_NE(0u, test_http_server_properties->GetSpdySettings( |
| 920 test_host_port_pair).size()); |
919 spdy_session_pool->OnIPAddressChanged(); | 921 spdy_session_pool->OnIPAddressChanged(); |
920 EXPECT_EQ(0u, test_settings_storage->Get(test_host_port_pair).size()); | 922 EXPECT_EQ(0u, test_http_server_properties->GetSpdySettings( |
| 923 test_host_port_pair).size()); |
921 } | 924 } |
922 | 925 |
923 } // namespace net | 926 } // namespace net |
OLD | NEW |