Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: net/http/http_network_transaction_unittest.cc

Issue 8824006: Migrate net/socket/socket.h, net/socket/stream_socket.h to base::Bind(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/ftp/ftp_transaction.h ('k') | net/http/http_proxy_client_socket.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 7630 matching lines...) Expand 10 before | Expand all | Expand 10 after
7641 MockRead(true, 0, 0), 7641 MockRead(true, 0, 0),
7642 }; 7642 };
7643 7643
7644 scoped_refptr<DelayedSocketData> spdy_data( 7644 scoped_refptr<DelayedSocketData> spdy_data(
7645 new DelayedSocketData( 7645 new DelayedSocketData(
7646 1, // wait for one write to finish before reading. 7646 1, // wait for one write to finish before reading.
7647 spdy_reads, arraysize(spdy_reads), 7647 spdy_reads, arraysize(spdy_reads),
7648 spdy_writes, arraysize(spdy_writes))); 7648 spdy_writes, arraysize(spdy_writes)));
7649 session_deps.socket_factory.AddSocketDataProvider(spdy_data); 7649 session_deps.socket_factory.AddSocketDataProvider(spdy_data);
7650 7650
7651 TestOldCompletionCallback callback; 7651 TestOldCompletionCallback callback_old;
7652 TestCompletionCallback callback;
7652 7653
7653 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); 7654 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
7654 7655
7655 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); 7656 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session));
7656 7657
7657 int rv = trans->Start(&request, &callback, BoundNetLog()); 7658 int rv = trans->Start(&request, &callback_old, BoundNetLog());
7658 EXPECT_EQ(ERR_IO_PENDING, rv); 7659 EXPECT_EQ(ERR_IO_PENDING, rv);
7659 EXPECT_EQ(OK, callback.WaitForResult()); 7660 EXPECT_EQ(OK, callback_old.WaitForResult());
7660 7661
7661 const HttpResponseInfo* response = trans->GetResponseInfo(); 7662 const HttpResponseInfo* response = trans->GetResponseInfo();
7662 ASSERT_TRUE(response != NULL); 7663 ASSERT_TRUE(response != NULL);
7663 ASSERT_TRUE(response->headers != NULL); 7664 ASSERT_TRUE(response->headers != NULL);
7664 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 7665 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
7665 7666
7666 std::string response_data; 7667 std::string response_data;
7667 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 7668 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
7668 EXPECT_EQ("hello world", response_data); 7669 EXPECT_EQ("hello world", response_data);
7669 7670
7670 // Set up an initial SpdySession in the pool to reuse. 7671 // Set up an initial SpdySession in the pool to reuse.
7671 HostPortPair host_port_pair("www.google.com", 443); 7672 HostPortPair host_port_pair("www.google.com", 443);
7672 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); 7673 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct());
7673 scoped_refptr<SpdySession> spdy_session = 7674 scoped_refptr<SpdySession> spdy_session =
7674 session->spdy_session_pool()->Get(pair, BoundNetLog()); 7675 session->spdy_session_pool()->Get(pair, BoundNetLog());
7675 scoped_refptr<TransportSocketParams> transport_params( 7676 scoped_refptr<TransportSocketParams> transport_params(
7676 new TransportSocketParams(host_port_pair, MEDIUM, false, false)); 7677 new TransportSocketParams(host_port_pair, MEDIUM, false, false));
7677 7678
7678 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); 7679 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle);
7679 EXPECT_EQ(ERR_IO_PENDING, 7680 EXPECT_EQ(ERR_IO_PENDING,
7680 connection->Init(host_port_pair.ToString(), 7681 connection->Init(host_port_pair.ToString(),
7681 transport_params, 7682 transport_params,
7682 LOWEST, 7683 LOWEST,
7683 &callback, 7684 &callback_old,
7684 session->GetTransportSocketPool(), 7685 session->GetTransportSocketPool(),
7685 BoundNetLog())); 7686 BoundNetLog()));
7686 EXPECT_EQ(OK, callback.WaitForResult()); 7687 EXPECT_EQ(OK, callback_old.WaitForResult());
7687 7688
7688 SSLConfig ssl_config; 7689 SSLConfig ssl_config;
7689 session->ssl_config_service()->GetSSLConfig(&ssl_config); 7690 session->ssl_config_service()->GetSSLConfig(&ssl_config);
7690 scoped_ptr<ClientSocketHandle> ssl_connection(new ClientSocketHandle); 7691 scoped_ptr<ClientSocketHandle> ssl_connection(new ClientSocketHandle);
7691 SSLClientSocketContext context; 7692 SSLClientSocketContext context;
7692 context.cert_verifier = session_deps.cert_verifier.get(); 7693 context.cert_verifier = session_deps.cert_verifier.get();
7693 ssl_connection->set_socket(session_deps.socket_factory.CreateSSLClientSocket( 7694 ssl_connection->set_socket(session_deps.socket_factory.CreateSSLClientSocket(
7694 connection.release(), HostPortPair("" , 443), ssl_config, 7695 connection.release(), HostPortPair("" , 443), ssl_config,
7695 NULL /* ssl_host_info */, context)); 7696 NULL /* ssl_host_info */, context));
7696 EXPECT_EQ(ERR_IO_PENDING, ssl_connection->socket()->Connect(&callback)); 7697 EXPECT_EQ(ERR_IO_PENDING,
7698 ssl_connection->socket()->Connect(callback.callback()));
7697 EXPECT_EQ(OK, callback.WaitForResult()); 7699 EXPECT_EQ(OK, callback.WaitForResult());
7698 7700
7699 EXPECT_EQ(OK, spdy_session->InitializeWithSocket(ssl_connection.release(), 7701 EXPECT_EQ(OK, spdy_session->InitializeWithSocket(ssl_connection.release(),
7700 true, OK)); 7702 true, OK));
7701 7703
7702 trans.reset(new HttpNetworkTransaction(session)); 7704 trans.reset(new HttpNetworkTransaction(session));
7703 7705
7704 rv = trans->Start(&request, &callback, BoundNetLog()); 7706 rv = trans->Start(&request, &callback_old, BoundNetLog());
7705 EXPECT_EQ(ERR_IO_PENDING, rv); 7707 EXPECT_EQ(ERR_IO_PENDING, rv);
7706 EXPECT_EQ(OK, callback.WaitForResult()); 7708 EXPECT_EQ(OK, callback_old.WaitForResult());
7707 7709
7708 response = trans->GetResponseInfo(); 7710 response = trans->GetResponseInfo();
7709 ASSERT_TRUE(response != NULL); 7711 ASSERT_TRUE(response != NULL);
7710 ASSERT_TRUE(response->headers != NULL); 7712 ASSERT_TRUE(response->headers != NULL);
7711 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 7713 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
7712 EXPECT_TRUE(response->was_fetched_via_spdy); 7714 EXPECT_TRUE(response->was_fetched_via_spdy);
7713 EXPECT_TRUE(response->was_npn_negotiated); 7715 EXPECT_TRUE(response->was_npn_negotiated);
7714 7716
7715 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 7717 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
7716 EXPECT_EQ("hello!", response_data); 7718 EXPECT_EQ("hello!", response_data);
(...skipping 2127 matching lines...) Expand 10 before | Expand all | Expand 10 after
9844 session->spdy_session_pool()->HasSession(host_port_proxy_pair_b)); 9846 session->spdy_session_pool()->HasSession(host_port_proxy_pair_b));
9845 9847
9846 HttpStreamFactory::set_next_protos(std::vector<std::string>()); 9848 HttpStreamFactory::set_next_protos(std::vector<std::string>());
9847 ClientSocketPoolManager::set_max_sockets_per_pool(old_max_sockets_per_pool); 9849 ClientSocketPoolManager::set_max_sockets_per_pool(old_max_sockets_per_pool);
9848 ClientSocketPoolManager::set_max_sockets_per_proxy_server( 9850 ClientSocketPoolManager::set_max_sockets_per_proxy_server(
9849 old_max_sockets_per_proxy_server); 9851 old_max_sockets_per_proxy_server);
9850 ClientSocketPoolManager::set_max_sockets_per_group(old_max_sockets_per_group); 9852 ClientSocketPoolManager::set_max_sockets_per_group(old_max_sockets_per_group);
9851 } 9853 }
9852 9854
9853 } // namespace net 9855 } // namespace net
OLDNEW
« no previous file with comments | « net/ftp/ftp_transaction.h ('k') | net/http/http_proxy_client_socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698