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

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

Issue 10054034: SPDY - replaced SpdySettings (list) with SettingsMap (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_session_pool.h ('k') | net/spdy/spdy_session_spdy3_unittest.cc » ('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 "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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 493
494 // Start with max concurrent streams set to 1. Request two streams. Receive a 494 // Start with max concurrent streams set to 1. Request two streams. Receive a
495 // settings frame setting max concurrent streams to 2. Have the callback 495 // settings frame setting max concurrent streams to 2. Have the callback
496 // release the stream, which releases its reference (the last) to the session. 496 // release the stream, which releases its reference (the last) to the session.
497 // Make sure nothing blows up. 497 // Make sure nothing blows up.
498 // http://crbug.com/57331 498 // http://crbug.com/57331
499 TEST_F(SpdySessionSpdy2Test, OnSettings) { 499 TEST_F(SpdySessionSpdy2Test, OnSettings) {
500 SpdySessionDependencies session_deps; 500 SpdySessionDependencies session_deps;
501 session_deps.host_resolver->set_synchronous_mode(true); 501 session_deps.host_resolver->set_synchronous_mode(true);
502 502
503 SpdySettings new_settings; 503 SettingsMap new_settings;
504 const SpdySettingsIds kSpdySettingsIds1 = SETTINGS_MAX_CONCURRENT_STREAMS; 504 const SpdySettingsIds kSpdySettingsIds1 = SETTINGS_MAX_CONCURRENT_STREAMS;
505 SettingsFlagsAndId id(SETTINGS_FLAG_NONE, kSpdySettingsIds1);
506 const size_t max_concurrent_streams = 2; 505 const size_t max_concurrent_streams = 2;
507 new_settings.push_back(SpdySetting(id, max_concurrent_streams)); 506 new_settings[kSpdySettingsIds1] =
507 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, max_concurrent_streams);
508 508
509 // Set up the socket so we read a SETTINGS frame that raises max concurrent 509 // Set up the socket so we read a SETTINGS frame that raises max concurrent
510 // streams to 2. 510 // streams to 2.
511 MockConnect connect_data(SYNCHRONOUS, OK); 511 MockConnect connect_data(SYNCHRONOUS, OK);
512 scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(new_settings)); 512 scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(new_settings));
513 MockRead reads[] = { 513 MockRead reads[] = {
514 CreateMockRead(*settings_frame), 514 CreateMockRead(*settings_frame),
515 MockRead(SYNCHRONOUS, 0, 0) // EOF 515 MockRead(SYNCHRONOUS, 0, 0) // EOF
516 }; 516 };
517 517
518 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); 518 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0);
519 data.set_connect_data(connect_data); 519 data.set_connect_data(connect_data);
520 session_deps.socket_factory->AddSocketDataProvider(&data); 520 session_deps.socket_factory->AddSocketDataProvider(&data);
521 521
522 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); 522 SSLSocketDataProvider ssl(SYNCHRONOUS, OK);
523 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); 523 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl);
524 524
525 scoped_refptr<HttpNetworkSession> http_session( 525 scoped_refptr<HttpNetworkSession> http_session(
526 SpdySessionDependencies::SpdyCreateSession(&session_deps)); 526 SpdySessionDependencies::SpdyCreateSession(&session_deps));
527 527
528 const std::string kTestHost("www.foo.com"); 528 const std::string kTestHost("www.foo.com");
529 const int kTestPort = 80; 529 const int kTestPort = 80;
530 HostPortPair test_host_port_pair(kTestHost, kTestPort); 530 HostPortPair test_host_port_pair(kTestHost, kTestPort);
531 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); 531 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct());
532 532
533 // Initialize the SpdySettingsStorage with 1 max concurrent streams. 533 // Initialize the SpdySetting with 1 max concurrent streams.
534 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); 534 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool());
535 spdy_session_pool->http_server_properties()->SetSpdySetting( 535 spdy_session_pool->http_server_properties()->SetSpdySetting(
536 test_host_port_pair, 536 test_host_port_pair,
537 kSpdySettingsIds1, 537 kSpdySettingsIds1,
538 SETTINGS_FLAG_PLEASE_PERSIST, 538 SETTINGS_FLAG_PLEASE_PERSIST,
539 1); 539 1);
540 540
541 // Create a session. 541 // Create a session.
542 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); 542 EXPECT_FALSE(spdy_session_pool->HasSession(pair));
543 scoped_refptr<SpdySession> session = 543 scoped_refptr<SpdySession> session =
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); 606 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl);
607 607
608 scoped_refptr<HttpNetworkSession> http_session( 608 scoped_refptr<HttpNetworkSession> http_session(
609 SpdySessionDependencies::SpdyCreateSession(&session_deps)); 609 SpdySessionDependencies::SpdyCreateSession(&session_deps));
610 610
611 const std::string kTestHost("www.foo.com"); 611 const std::string kTestHost("www.foo.com");
612 const int kTestPort = 80; 612 const int kTestPort = 80;
613 HostPortPair test_host_port_pair(kTestHost, kTestPort); 613 HostPortPair test_host_port_pair(kTestHost, kTestPort);
614 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); 614 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct());
615 615
616 // Initialize the SpdySettingsStorage with 1 max concurrent streams. 616 // Initialize the SpdySetting with 1 max concurrent streams.
617 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); 617 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool());
618 spdy_session_pool->http_server_properties()->SetSpdySetting( 618 spdy_session_pool->http_server_properties()->SetSpdySetting(
619 test_host_port_pair, 619 test_host_port_pair,
620 SETTINGS_MAX_CONCURRENT_STREAMS, 620 SETTINGS_MAX_CONCURRENT_STREAMS,
621 SETTINGS_FLAG_PLEASE_PERSIST, 621 SETTINGS_FLAG_PLEASE_PERSIST,
622 1); 622 1);
623 623
624 // Create a session. 624 // Create a session.
625 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); 625 EXPECT_FALSE(spdy_session_pool->HasSession(pair));
626 scoped_refptr<SpdySession> session = 626 scoped_refptr<SpdySession> session =
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 TEST_F(SpdySessionSpdy2Test, SendSettingsOnNewSession) { 676 TEST_F(SpdySessionSpdy2Test, SendSettingsOnNewSession) {
677 SpdySessionDependencies session_deps; 677 SpdySessionDependencies session_deps;
678 session_deps.host_resolver->set_synchronous_mode(true); 678 session_deps.host_resolver->set_synchronous_mode(true);
679 679
680 MockRead reads[] = { 680 MockRead reads[] = {
681 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever. 681 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever.
682 }; 682 };
683 683
684 // Create the bogus setting that we want to verify is sent out. 684 // Create the bogus setting that we want to verify is sent out.
685 // Note that it will be marked as SETTINGS_FLAG_PERSISTED when sent out. But 685 // Note that it will be marked as SETTINGS_FLAG_PERSISTED when sent out. But
686 // to set it into the SpdySettingsStorage, we need to mark as 686 // to persist it into the HttpServerProperties, we need to mark as
687 // SETTINGS_FLAG_PLEASE_PERSIST. 687 // SETTINGS_FLAG_PLEASE_PERSIST.
688 SpdySettings settings; 688 SettingsMap settings;
689 const SpdySettingsIds kSpdySettingsIds1 = SETTINGS_UPLOAD_BANDWIDTH; 689 const SpdySettingsIds kSpdySettingsIds1 = SETTINGS_UPLOAD_BANDWIDTH;
690 const uint32 kBogusSettingValue = 0xCDCD; 690 const uint32 kBogusSettingValue = 0xCDCD;
691 SettingsFlagsAndId id(SETTINGS_FLAG_PERSISTED, kSpdySettingsIds1); 691 settings[kSpdySettingsIds1] =
692 settings.push_back(SpdySetting(id, kBogusSettingValue)); 692 SettingsFlagsAndValue(SETTINGS_FLAG_PERSISTED, kBogusSettingValue);
693 MockConnect connect_data(SYNCHRONOUS, OK); 693 MockConnect connect_data(SYNCHRONOUS, OK);
694 scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings)); 694 scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings));
695 MockWrite writes[] = { 695 MockWrite writes[] = {
696 CreateMockWrite(*settings_frame), 696 CreateMockWrite(*settings_frame),
697 }; 697 };
698 698
699 StaticSocketDataProvider data( 699 StaticSocketDataProvider data(
700 reads, arraysize(reads), writes, arraysize(writes)); 700 reads, arraysize(reads), writes, arraysize(writes));
701 data.set_connect_data(connect_data); 701 data.set_connect_data(connect_data);
702 session_deps.socket_factory->AddSocketDataProvider(&data); 702 session_deps.socket_factory->AddSocketDataProvider(&data);
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 } // namespace 879 } // namespace
880 880
881 TEST_F(SpdySessionSpdy2Test, IPPooling) { 881 TEST_F(SpdySessionSpdy2Test, IPPooling) {
882 IPPoolingTest(false); 882 IPPoolingTest(false);
883 } 883 }
884 884
885 TEST_F(SpdySessionSpdy2Test, IPPoolingCloseCurrentSessions) { 885 TEST_F(SpdySessionSpdy2Test, IPPoolingCloseCurrentSessions) {
886 IPPoolingTest(true); 886 IPPoolingTest(true);
887 } 887 }
888 888
889 TEST_F(SpdySessionSpdy2Test, ClearSettingsStorage) {
890 SpdySettingsStorage settings_storage;
891 const std::string kTestHost("www.foo.com");
892 const int kTestPort = 80;
893 HostPortPair test_host_port_pair(kTestHost, kTestPort);
894 SpdySettings test_settings;
895 SettingsFlagsAndId id(SETTINGS_FLAG_PLEASE_PERSIST,
896 SETTINGS_MAX_CONCURRENT_STREAMS);
897 const size_t max_concurrent_streams = 2;
898 test_settings.push_back(SpdySetting(id, max_concurrent_streams));
899
900 settings_storage.Set(test_host_port_pair, test_settings);
901 EXPECT_NE(0u, settings_storage.Get(test_host_port_pair).size());
902 settings_storage.Clear();
903 EXPECT_EQ(0u, settings_storage.Get(test_host_port_pair).size());
904 }
905
906 TEST_F(SpdySessionSpdy2Test, ClearSettingsStorageOnIPAddressChanged) { 889 TEST_F(SpdySessionSpdy2Test, ClearSettingsStorageOnIPAddressChanged) {
907 const std::string kTestHost("www.foo.com"); 890 const std::string kTestHost("www.foo.com");
908 const int kTestPort = 80; 891 const int kTestPort = 80;
909 HostPortPair test_host_port_pair(kTestHost, kTestPort); 892 HostPortPair test_host_port_pair(kTestHost, kTestPort);
910 893
911 SpdySessionDependencies session_deps; 894 SpdySessionDependencies session_deps;
912 scoped_refptr<HttpNetworkSession> http_session( 895 scoped_refptr<HttpNetworkSession> http_session(
913 SpdySessionDependencies::SpdyCreateSession(&session_deps)); 896 SpdySessionDependencies::SpdyCreateSession(&session_deps));
914 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); 897 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool());
915 898
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 net::NetLog::PHASE_NONE); 1041 net::NetLog::PHASE_NONE);
1059 1042
1060 CapturingNetLog::Entry entry = entries[pos]; 1043 CapturingNetLog::Entry entry = entries[pos];
1061 NetLogSpdySessionCloseParameter* request_params = 1044 NetLogSpdySessionCloseParameter* request_params =
1062 static_cast<NetLogSpdySessionCloseParameter*>( 1045 static_cast<NetLogSpdySessionCloseParameter*>(
1063 entry.extra_parameters.get()); 1046 entry.extra_parameters.get());
1064 EXPECT_EQ(ERR_CONNECTION_CLOSED, request_params->status()); 1047 EXPECT_EQ(ERR_CONNECTION_CLOSED, request_params->status());
1065 } 1048 }
1066 1049
1067 } // namespace net 1050 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session_pool.h ('k') | net/spdy/spdy_session_spdy3_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698