| 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_proxy_client_socket_pool.h" | 5 #include "net/http/http_proxy_client_socket_pool.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "net/base/auth.h" | 12 #include "net/base/auth.h" |
| 13 #include "net/base/cert_verifier.h" | 13 #include "net/base/cert_verifier.h" |
| 14 #include "net/base/mock_host_resolver.h" | 14 #include "net/base/mock_host_resolver.h" |
| 15 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
| 16 #include "net/base/ssl_config_service_defaults.h" | 16 #include "net/base/ssl_config_service_defaults.h" |
| 17 #include "net/base/sys_addrinfo.h" | |
| 18 #include "net/base/test_certificate_data.h" | 17 #include "net/base/test_certificate_data.h" |
| 19 #include "net/base/test_completion_callback.h" | 18 #include "net/base/test_completion_callback.h" |
| 20 #include "net/http/http_auth_handler_factory.h" | 19 #include "net/http/http_auth_handler_factory.h" |
| 21 #include "net/http/http_network_session.h" | 20 #include "net/http/http_network_session.h" |
| 22 #include "net/http/http_request_headers.h" | 21 #include "net/http/http_request_headers.h" |
| 23 #include "net/http/http_response_headers.h" | 22 #include "net/http/http_response_headers.h" |
| 24 #include "net/http/http_server_properties_impl.h" | 23 #include "net/http/http_server_properties_impl.h" |
| 25 #include "net/proxy/proxy_service.h" | 24 #include "net/proxy/proxy_service.h" |
| 26 #include "net/socket/client_socket_handle.h" | 25 #include "net/socket/client_socket_handle.h" |
| 27 #include "net/socket/client_socket_pool_histograms.h" | 26 #include "net/socket/client_socket_pool_histograms.h" |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 SSLClientSocket* ssl_socket = static_cast<SSLClientSocket*>(handle->socket()); | 713 SSLClientSocket* ssl_socket = static_cast<SSLClientSocket*>(handle->socket()); |
| 715 EXPECT_TRUE(ssl_socket->was_npn_negotiated()); | 714 EXPECT_TRUE(ssl_socket->was_npn_negotiated()); |
| 716 std::string proto; | 715 std::string proto; |
| 717 std::string server_protos; | 716 std::string server_protos; |
| 718 ssl_socket->GetNextProto(&proto, &server_protos); | 717 ssl_socket->GetNextProto(&proto, &server_protos); |
| 719 EXPECT_EQ(SSLClientSocket::NextProtoFromString(proto), | 718 EXPECT_EQ(SSLClientSocket::NextProtoFromString(proto), |
| 720 kProtoSPDY2); | 719 kProtoSPDY2); |
| 721 | 720 |
| 722 // TODO(rtenneti): MockClientSocket::GetPeerAddress returns 0 as the port | 721 // TODO(rtenneti): MockClientSocket::GetPeerAddress returns 0 as the port |
| 723 // number. Fix it to return port 80 and then use GetPeerAddress to AddAlias. | 722 // number. Fix it to return port 80 and then use GetPeerAddress to AddAlias. |
| 724 const addrinfo* address = test_hosts[0].addresses.head(); | |
| 725 SpdySessionPoolPeer pool_peer(session_->spdy_session_pool()); | 723 SpdySessionPoolPeer pool_peer(session_->spdy_session_pool()); |
| 726 pool_peer.AddAlias(address, test_hosts[0].pair); | 724 pool_peer.AddAlias(test_hosts[0].addresses.front(), test_hosts[0].pair); |
| 727 | 725 |
| 728 scoped_refptr<SpdySession> spdy_session; | 726 scoped_refptr<SpdySession> spdy_session; |
| 729 rv = session_->spdy_session_pool()->GetSpdySessionFromSocket( | 727 rv = session_->spdy_session_pool()->GetSpdySessionFromSocket( |
| 730 test_hosts[0].pair, handle.release(), BoundNetLog(), 0, | 728 test_hosts[0].pair, handle.release(), BoundNetLog(), 0, |
| 731 &spdy_session, true); | 729 &spdy_session, true); |
| 732 EXPECT_EQ(0, rv); | 730 EXPECT_EQ(0, rv); |
| 733 | 731 |
| 734 EXPECT_TRUE(session_->spdy_session_pool()->HasSession(test_hosts[0].pair)); | 732 EXPECT_TRUE(session_->spdy_session_pool()->HasSession(test_hosts[0].pair)); |
| 735 EXPECT_FALSE(session_->spdy_session_pool()->HasSession(test_hosts[1].pair)); | 733 EXPECT_FALSE(session_->spdy_session_pool()->HasSession(test_hosts[1].pair)); |
| 736 EXPECT_TRUE(session_->spdy_session_pool()->HasSession(test_hosts[2].pair)); | 734 EXPECT_TRUE(session_->spdy_session_pool()->HasSession(test_hosts[2].pair)); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 SSLClientSocket* ssl_socket = static_cast<SSLClientSocket*>(handle->socket()); | 798 SSLClientSocket* ssl_socket = static_cast<SSLClientSocket*>(handle->socket()); |
| 801 EXPECT_TRUE(ssl_socket->was_npn_negotiated()); | 799 EXPECT_TRUE(ssl_socket->was_npn_negotiated()); |
| 802 std::string proto; | 800 std::string proto; |
| 803 std::string server_protos; | 801 std::string server_protos; |
| 804 ssl_socket->GetNextProto(&proto, &server_protos); | 802 ssl_socket->GetNextProto(&proto, &server_protos); |
| 805 EXPECT_EQ(SSLClientSocket::NextProtoFromString(proto), | 803 EXPECT_EQ(SSLClientSocket::NextProtoFromString(proto), |
| 806 kProtoSPDY2); | 804 kProtoSPDY2); |
| 807 | 805 |
| 808 // TODO(rtenneti): MockClientSocket::GetPeerAddress returns 0 as the port | 806 // TODO(rtenneti): MockClientSocket::GetPeerAddress returns 0 as the port |
| 809 // number. Fix it to return port 80 and then use GetPeerAddress to AddAlias. | 807 // number. Fix it to return port 80 and then use GetPeerAddress to AddAlias. |
| 810 const addrinfo* address = test_hosts[0].addresses.head(); | |
| 811 SpdySessionPoolPeer pool_peer(session_->spdy_session_pool()); | 808 SpdySessionPoolPeer pool_peer(session_->spdy_session_pool()); |
| 812 pool_peer.AddAlias(address, test_hosts[0].pair); | 809 pool_peer.AddAlias(test_hosts[0].addresses.front(), test_hosts[0].pair); |
| 813 | 810 |
| 814 scoped_refptr<SpdySession> spdy_session; | 811 scoped_refptr<SpdySession> spdy_session; |
| 815 rv = session_->spdy_session_pool()->GetSpdySessionFromSocket( | 812 rv = session_->spdy_session_pool()->GetSpdySessionFromSocket( |
| 816 test_hosts[0].pair, handle.release(), BoundNetLog(), 0, | 813 test_hosts[0].pair, handle.release(), BoundNetLog(), 0, |
| 817 &spdy_session, true); | 814 &spdy_session, true); |
| 818 EXPECT_EQ(0, rv); | 815 EXPECT_EQ(0, rv); |
| 819 | 816 |
| 820 EXPECT_TRUE(session_->spdy_session_pool()->HasSession(test_hosts[0].pair)); | 817 EXPECT_TRUE(session_->spdy_session_pool()->HasSession(test_hosts[0].pair)); |
| 821 EXPECT_FALSE(session_->spdy_session_pool()->HasSession(test_hosts[1].pair)); | 818 EXPECT_FALSE(session_->spdy_session_pool()->HasSession(test_hosts[1].pair)); |
| 822 | 819 |
| 823 session_->spdy_session_pool()->CloseAllSessions(); | 820 session_->spdy_session_pool()->CloseAllSessions(); |
| 824 } | 821 } |
| 825 | 822 |
| 826 // It would be nice to also test the timeouts in SSLClientSocketPool. | 823 // It would be nice to also test the timeouts in SSLClientSocketPool. |
| 827 | 824 |
| 828 } // namespace | 825 } // namespace |
| 829 | 826 |
| 830 } // namespace net | 827 } // namespace net |
| OLD | NEW |