| 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 "chrome/test/base/testing_pref_service.h" | 7 #include "chrome/test/base/testing_pref_service.h" |
| 8 #include "content/test/test_browser_thread.h" | 8 #include "content/test/test_browser_thread.h" |
| 9 #include "net/base/cert_verifier.h" | 9 #include "net/base/cert_verifier.h" |
| 10 #include "net/base/mock_host_resolver.h" | 10 #include "net/base/mock_host_resolver.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // Destroy last the MessageLoop last to give a chance for objects like | 101 // Destroy last the MessageLoop last to give a chance for objects like |
| 102 // ObserverListThreadSave to shut down properly. For example, | 102 // ObserverListThreadSave to shut down properly. For example, |
| 103 // SSLClientAuthCache calls RemoveObserver when destroyed, but if the | 103 // SSLClientAuthCache calls RemoveObserver when destroyed, but if the |
| 104 // MessageLoop is already destroyed, then the RemoveObserver will be a | 104 // MessageLoop is already destroyed, then the RemoveObserver will be a |
| 105 // no-op, and the ObserverList will contain invalid entries. | 105 // no-op, and the ObserverList will contain invalid entries. |
| 106 MessageLoop message_loop_; | 106 MessageLoop message_loop_; |
| 107 content::TestBrowserThread io_thread_; | 107 content::TestBrowserThread io_thread_; |
| 108 net::TestServer test_server_; | 108 net::TestServer test_server_; |
| 109 ConnectionTesterDelegate test_delegate_; | 109 ConnectionTesterDelegate test_delegate_; |
| 110 net::MockHostResolver host_resolver_; | 110 net::MockHostResolver host_resolver_; |
| 111 net::CertVerifier cert_verifier_; | 111 scoped_ptr<net::CertVerifier> cert_verifier_; |
| 112 scoped_ptr<net::ProxyService> proxy_service_; | 112 scoped_ptr<net::ProxyService> proxy_service_; |
| 113 scoped_refptr<net::SSLConfigService> ssl_config_service_; | 113 scoped_refptr<net::SSLConfigService> ssl_config_service_; |
| 114 scoped_ptr<net::HttpTransactionFactory> http_transaction_factory_; | 114 scoped_ptr<net::HttpTransactionFactory> http_transaction_factory_; |
| 115 net::HttpAuthHandlerRegistryFactory http_auth_handler_factory_; | 115 net::HttpAuthHandlerRegistryFactory http_auth_handler_factory_; |
| 116 scoped_refptr<net::URLRequestContext> proxy_script_fetcher_context_; | 116 scoped_refptr<net::URLRequestContext> proxy_script_fetcher_context_; |
| 117 net::HttpServerPropertiesImpl http_server_properties_impl_; | 117 net::HttpServerPropertiesImpl http_server_properties_impl_; |
| 118 | 118 |
| 119 private: | 119 private: |
| 120 void InitializeRequestContext() { | 120 void InitializeRequestContext() { |
| 121 proxy_script_fetcher_context_->set_host_resolver(&host_resolver_); | 121 proxy_script_fetcher_context_->set_host_resolver(&host_resolver_); |
| 122 proxy_script_fetcher_context_->set_cert_verifier(&cert_verifier_); | 122 cert_verifier_.reset(net::CertVerifier::CreateDefault()); |
| 123 proxy_script_fetcher_context_->set_cert_verifier(cert_verifier_.get()); |
| 123 proxy_script_fetcher_context_->set_http_auth_handler_factory( | 124 proxy_script_fetcher_context_->set_http_auth_handler_factory( |
| 124 &http_auth_handler_factory_); | 125 &http_auth_handler_factory_); |
| 125 proxy_service_.reset(net::ProxyService::CreateDirect()); | 126 proxy_service_.reset(net::ProxyService::CreateDirect()); |
| 126 proxy_script_fetcher_context_->set_proxy_service(proxy_service_.get()); | 127 proxy_script_fetcher_context_->set_proxy_service(proxy_service_.get()); |
| 127 ssl_config_service_ = new net::SSLConfigServiceDefaults; | 128 ssl_config_service_ = new net::SSLConfigServiceDefaults; |
| 128 net::HttpNetworkSession::Params session_params; | 129 net::HttpNetworkSession::Params session_params; |
| 129 session_params.host_resolver = &host_resolver_; | 130 session_params.host_resolver = &host_resolver_; |
| 130 session_params.cert_verifier = &cert_verifier_; | 131 session_params.cert_verifier = cert_verifier_.get(); |
| 131 session_params.http_auth_handler_factory = &http_auth_handler_factory_; | 132 session_params.http_auth_handler_factory = &http_auth_handler_factory_; |
| 132 session_params.ssl_config_service = ssl_config_service_; | 133 session_params.ssl_config_service = ssl_config_service_; |
| 133 session_params.proxy_service = proxy_service_.get(); | 134 session_params.proxy_service = proxy_service_.get(); |
| 134 session_params.http_server_properties = &http_server_properties_impl_; | 135 session_params.http_server_properties = &http_server_properties_impl_; |
| 135 scoped_refptr<net::HttpNetworkSession> network_session( | 136 scoped_refptr<net::HttpNetworkSession> network_session( |
| 136 new net::HttpNetworkSession(session_params)); | 137 new net::HttpNetworkSession(session_params)); |
| 137 http_transaction_factory_.reset( | 138 http_transaction_factory_.reset( |
| 138 new net::HttpNetworkLayer(network_session)); | 139 new net::HttpNetworkLayer(network_session)); |
| 139 proxy_script_fetcher_context_->set_http_transaction_factory( | 140 proxy_script_fetcher_context_->set_http_transaction_factory( |
| 140 http_transaction_factory_.get()); | 141 http_transaction_factory_.get()); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 // any pending tasks instead of running them. This causes a problem with | 197 // any pending tasks instead of running them. This causes a problem with |
| 197 // net::ClientSocketPoolBaseHelper, since the "Group" holds a pointer | 198 // net::ClientSocketPoolBaseHelper, since the "Group" holds a pointer |
| 198 // |backup_task| that it will try to deref during the destructor, but | 199 // |backup_task| that it will try to deref during the destructor, but |
| 199 // depending on the order that pending tasks were deleted in, it might | 200 // depending on the order that pending tasks were deleted in, it might |
| 200 // already be invalid! See http://crbug.com/43291. | 201 // already be invalid! See http://crbug.com/43291. |
| 201 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 202 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 202 MessageLoop::current()->Run(); | 203 MessageLoop::current()->Run(); |
| 203 } | 204 } |
| 204 | 205 |
| 205 } // namespace | 206 } // namespace |
| OLD | NEW |