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/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/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/debug/alias.h" | 15 #include "base/debug/alias.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
18 #include "base/prefs/pref_service.h" | 18 #include "base/prefs/pref_service.h" |
19 #include "base/profiler/scoped_tracker.h" | |
20 #include "base/stl_util.h" | 19 #include "base/stl_util.h" |
21 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
22 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
23 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
24 #include "base/thread_task_runner_handle.h" | 23 #include "base/thread_task_runner_handle.h" |
25 #include "base/threading/sequenced_worker_pool.h" | 24 #include "base/threading/sequenced_worker_pool.h" |
26 #include "chrome/browser/browser_process.h" | 25 #include "chrome/browser/browser_process.h" |
27 #include "chrome/browser/chrome_notification_types.h" | 26 #include "chrome/browser/chrome_notification_types.h" |
28 #include "chrome/browser/content_settings/cookie_settings.h" | 27 #include "chrome/browser/content_settings/cookie_settings.h" |
29 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 28 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 // unique string to partition the SSL session cache. Each time we create a | 975 // unique string to partition the SSL session cache. Each time we create a |
977 // new profile, we'll get a fresh SSL session cache which is separate from | 976 // new profile, we'll get a fresh SSL session cache which is separate from |
978 // the other profiles. | 977 // the other profiles. |
979 static unsigned ssl_session_cache_instance = 0; | 978 static unsigned ssl_session_cache_instance = 0; |
980 return base::StringPrintf("profile/%u", ssl_session_cache_instance++); | 979 return base::StringPrintf("profile/%u", ssl_session_cache_instance++); |
981 } | 980 } |
982 | 981 |
983 void ProfileIOData::Init( | 982 void ProfileIOData::Init( |
984 content::ProtocolHandlerMap* protocol_handlers, | 983 content::ProtocolHandlerMap* protocol_handlers, |
985 content::URLRequestInterceptorScopedVector request_interceptors) const { | 984 content::URLRequestInterceptorScopedVector request_interceptors) const { |
986 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436671 is fixed. | |
987 tracked_objects::ScopedTracker tracking_profile( | |
988 FROM_HERE_WITH_EXPLICIT_FUNCTION("436671 ProfileIOData::Init")); | |
989 | |
990 // The basic logic is implemented here. The specific initialization | 985 // The basic logic is implemented here. The specific initialization |
991 // is done in InitializeInternal(), implemented by subtypes. Static helper | 986 // is done in InitializeInternal(), implemented by subtypes. Static helper |
992 // functions have been provided to assist in common operations. | 987 // functions have been provided to assist in common operations. |
993 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 988 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
994 DCHECK(!initialized_); | 989 DCHECK(!initialized_); |
995 | 990 |
996 startup_metric_utils::ScopedSlowStartupUMA | 991 startup_metric_utils::ScopedSlowStartupUMA |
997 scoped_timer("Startup.SlowStartupProfileIODataInit"); | 992 scoped_timer("Startup.SlowStartupProfileIODataInit"); |
998 | 993 |
999 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. | 994 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. |
1000 CHECK(initialized_on_UI_thread_); | 995 CHECK(initialized_on_UI_thread_); |
1001 | 996 |
1002 // TODO(jhawkins): Return to DCHECK once crbug.com/102004 is fixed. | 997 // TODO(jhawkins): Return to DCHECK once crbug.com/102004 is fixed. |
1003 CHECK(profile_params_.get()); | 998 CHECK(profile_params_.get()); |
1004 | 999 |
1005 IOThread* const io_thread = profile_params_->io_thread; | 1000 IOThread* const io_thread = profile_params_->io_thread; |
1006 IOThread::Globals* const io_thread_globals = io_thread->globals(); | 1001 IOThread::Globals* const io_thread_globals = io_thread->globals(); |
1007 const base::CommandLine& command_line = | 1002 const base::CommandLine& command_line = |
1008 *base::CommandLine::ForCurrentProcess(); | 1003 *base::CommandLine::ForCurrentProcess(); |
1009 | 1004 |
1010 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436671 is fixed. | |
1011 tracked_objects::ScopedTracker tracking_profile1( | |
1012 FROM_HERE_WITH_EXPLICIT_FUNCTION("436671 ProfileIOData::Init1")); | |
1013 | |
1014 // Create the common request contexts. | 1005 // Create the common request contexts. |
1015 main_request_context_.reset(new net::URLRequestContext()); | 1006 main_request_context_.reset(new net::URLRequestContext()); |
1016 extensions_request_context_.reset(new net::URLRequestContext()); | 1007 extensions_request_context_.reset(new net::URLRequestContext()); |
1017 | 1008 |
1018 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436671 is fixed. | |
1019 tracked_objects::ScopedTracker tracking_profile2( | |
1020 FROM_HERE_WITH_EXPLICIT_FUNCTION("436671 ProfileIOData::Init2")); | |
1021 | |
1022 scoped_ptr<ChromeNetworkDelegate> network_delegate( | 1009 scoped_ptr<ChromeNetworkDelegate> network_delegate( |
1023 new ChromeNetworkDelegate( | 1010 new ChromeNetworkDelegate( |
1024 #if defined(ENABLE_EXTENSIONS) | 1011 #if defined(ENABLE_EXTENSIONS) |
1025 io_thread_globals->extension_event_router_forwarder.get(), | 1012 io_thread_globals->extension_event_router_forwarder.get(), |
1026 #else | 1013 #else |
1027 NULL, | 1014 NULL, |
1028 #endif | 1015 #endif |
1029 &enable_referrers_)); | 1016 &enable_referrers_)); |
1030 #if defined(ENABLE_EXTENSIONS) | 1017 #if defined(ENABLE_EXTENSIONS) |
1031 network_delegate->set_extension_info_map( | 1018 network_delegate->set_extension_info_map( |
1032 profile_params_->extension_info_map.get()); | 1019 profile_params_->extension_info_map.get()); |
1033 #endif | 1020 #endif |
1034 #if defined(ENABLE_CONFIGURATION_POLICY) | 1021 #if defined(ENABLE_CONFIGURATION_POLICY) |
1035 network_delegate->set_url_blacklist_manager(url_blacklist_manager_.get()); | 1022 network_delegate->set_url_blacklist_manager(url_blacklist_manager_.get()); |
1036 #endif | 1023 #endif |
1037 network_delegate->set_profile(profile_params_->profile); | 1024 network_delegate->set_profile(profile_params_->profile); |
1038 network_delegate->set_profile_path(profile_params_->path); | 1025 network_delegate->set_profile_path(profile_params_->path); |
1039 network_delegate->set_cookie_settings(profile_params_->cookie_settings.get()); | 1026 network_delegate->set_cookie_settings(profile_params_->cookie_settings.get()); |
1040 network_delegate->set_enable_do_not_track(&enable_do_not_track_); | 1027 network_delegate->set_enable_do_not_track(&enable_do_not_track_); |
1041 network_delegate->set_force_safe_search(&force_safesearch_); | 1028 network_delegate->set_force_safe_search(&force_safesearch_); |
1042 network_delegate->set_force_google_safe_search(&force_google_safesearch_); | 1029 network_delegate->set_force_google_safe_search(&force_google_safesearch_); |
1043 network_delegate->set_force_youtube_safety_mode(&force_youtube_safety_mode_); | 1030 network_delegate->set_force_youtube_safety_mode(&force_youtube_safety_mode_); |
1044 fraudulent_certificate_reporter_.reset( | 1031 fraudulent_certificate_reporter_.reset( |
1045 new chrome_browser_net::ChromeFraudulentCertificateReporter( | 1032 new chrome_browser_net::ChromeFraudulentCertificateReporter( |
1046 main_request_context_.get())); | 1033 main_request_context_.get())); |
1047 | 1034 |
1048 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436671 is fixed. | |
1049 tracked_objects::ScopedTracker tracking_profile3( | |
1050 FROM_HERE_WITH_EXPLICIT_FUNCTION("436671 ProfileIOData::Init3")); | |
1051 | |
1052 // NOTE: Proxy service uses the default io thread network delegate, not the | 1035 // NOTE: Proxy service uses the default io thread network delegate, not the |
1053 // delegate just created. | 1036 // delegate just created. |
1054 proxy_service_.reset( | 1037 proxy_service_.reset( |
1055 ProxyServiceFactory::CreateProxyService( | 1038 ProxyServiceFactory::CreateProxyService( |
1056 io_thread->net_log(), | 1039 io_thread->net_log(), |
1057 io_thread_globals->proxy_script_fetcher_context.get(), | 1040 io_thread_globals->proxy_script_fetcher_context.get(), |
1058 io_thread_globals->system_network_delegate.get(), | 1041 io_thread_globals->system_network_delegate.get(), |
1059 profile_params_->proxy_config_service.release(), | 1042 profile_params_->proxy_config_service.release(), |
1060 command_line, | 1043 command_line, |
1061 quick_check_enabled_.GetValue())); | 1044 quick_check_enabled_.GetValue())); |
1062 transport_security_state_.reset(new net::TransportSecurityState()); | 1045 transport_security_state_.reset(new net::TransportSecurityState()); |
1063 transport_security_persister_.reset( | 1046 transport_security_persister_.reset( |
1064 new net::TransportSecurityPersister( | 1047 new net::TransportSecurityPersister( |
1065 transport_security_state_.get(), | 1048 transport_security_state_.get(), |
1066 profile_params_->path, | 1049 profile_params_->path, |
1067 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 1050 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
1068 IsOffTheRecord())); | 1051 IsOffTheRecord())); |
1069 | 1052 |
1070 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436671 is fixed. | |
1071 tracked_objects::ScopedTracker tracking_profile4( | |
1072 FROM_HERE_WITH_EXPLICIT_FUNCTION("436671 ProfileIOData::Init4")); | |
1073 | |
1074 // Take ownership over these parameters. | 1053 // Take ownership over these parameters. |
1075 cookie_settings_ = profile_params_->cookie_settings; | 1054 cookie_settings_ = profile_params_->cookie_settings; |
1076 host_content_settings_map_ = profile_params_->host_content_settings_map; | 1055 host_content_settings_map_ = profile_params_->host_content_settings_map; |
1077 #if defined(ENABLE_EXTENSIONS) | 1056 #if defined(ENABLE_EXTENSIONS) |
1078 extension_info_map_ = profile_params_->extension_info_map; | 1057 extension_info_map_ = profile_params_->extension_info_map; |
1079 #endif | 1058 #endif |
1080 | 1059 |
1081 resource_context_->host_resolver_ = io_thread_globals->host_resolver.get(); | 1060 resource_context_->host_resolver_ = io_thread_globals->host_resolver.get(); |
1082 resource_context_->request_context_ = main_request_context_.get(); | 1061 resource_context_->request_context_ = main_request_context_.get(); |
1083 | 1062 |
(...skipping 23 matching lines...) Expand all Loading... |
1107 policy_cert_verifier_->InitializeOnIOThread(verify_proc); | 1086 policy_cert_verifier_->InitializeOnIOThread(verify_proc); |
1108 } else { | 1087 } else { |
1109 cert_verifier_.reset(new net::MultiThreadedCertVerifier(verify_proc.get())); | 1088 cert_verifier_.reset(new net::MultiThreadedCertVerifier(verify_proc.get())); |
1110 } | 1089 } |
1111 main_request_context_->set_cert_verifier(cert_verifier_.get()); | 1090 main_request_context_->set_cert_verifier(cert_verifier_.get()); |
1112 #else | 1091 #else |
1113 main_request_context_->set_cert_verifier( | 1092 main_request_context_->set_cert_verifier( |
1114 io_thread_globals->cert_verifier.get()); | 1093 io_thread_globals->cert_verifier.get()); |
1115 #endif | 1094 #endif |
1116 | 1095 |
1117 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436671 is fixed. | |
1118 tracked_objects::ScopedTracker tracking_profile5( | |
1119 FROM_HERE_WITH_EXPLICIT_FUNCTION("436671 ProfileIOData::Init5")); | |
1120 | |
1121 // Install the New Tab Page Interceptor. | 1096 // Install the New Tab Page Interceptor. |
1122 if (profile_params_->new_tab_page_interceptor.get()) { | 1097 if (profile_params_->new_tab_page_interceptor.get()) { |
1123 request_interceptors.push_back( | 1098 request_interceptors.push_back( |
1124 profile_params_->new_tab_page_interceptor.release()); | 1099 profile_params_->new_tab_page_interceptor.release()); |
1125 } | 1100 } |
1126 | 1101 |
1127 InitializeInternal( | 1102 InitializeInternal( |
1128 network_delegate.Pass(), profile_params_.get(), | 1103 network_delegate.Pass(), profile_params_.get(), |
1129 protocol_handlers, request_interceptors.Pass()); | 1104 protocol_handlers, request_interceptors.Pass()); |
1130 | 1105 |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1322 void ProfileIOData::SetCookieSettingsForTesting( | 1297 void ProfileIOData::SetCookieSettingsForTesting( |
1323 CookieSettings* cookie_settings) { | 1298 CookieSettings* cookie_settings) { |
1324 DCHECK(!cookie_settings_.get()); | 1299 DCHECK(!cookie_settings_.get()); |
1325 cookie_settings_ = cookie_settings; | 1300 cookie_settings_ = cookie_settings; |
1326 } | 1301 } |
1327 | 1302 |
1328 void ProfileIOData::set_signin_names_for_testing( | 1303 void ProfileIOData::set_signin_names_for_testing( |
1329 SigninNamesOnIOThread* signin_names) { | 1304 SigninNamesOnIOThread* signin_names) { |
1330 signin_names_.reset(signin_names); | 1305 signin_names_.reset(signin_names); |
1331 } | 1306 } |
OLD | NEW |