| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/net/connection_tester.h" | 5 #include "chrome/browser/net/connection_tester.h" |
| 6 | 6 |
| 7 #include "base/threading/worker_pool.h" |
| 7 #include "chrome/test/base/testing_pref_service.h" | 8 #include "chrome/test/base/testing_pref_service.h" |
| 8 #include "content/public/test/test_browser_thread.h" | 9 #include "content/public/test/test_browser_thread.h" |
| 10 #include "net/base/default_server_bound_cert_store.h" |
| 9 #include "net/base/mock_cert_verifier.h" | 11 #include "net/base/mock_cert_verifier.h" |
| 10 #include "net/base/mock_host_resolver.h" | 12 #include "net/base/mock_host_resolver.h" |
| 13 #include "net/base/server_bound_cert_service.h" |
| 11 #include "net/base/ssl_config_service_defaults.h" | 14 #include "net/base/ssl_config_service_defaults.h" |
| 12 #include "net/cookies/cookie_monster.h" | 15 #include "net/cookies/cookie_monster.h" |
| 13 #include "net/ftp/ftp_network_layer.h" | 16 #include "net/ftp/ftp_network_layer.h" |
| 14 #include "net/http/http_auth_handler_factory.h" | 17 #include "net/http/http_auth_handler_factory.h" |
| 15 #include "net/http/http_network_layer.h" | 18 #include "net/http/http_network_layer.h" |
| 16 #include "net/http/http_network_session.h" | 19 #include "net/http/http_network_session.h" |
| 17 #include "net/http/http_server_properties_impl.h" | 20 #include "net/http/http_server_properties_impl.h" |
| 18 #include "net/proxy/proxy_config_service_fixed.h" | 21 #include "net/proxy/proxy_config_service_fixed.h" |
| 19 #include "net/proxy/proxy_service.h" | 22 #include "net/proxy/proxy_service.h" |
| 20 #include "net/test/test_server.h" | 23 #include "net/test/test_server.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 net::TestServer test_server_; | 111 net::TestServer test_server_; |
| 109 ConnectionTesterDelegate test_delegate_; | 112 ConnectionTesterDelegate test_delegate_; |
| 110 net::MockHostResolver host_resolver_; | 113 net::MockHostResolver host_resolver_; |
| 111 scoped_ptr<net::CertVerifier> cert_verifier_; | 114 scoped_ptr<net::CertVerifier> cert_verifier_; |
| 112 scoped_ptr<net::ProxyService> proxy_service_; | 115 scoped_ptr<net::ProxyService> proxy_service_; |
| 113 scoped_refptr<net::SSLConfigService> ssl_config_service_; | 116 scoped_refptr<net::SSLConfigService> ssl_config_service_; |
| 114 scoped_ptr<net::HttpTransactionFactory> http_transaction_factory_; | 117 scoped_ptr<net::HttpTransactionFactory> http_transaction_factory_; |
| 115 net::HttpAuthHandlerRegistryFactory http_auth_handler_factory_; | 118 net::HttpAuthHandlerRegistryFactory http_auth_handler_factory_; |
| 116 net::HttpServerPropertiesImpl http_server_properties_impl_; | 119 net::HttpServerPropertiesImpl http_server_properties_impl_; |
| 117 scoped_ptr<net::URLRequestContext> proxy_script_fetcher_context_; | 120 scoped_ptr<net::URLRequestContext> proxy_script_fetcher_context_; |
| 121 scoped_ptr<net::ServerBoundCertService> server_bound_cert_service_; |
| 118 | 122 |
| 119 private: | 123 private: |
| 120 void InitializeRequestContext() { | 124 void InitializeRequestContext() { |
| 121 proxy_script_fetcher_context_->set_host_resolver(&host_resolver_); | 125 proxy_script_fetcher_context_->set_host_resolver(&host_resolver_); |
| 122 cert_verifier_.reset(new net::MockCertVerifier); | 126 cert_verifier_.reset(new net::MockCertVerifier); |
| 123 proxy_script_fetcher_context_->set_cert_verifier(cert_verifier_.get()); | 127 proxy_script_fetcher_context_->set_cert_verifier(cert_verifier_.get()); |
| 124 proxy_script_fetcher_context_->set_http_auth_handler_factory( | 128 proxy_script_fetcher_context_->set_http_auth_handler_factory( |
| 125 &http_auth_handler_factory_); | 129 &http_auth_handler_factory_); |
| 126 proxy_service_.reset(net::ProxyService::CreateDirect()); | 130 proxy_service_.reset(net::ProxyService::CreateDirect()); |
| 127 proxy_script_fetcher_context_->set_proxy_service(proxy_service_.get()); | 131 proxy_script_fetcher_context_->set_proxy_service(proxy_service_.get()); |
| 132 // In-memory server bound cert service. |
| 133 server_bound_cert_service_.reset(new net::ServerBoundCertService( |
| 134 new net::DefaultServerBoundCertStore(NULL), |
| 135 base::WorkerPool::GetTaskRunner(true))); |
| 136 |
| 128 ssl_config_service_ = new net::SSLConfigServiceDefaults; | 137 ssl_config_service_ = new net::SSLConfigServiceDefaults; |
| 129 net::HttpNetworkSession::Params session_params; | 138 net::HttpNetworkSession::Params session_params; |
| 130 session_params.host_resolver = &host_resolver_; | 139 session_params.host_resolver = &host_resolver_; |
| 131 session_params.cert_verifier = cert_verifier_.get(); | 140 session_params.cert_verifier = cert_verifier_.get(); |
| 141 session_params.server_bound_cert_service = server_bound_cert_service_.get(); |
| 132 session_params.http_auth_handler_factory = &http_auth_handler_factory_; | 142 session_params.http_auth_handler_factory = &http_auth_handler_factory_; |
| 133 session_params.ssl_config_service = ssl_config_service_; | 143 session_params.ssl_config_service = ssl_config_service_; |
| 134 session_params.proxy_service = proxy_service_.get(); | 144 session_params.proxy_service = proxy_service_.get(); |
| 135 session_params.http_server_properties = &http_server_properties_impl_; | 145 session_params.http_server_properties = &http_server_properties_impl_; |
| 136 scoped_refptr<net::HttpNetworkSession> network_session( | 146 scoped_refptr<net::HttpNetworkSession> network_session( |
| 137 new net::HttpNetworkSession(session_params)); | 147 new net::HttpNetworkSession(session_params)); |
| 138 http_transaction_factory_.reset( | 148 http_transaction_factory_.reset( |
| 139 new net::HttpNetworkLayer(network_session)); | 149 new net::HttpNetworkLayer(network_session)); |
| 140 proxy_script_fetcher_context_->set_http_transaction_factory( | 150 proxy_script_fetcher_context_->set_http_transaction_factory( |
| 141 http_transaction_factory_.get()); | 151 http_transaction_factory_.get()); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 // any pending tasks instead of running them. This causes a problem with | 211 // any pending tasks instead of running them. This causes a problem with |
| 202 // net::ClientSocketPoolBaseHelper, since the "Group" holds a pointer | 212 // net::ClientSocketPoolBaseHelper, since the "Group" holds a pointer |
| 203 // |backup_task| that it will try to deref during the destructor, but | 213 // |backup_task| that it will try to deref during the destructor, but |
| 204 // depending on the order that pending tasks were deleted in, it might | 214 // depending on the order that pending tasks were deleted in, it might |
| 205 // already be invalid! See http://crbug.com/43291. | 215 // already be invalid! See http://crbug.com/43291. |
| 206 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 216 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 207 MessageLoop::current()->Run(); | 217 MessageLoop::current()->Run(); |
| 208 } | 218 } |
| 209 | 219 |
| 210 } // namespace | 220 } // namespace |
| OLD | NEW |