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 7294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7305 scoped_refptr<SpdySession> spdy_session = | 7305 scoped_refptr<SpdySession> spdy_session = |
7306 session->spdy_session_pool()->Get(pair, BoundNetLog()); | 7306 session->spdy_session_pool()->Get(pair, BoundNetLog()); |
7307 scoped_refptr<TransportSocketParams> transport_params( | 7307 scoped_refptr<TransportSocketParams> transport_params( |
7308 new TransportSocketParams(host_port_pair, MEDIUM, false, false)); | 7308 new TransportSocketParams(host_port_pair, MEDIUM, false, false)); |
7309 | 7309 |
7310 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); | 7310 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); |
7311 EXPECT_EQ(ERR_IO_PENDING, | 7311 EXPECT_EQ(ERR_IO_PENDING, |
7312 connection->Init(host_port_pair.ToString(), | 7312 connection->Init(host_port_pair.ToString(), |
7313 transport_params, | 7313 transport_params, |
7314 LOWEST, | 7314 LOWEST, |
7315 &callback_old, | 7315 callback.callback(), |
7316 session->GetTransportSocketPool(), | 7316 session->GetTransportSocketPool(), |
7317 BoundNetLog())); | 7317 BoundNetLog())); |
7318 EXPECT_EQ(OK, callback_old.WaitForResult()); | 7318 EXPECT_EQ(OK, callback.WaitForResult()); |
7319 | 7319 |
7320 SSLConfig ssl_config; | 7320 SSLConfig ssl_config; |
7321 session->ssl_config_service()->GetSSLConfig(&ssl_config); | 7321 session->ssl_config_service()->GetSSLConfig(&ssl_config); |
7322 scoped_ptr<ClientSocketHandle> ssl_connection(new ClientSocketHandle); | 7322 scoped_ptr<ClientSocketHandle> ssl_connection(new ClientSocketHandle); |
7323 SSLClientSocketContext context; | 7323 SSLClientSocketContext context; |
7324 context.cert_verifier = session_deps.cert_verifier.get(); | 7324 context.cert_verifier = session_deps.cert_verifier.get(); |
7325 ssl_connection->set_socket(session_deps.socket_factory.CreateSSLClientSocket( | 7325 ssl_connection->set_socket(session_deps.socket_factory.CreateSSLClientSocket( |
7326 connection.release(), HostPortPair("" , 443), ssl_config, | 7326 connection.release(), HostPortPair("" , 443), ssl_config, |
7327 NULL /* ssl_host_info */, context)); | 7327 NULL /* ssl_host_info */, context)); |
7328 EXPECT_EQ(ERR_IO_PENDING, | 7328 EXPECT_EQ(ERR_IO_PENDING, |
(...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8560 | 8560 |
8561 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8561 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
8562 | 8562 |
8563 // Set up an initial SpdySession in the pool to reuse. | 8563 // Set up an initial SpdySession in the pool to reuse. |
8564 HostPortPair host_port_pair("www.google.com", 443); | 8564 HostPortPair host_port_pair("www.google.com", 443); |
8565 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); | 8565 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); |
8566 scoped_refptr<SpdySession> spdy_session = | 8566 scoped_refptr<SpdySession> spdy_session = |
8567 session->spdy_session_pool()->Get(pair, BoundNetLog()); | 8567 session->spdy_session_pool()->Get(pair, BoundNetLog()); |
8568 scoped_refptr<TransportSocketParams> transport_params( | 8568 scoped_refptr<TransportSocketParams> transport_params( |
8569 new TransportSocketParams(host_port_pair, MEDIUM, false, false)); | 8569 new TransportSocketParams(host_port_pair, MEDIUM, false, false)); |
8570 TestOldCompletionCallback callback; | 8570 TestOldCompletionCallback old_callback; |
| 8571 TestCompletionCallback callback; |
8571 | 8572 |
8572 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); | 8573 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); |
8573 EXPECT_EQ(ERR_IO_PENDING, | 8574 EXPECT_EQ(ERR_IO_PENDING, |
8574 connection->Init(host_port_pair.ToString(), transport_params, | 8575 connection->Init(host_port_pair.ToString(), transport_params, |
8575 LOWEST, &callback, | 8576 LOWEST, callback.callback(), |
8576 session->GetTransportSocketPool(), BoundNetLog())); | 8577 session->GetTransportSocketPool(), BoundNetLog())); |
8577 EXPECT_EQ(OK, callback.WaitForResult()); | 8578 EXPECT_EQ(OK, callback.WaitForResult()); |
8578 spdy_session->InitializeWithSocket(connection.release(), false, OK); | 8579 spdy_session->InitializeWithSocket(connection.release(), false, OK); |
8579 | 8580 |
8580 HttpRequestInfo request; | 8581 HttpRequestInfo request; |
8581 request.method = "GET"; | 8582 request.method = "GET"; |
8582 request.url = GURL("https://www.google.com/"); | 8583 request.url = GURL("https://www.google.com/"); |
8583 request.load_flags = 0; | 8584 request.load_flags = 0; |
8584 | 8585 |
8585 // This is the important line that marks this as a preconnect. | 8586 // This is the important line that marks this as a preconnect. |
8586 request.motivation = HttpRequestInfo::PRECONNECT_MOTIVATED; | 8587 request.motivation = HttpRequestInfo::PRECONNECT_MOTIVATED; |
8587 | 8588 |
8588 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); | 8589 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); |
8589 | 8590 |
8590 int rv = trans->Start(&request, &callback, BoundNetLog()); | 8591 int rv = trans->Start(&request, &old_callback, BoundNetLog()); |
8591 EXPECT_EQ(ERR_IO_PENDING, rv); | 8592 EXPECT_EQ(ERR_IO_PENDING, rv); |
8592 EXPECT_EQ(OK, callback.WaitForResult()); | 8593 EXPECT_EQ(OK, old_callback.WaitForResult()); |
8593 } | 8594 } |
8594 | 8595 |
8595 // Given a net error, cause that error to be returned from the first Write() | 8596 // Given a net error, cause that error to be returned from the first Write() |
8596 // call and verify that the HttpTransaction fails with that error. | 8597 // call and verify that the HttpTransaction fails with that error. |
8597 static void CheckErrorIsPassedBack(int error, bool async) { | 8598 static void CheckErrorIsPassedBack(int error, bool async) { |
8598 net::HttpRequestInfo request_info; | 8599 net::HttpRequestInfo request_info; |
8599 request_info.url = GURL("https://www.example.com/"); | 8600 request_info.url = GURL("https://www.example.com/"); |
8600 request_info.method = "GET"; | 8601 request_info.method = "GET"; |
8601 request_info.load_flags = net::LOAD_NORMAL; | 8602 request_info.load_flags = net::LOAD_NORMAL; |
8602 | 8603 |
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9451 session->spdy_session_pool()->HasSession(host_port_proxy_pair_b)); | 9452 session->spdy_session_pool()->HasSession(host_port_proxy_pair_b)); |
9452 | 9453 |
9453 HttpStreamFactory::set_next_protos(std::vector<std::string>()); | 9454 HttpStreamFactory::set_next_protos(std::vector<std::string>()); |
9454 ClientSocketPoolManager::set_max_sockets_per_pool(old_max_sockets_per_pool); | 9455 ClientSocketPoolManager::set_max_sockets_per_pool(old_max_sockets_per_pool); |
9455 ClientSocketPoolManager::set_max_sockets_per_proxy_server( | 9456 ClientSocketPoolManager::set_max_sockets_per_proxy_server( |
9456 old_max_sockets_per_proxy_server); | 9457 old_max_sockets_per_proxy_server); |
9457 ClientSocketPoolManager::set_max_sockets_per_group(old_max_sockets_per_group); | 9458 ClientSocketPoolManager::set_max_sockets_per_group(old_max_sockets_per_group); |
9458 } | 9459 } |
9459 | 9460 |
9460 } // namespace net | 9461 } // namespace net |
OLD | NEW |