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/profiles/profile_io_data.h" | 5 #include "chrome/browser/profiles/profile_io_data.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
16 #include "base/task.h" | 16 #include "base/task.h" |
17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
18 #include "chrome/browser/content_settings/host_content_settings_map.h" | 18 #include "chrome/browser/content_settings/host_content_settings_map.h" |
19 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 19 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
20 #include "chrome/browser/extensions/extension_info_map.h" | 20 #include "chrome/browser/extensions/extension_info_map.h" |
21 #include "chrome/browser/extensions/extension_protocols.h" | 21 #include "chrome/browser/extensions/extension_protocols.h" |
22 #include "chrome/browser/io_thread.h" | 22 #include "chrome/browser/io_thread.h" |
23 #include "chrome/browser/media/media_internals.h" | 23 #include "chrome/browser/media/media_internals.h" |
24 #include "chrome/browser/net/chrome_cookie_notification_details.h" | 24 #include "chrome/browser/net/chrome_cookie_notification_details.h" |
25 #include "chrome/browser/net/chrome_dns_cert_provenance_checker_factory.h" | 25 #include "chrome/browser/net/chrome_dns_cert_provenance_checker_factory.h" |
26 #include "chrome/browser/net/chrome_net_log.h" | 26 #include "chrome/browser/net/chrome_net_log.h" |
27 #include "chrome/browser/net/chrome_network_delegate.h" | 27 #include "chrome/browser/net/chrome_network_delegate.h" |
| 28 #include "chrome/browser/net/http_server_properties_manager.h" |
28 #include "chrome/browser/net/pref_proxy_config_service.h" | 29 #include "chrome/browser/net/pref_proxy_config_service.h" |
29 #include "chrome/browser/net/proxy_service_factory.h" | 30 #include "chrome/browser/net/proxy_service_factory.h" |
30 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 31 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
31 #include "chrome/browser/policy/url_blacklist_manager.h" | 32 #include "chrome/browser/policy/url_blacklist_manager.h" |
32 #include "chrome/browser/prefs/pref_service.h" | 33 #include "chrome/browser/prefs/pref_service.h" |
33 #include "chrome/browser/prerender/prerender_manager.h" | 34 #include "chrome/browser/prerender/prerender_manager.h" |
34 #include "chrome/browser/prerender/prerender_manager_factory.h" | 35 #include "chrome/browser/prerender/prerender_manager_factory.h" |
35 #include "chrome/browser/profiles/profile.h" | 36 #include "chrome/browser/profiles/profile.h" |
36 #include "chrome/browser/profiles/profile_manager.h" | 37 #include "chrome/browser/profiles/profile_manager.h" |
37 #include "chrome/browser/transport_security_persister.h" | 38 #include "chrome/browser/transport_security_persister.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 params->prerender_manager_getter = | 249 params->prerender_manager_getter = |
249 base::Bind(&GetPrerenderManagerOnUI, profile_getter); | 250 base::Bind(&GetPrerenderManagerOnUI, profile_getter); |
250 params->protocol_handler_registry = profile->GetProtocolHandlerRegistry(); | 251 params->protocol_handler_registry = profile->GetProtocolHandlerRegistry(); |
251 | 252 |
252 params->proxy_config_service.reset( | 253 params->proxy_config_service.reset( |
253 ProxyServiceFactory::CreateProxyConfigService( | 254 ProxyServiceFactory::CreateProxyConfigService( |
254 profile->GetProxyConfigTracker())); | 255 profile->GetProxyConfigTracker())); |
255 params->profile = profile; | 256 params->profile = profile; |
256 profile_params_.reset(params.release()); | 257 profile_params_.reset(params.release()); |
257 | 258 |
258 // The URLBlacklistManager has to be created on the UI thread to register | 259 // URLBlacklistManager and HttpServerPropertiesManager have to be created on |
259 // observers of |pref_service|, and it also has to clean up on | 260 // the UI thread to register observers of |pref_service|, and it also has to |
260 // ShutdownOnUIThread to release these observers on the right thread. | 261 // clean up on ShutdownOnUIThread to release these observers on the right |
261 // Don't pass it in |profile_params_| to make sure it is correctly cleaned up, | 262 // thread. Don't pass it in |profile_params_| to make sure it is correctly |
262 // in particular when this ProfileIOData isn't |initialized_| during deletion. | 263 // cleaned up, in particular when this ProfileIOData isn't |initialized_| |
| 264 // during deletion. |
263 #if defined(ENABLE_CONFIGURATION_POLICY) | 265 #if defined(ENABLE_CONFIGURATION_POLICY) |
264 url_blacklist_manager_.reset(new policy::URLBlacklistManager(pref_service)); | 266 url_blacklist_manager_.reset(new policy::URLBlacklistManager(pref_service)); |
265 #endif | 267 #endif |
| 268 http_server_properties_manager_.reset( |
| 269 new chrome_browser_net::HttpServerPropertiesManager(pref_service)); |
266 } | 270 } |
267 | 271 |
268 ProfileIOData::AppRequestContext::AppRequestContext() {} | 272 ProfileIOData::AppRequestContext::AppRequestContext() {} |
269 ProfileIOData::AppRequestContext::~AppRequestContext() {} | 273 ProfileIOData::AppRequestContext::~AppRequestContext() {} |
270 | 274 |
271 void ProfileIOData::AppRequestContext::SetCookieStore( | 275 void ProfileIOData::AppRequestContext::SetCookieStore( |
272 net::CookieStore* cookie_store) { | 276 net::CookieStore* cookie_store) { |
273 cookie_store_ = cookie_store; | 277 cookie_store_ = cookie_store; |
274 set_cookie_store(cookie_store); | 278 set_cookie_store(cookie_store); |
275 } | 279 } |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 void ProfileIOData::LazyInitialize() const { | 405 void ProfileIOData::LazyInitialize() const { |
402 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 406 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
403 if (initialized_) | 407 if (initialized_) |
404 return; | 408 return; |
405 DCHECK(profile_params_.get()); | 409 DCHECK(profile_params_.get()); |
406 | 410 |
407 IOThread* const io_thread = profile_params_->io_thread; | 411 IOThread* const io_thread = profile_params_->io_thread; |
408 IOThread::Globals* const io_thread_globals = io_thread->globals(); | 412 IOThread::Globals* const io_thread_globals = io_thread->globals(); |
409 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 413 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
410 | 414 |
| 415 if (http_server_properties_manager_.get()) |
| 416 http_server_properties_manager_->InitializeOnIOThread(); |
| 417 |
411 // Create the common request contexts. | 418 // Create the common request contexts. |
412 main_request_context_ = new ChromeURLRequestContext; | 419 main_request_context_ = new ChromeURLRequestContext; |
413 extensions_request_context_ = new ChromeURLRequestContext; | 420 extensions_request_context_ = new ChromeURLRequestContext; |
414 | 421 |
415 profile_params_->appcache_service->set_request_context(main_request_context_); | 422 profile_params_->appcache_service->set_request_context(main_request_context_); |
416 | 423 |
417 chrome_url_data_manager_backend_.reset(new ChromeURLDataManagerBackend); | 424 chrome_url_data_manager_backend_.reset(new ChromeURLDataManagerBackend); |
418 | 425 |
419 network_delegate_.reset(new ChromeNetworkDelegate( | 426 network_delegate_.reset(new ChromeNetworkDelegate( |
420 io_thread_globals->extension_event_router_forwarder.get(), | 427 io_thread_globals->extension_event_router_forwarder.get(), |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 | 538 |
532 void ProfileIOData::ShutdownOnUIThread() { | 539 void ProfileIOData::ShutdownOnUIThread() { |
533 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 540 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
534 enable_referrers_.Destroy(); | 541 enable_referrers_.Destroy(); |
535 clear_local_state_on_exit_.Destroy(); | 542 clear_local_state_on_exit_.Destroy(); |
536 safe_browsing_enabled_.Destroy(); | 543 safe_browsing_enabled_.Destroy(); |
537 #if defined(ENABLE_CONFIGURATION_POLICY) | 544 #if defined(ENABLE_CONFIGURATION_POLICY) |
538 if (url_blacklist_manager_.get()) | 545 if (url_blacklist_manager_.get()) |
539 url_blacklist_manager_->ShutdownOnUIThread(); | 546 url_blacklist_manager_->ShutdownOnUIThread(); |
540 #endif | 547 #endif |
| 548 if (http_server_properties_manager_.get()) |
| 549 http_server_properties_manager_->ShutdownOnUIThread(); |
541 BrowserThread::PostTask( | 550 BrowserThread::PostTask( |
542 BrowserThread::IO, FROM_HERE, | 551 BrowserThread::IO, FROM_HERE, |
543 base::Bind( | 552 base::Bind( |
544 &ResourceDispatcherHost::CancelRequestsForContext, | 553 &ResourceDispatcherHost::CancelRequestsForContext, |
545 base::Unretained(g_browser_process->resource_dispatcher_host()), | 554 base::Unretained(g_browser_process->resource_dispatcher_host()), |
546 &resource_context_)); | 555 &resource_context_)); |
547 bool posted = BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 556 bool posted = BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
548 new DeleteTask<ProfileIOData>(this)); | 557 new DeleteTask<ProfileIOData>(this)); |
549 if (!posted) | 558 if (!posted) |
550 delete this; | 559 delete this; |
551 } | 560 } |
552 | 561 |
553 void ProfileIOData::set_origin_bound_cert_service( | 562 void ProfileIOData::set_origin_bound_cert_service( |
554 net::OriginBoundCertService* origin_bound_cert_service) const { | 563 net::OriginBoundCertService* origin_bound_cert_service) const { |
555 origin_bound_cert_service_.reset(origin_bound_cert_service); | 564 origin_bound_cert_service_.reset(origin_bound_cert_service); |
556 } | 565 } |
OLD | NEW |