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