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

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

Issue 5386001: Cache certificate verification results in memory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Upload before checkin Created 10 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/http/http_network_session.cc ('k') | net/http/http_proxy_client_socket_pool_unittest.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } // namespace 67 } // namespace
68 68
69 namespace net { 69 namespace net {
70 70
71 // Helper to manage the lifetimes of the dependencies for a 71 // Helper to manage the lifetimes of the dependencies for a
72 // HttpNetworkTransaction. 72 // HttpNetworkTransaction.
73 struct SessionDependencies { 73 struct SessionDependencies {
74 // Default set of dependencies -- "null" proxy service. 74 // Default set of dependencies -- "null" proxy service.
75 SessionDependencies() 75 SessionDependencies()
76 : host_resolver(new MockHostResolver), 76 : host_resolver(new MockHostResolver),
77 cert_verifier(new CertVerifier),
77 proxy_service(ProxyService::CreateDirect()), 78 proxy_service(ProxyService::CreateDirect()),
78 ssl_config_service(new SSLConfigServiceDefaults), 79 ssl_config_service(new SSLConfigServiceDefaults),
79 http_auth_handler_factory( 80 http_auth_handler_factory(
80 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())), 81 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())),
81 net_log(NULL) {} 82 net_log(NULL) {}
82 83
83 // Custom proxy service dependency. 84 // Custom proxy service dependency.
84 explicit SessionDependencies(ProxyService* proxy_service) 85 explicit SessionDependencies(ProxyService* proxy_service)
85 : host_resolver(new MockHostResolver), 86 : host_resolver(new MockHostResolver),
87 cert_verifier(new CertVerifier),
86 proxy_service(proxy_service), 88 proxy_service(proxy_service),
87 ssl_config_service(new SSLConfigServiceDefaults), 89 ssl_config_service(new SSLConfigServiceDefaults),
88 http_auth_handler_factory( 90 http_auth_handler_factory(
89 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())), 91 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())),
90 net_log(NULL) {} 92 net_log(NULL) {}
91 93
92 scoped_ptr<MockHostResolverBase> host_resolver; 94 scoped_ptr<MockHostResolverBase> host_resolver;
95 scoped_ptr<CertVerifier> cert_verifier;
93 scoped_refptr<ProxyService> proxy_service; 96 scoped_refptr<ProxyService> proxy_service;
94 scoped_refptr<SSLConfigService> ssl_config_service; 97 scoped_refptr<SSLConfigService> ssl_config_service;
95 MockClientSocketFactory socket_factory; 98 MockClientSocketFactory socket_factory;
96 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory; 99 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory;
97 NetLog* net_log; 100 NetLog* net_log;
98 }; 101 };
99 102
100 HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { 103 HttpNetworkSession* CreateSession(SessionDependencies* session_deps) {
101 return new HttpNetworkSession(session_deps->host_resolver.get(), 104 return new HttpNetworkSession(session_deps->host_resolver.get(),
105 session_deps->cert_verifier.get(),
102 NULL /* dnsrr_resolver */, 106 NULL /* dnsrr_resolver */,
103 NULL /* dns_cert_checker */, 107 NULL /* dns_cert_checker */,
104 NULL /* ssl_host_info_factory */, 108 NULL /* ssl_host_info_factory */,
105 session_deps->proxy_service, 109 session_deps->proxy_service,
106 &session_deps->socket_factory, 110 &session_deps->socket_factory,
107 session_deps->ssl_config_service, 111 session_deps->ssl_config_service,
108 new SpdySessionPool(NULL), 112 new SpdySessionPool(NULL),
109 session_deps->http_auth_handler_factory.get(), 113 session_deps->http_auth_handler_factory.get(),
110 NULL, 114 NULL,
111 session_deps->net_log); 115 session_deps->net_log);
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 307
304 template<> 308 template<>
305 CaptureGroupNameHttpProxySocketPool::CaptureGroupNameSocketPool( 309 CaptureGroupNameHttpProxySocketPool::CaptureGroupNameSocketPool(
306 HttpNetworkSession* session) 310 HttpNetworkSession* session)
307 : HttpProxyClientSocketPool(0, 0, NULL, session->host_resolver(), NULL, 311 : HttpProxyClientSocketPool(0, 0, NULL, session->host_resolver(), NULL,
308 NULL, NULL) {} 312 NULL, NULL) {}
309 313
310 template<> 314 template<>
311 CaptureGroupNameSSLSocketPool::CaptureGroupNameSocketPool( 315 CaptureGroupNameSSLSocketPool::CaptureGroupNameSocketPool(
312 HttpNetworkSession* session) 316 HttpNetworkSession* session)
313 : SSLClientSocketPool(0, 0, NULL, session->host_resolver(), NULL, NULL, 317 : SSLClientSocketPool(0, 0, NULL, session->host_resolver(),
318 session->cert_verifier(), NULL, NULL,
314 NULL, NULL, NULL, NULL, NULL, NULL, NULL) {} 319 NULL, NULL, NULL, NULL, NULL, NULL, NULL) {}
315 320
316 //----------------------------------------------------------------------------- 321 //-----------------------------------------------------------------------------
317 322
318 // This is the expected list of advertised protocols from the browser's NPN 323 // This is the expected list of advertised protocols from the browser's NPN
319 // list. 324 // list.
320 static const char kExpectedNPNString[] = "\x08http/1.1\x06spdy/2"; 325 static const char kExpectedNPNString[] = "\x08http/1.1\x06spdy/2";
321 326
322 // This is the expected return from a current server advertising SPDY. 327 // This is the expected return from a current server advertising SPDY.
323 static const char kAlternateProtocolHttpHeader[] = 328 static const char kAlternateProtocolHttpHeader[] =
(...skipping 6348 matching lines...) Expand 10 before | Expand all | Expand 10 after
6672 EXPECT_EQ(ERR_IO_PENDING, 6677 EXPECT_EQ(ERR_IO_PENDING,
6673 connection->Init(host_port_pair.ToString(),tcp_params, LOWEST, 6678 connection->Init(host_port_pair.ToString(),tcp_params, LOWEST,
6674 &callback, session->tcp_socket_pool(), 6679 &callback, session->tcp_socket_pool(),
6675 BoundNetLog())); 6680 BoundNetLog()));
6676 EXPECT_EQ(OK, callback.WaitForResult()); 6681 EXPECT_EQ(OK, callback.WaitForResult());
6677 6682
6678 SSLConfig ssl_config; 6683 SSLConfig ssl_config;
6679 session->ssl_config_service()->GetSSLConfig(&ssl_config); 6684 session->ssl_config_service()->GetSSLConfig(&ssl_config);
6680 ClientSocket* socket = connection->release_socket(); 6685 ClientSocket* socket = connection->release_socket();
6681 socket = session->socket_factory()->CreateSSLClientSocket( 6686 socket = session->socket_factory()->CreateSSLClientSocket(
6682 socket, HostPortPair("" , 443), ssl_config, NULL /* ssl_host_info */); 6687 socket, HostPortPair("" , 443), ssl_config, NULL /* ssl_host_info */,
6688 session->cert_verifier());
6683 connection->set_socket(socket); 6689 connection->set_socket(socket);
6684 EXPECT_EQ(ERR_IO_PENDING, socket->Connect(&callback)); 6690 EXPECT_EQ(ERR_IO_PENDING, socket->Connect(&callback));
6685 EXPECT_EQ(OK, callback.WaitForResult()); 6691 EXPECT_EQ(OK, callback.WaitForResult());
6686 6692
6687 EXPECT_EQ(OK, spdy_session->InitializeWithSocket(connection.release(), 6693 EXPECT_EQ(OK, spdy_session->InitializeWithSocket(connection.release(),
6688 true, OK)); 6694 true, OK));
6689 6695
6690 trans.reset(new HttpNetworkTransaction(session)); 6696 trans.reset(new HttpNetworkTransaction(session));
6691 6697
6692 rv = trans->Start(&request, &callback, BoundNetLog()); 6698 rv = trans->Start(&request, &callback, BoundNetLog());
(...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after
7958 rv = callback.WaitForResult(); 7964 rv = callback.WaitForResult();
7959 ASSERT_EQ(OK, rv); 7965 ASSERT_EQ(OK, rv);
7960 7966
7961 std::string contents; 7967 std::string contents;
7962 rv = ReadTransaction(trans.get(), &contents); 7968 rv = ReadTransaction(trans.get(), &contents);
7963 EXPECT_EQ(net::OK, rv); 7969 EXPECT_EQ(net::OK, rv);
7964 EXPECT_EQ("hello world", contents); 7970 EXPECT_EQ("hello world", contents);
7965 } 7971 }
7966 7972
7967 } // namespace net 7973 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_session.cc ('k') | net/http/http_proxy_client_socket_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698