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/http/http_stream_factory_impl.h" | 5 #include "net/http/http_stream_factory_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 | 610 |
611 // The proxy that failed should now be known to the proxy_service as bad. | 611 // The proxy that failed should now be known to the proxy_service as bad. |
612 const ProxyRetryInfoMap& retry_info = | 612 const ProxyRetryInfoMap& retry_info = |
613 session->proxy_service()->proxy_retry_info(); | 613 session->proxy_service()->proxy_retry_info(); |
614 EXPECT_EQ(1u, retry_info.size()); | 614 EXPECT_EQ(1u, retry_info.size()); |
615 ProxyRetryInfoMap::const_iterator iter = retry_info.find("bad:99"); | 615 ProxyRetryInfoMap::const_iterator iter = retry_info.find("bad:99"); |
616 EXPECT_TRUE(iter != retry_info.end()); | 616 EXPECT_TRUE(iter != retry_info.end()); |
617 } | 617 } |
618 | 618 |
619 TEST_P(HttpStreamFactoryTest, UnreachableQuicProxyMarkedAsBad) { | 619 TEST_P(HttpStreamFactoryTest, UnreachableQuicProxyMarkedAsBad) { |
620 scoped_ptr<ProxyService> proxy_service_; | 620 for (int i = 1; i <= 2; i++) { |
621 proxy_service_.reset( | 621 int mock_error = |
622 ProxyService::CreateFixedFromPacResult("QUIC bad:99; DIRECT")); | 622 i == 1 ? ERR_QUIC_PROTOCOL_ERROR : ERR_QUIC_HANDSHAKE_FAILED; |
623 | 623 |
624 HttpNetworkSession::Params params_; | 624 scoped_ptr<ProxyService> proxy_service; |
625 params_.enable_quic = true; | 625 proxy_service.reset( |
626 scoped_refptr<SSLConfigServiceDefaults> ssl_config_service_( | 626 ProxyService::CreateFixedFromPacResult("QUIC bad:99; DIRECT")); |
627 new SSLConfigServiceDefaults); | |
628 HttpServerPropertiesImpl http_server_properties; | |
629 MockClientSocketFactory socket_factory_; | |
630 params_.client_socket_factory = &socket_factory_; | |
631 MockHostResolver host_resolver_; | |
632 params_.host_resolver = &host_resolver_; | |
633 TransportSecurityState transport_security_state_; | |
634 params_.transport_security_state = &transport_security_state_; | |
635 params_.proxy_service = proxy_service_.get(); | |
636 params_.ssl_config_service = ssl_config_service_.get(); | |
637 params_.http_server_properties = http_server_properties.GetWeakPtr(); | |
638 | 627 |
639 scoped_refptr<HttpNetworkSession> session; | 628 HttpNetworkSession::Params params; |
640 session = new HttpNetworkSession(params_); | 629 params.enable_quic = true; |
641 session->quic_stream_factory()->set_require_confirmation(false); | 630 scoped_refptr<SSLConfigServiceDefaults> ssl_config_service( |
| 631 new SSLConfigServiceDefaults); |
| 632 HttpServerPropertiesImpl http_server_properties; |
| 633 MockClientSocketFactory socket_factory; |
| 634 params.client_socket_factory = &socket_factory; |
| 635 MockHostResolver host_resolver; |
| 636 params.host_resolver = &host_resolver; |
| 637 TransportSecurityState transport_security_state; |
| 638 params.transport_security_state = &transport_security_state; |
| 639 params.proxy_service = proxy_service.get(); |
| 640 params.ssl_config_service = ssl_config_service.get(); |
| 641 params.http_server_properties = http_server_properties.GetWeakPtr(); |
642 | 642 |
643 StaticSocketDataProvider socket_data1; | 643 scoped_refptr<HttpNetworkSession> session; |
644 socket_data1.set_connect_data(MockConnect(ASYNC, ERR_QUIC_PROTOCOL_ERROR)); | 644 session = new HttpNetworkSession(params); |
645 socket_factory_.AddSocketDataProvider(&socket_data1); | 645 session->quic_stream_factory()->set_require_confirmation(false); |
646 | 646 |
647 // Second connection attempt succeeds | 647 StaticSocketDataProvider socket_data1; |
648 StaticSocketDataProvider socket_data2; | 648 socket_data1.set_connect_data(MockConnect(ASYNC, mock_error)); |
649 socket_data2.set_connect_data(MockConnect(ASYNC, OK)); | 649 socket_factory.AddSocketDataProvider(&socket_data1); |
650 socket_factory_.AddSocketDataProvider(&socket_data2); | |
651 | 650 |
652 // Now request a stream. It should succeed using the second proxy in the | 651 // Second connection attempt succeeds. |
653 // list. | 652 StaticSocketDataProvider socket_data2; |
654 HttpRequestInfo request_info; | 653 socket_data2.set_connect_data(MockConnect(ASYNC, OK)); |
655 request_info.method = "GET"; | 654 socket_factory.AddSocketDataProvider(&socket_data2); |
656 request_info.url = GURL("http://www.google.com"); | |
657 | 655 |
658 SSLConfig ssl_config; | 656 // Now request a stream. It should succeed using the second proxy in the |
659 StreamRequestWaiter waiter; | 657 // list. |
660 scoped_ptr<HttpStreamRequest> request( | 658 HttpRequestInfo request_info; |
661 session->http_stream_factory()->RequestStream( | 659 request_info.method = "GET"; |
662 request_info, DEFAULT_PRIORITY, ssl_config, ssl_config, &waiter, | 660 request_info.url = GURL("http://www.google.com"); |
663 BoundNetLog())); | |
664 waiter.WaitForStream(); | |
665 | 661 |
666 // The proxy that failed should now be known to the proxy_service as bad. | 662 SSLConfig ssl_config; |
667 const ProxyRetryInfoMap& retry_info = | 663 StreamRequestWaiter waiter; |
668 session->proxy_service()->proxy_retry_info(); | 664 scoped_ptr<HttpStreamRequest> request( |
669 // proxy_headers_handler.proxy_info_used.proxy_retry_info(); | 665 session->http_stream_factory()->RequestStream( |
670 EXPECT_EQ(1u, retry_info.size()); | 666 request_info, DEFAULT_PRIORITY, ssl_config, ssl_config, &waiter, |
671 EXPECT_TRUE(waiter.used_proxy_info().is_direct()); | 667 BoundNetLog())); |
| 668 waiter.WaitForStream(); |
672 | 669 |
673 ProxyRetryInfoMap::const_iterator iter = retry_info.find("quic://bad:99"); | 670 // The proxy that failed should now be known to the proxy_service as bad. |
674 EXPECT_TRUE(iter != retry_info.end()); | 671 const ProxyRetryInfoMap& retry_info = |
| 672 session->proxy_service()->proxy_retry_info(); |
| 673 // proxy_headers_handler.proxy_info_used.proxy_retry_info(); |
| 674 EXPECT_EQ(1u, retry_info.size()) << i; |
| 675 // EXPECT_TRUE(waiter.used_proxy_info().is_direct()); |
| 676 |
| 677 ProxyRetryInfoMap::const_iterator iter = retry_info.find("quic://bad:99"); |
| 678 EXPECT_TRUE(iter != retry_info.end()) << i; |
| 679 } |
675 } | 680 } |
676 | 681 |
677 TEST_P(HttpStreamFactoryTest, PrivacyModeDisablesChannelId) { | 682 TEST_P(HttpStreamFactoryTest, PrivacyModeDisablesChannelId) { |
678 SpdySessionDependencies session_deps( | 683 SpdySessionDependencies session_deps( |
679 GetParam(), ProxyService::CreateDirect()); | 684 GetParam(), ProxyService::CreateDirect()); |
680 | 685 |
681 StaticSocketDataProvider socket_data; | 686 StaticSocketDataProvider socket_data; |
682 socket_data.set_connect_data(MockConnect(ASYNC, OK)); | 687 socket_data.set_connect_data(MockConnect(ASYNC, OK)); |
683 session_deps.socket_factory->AddSocketDataProvider(&socket_data); | 688 session_deps.socket_factory->AddSocketDataProvider(&socket_data); |
684 | 689 |
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 EXPECT_TRUE(waiter.used_proxy_info().is_direct()); | 1359 EXPECT_TRUE(waiter.used_proxy_info().is_direct()); |
1355 | 1360 |
1356 // Make sure there is no orphaned job. it is already canceled. | 1361 // Make sure there is no orphaned job. it is already canceled. |
1357 ASSERT_EQ(0u, static_cast<HttpStreamFactoryImpl*>( | 1362 ASSERT_EQ(0u, static_cast<HttpStreamFactoryImpl*>( |
1358 session->http_stream_factory_for_websocket())->num_orphaned_jobs()); | 1363 session->http_stream_factory_for_websocket())->num_orphaned_jobs()); |
1359 } | 1364 } |
1360 | 1365 |
1361 } // namespace | 1366 } // namespace |
1362 | 1367 |
1363 } // namespace net | 1368 } // namespace net |
OLD | NEW |