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

Side by Side Diff: net/socket/ssl_client_socket_pool_unittest.cc

Issue 8549004: base::Bind: Convert HostResolver::Resolve. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 9 years, 1 month 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/socket/socks_client_socket_unittest.cc ('k') | net/socket/transport_client_socket_pool.cc » ('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_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"
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 }; 668 };
669 669
670 host_resolver_.set_synchronous_mode(true); 670 host_resolver_.set_synchronous_mode(true);
671 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_hosts); i++) { 671 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_hosts); i++) {
672 host_resolver_.rules()->AddIPLiteralRule(test_hosts[i].name, 672 host_resolver_.rules()->AddIPLiteralRule(test_hosts[i].name,
673 test_hosts[i].iplist, ""); 673 test_hosts[i].iplist, "");
674 674
675 // This test requires that the HostResolver cache be populated. Normal 675 // This test requires that the HostResolver cache be populated. Normal
676 // code would have done this already, but we do it manually. 676 // code would have done this already, but we do it manually.
677 HostResolver::RequestInfo info(HostPortPair(test_hosts[i].name, kTestPort)); 677 HostResolver::RequestInfo info(HostPortPair(test_hosts[i].name, kTestPort));
678 host_resolver_.Resolve(info, &test_hosts[i].addresses, NULL, NULL, 678 host_resolver_.Resolve(info, &test_hosts[i].addresses, CompletionCallback(),
679 BoundNetLog()); 679 NULL, BoundNetLog());
680 680
681 // Setup a HostPortProxyPair 681 // Setup a HostPortProxyPair
682 test_hosts[i].pair = HostPortProxyPair( 682 test_hosts[i].pair = HostPortProxyPair(
683 HostPortPair(test_hosts[i].name, kTestPort), ProxyServer::Direct()); 683 HostPortPair(test_hosts[i].name, kTestPort), ProxyServer::Direct());
684 } 684 }
685 685
686 MockRead reads[] = { 686 MockRead reads[] = {
687 MockRead(true, ERR_IO_PENDING), 687 MockRead(true, ERR_IO_PENDING),
688 }; 688 };
689 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); 689 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 struct TestHosts { 744 struct TestHosts {
745 std::string name; 745 std::string name;
746 std::string iplist; 746 std::string iplist;
747 HostPortProxyPair pair; 747 HostPortProxyPair pair;
748 AddressList addresses; 748 AddressList addresses;
749 } test_hosts[] = { 749 } test_hosts[] = {
750 { "www.webkit.org", "192.0.2.33,192.168.0.1,192.168.0.5" }, 750 { "www.webkit.org", "192.0.2.33,192.168.0.1,192.168.0.5" },
751 { "js.webkit.org", "192.168.0.4,192.168.0.1,192.0.2.33" }, 751 { "js.webkit.org", "192.168.0.4,192.168.0.1,192.0.2.33" },
752 }; 752 };
753 753
754 TestOldCompletionCallback callback; 754 TestCompletionCallback callback;
755 TestOldCompletionCallback old_callback;
755 int rv; 756 int rv;
756 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_hosts); i++) { 757 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_hosts); i++) {
757 host_resolver_.rules()->AddIPLiteralRule(test_hosts[i].name, 758 host_resolver_.rules()->AddIPLiteralRule(test_hosts[i].name,
758 test_hosts[i].iplist, ""); 759 test_hosts[i].iplist, "");
759 760
760 // This test requires that the HostResolver cache be populated. Normal 761 // This test requires that the HostResolver cache be populated. Normal
761 // code would have done this already, but we do it manually. 762 // code would have done this already, but we do it manually.
762 HostResolver::RequestInfo info(HostPortPair(test_hosts[i].name, kTestPort)); 763 HostResolver::RequestInfo info(HostPortPair(test_hosts[i].name, kTestPort));
763 rv = host_resolver_.Resolve(info, &test_hosts[i].addresses, &callback, 764 rv = host_resolver_.Resolve(info, &test_hosts[i].addresses,
764 NULL, BoundNetLog()); 765 callback.callback(), NULL, BoundNetLog());
765 EXPECT_EQ(OK, callback.GetResult(rv)); 766 EXPECT_EQ(OK, callback.GetResult(rv));
766 767
767 // Setup a HostPortProxyPair 768 // Setup a HostPortProxyPair
768 test_hosts[i].pair = HostPortProxyPair( 769 test_hosts[i].pair = HostPortProxyPair(
769 HostPortPair(test_hosts[i].name, kTestPort), ProxyServer::Direct()); 770 HostPortPair(test_hosts[i].name, kTestPort), ProxyServer::Direct());
770 } 771 }
771 772
772 MockRead reads[] = { 773 MockRead reads[] = {
773 MockRead(true, ERR_IO_PENDING), 774 MockRead(true, ERR_IO_PENDING),
774 }; 775 };
775 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); 776 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0);
776 socket_factory_.AddSocketDataProvider(&data); 777 socket_factory_.AddSocketDataProvider(&data);
777 SSLSocketDataProvider ssl(true, OK); 778 SSLSocketDataProvider ssl(true, OK);
778 ssl.cert = X509Certificate::CreateFromBytes( 779 ssl.cert = X509Certificate::CreateFromBytes(
779 reinterpret_cast<const char*>(webkit_der), sizeof(webkit_der)); 780 reinterpret_cast<const char*>(webkit_der), sizeof(webkit_der));
780 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; 781 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated;
781 ssl.next_proto = "spdy/2"; 782 ssl.next_proto = "spdy/2";
782 ssl.client_cert_sent = true; 783 ssl.client_cert_sent = true;
783 socket_factory_.AddSSLSocketDataProvider(&ssl); 784 socket_factory_.AddSSLSocketDataProvider(&ssl);
784 785
785 CreatePool(true /* tcp pool */, false, false); 786 CreatePool(true /* tcp pool */, false, false);
786 scoped_refptr<SSLSocketParams> params = SSLParams(ProxyServer::SCHEME_DIRECT, 787 scoped_refptr<SSLSocketParams> params = SSLParams(ProxyServer::SCHEME_DIRECT,
787 true); 788 true);
788 789
789 scoped_ptr<ClientSocketHandle> handle(new ClientSocketHandle()); 790 scoped_ptr<ClientSocketHandle> handle(new ClientSocketHandle());
790 rv = handle->Init( 791 rv = handle->Init(
791 "a", params, MEDIUM, &callback, pool_.get(), BoundNetLog()); 792 "a", params, MEDIUM, &old_callback, pool_.get(), BoundNetLog());
792 EXPECT_EQ(ERR_IO_PENDING, rv); 793 EXPECT_EQ(ERR_IO_PENDING, rv);
793 EXPECT_FALSE(handle->is_initialized()); 794 EXPECT_FALSE(handle->is_initialized());
794 EXPECT_FALSE(handle->socket()); 795 EXPECT_FALSE(handle->socket());
795 796
796 EXPECT_EQ(OK, callback.WaitForResult()); 797 EXPECT_EQ(OK, old_callback.WaitForResult());
797 EXPECT_TRUE(handle->is_initialized()); 798 EXPECT_TRUE(handle->is_initialized());
798 EXPECT_TRUE(handle->socket()); 799 EXPECT_TRUE(handle->socket());
799 800
800 SSLClientSocket* ssl_socket = static_cast<SSLClientSocket*>(handle->socket()); 801 SSLClientSocket* ssl_socket = static_cast<SSLClientSocket*>(handle->socket());
801 EXPECT_TRUE(ssl_socket->was_npn_negotiated()); 802 EXPECT_TRUE(ssl_socket->was_npn_negotiated());
802 std::string proto; 803 std::string proto;
803 ssl_socket->GetNextProto(&proto); 804 ssl_socket->GetNextProto(&proto);
804 EXPECT_EQ(SSLClientSocket::NextProtoFromString(proto), 805 EXPECT_EQ(SSLClientSocket::NextProtoFromString(proto),
805 SSLClientSocket::kProtoSPDY2); 806 SSLClientSocket::kProtoSPDY2);
806 807
(...skipping 13 matching lines...) Expand all
820 EXPECT_FALSE(session_->spdy_session_pool()->HasSession(test_hosts[1].pair)); 821 EXPECT_FALSE(session_->spdy_session_pool()->HasSession(test_hosts[1].pair));
821 822
822 session_->spdy_session_pool()->CloseAllSessions(); 823 session_->spdy_session_pool()->CloseAllSessions();
823 } 824 }
824 825
825 // It would be nice to also test the timeouts in SSLClientSocketPool. 826 // It would be nice to also test the timeouts in SSLClientSocketPool.
826 827
827 } // namespace 828 } // namespace
828 829
829 } // namespace net 830 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/socks_client_socket_unittest.cc ('k') | net/socket/transport_client_socket_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698