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

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

Issue 9802003: SPDY - persist SPDY settings. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
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 "net/base/host_cache.h" 7 #include "net/base/host_cache.h"
8 #include "net/base/ip_endpoint.h" 8 #include "net/base/ip_endpoint.h"
9 #include "net/base/net_log_unittest.h" 9 #include "net/base/net_log_unittest.h"
10 #include "net/spdy/spdy_io_buffer.h" 10 #include "net/spdy/spdy_io_buffer.h"
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 scoped_refptr<HttpNetworkSession> http_session( 531 scoped_refptr<HttpNetworkSession> http_session(
532 SpdySessionDependencies::SpdyCreateSession(&session_deps)); 532 SpdySessionDependencies::SpdyCreateSession(&session_deps));
533 533
534 const std::string kTestHost("www.foo.com"); 534 const std::string kTestHost("www.foo.com");
535 const int kTestPort = 80; 535 const int kTestPort = 80;
536 HostPortPair test_host_port_pair(kTestHost, kTestPort); 536 HostPortPair test_host_port_pair(kTestHost, kTestPort);
537 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); 537 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct());
538 538
539 // Initialize the SpdySettingsStorage with 1 max concurrent streams. 539 // Initialize the SpdySettingsStorage with 1 max concurrent streams.
540 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); 540 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool());
541 spdy::SpdySettings old_settings; 541 spdy::SettingsFlagsAndValue flags_and_value1(
542 spdy::SettingsFlagsAndId id1(spdy::SETTINGS_FLAG_PLEASE_PERSIST, id.id()); 542 spdy::SETTINGS_FLAG_PLEASE_PERSIST, 1);
543 old_settings.push_back(spdy::SpdySetting(id1, 1)); 543 spdy_session_pool->http_server_properties()->SetSpdySetting(
544 spdy_session_pool->http_server_properties()->SetSpdySettings( 544 test_host_port_pair, id.id(), flags_and_value1);
545 test_host_port_pair, old_settings);
546 545
547 // Create a session. 546 // Create a session.
548 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); 547 EXPECT_FALSE(spdy_session_pool->HasSession(pair));
549 scoped_refptr<SpdySession> session = 548 scoped_refptr<SpdySession> session =
550 spdy_session_pool->Get(pair, BoundNetLog()); 549 spdy_session_pool->Get(pair, BoundNetLog());
551 ASSERT_TRUE(spdy_session_pool->HasSession(pair)); 550 ASSERT_TRUE(spdy_session_pool->HasSession(pair));
552 551
553 scoped_refptr<TransportSocketParams> transport_params( 552 scoped_refptr<TransportSocketParams> transport_params(
554 new TransportSocketParams(test_host_port_pair, 553 new TransportSocketParams(test_host_port_pair,
555 MEDIUM, 554 MEDIUM,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 scoped_refptr<HttpNetworkSession> http_session( 613 scoped_refptr<HttpNetworkSession> http_session(
615 SpdySessionDependencies::SpdyCreateSession(&session_deps)); 614 SpdySessionDependencies::SpdyCreateSession(&session_deps));
616 615
617 const std::string kTestHost("www.foo.com"); 616 const std::string kTestHost("www.foo.com");
618 const int kTestPort = 80; 617 const int kTestPort = 80;
619 HostPortPair test_host_port_pair(kTestHost, kTestPort); 618 HostPortPair test_host_port_pair(kTestHost, kTestPort);
620 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); 619 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct());
621 620
622 // Initialize the SpdySettingsStorage with 1 max concurrent streams. 621 // Initialize the SpdySettingsStorage with 1 max concurrent streams.
623 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); 622 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool());
624 spdy::SpdySettings settings; 623 spdy::SettingsFlagsAndValue flags_and_value1(
625 spdy::SettingsFlagsAndId id(spdy::SETTINGS_FLAG_PLEASE_PERSIST, 624 spdy::SETTINGS_FLAG_PLEASE_PERSIST, 1);
626 spdy::SETTINGS_MAX_CONCURRENT_STREAMS); 625 spdy_session_pool->http_server_properties()->SetSpdySetting(
627 settings.push_back(spdy::SpdySetting(id, 1)); 626 test_host_port_pair,
628 spdy_session_pool->http_server_properties()->SetSpdySettings( 627 spdy::SETTINGS_MAX_CONCURRENT_STREAMS,
629 test_host_port_pair, settings); 628 flags_and_value1);
630 629
631 // Create a session. 630 // Create a session.
632 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); 631 EXPECT_FALSE(spdy_session_pool->HasSession(pair));
633 scoped_refptr<SpdySession> session = 632 scoped_refptr<SpdySession> session =
634 spdy_session_pool->Get(pair, BoundNetLog()); 633 spdy_session_pool->Get(pair, BoundNetLog());
635 ASSERT_TRUE(spdy_session_pool->HasSession(pair)); 634 ASSERT_TRUE(spdy_session_pool->HasSession(pair));
636 635
637 scoped_refptr<TransportSocketParams> transport_params( 636 scoped_refptr<TransportSocketParams> transport_params(
638 new TransportSocketParams(test_host_port_pair, 637 new TransportSocketParams(test_host_port_pair,
639 MEDIUM, 638 MEDIUM,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); 712 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl);
714 713
715 scoped_refptr<HttpNetworkSession> http_session( 714 scoped_refptr<HttpNetworkSession> http_session(
716 SpdySessionDependencies::SpdyCreateSession(&session_deps)); 715 SpdySessionDependencies::SpdyCreateSession(&session_deps));
717 716
718 const std::string kTestHost("www.foo.com"); 717 const std::string kTestHost("www.foo.com");
719 const int kTestPort = 80; 718 const int kTestPort = 80;
720 HostPortPair test_host_port_pair(kTestHost, kTestPort); 719 HostPortPair test_host_port_pair(kTestHost, kTestPort);
721 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); 720 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct());
722 721
723 spdy::SettingsFlagsAndId id1(spdy::SETTINGS_FLAG_PLEASE_PERSIST, id.id()); 722 spdy::SettingsFlagsAndValue flags_and_value1(
724 settings.clear(); 723 spdy::SETTINGS_FLAG_PLEASE_PERSIST, kBogusSettingValue);
725 settings.push_back(spdy::SpdySetting(id1, kBogusSettingValue));
726 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); 724 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool());
727 spdy_session_pool->http_server_properties()->SetSpdySettings( 725 spdy_session_pool->http_server_properties()->SetSpdySetting(
728 test_host_port_pair, settings); 726 test_host_port_pair, id.id(), flags_and_value1);
727
729 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); 728 EXPECT_FALSE(spdy_session_pool->HasSession(pair));
730 scoped_refptr<SpdySession> session = 729 scoped_refptr<SpdySession> session =
731 spdy_session_pool->Get(pair, BoundNetLog()); 730 spdy_session_pool->Get(pair, BoundNetLog());
732 EXPECT_TRUE(spdy_session_pool->HasSession(pair)); 731 EXPECT_TRUE(spdy_session_pool->HasSession(pair));
733 732
734 scoped_refptr<TransportSocketParams> transport_params( 733 scoped_refptr<TransportSocketParams> transport_params(
735 new TransportSocketParams(test_host_port_pair, 734 new TransportSocketParams(test_host_port_pair,
736 MEDIUM, 735 MEDIUM,
737 false, 736 false,
738 false)); 737 false));
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 const int kTestPort = 80; 914 const int kTestPort = 80;
916 HostPortPair test_host_port_pair(kTestHost, kTestPort); 915 HostPortPair test_host_port_pair(kTestHost, kTestPort);
917 916
918 SpdySessionDependencies session_deps; 917 SpdySessionDependencies session_deps;
919 scoped_refptr<HttpNetworkSession> http_session( 918 scoped_refptr<HttpNetworkSession> http_session(
920 SpdySessionDependencies::SpdyCreateSession(&session_deps)); 919 SpdySessionDependencies::SpdyCreateSession(&session_deps));
921 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); 920 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool());
922 921
923 HttpServerProperties* test_http_server_properties = 922 HttpServerProperties* test_http_server_properties =
924 spdy_session_pool->http_server_properties(); 923 spdy_session_pool->http_server_properties();
925 spdy::SettingsFlagsAndId id(spdy::SETTINGS_FLAG_PLEASE_PERSIST, 924 spdy::SettingsFlagsAndValue flags_and_value1(
926 spdy::SETTINGS_MAX_CONCURRENT_STREAMS); 925 spdy::SETTINGS_FLAG_PLEASE_PERSIST, 2);
927 const size_t max_concurrent_streams = 2; 926 test_http_server_properties->SetSpdySetting(
928 spdy::SpdySettings test_settings; 927 test_host_port_pair,
929 test_settings.push_back(spdy::SpdySetting(id, max_concurrent_streams)); 928 spdy::SETTINGS_MAX_CONCURRENT_STREAMS,
930 929 flags_and_value1);
931 test_http_server_properties->SetSpdySettings(test_host_port_pair,
932 test_settings);
933 EXPECT_NE(0u, test_http_server_properties->GetSpdySettings( 930 EXPECT_NE(0u, test_http_server_properties->GetSpdySettings(
934 test_host_port_pair).size()); 931 test_host_port_pair).size());
935 spdy_session_pool->OnIPAddressChanged(); 932 spdy_session_pool->OnIPAddressChanged();
936 EXPECT_EQ(0u, test_http_server_properties->GetSpdySettings( 933 EXPECT_EQ(0u, test_http_server_properties->GetSpdySettings(
937 test_host_port_pair).size()); 934 test_host_port_pair).size());
938 } 935 }
939 936
940 TEST_F(SpdySessionSpdy2Test, NeedsCredentials) { 937 TEST_F(SpdySessionSpdy2Test, NeedsCredentials) {
941 SpdySessionDependencies session_deps; 938 SpdySessionDependencies session_deps;
942 939
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 1207
1211 // But now if we drop our reference to the session, it will be destructed 1208 // But now if we drop our reference to the session, it will be destructed
1212 // and the transport socket will return to the pool, unblocking this 1209 // and the transport socket will return to the pool, unblocking this
1213 // request. 1210 // request.
1214 session2 = NULL; 1211 session2 = NULL;
1215 EXPECT_EQ(OK, callback6.WaitForResult()); 1212 EXPECT_EQ(OK, callback6.WaitForResult());
1216 EXPECT_FALSE(pool.IsStalled()); 1213 EXPECT_FALSE(pool.IsStalled());
1217 } 1214 }
1218 1215
1219 } // namespace net 1216 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698