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/io_thread.h" | 5 #include "chrome/browser/io_thread.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/leak_tracker.h" | 10 #include "base/debug/leak_tracker.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
13 #include "base/stl_util-inl.h" | 13 #include "base/stl_util-inl.h" |
14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
15 #include "base/string_split.h" | 15 #include "base/string_split.h" |
16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
17 #include "base/threading/thread_restrictions.h" | 17 #include "base/threading/thread_restrictions.h" |
18 #include "chrome/browser/browser_process.h" | |
18 #include "chrome/browser/browser_thread.h" | 19 #include "chrome/browser/browser_thread.h" |
20 #if defined(OS_CHROMEOS) | |
21 #include "chrome/browser/chromeos/proxy_config_service_impl.h" | |
22 #endif // defined(OS_CHROMEOS) | |
19 #include "chrome/browser/gpu_process_host.h" | 23 #include "chrome/browser/gpu_process_host.h" |
20 #include "chrome/browser/in_process_webkit/indexed_db_key_utility_client.h" | 24 #include "chrome/browser/in_process_webkit/indexed_db_key_utility_client.h" |
21 #include "chrome/browser/net/chrome_net_log.h" | 25 #include "chrome/browser/net/chrome_net_log.h" |
22 #include "chrome/browser/net/chrome_url_request_context.h" | 26 #include "chrome/browser/net/chrome_url_request_context.h" |
23 #include "chrome/browser/net/connect_interceptor.h" | 27 #include "chrome/browser/net/connect_interceptor.h" |
24 #include "chrome/browser/net/passive_log_collector.h" | 28 #include "chrome/browser/net/passive_log_collector.h" |
25 #include "chrome/browser/net/predictor_api.h" | 29 #include "chrome/browser/net/predictor_api.h" |
30 #include "chrome/browser/net/pref_proxy_config_service.h" | |
26 #include "chrome/browser/prefs/pref_service.h" | 31 #include "chrome/browser/prefs/pref_service.h" |
27 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
28 #include "chrome/common/net/raw_host_resolver_proc.h" | 33 #include "chrome/common/net/raw_host_resolver_proc.h" |
29 #include "chrome/common/net/url_fetcher.h" | 34 #include "chrome/common/net/url_fetcher.h" |
30 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
31 #include "net/base/cert_verifier.h" | 36 #include "net/base/cert_verifier.h" |
32 #include "net/base/dnsrr_resolver.h" | 37 #include "net/base/dnsrr_resolver.h" |
33 #include "net/base/host_cache.h" | 38 #include "net/base/host_cache.h" |
34 #include "net/base/host_resolver.h" | 39 #include "net/base/host_resolver.h" |
35 #include "net/base/host_resolver_impl.h" | 40 #include "net/base/host_resolver_impl.h" |
36 #include "net/base/mapped_host_resolver.h" | 41 #include "net/base/mapped_host_resolver.h" |
37 #include "net/base/net_util.h" | 42 #include "net/base/net_util.h" |
43 #include "net/proxy/proxy_config_service_fixed.h" | |
38 #include "net/http/http_auth_filter.h" | 44 #include "net/http/http_auth_filter.h" |
39 #include "net/http/http_auth_handler_factory.h" | 45 #include "net/http/http_auth_handler_factory.h" |
40 #include "net/http/http_network_layer.h" | 46 #include "net/http/http_network_layer.h" |
41 #include "net/http/http_network_session.h" | 47 #include "net/http/http_network_session.h" |
42 #if defined(USE_NSS) | 48 #if defined(USE_NSS) |
43 #include "net/ocsp/nss_ocsp.h" | 49 #include "net/ocsp/nss_ocsp.h" |
44 #endif // defined(USE_NSS) | 50 #endif // defined(USE_NSS) |
45 #include "net/proxy/proxy_script_fetcher_impl.h" | 51 #include "net/proxy/proxy_script_fetcher_impl.h" |
46 | 52 |
47 namespace { | 53 namespace { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 globals->http_auth_handler_factory.get()); | 194 globals->http_auth_handler_factory.get()); |
189 context->set_proxy_service(globals->proxy_script_fetcher_proxy_service.get()); | 195 context->set_proxy_service(globals->proxy_script_fetcher_proxy_service.get()); |
190 context->set_http_transaction_factory( | 196 context->set_http_transaction_factory( |
191 globals->proxy_script_fetcher_http_transaction_factory.get()); | 197 globals->proxy_script_fetcher_http_transaction_factory.get()); |
192 // In-memory cookie store. | 198 // In-memory cookie store. |
193 context->set_cookie_store(new net::CookieMonster(NULL, NULL)); | 199 context->set_cookie_store(new net::CookieMonster(NULL, NULL)); |
194 // TODO(mpcomplete): give it a SystemNetworkDelegate. | 200 // TODO(mpcomplete): give it a SystemNetworkDelegate. |
195 return context; | 201 return context; |
196 } | 202 } |
197 | 203 |
204 scoped_refptr<net::URLRequestContext> | |
205 ConstructSystemRequestContext(IOThread::Globals* globals, | |
206 net::NetLog* net_log) { | |
207 scoped_refptr<net::URLRequestContext> context(new net::URLRequestContext); | |
208 context->set_net_log(net_log); | |
209 context->set_host_resolver(globals->host_resolver.get()); | |
210 context->set_cert_verifier(globals->cert_verifier.get()); | |
211 context->set_dnsrr_resolver(globals->dnsrr_resolver.get()); | |
212 context->set_http_auth_handler_factory( | |
213 globals->http_auth_handler_factory.get()); | |
214 context->set_proxy_service(globals->system_proxy_service.get()); | |
215 context->set_http_transaction_factory( | |
216 globals->system_http_transaction_factory.get()); | |
217 // In-memory cookie store. | |
218 context->set_cookie_store(new net::CookieMonster(NULL, NULL)); | |
219 return context; | |
220 } | |
221 | |
198 } // namespace | 222 } // namespace |
199 | 223 |
200 // The IOThread object must outlive any tasks posted to the IO thread before the | 224 // The IOThread object must outlive any tasks posted to the IO thread before the |
201 // Quit task. | 225 // Quit task. |
202 DISABLE_RUNNABLE_METHOD_REFCOUNT(IOThread); | 226 DISABLE_RUNNABLE_METHOD_REFCOUNT(IOThread); |
203 | 227 |
204 IOThread::Globals::Globals() {} | 228 IOThread::Globals::Globals() {} |
205 | 229 |
206 IOThread::Globals::~Globals() {} | 230 IOThread::Globals::~Globals() {} |
207 | 231 |
(...skipping 28 matching lines...) Expand all Loading... | |
236 | 260 |
237 IOThread::Globals* IOThread::globals() { | 261 IOThread::Globals* IOThread::globals() { |
238 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 262 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
239 return globals_; | 263 return globals_; |
240 } | 264 } |
241 | 265 |
242 ChromeNetLog* IOThread::net_log() { | 266 ChromeNetLog* IOThread::net_log() { |
243 return net_log_; | 267 return net_log_; |
244 } | 268 } |
245 | 269 |
270 void IOThread::InitSystemRequestContext( | |
271 net::ProxyConfigService* config_service) { | |
272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
273 message_loop()->PostTask( | |
274 FROM_HERE, | |
275 NewRunnableMethod( | |
276 this, | |
277 &IOThread::InitSystemRequestContextOnIOThread, | |
278 config_service)); | |
279 } | |
280 | |
281 void IOThread::InitSystemRequestContextOnIOThread( | |
282 net::ProxyConfigService* config_service) { | |
283 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
284 | |
285 size_t num_pac_threads = 0u; // Use default number of threads. | |
286 globals_->system_proxy_service = | |
willchan no longer on Chromium
2011/02/08 22:52:04
I think this code when I wrote it was a bit off. W
battre
2011/02/14 18:22:05
I don't see a code path that could instantiate a V
willchan no longer on Chromium
2011/02/15 01:05:58
Yes. Perhaps you could refactor them both to share
| |
287 net::ProxyService::CreateUsingSystemProxyResolver( | |
288 config_service, num_pac_threads, net_log_); | |
289 net::HttpNetworkSession::Params system_params; | |
290 system_params.host_resolver = globals_->host_resolver.get(); | |
291 system_params.cert_verifier = globals_->cert_verifier.get(); | |
292 system_params.dnsrr_resolver = globals_->dnsrr_resolver.get(); | |
293 system_params.dns_cert_checker = NULL; | |
294 system_params.ssl_host_info_factory = NULL; | |
295 system_params.proxy_service = globals_->system_proxy_service.get(); | |
296 system_params.ssl_config_service = globals_->ssl_config_service.get(); | |
297 system_params.http_auth_handler_factory = | |
298 globals_->http_auth_handler_factory.get(); | |
299 system_params.network_delegate = &globals_->network_delegate; | |
300 system_params.net_log = net_log_; | |
301 globals_->system_http_transaction_factory.reset( | |
302 new net::HttpNetworkLayer( | |
303 new net::HttpNetworkSession(system_params))); | |
304 globals_->system_request_context = | |
305 ConstructSystemRequestContext(globals_, net_log_); | |
306 } | |
307 | |
246 void IOThread::InitNetworkPredictor( | 308 void IOThread::InitNetworkPredictor( |
247 bool prefetching_enabled, | 309 bool prefetching_enabled, |
248 base::TimeDelta max_dns_queue_delay, | 310 base::TimeDelta max_dns_queue_delay, |
249 size_t max_speculative_parallel_resolves, | 311 size_t max_speculative_parallel_resolves, |
250 const chrome_common_net::UrlList& startup_urls, | 312 const chrome_common_net::UrlList& startup_urls, |
251 ListValue* referral_list, | 313 ListValue* referral_list, |
252 bool preconnect_enabled) { | 314 bool preconnect_enabled) { |
253 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 315 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
254 message_loop()->PostTask( | 316 message_loop()->PostTask( |
255 FROM_HERE, | 317 FROM_HERE, |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
507 net::HostCache* host_cache = | 569 net::HostCache* host_cache = |
508 globals_->host_resolver.get()->GetAsHostResolverImpl()->cache(); | 570 globals_->host_resolver.get()->GetAsHostResolverImpl()->cache(); |
509 if (host_cache) | 571 if (host_cache) |
510 host_cache->clear(); | 572 host_cache->clear(); |
511 } | 573 } |
512 // Clear all of the passively logged data. | 574 // Clear all of the passively logged data. |
513 // TODO(eroman): this is a bit heavy handed, really all we need to do is | 575 // TODO(eroman): this is a bit heavy handed, really all we need to do is |
514 // clear the data pertaining to off the record context. | 576 // clear the data pertaining to off the record context. |
515 net_log_->ClearAllPassivelyCapturedEvents(); | 577 net_log_->ClearAllPassivelyCapturedEvents(); |
516 } | 578 } |
OLD | NEW |