| OLD | NEW |
| 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/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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 } | 105 } |
| 106 | 106 |
| 107 TEST_F(SpdySessionTest, GoAway) { | 107 TEST_F(SpdySessionTest, GoAway) { |
| 108 SpdySessionDependencies session_deps; | 108 SpdySessionDependencies session_deps; |
| 109 session_deps.host_resolver->set_synchronous_mode(true); | 109 session_deps.host_resolver->set_synchronous_mode(true); |
| 110 | 110 |
| 111 MockConnect connect_data(SYNCHRONOUS, OK); | 111 MockConnect connect_data(SYNCHRONOUS, OK); |
| 112 scoped_ptr<spdy::SpdyFrame> goaway(ConstructSpdyGoAway()); | 112 scoped_ptr<spdy::SpdyFrame> goaway(ConstructSpdyGoAway()); |
| 113 MockRead reads[] = { | 113 MockRead reads[] = { |
| 114 CreateMockRead(*goaway), | 114 CreateMockRead(*goaway), |
| 115 MockRead(false, 0, 0) // EOF | 115 MockRead(SYNCHRONOUS, 0, 0) // EOF |
| 116 }; | 116 }; |
| 117 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); | 117 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); |
| 118 data.set_connect_data(connect_data); | 118 data.set_connect_data(connect_data); |
| 119 session_deps.socket_factory->AddSocketDataProvider(&data); | 119 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 120 | 120 |
| 121 SSLSocketDataProvider ssl(false, OK); | 121 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); |
| 122 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); | 122 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 123 | 123 |
| 124 scoped_refptr<HttpNetworkSession> http_session( | 124 scoped_refptr<HttpNetworkSession> http_session( |
| 125 SpdySessionDependencies::SpdyCreateSession(&session_deps)); | 125 SpdySessionDependencies::SpdyCreateSession(&session_deps)); |
| 126 | 126 |
| 127 const std::string kTestHost("www.foo.com"); | 127 const std::string kTestHost("www.foo.com"); |
| 128 const int kTestPort = 80; | 128 const int kTestPort = 80; |
| 129 HostPortPair test_host_port_pair(kTestHost, kTestPort); | 129 HostPortPair test_host_port_pair(kTestHost, kTestPort); |
| 130 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); | 130 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); |
| 131 | 131 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 165 |
| 166 TEST_F(SpdySessionTest, Ping) { | 166 TEST_F(SpdySessionTest, Ping) { |
| 167 SpdySessionDependencies session_deps; | 167 SpdySessionDependencies session_deps; |
| 168 session_deps.host_resolver->set_synchronous_mode(true); | 168 session_deps.host_resolver->set_synchronous_mode(true); |
| 169 | 169 |
| 170 MockConnect connect_data(SYNCHRONOUS, OK); | 170 MockConnect connect_data(SYNCHRONOUS, OK); |
| 171 scoped_ptr<spdy::SpdyFrame> read_ping(ConstructSpdyPing()); | 171 scoped_ptr<spdy::SpdyFrame> read_ping(ConstructSpdyPing()); |
| 172 MockRead reads[] = { | 172 MockRead reads[] = { |
| 173 CreateMockRead(*read_ping), | 173 CreateMockRead(*read_ping), |
| 174 CreateMockRead(*read_ping), | 174 CreateMockRead(*read_ping), |
| 175 MockRead(false, 0, 0) // EOF | 175 MockRead(SYNCHRONOUS, 0, 0) // EOF |
| 176 }; | 176 }; |
| 177 scoped_ptr<spdy::SpdyFrame> write_ping(ConstructSpdyPing()); | 177 scoped_ptr<spdy::SpdyFrame> write_ping(ConstructSpdyPing()); |
| 178 MockRead writes[] = { | 178 MockRead writes[] = { |
| 179 CreateMockRead(*write_ping), | 179 CreateMockRead(*write_ping), |
| 180 CreateMockRead(*write_ping), | 180 CreateMockRead(*write_ping), |
| 181 }; | 181 }; |
| 182 StaticSocketDataProvider data( | 182 StaticSocketDataProvider data( |
| 183 reads, arraysize(reads), writes, arraysize(writes)); | 183 reads, arraysize(reads), writes, arraysize(writes)); |
| 184 data.set_connect_data(connect_data); | 184 data.set_connect_data(connect_data); |
| 185 session_deps.socket_factory->AddSocketDataProvider(&data); | 185 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 186 | 186 |
| 187 SSLSocketDataProvider ssl(false, OK); | 187 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); |
| 188 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); | 188 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 189 | 189 |
| 190 scoped_refptr<HttpNetworkSession> http_session( | 190 scoped_refptr<HttpNetworkSession> http_session( |
| 191 SpdySessionDependencies::SpdyCreateSession(&session_deps)); | 191 SpdySessionDependencies::SpdyCreateSession(&session_deps)); |
| 192 | 192 |
| 193 static const char kStreamUrl[] = "http://www.google.com/"; | 193 static const char kStreamUrl[] = "http://www.google.com/"; |
| 194 GURL url(kStreamUrl); | 194 GURL url(kStreamUrl); |
| 195 | 195 |
| 196 const std::string kTestHost("www.google.com"); | 196 const std::string kTestHost("www.google.com"); |
| 197 const int kTestPort = 80; | 197 const int kTestPort = 80; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 } | 255 } |
| 256 | 256 |
| 257 TEST_F(SpdySessionTest, FailedPing) { | 257 TEST_F(SpdySessionTest, FailedPing) { |
| 258 SpdySessionDependencies session_deps; | 258 SpdySessionDependencies session_deps; |
| 259 session_deps.host_resolver->set_synchronous_mode(true); | 259 session_deps.host_resolver->set_synchronous_mode(true); |
| 260 | 260 |
| 261 MockConnect connect_data(SYNCHRONOUS, OK); | 261 MockConnect connect_data(SYNCHRONOUS, OK); |
| 262 scoped_ptr<spdy::SpdyFrame> read_ping(ConstructSpdyPing()); | 262 scoped_ptr<spdy::SpdyFrame> read_ping(ConstructSpdyPing()); |
| 263 MockRead reads[] = { | 263 MockRead reads[] = { |
| 264 CreateMockRead(*read_ping), | 264 CreateMockRead(*read_ping), |
| 265 MockRead(false, 0, 0) // EOF | 265 MockRead(SYNCHRONOUS, 0, 0) // EOF |
| 266 }; | 266 }; |
| 267 scoped_ptr<spdy::SpdyFrame> write_ping(ConstructSpdyPing()); | 267 scoped_ptr<spdy::SpdyFrame> write_ping(ConstructSpdyPing()); |
| 268 MockRead writes[] = { | 268 MockRead writes[] = { |
| 269 CreateMockRead(*write_ping), | 269 CreateMockRead(*write_ping), |
| 270 }; | 270 }; |
| 271 StaticSocketDataProvider data( | 271 StaticSocketDataProvider data( |
| 272 reads, arraysize(reads), writes, arraysize(writes)); | 272 reads, arraysize(reads), writes, arraysize(writes)); |
| 273 data.set_connect_data(connect_data); | 273 data.set_connect_data(connect_data); |
| 274 session_deps.socket_factory->AddSocketDataProvider(&data); | 274 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 275 | 275 |
| 276 SSLSocketDataProvider ssl(false, OK); | 276 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); |
| 277 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); | 277 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 278 | 278 |
| 279 scoped_refptr<HttpNetworkSession> http_session( | 279 scoped_refptr<HttpNetworkSession> http_session( |
| 280 SpdySessionDependencies::SpdyCreateSession(&session_deps)); | 280 SpdySessionDependencies::SpdyCreateSession(&session_deps)); |
| 281 | 281 |
| 282 static const char kStreamUrl[] = "http://www.gmail.com/"; | 282 static const char kStreamUrl[] = "http://www.gmail.com/"; |
| 283 GURL url(kStreamUrl); | 283 GURL url(kStreamUrl); |
| 284 | 284 |
| 285 const std::string kTestHost("www.gmail.com"); | 285 const std::string kTestHost("www.gmail.com"); |
| 286 const int kTestPort = 80; | 286 const int kTestPort = 80; |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 const size_t max_concurrent_streams = 2; | 499 const size_t max_concurrent_streams = 2; |
| 500 new_settings.push_back(spdy::SpdySetting(id, max_concurrent_streams)); | 500 new_settings.push_back(spdy::SpdySetting(id, max_concurrent_streams)); |
| 501 | 501 |
| 502 // Set up the socket so we read a SETTINGS frame that raises max concurrent | 502 // Set up the socket so we read a SETTINGS frame that raises max concurrent |
| 503 // streams to 2. | 503 // streams to 2. |
| 504 MockConnect connect_data(SYNCHRONOUS, OK); | 504 MockConnect connect_data(SYNCHRONOUS, OK); |
| 505 scoped_ptr<spdy::SpdyFrame> settings_frame( | 505 scoped_ptr<spdy::SpdyFrame> settings_frame( |
| 506 ConstructSpdySettings(new_settings)); | 506 ConstructSpdySettings(new_settings)); |
| 507 MockRead reads[] = { | 507 MockRead reads[] = { |
| 508 CreateMockRead(*settings_frame), | 508 CreateMockRead(*settings_frame), |
| 509 MockRead(false, 0, 0) // EOF | 509 MockRead(SYNCHRONOUS, 0, 0) // EOF |
| 510 }; | 510 }; |
| 511 | 511 |
| 512 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); | 512 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); |
| 513 data.set_connect_data(connect_data); | 513 data.set_connect_data(connect_data); |
| 514 session_deps.socket_factory->AddSocketDataProvider(&data); | 514 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 515 | 515 |
| 516 SSLSocketDataProvider ssl(false, OK); | 516 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); |
| 517 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); | 517 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 518 | 518 |
| 519 scoped_refptr<HttpNetworkSession> http_session( | 519 scoped_refptr<HttpNetworkSession> http_session( |
| 520 SpdySessionDependencies::SpdyCreateSession(&session_deps)); | 520 SpdySessionDependencies::SpdyCreateSession(&session_deps)); |
| 521 | 521 |
| 522 const std::string kTestHost("www.foo.com"); | 522 const std::string kTestHost("www.foo.com"); |
| 523 const int kTestPort = 80; | 523 const int kTestPort = 80; |
| 524 HostPortPair test_host_port_pair(kTestHost, kTestPort); | 524 HostPortPair test_host_port_pair(kTestHost, kTestPort); |
| 525 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); | 525 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); |
| 526 | 526 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 | 579 |
| 580 // Start with max concurrent streams set to 1. Request two streams. When the | 580 // Start with max concurrent streams set to 1. Request two streams. When the |
| 581 // first completes, have the callback close itself, which should trigger the | 581 // first completes, have the callback close itself, which should trigger the |
| 582 // second stream creation. Then cancel that one immediately. Don't crash. | 582 // second stream creation. Then cancel that one immediately. Don't crash. |
| 583 // http://crbug.com/63532 | 583 // http://crbug.com/63532 |
| 584 TEST_F(SpdySessionTest, CancelPendingCreateStream) { | 584 TEST_F(SpdySessionTest, CancelPendingCreateStream) { |
| 585 SpdySessionDependencies session_deps; | 585 SpdySessionDependencies session_deps; |
| 586 session_deps.host_resolver->set_synchronous_mode(true); | 586 session_deps.host_resolver->set_synchronous_mode(true); |
| 587 | 587 |
| 588 MockRead reads[] = { | 588 MockRead reads[] = { |
| 589 MockRead(false, ERR_IO_PENDING) // Stall forever. | 589 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever. |
| 590 }; | 590 }; |
| 591 | 591 |
| 592 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); | 592 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); |
| 593 MockConnect connect_data(SYNCHRONOUS, OK); | 593 MockConnect connect_data(SYNCHRONOUS, OK); |
| 594 | 594 |
| 595 data.set_connect_data(connect_data); | 595 data.set_connect_data(connect_data); |
| 596 session_deps.socket_factory->AddSocketDataProvider(&data); | 596 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 597 | 597 |
| 598 SSLSocketDataProvider ssl(false, OK); | 598 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); |
| 599 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); | 599 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 600 | 600 |
| 601 scoped_refptr<HttpNetworkSession> http_session( | 601 scoped_refptr<HttpNetworkSession> http_session( |
| 602 SpdySessionDependencies::SpdyCreateSession(&session_deps)); | 602 SpdySessionDependencies::SpdyCreateSession(&session_deps)); |
| 603 | 603 |
| 604 const std::string kTestHost("www.foo.com"); | 604 const std::string kTestHost("www.foo.com"); |
| 605 const int kTestPort = 80; | 605 const int kTestPort = 80; |
| 606 HostPortPair test_host_port_pair(kTestHost, kTestPort); | 606 HostPortPair test_host_port_pair(kTestHost, kTestPort); |
| 607 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); | 607 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); |
| 608 | 608 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 | 665 |
| 666 // Should not crash when running the pending callback. | 666 // Should not crash when running the pending callback. |
| 667 MessageLoop::current()->RunAllPending(); | 667 MessageLoop::current()->RunAllPending(); |
| 668 } | 668 } |
| 669 | 669 |
| 670 TEST_F(SpdySessionTest, SendSettingsOnNewSession) { | 670 TEST_F(SpdySessionTest, SendSettingsOnNewSession) { |
| 671 SpdySessionDependencies session_deps; | 671 SpdySessionDependencies session_deps; |
| 672 session_deps.host_resolver->set_synchronous_mode(true); | 672 session_deps.host_resolver->set_synchronous_mode(true); |
| 673 | 673 |
| 674 MockRead reads[] = { | 674 MockRead reads[] = { |
| 675 MockRead(false, ERR_IO_PENDING) // Stall forever. | 675 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever. |
| 676 }; | 676 }; |
| 677 | 677 |
| 678 // Create the bogus setting that we want to verify is sent out. | 678 // Create the bogus setting that we want to verify is sent out. |
| 679 // Note that it will be marked as SETTINGS_FLAG_PERSISTED when sent out. But | 679 // Note that it will be marked as SETTINGS_FLAG_PERSISTED when sent out. But |
| 680 // to set it into the SpdySettingsStorage, we need to mark as | 680 // to set it into the SpdySettingsStorage, we need to mark as |
| 681 // SETTINGS_FLAG_PLEASE_PERSIST. | 681 // SETTINGS_FLAG_PLEASE_PERSIST. |
| 682 spdy::SpdySettings settings; | 682 spdy::SpdySettings settings; |
| 683 const uint32 kBogusSettingId = 0xABAB; | 683 const uint32 kBogusSettingId = 0xABAB; |
| 684 const uint32 kBogusSettingValue = 0xCDCD; | 684 const uint32 kBogusSettingValue = 0xCDCD; |
| 685 spdy::SettingsFlagsAndId id(0); | 685 spdy::SettingsFlagsAndId id(0); |
| 686 id.set_id(kBogusSettingId); | 686 id.set_id(kBogusSettingId); |
| 687 id.set_flags(spdy::SETTINGS_FLAG_PERSISTED); | 687 id.set_flags(spdy::SETTINGS_FLAG_PERSISTED); |
| 688 settings.push_back(spdy::SpdySetting(id, kBogusSettingValue)); | 688 settings.push_back(spdy::SpdySetting(id, kBogusSettingValue)); |
| 689 MockConnect connect_data(SYNCHRONOUS, OK); | 689 MockConnect connect_data(SYNCHRONOUS, OK); |
| 690 scoped_ptr<spdy::SpdyFrame> settings_frame( | 690 scoped_ptr<spdy::SpdyFrame> settings_frame( |
| 691 ConstructSpdySettings(settings)); | 691 ConstructSpdySettings(settings)); |
| 692 MockWrite writes[] = { | 692 MockWrite writes[] = { |
| 693 CreateMockWrite(*settings_frame), | 693 CreateMockWrite(*settings_frame), |
| 694 }; | 694 }; |
| 695 | 695 |
| 696 StaticSocketDataProvider data( | 696 StaticSocketDataProvider data( |
| 697 reads, arraysize(reads), writes, arraysize(writes)); | 697 reads, arraysize(reads), writes, arraysize(writes)); |
| 698 data.set_connect_data(connect_data); | 698 data.set_connect_data(connect_data); |
| 699 session_deps.socket_factory->AddSocketDataProvider(&data); | 699 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 700 | 700 |
| 701 SSLSocketDataProvider ssl(false, OK); | 701 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); |
| 702 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); | 702 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 703 | 703 |
| 704 scoped_refptr<HttpNetworkSession> http_session( | 704 scoped_refptr<HttpNetworkSession> http_session( |
| 705 SpdySessionDependencies::SpdyCreateSession(&session_deps)); | 705 SpdySessionDependencies::SpdyCreateSession(&session_deps)); |
| 706 | 706 |
| 707 const std::string kTestHost("www.foo.com"); | 707 const std::string kTestHost("www.foo.com"); |
| 708 const int kTestPort = 80; | 708 const int kTestPort = 80; |
| 709 HostPortPair test_host_port_pair(kTestHost, kTestPort); | 709 HostPortPair test_host_port_pair(kTestHost, kTestPort); |
| 710 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); | 710 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); |
| 711 | 711 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 info, &test_hosts[i].addresses, CompletionCallback(), NULL, | 765 info, &test_hosts[i].addresses, CompletionCallback(), NULL, |
| 766 BoundNetLog()); | 766 BoundNetLog()); |
| 767 | 767 |
| 768 // Setup a HostPortProxyPair | 768 // Setup a HostPortProxyPair |
| 769 test_hosts[i].pair = HostPortProxyPair( | 769 test_hosts[i].pair = HostPortProxyPair( |
| 770 HostPortPair(test_hosts[i].name, kTestPort), ProxyServer::Direct()); | 770 HostPortPair(test_hosts[i].name, kTestPort), ProxyServer::Direct()); |
| 771 } | 771 } |
| 772 | 772 |
| 773 MockConnect connect_data(SYNCHRONOUS, OK); | 773 MockConnect connect_data(SYNCHRONOUS, OK); |
| 774 MockRead reads[] = { | 774 MockRead reads[] = { |
| 775 MockRead(false, ERR_IO_PENDING) // Stall forever. | 775 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever. |
| 776 }; | 776 }; |
| 777 | 777 |
| 778 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); | 778 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); |
| 779 data.set_connect_data(connect_data); | 779 data.set_connect_data(connect_data); |
| 780 session_deps.socket_factory->AddSocketDataProvider(&data); | 780 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 781 | 781 |
| 782 SSLSocketDataProvider ssl(false, OK); | 782 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); |
| 783 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); | 783 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 784 | 784 |
| 785 scoped_refptr<HttpNetworkSession> http_session( | 785 scoped_refptr<HttpNetworkSession> http_session( |
| 786 SpdySessionDependencies::SpdyCreateSession(&session_deps)); | 786 SpdySessionDependencies::SpdyCreateSession(&session_deps)); |
| 787 | 787 |
| 788 // Setup the first session to the first host. | 788 // Setup the first session to the first host. |
| 789 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); | 789 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); |
| 790 EXPECT_FALSE(spdy_session_pool->HasSession(test_hosts[0].pair)); | 790 EXPECT_FALSE(spdy_session_pool->HasSession(test_hosts[0].pair)); |
| 791 scoped_refptr<SpdySession> session = | 791 scoped_refptr<SpdySession> session = |
| 792 spdy_session_pool->Get(test_hosts[0].pair, BoundNetLog()); | 792 spdy_session_pool->Get(test_hosts[0].pair, BoundNetLog()); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 spdy_session_pool->OnIPAddressChanged(); | 905 spdy_session_pool->OnIPAddressChanged(); |
| 906 EXPECT_EQ(0u, test_http_server_properties->GetSpdySettings( | 906 EXPECT_EQ(0u, test_http_server_properties->GetSpdySettings( |
| 907 test_host_port_pair).size()); | 907 test_host_port_pair).size()); |
| 908 } | 908 } |
| 909 | 909 |
| 910 TEST_F(SpdySessionTest, NeedsCredentials) { | 910 TEST_F(SpdySessionTest, NeedsCredentials) { |
| 911 SpdySessionDependencies session_deps; | 911 SpdySessionDependencies session_deps; |
| 912 | 912 |
| 913 MockConnect connect_data(SYNCHRONOUS, OK); | 913 MockConnect connect_data(SYNCHRONOUS, OK); |
| 914 MockRead reads[] = { | 914 MockRead reads[] = { |
| 915 MockRead(false, ERR_IO_PENDING) // Stall forever. | 915 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever. |
| 916 }; | 916 }; |
| 917 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); | 917 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); |
| 918 data.set_connect_data(connect_data); | 918 data.set_connect_data(connect_data); |
| 919 session_deps.socket_factory->AddSocketDataProvider(&data); | 919 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 920 | 920 |
| 921 SSLSocketDataProvider ssl(false, OK); | 921 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); |
| 922 ssl.origin_bound_cert_type = CLIENT_CERT_RSA_SIGN; | 922 ssl.origin_bound_cert_type = CLIENT_CERT_RSA_SIGN; |
| 923 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY3; | 923 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY3; |
| 924 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); | 924 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 925 | 925 |
| 926 scoped_refptr<HttpNetworkSession> http_session( | 926 scoped_refptr<HttpNetworkSession> http_session( |
| 927 SpdySessionDependencies::SpdyCreateSession(&session_deps)); | 927 SpdySessionDependencies::SpdyCreateSession(&session_deps)); |
| 928 | 928 |
| 929 const std::string kTestHost("www.foo.com"); | 929 const std::string kTestHost("www.foo.com"); |
| 930 const int kTestPort = 80; | 930 const int kTestPort = 80; |
| 931 HostPortPair test_host_port_pair(kTestHost, kTestPort); | 931 HostPortPair test_host_port_pair(kTestHost, kTestPort); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 | 973 |
| 974 spdy_session_pool->Remove(session); | 974 spdy_session_pool->Remove(session); |
| 975 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); | 975 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); |
| 976 } | 976 } |
| 977 | 977 |
| 978 TEST_F(SpdySessionTest, SendCredentials) { | 978 TEST_F(SpdySessionTest, SendCredentials) { |
| 979 SpdySessionDependencies session_deps; | 979 SpdySessionDependencies session_deps; |
| 980 | 980 |
| 981 MockConnect connect_data(SYNCHRONOUS, OK); | 981 MockConnect connect_data(SYNCHRONOUS, OK); |
| 982 MockRead reads[] = { | 982 MockRead reads[] = { |
| 983 MockRead(false, ERR_IO_PENDING) // Stall forever. | 983 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever. |
| 984 }; | 984 }; |
| 985 spdy::SpdySettings settings; | 985 spdy::SpdySettings settings; |
| 986 scoped_ptr<spdy::SpdyFrame> settings_frame( | 986 scoped_ptr<spdy::SpdyFrame> settings_frame( |
| 987 ConstructSpdySettings(settings)); | 987 ConstructSpdySettings(settings)); |
| 988 MockWrite writes[] = { | 988 MockWrite writes[] = { |
| 989 CreateMockWrite(*settings_frame), | 989 CreateMockWrite(*settings_frame), |
| 990 }; | 990 }; |
| 991 StaticSocketDataProvider data(reads, arraysize(reads), | 991 StaticSocketDataProvider data(reads, arraysize(reads), |
| 992 writes, arraysize(writes)); | 992 writes, arraysize(writes)); |
| 993 data.set_connect_data(connect_data); | 993 data.set_connect_data(connect_data); |
| 994 session_deps.socket_factory->AddSocketDataProvider(&data); | 994 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 995 | 995 |
| 996 SSLSocketDataProvider ssl(false, OK); | 996 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); |
| 997 ssl.origin_bound_cert_type = CLIENT_CERT_RSA_SIGN; | 997 ssl.origin_bound_cert_type = CLIENT_CERT_RSA_SIGN; |
| 998 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY3; | 998 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY3; |
| 999 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); | 999 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 1000 | 1000 |
| 1001 scoped_refptr<HttpNetworkSession> http_session( | 1001 scoped_refptr<HttpNetworkSession> http_session( |
| 1002 SpdySessionDependencies::SpdyCreateSession(&session_deps)); | 1002 SpdySessionDependencies::SpdyCreateSession(&session_deps)); |
| 1003 | 1003 |
| 1004 const std::string kTestHost("www.foo.com"); | 1004 const std::string kTestHost("www.foo.com"); |
| 1005 const int kTestPort = 80; | 1005 const int kTestPort = 80; |
| 1006 HostPortPair test_host_port_pair(kTestHost, kTestPort); | 1006 HostPortPair test_host_port_pair(kTestHost, kTestPort); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1044 EXPECT_TRUE(session->NeedsCredentials(test_host_port_pair2)); | 1044 EXPECT_TRUE(session->NeedsCredentials(test_host_port_pair2)); |
| 1045 | 1045 |
| 1046 // Flush the SpdySession::OnReadComplete() task. | 1046 // Flush the SpdySession::OnReadComplete() task. |
| 1047 MessageLoop::current()->RunAllPending(); | 1047 MessageLoop::current()->RunAllPending(); |
| 1048 | 1048 |
| 1049 spdy_session_pool->Remove(session); | 1049 spdy_session_pool->Remove(session); |
| 1050 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); | 1050 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); |
| 1051 } | 1051 } |
| 1052 | 1052 |
| 1053 } // namespace net | 1053 } // namespace net |
| OLD | NEW |