Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Side by Side Diff: chrome/browser/profiles/profile_io_data.cc

Issue 7966005: Move TransportSecurityPersister completely to IO thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 15 matching lines...) Expand all
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/pref_proxy_config_service.h" 28 #include "chrome/browser/net/pref_proxy_config_service.h"
29 #include "chrome/browser/net/proxy_service_factory.h" 29 #include "chrome/browser/net/proxy_service_factory.h"
30 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 30 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
31 #include "chrome/browser/policy/url_blacklist_manager.h" 31 #include "chrome/browser/policy/url_blacklist_manager.h"
32 #include "chrome/browser/prefs/pref_service.h" 32 #include "chrome/browser/prefs/pref_service.h"
33 #include "chrome/browser/prerender/prerender_manager.h" 33 #include "chrome/browser/prerender/prerender_manager.h"
34 #include "chrome/browser/profiles/profile.h" 34 #include "chrome/browser/profiles/profile.h"
35 #include "chrome/browser/profiles/profile_manager.h" 35 #include "chrome/browser/profiles/profile_manager.h"
36 #include "chrome/browser/transport_security_persister.h"
36 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h" 37 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h"
37 #include "chrome/common/chrome_notification_types.h" 38 #include "chrome/common/chrome_notification_types.h"
38 #include "chrome/common/chrome_switches.h" 39 #include "chrome/common/chrome_switches.h"
39 #include "chrome/common/pref_names.h" 40 #include "chrome/common/pref_names.h"
40 #include "chrome/common/url_constants.h" 41 #include "chrome/common/url_constants.h"
41 #include "content/browser/appcache/chrome_appcache_service.h" 42 #include "content/browser/appcache/chrome_appcache_service.h"
42 #include "content/browser/browser_thread.h" 43 #include "content/browser/browser_thread.h"
43 #include "content/browser/chrome_blob_storage_context.h" 44 #include "content/browser/chrome_blob_storage_context.h"
44 #include "content/browser/host_zoom_map.h" 45 #include "content/browser/host_zoom_map.h"
45 #include "content/browser/renderer_host/resource_dispatcher_host.h" 46 #include "content/browser/renderer_host/resource_dispatcher_host.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 return NULL; 188 return NULL;
188 } 189 }
189 190
190 } // namespace 191 } // namespace
191 192
192 void ProfileIOData::InitializeOnUIThread(Profile* profile) { 193 void ProfileIOData::InitializeOnUIThread(Profile* profile) {
193 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
194 PrefService* pref_service = profile->GetPrefs(); 195 PrefService* pref_service = profile->GetPrefs();
195 196
196 scoped_ptr<ProfileParams> params(new ProfileParams); 197 scoped_ptr<ProfileParams> params(new ProfileParams);
198 params->path = profile->GetPath();
197 params->is_incognito = profile->IsOffTheRecord(); 199 params->is_incognito = profile->IsOffTheRecord();
198 params->clear_local_state_on_exit = 200 params->clear_local_state_on_exit =
199 pref_service->GetBoolean(prefs::kClearSiteDataOnExit); 201 pref_service->GetBoolean(prefs::kClearSiteDataOnExit);
200 202
201 params->appcache_service = profile->GetAppCacheService(); 203 params->appcache_service = profile->GetAppCacheService();
202 204
203 // Set up Accept-Language and Accept-Charset header values 205 // Set up Accept-Language and Accept-Charset header values
204 params->accept_language = net::HttpUtil::GenerateAcceptLanguageHeader( 206 params->accept_language = net::HttpUtil::GenerateAcceptLanguageHeader(
205 pref_service->GetString(prefs::kAcceptLanguages)); 207 pref_service->GetString(prefs::kAcceptLanguages));
206 std::string default_charset = pref_service->GetString(prefs::kDefaultCharset); 208 std::string default_charset = pref_service->GetString(prefs::kDefaultCharset);
(...skipping 11 matching lines...) Expand all
218 // We initialize it to the default charset here and a user will 220 // We initialize it to the default charset here and a user will
219 // have an *arguably* better default charset for interpreting a raw 8bit 221 // have an *arguably* better default charset for interpreting a raw 8bit
220 // C-D header field. It means the native OS codepage fallback in 222 // C-D header field. It means the native OS codepage fallback in
221 // net_util::GetSuggestedFilename is unlikely to be taken. 223 // net_util::GetSuggestedFilename is unlikely to be taken.
222 params->referrer_charset = default_charset; 224 params->referrer_charset = default_charset;
223 225
224 params->io_thread = g_browser_process->io_thread(); 226 params->io_thread = g_browser_process->io_thread();
225 227
226 params->host_content_settings_map = profile->GetHostContentSettingsMap(); 228 params->host_content_settings_map = profile->GetHostContentSettingsMap();
227 params->host_zoom_map = profile->GetHostZoomMap(); 229 params->host_zoom_map = profile->GetHostZoomMap();
228 params->transport_security_state = profile->GetTransportSecurityState();
229 params->ssl_config_service = profile->GetSSLConfigService(); 230 params->ssl_config_service = profile->GetSSLConfigService();
230 base::Callback<Profile*(void)> profile_getter = 231 base::Callback<Profile*(void)> profile_getter =
231 base::Bind(&GetProfileOnUI, g_browser_process->profile_manager(), 232 base::Bind(&GetProfileOnUI, g_browser_process->profile_manager(),
232 profile); 233 profile);
233 params->cookie_monster_delegate = 234 params->cookie_monster_delegate =
234 new ChromeCookieMonsterDelegate(profile_getter); 235 new ChromeCookieMonsterDelegate(profile_getter);
235 params->database_tracker = profile->GetDatabaseTracker(); 236 params->database_tracker = profile->GetDatabaseTracker();
236 params->appcache_service = profile->GetAppCacheService(); 237 params->appcache_service = profile->GetAppCacheService();
237 params->blob_storage_context = profile->GetBlobStorageContext(); 238 params->blob_storage_context = profile->GetBlobStorageContext();
238 params->file_system_context = profile->GetFileSystemContext(); 239 params->file_system_context = profile->GetFileSystemContext();
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 CreateDnsCertProvenanceChecker(io_thread_globals->dnsrr_resolver.get(), 423 CreateDnsCertProvenanceChecker(io_thread_globals->dnsrr_resolver.get(),
423 main_request_context_)); 424 main_request_context_));
424 425
425 proxy_service_.reset( 426 proxy_service_.reset(
426 ProxyServiceFactory::CreateProxyService( 427 ProxyServiceFactory::CreateProxyService(
427 io_thread->net_log(), 428 io_thread->net_log(),
428 io_thread_globals->proxy_script_fetcher_context.get(), 429 io_thread_globals->proxy_script_fetcher_context.get(),
429 profile_params_->proxy_config_service.release(), 430 profile_params_->proxy_config_service.release(),
430 command_line)); 431 command_line));
431 432
433 transport_security_state_ = new net::TransportSecurityState(
434 command_line.GetSwitchValueASCII(switches::kHstsHosts));
435 transport_security_persister_ =
436 new TransportSecurityPersister(transport_security_state_.get(),
437 profile_params_->path,
438 !profile_params_->is_incognito);
439 transport_security_persister_->Init();
willchan no longer on Chromium 2011/09/20 01:29:51 Is this Init() necessary now? Can't it just be don
440
432 // NOTE(willchan): Keep these protocol handlers in sync with 441 // NOTE(willchan): Keep these protocol handlers in sync with
433 // ProfileIOData::IsHandledProtocol(). 442 // ProfileIOData::IsHandledProtocol().
434 job_factory_.reset(new net::URLRequestJobFactory); 443 job_factory_.reset(new net::URLRequestJobFactory);
435 if (profile_params_->protocol_handler_registry) { 444 if (profile_params_->protocol_handler_registry) {
436 job_factory_->AddInterceptor( 445 job_factory_->AddInterceptor(
437 new ProtocolHandlerRegistryInterceptor( 446 new ProtocolHandlerRegistryInterceptor(
438 profile_params_->protocol_handler_registry)); 447 profile_params_->protocol_handler_registry));
439 } 448 }
440 bool set_protocol = job_factory_->SetProtocolHandler( 449 bool set_protocol = job_factory_->SetProtocolHandler(
441 chrome::kExtensionScheme, 450 chrome::kExtensionScheme,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 profile_params_.reset(); 512 profile_params_.reset();
504 initialized_ = true; 513 initialized_ = true;
505 } 514 }
506 515
507 void ProfileIOData::ApplyProfileParamsToContext( 516 void ProfileIOData::ApplyProfileParamsToContext(
508 ChromeURLRequestContext* context) const { 517 ChromeURLRequestContext* context) const {
509 context->set_is_incognito(profile_params_->is_incognito); 518 context->set_is_incognito(profile_params_->is_incognito);
510 context->set_accept_language(profile_params_->accept_language); 519 context->set_accept_language(profile_params_->accept_language);
511 context->set_accept_charset(profile_params_->accept_charset); 520 context->set_accept_charset(profile_params_->accept_charset);
512 context->set_referrer_charset(profile_params_->referrer_charset); 521 context->set_referrer_charset(profile_params_->referrer_charset);
513 context->set_transport_security_state(
514 profile_params_->transport_security_state);
515 context->set_ssl_config_service(profile_params_->ssl_config_service); 522 context->set_ssl_config_service(profile_params_->ssl_config_service);
516 } 523 }
517 524
518 void ProfileIOData::ShutdownOnUIThread() { 525 void ProfileIOData::ShutdownOnUIThread() {
519 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 526 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
520 enable_referrers_.Destroy(); 527 enable_referrers_.Destroy();
521 clear_local_state_on_exit_.Destroy(); 528 clear_local_state_on_exit_.Destroy();
522 safe_browsing_enabled_.Destroy(); 529 safe_browsing_enabled_.Destroy();
523 #if defined(ENABLE_CONFIGURATION_POLICY) 530 #if defined(ENABLE_CONFIGURATION_POLICY)
524 if (url_blacklist_manager_.get()) 531 if (url_blacklist_manager_.get())
525 url_blacklist_manager_->ShutdownOnUIThread(); 532 url_blacklist_manager_->ShutdownOnUIThread();
526 #endif 533 #endif
527 BrowserThread::PostTask( 534 BrowserThread::PostTask(
528 BrowserThread::IO, FROM_HERE, 535 BrowserThread::IO, FROM_HERE,
529 base::Bind( 536 base::Bind(
530 &ResourceDispatcherHost::CancelRequestsForContext, 537 &ResourceDispatcherHost::CancelRequestsForContext,
531 base::Unretained(g_browser_process->resource_dispatcher_host()), 538 base::Unretained(g_browser_process->resource_dispatcher_host()),
532 &resource_context_)); 539 &resource_context_));
533 bool posted = BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 540 bool posted = BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
534 new DeleteTask<ProfileIOData>(this)); 541 new DeleteTask<ProfileIOData>(this));
535 if (!posted) 542 if (!posted)
536 delete this; 543 delete this;
537 } 544 }
538 545
539 void ProfileIOData::set_origin_bound_cert_service( 546 void ProfileIOData::set_origin_bound_cert_service(
540 net::OriginBoundCertService* origin_bound_cert_service) const { 547 net::OriginBoundCertService* origin_bound_cert_service) const {
541 origin_bound_cert_service_.reset(origin_bound_cert_service); 548 origin_bound_cert_service_.reset(origin_bound_cert_service);
542 } 549 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698