| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
| 6 | 6 |
| 7 #include <math.h> // ceil | 7 #include <math.h> // ceil |
| 8 #include <stdarg.h> | 8 #include <stdarg.h> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 7663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7674 scoped_refptr<SpdySession> spdy_session = | 7674 scoped_refptr<SpdySession> spdy_session = |
| 7675 session->spdy_session_pool()->Get(pair, BoundNetLog()); | 7675 session->spdy_session_pool()->Get(pair, BoundNetLog()); |
| 7676 scoped_refptr<TransportSocketParams> transport_params( | 7676 scoped_refptr<TransportSocketParams> transport_params( |
| 7677 new TransportSocketParams(host_port_pair, MEDIUM, false, false)); | 7677 new TransportSocketParams(host_port_pair, MEDIUM, false, false)); |
| 7678 | 7678 |
| 7679 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); | 7679 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); |
| 7680 EXPECT_EQ(ERR_IO_PENDING, | 7680 EXPECT_EQ(ERR_IO_PENDING, |
| 7681 connection->Init(host_port_pair.ToString(), | 7681 connection->Init(host_port_pair.ToString(), |
| 7682 transport_params, | 7682 transport_params, |
| 7683 LOWEST, | 7683 LOWEST, |
| 7684 &callback_old, | 7684 callback.callback(), |
| 7685 session->GetTransportSocketPool(), | 7685 session->GetTransportSocketPool(), |
| 7686 BoundNetLog())); | 7686 BoundNetLog())); |
| 7687 EXPECT_EQ(OK, callback_old.WaitForResult()); | 7687 EXPECT_EQ(OK, callback_old.WaitForResult()); |
| 7688 | 7688 |
| 7689 SSLConfig ssl_config; | 7689 SSLConfig ssl_config; |
| 7690 session->ssl_config_service()->GetSSLConfig(&ssl_config); | 7690 session->ssl_config_service()->GetSSLConfig(&ssl_config); |
| 7691 scoped_ptr<ClientSocketHandle> ssl_connection(new ClientSocketHandle); | 7691 scoped_ptr<ClientSocketHandle> ssl_connection(new ClientSocketHandle); |
| 7692 SSLClientSocketContext context; | 7692 SSLClientSocketContext context; |
| 7693 context.cert_verifier = session_deps.cert_verifier.get(); | 7693 context.cert_verifier = session_deps.cert_verifier.get(); |
| 7694 ssl_connection->set_socket(session_deps.socket_factory.CreateSSLClientSocket( | 7694 ssl_connection->set_socket(session_deps.socket_factory.CreateSSLClientSocket( |
| (...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8956 | 8956 |
| 8957 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8957 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8958 | 8958 |
| 8959 // Set up an initial SpdySession in the pool to reuse. | 8959 // Set up an initial SpdySession in the pool to reuse. |
| 8960 HostPortPair host_port_pair("www.google.com", 443); | 8960 HostPortPair host_port_pair("www.google.com", 443); |
| 8961 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); | 8961 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); |
| 8962 scoped_refptr<SpdySession> spdy_session = | 8962 scoped_refptr<SpdySession> spdy_session = |
| 8963 session->spdy_session_pool()->Get(pair, BoundNetLog()); | 8963 session->spdy_session_pool()->Get(pair, BoundNetLog()); |
| 8964 scoped_refptr<TransportSocketParams> transport_params( | 8964 scoped_refptr<TransportSocketParams> transport_params( |
| 8965 new TransportSocketParams(host_port_pair, MEDIUM, false, false)); | 8965 new TransportSocketParams(host_port_pair, MEDIUM, false, false)); |
| 8966 TestOldCompletionCallback callback; | 8966 TestOldCompletionCallback old_callback; |
| 8967 TestCompletionCallback callback; |
| 8967 | 8968 |
| 8968 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); | 8969 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); |
| 8969 EXPECT_EQ(ERR_IO_PENDING, | 8970 EXPECT_EQ(ERR_IO_PENDING, |
| 8970 connection->Init(host_port_pair.ToString(), transport_params, | 8971 connection->Init(host_port_pair.ToString(), transport_params, |
| 8971 LOWEST, &callback, | 8972 LOWEST, callback.callback(), |
| 8972 session->GetTransportSocketPool(), BoundNetLog())); | 8973 session->GetTransportSocketPool(), BoundNetLog())); |
| 8973 EXPECT_EQ(OK, callback.WaitForResult()); | 8974 EXPECT_EQ(OK, callback.WaitForResult()); |
| 8974 spdy_session->InitializeWithSocket(connection.release(), false, OK); | 8975 spdy_session->InitializeWithSocket(connection.release(), false, OK); |
| 8975 | 8976 |
| 8976 HttpRequestInfo request; | 8977 HttpRequestInfo request; |
| 8977 request.method = "GET"; | 8978 request.method = "GET"; |
| 8978 request.url = GURL("https://www.google.com/"); | 8979 request.url = GURL("https://www.google.com/"); |
| 8979 request.load_flags = 0; | 8980 request.load_flags = 0; |
| 8980 | 8981 |
| 8981 // This is the important line that marks this as a preconnect. | 8982 // This is the important line that marks this as a preconnect. |
| 8982 request.motivation = HttpRequestInfo::PRECONNECT_MOTIVATED; | 8983 request.motivation = HttpRequestInfo::PRECONNECT_MOTIVATED; |
| 8983 | 8984 |
| 8984 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); | 8985 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); |
| 8985 | 8986 |
| 8986 int rv = trans->Start(&request, &callback, BoundNetLog()); | 8987 int rv = trans->Start(&request, &old_callback, BoundNetLog()); |
| 8987 EXPECT_EQ(ERR_IO_PENDING, rv); | 8988 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8988 EXPECT_EQ(OK, callback.WaitForResult()); | 8989 EXPECT_EQ(OK, old_callback.WaitForResult()); |
| 8989 } | 8990 } |
| 8990 | 8991 |
| 8991 // Given a net error, cause that error to be returned from the first Write() | 8992 // Given a net error, cause that error to be returned from the first Write() |
| 8992 // call and verify that the HttpTransaction fails with that error. | 8993 // call and verify that the HttpTransaction fails with that error. |
| 8993 static void CheckErrorIsPassedBack(int error, bool async) { | 8994 static void CheckErrorIsPassedBack(int error, bool async) { |
| 8994 net::HttpRequestInfo request_info; | 8995 net::HttpRequestInfo request_info; |
| 8995 request_info.url = GURL("https://www.example.com/"); | 8996 request_info.url = GURL("https://www.example.com/"); |
| 8996 request_info.method = "GET"; | 8997 request_info.method = "GET"; |
| 8997 request_info.load_flags = net::LOAD_NORMAL; | 8998 request_info.load_flags = net::LOAD_NORMAL; |
| 8998 | 8999 |
| (...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9847 session->spdy_session_pool()->HasSession(host_port_proxy_pair_b)); | 9848 session->spdy_session_pool()->HasSession(host_port_proxy_pair_b)); |
| 9848 | 9849 |
| 9849 HttpStreamFactory::set_next_protos(std::vector<std::string>()); | 9850 HttpStreamFactory::set_next_protos(std::vector<std::string>()); |
| 9850 ClientSocketPoolManager::set_max_sockets_per_pool(old_max_sockets_per_pool); | 9851 ClientSocketPoolManager::set_max_sockets_per_pool(old_max_sockets_per_pool); |
| 9851 ClientSocketPoolManager::set_max_sockets_per_proxy_server( | 9852 ClientSocketPoolManager::set_max_sockets_per_proxy_server( |
| 9852 old_max_sockets_per_proxy_server); | 9853 old_max_sockets_per_proxy_server); |
| 9853 ClientSocketPoolManager::set_max_sockets_per_group(old_max_sockets_per_group); | 9854 ClientSocketPoolManager::set_max_sockets_per_group(old_max_sockets_per_group); |
| 9854 } | 9855 } |
| 9855 | 9856 |
| 9856 } // namespace net | 9857 } // namespace net |
| OLD | NEW |