| 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" |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 ChromeURLRequestContext* ProfileIOData::GetExtensionsRequestContext() const { | 675 ChromeURLRequestContext* ProfileIOData::GetExtensionsRequestContext() const { |
| 676 DCHECK(initialized_); | 676 DCHECK(initialized_); |
| 677 return extensions_request_context_.get(); | 677 return extensions_request_context_.get(); |
| 678 } | 678 } |
| 679 | 679 |
| 680 ChromeURLRequestContext* ProfileIOData::GetIsolatedAppRequestContext( | 680 ChromeURLRequestContext* ProfileIOData::GetIsolatedAppRequestContext( |
| 681 ChromeURLRequestContext* main_context, | 681 ChromeURLRequestContext* main_context, |
| 682 const StoragePartitionDescriptor& partition_descriptor, | 682 const StoragePartitionDescriptor& partition_descriptor, |
| 683 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 683 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 684 protocol_handler_interceptor, | 684 protocol_handler_interceptor, |
| 685 content::ProtocolHandlerMap* protocol_handlers) const { | 685 content::ProtocolHandlerMap* protocol_handlers, |
| 686 content::ProtocolHandlerScopedVector protocol_interceptors) const { |
| 686 DCHECK(initialized_); | 687 DCHECK(initialized_); |
| 687 ChromeURLRequestContext* context = NULL; | 688 ChromeURLRequestContext* context = NULL; |
| 688 if (ContainsKey(app_request_context_map_, partition_descriptor)) { | 689 if (ContainsKey(app_request_context_map_, partition_descriptor)) { |
| 689 context = app_request_context_map_[partition_descriptor]; | 690 context = app_request_context_map_[partition_descriptor]; |
| 690 } else { | 691 } else { |
| 691 context = AcquireIsolatedAppRequestContext( | 692 context = AcquireIsolatedAppRequestContext( |
| 692 main_context, partition_descriptor, protocol_handler_interceptor.Pass(), | 693 main_context, partition_descriptor, protocol_handler_interceptor.Pass(), |
| 693 protocol_handlers); | 694 protocol_handlers, |
| 695 protocol_interceptors.Pass()); |
| 694 app_request_context_map_[partition_descriptor] = context; | 696 app_request_context_map_[partition_descriptor] = context; |
| 695 } | 697 } |
| 696 DCHECK(context); | 698 DCHECK(context); |
| 697 return context; | 699 return context; |
| 698 } | 700 } |
| 699 | 701 |
| 700 ChromeURLRequestContext* ProfileIOData::GetIsolatedMediaRequestContext( | 702 ChromeURLRequestContext* ProfileIOData::GetIsolatedMediaRequestContext( |
| 701 ChromeURLRequestContext* app_context, | 703 ChromeURLRequestContext* app_context, |
| 702 const StoragePartitionDescriptor& partition_descriptor) const { | 704 const StoragePartitionDescriptor& partition_descriptor) const { |
| 703 DCHECK(initialized_); | 705 DCHECK(initialized_); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 std::string ProfileIOData::GetSSLSessionCacheShard() { | 886 std::string ProfileIOData::GetSSLSessionCacheShard() { |
| 885 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 887 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 886 // The SSL session cache is partitioned by setting a string. This returns a | 888 // The SSL session cache is partitioned by setting a string. This returns a |
| 887 // unique string to partition the SSL session cache. Each time we create a | 889 // unique string to partition the SSL session cache. Each time we create a |
| 888 // new profile, we'll get a fresh SSL session cache which is separate from | 890 // new profile, we'll get a fresh SSL session cache which is separate from |
| 889 // the other profiles. | 891 // the other profiles. |
| 890 static unsigned ssl_session_cache_instance = 0; | 892 static unsigned ssl_session_cache_instance = 0; |
| 891 return base::StringPrintf("profile/%u", ssl_session_cache_instance++); | 893 return base::StringPrintf("profile/%u", ssl_session_cache_instance++); |
| 892 } | 894 } |
| 893 | 895 |
| 894 void ProfileIOData::Init(content::ProtocolHandlerMap* protocol_handlers) const { | 896 void ProfileIOData::Init( |
| 897 content::ProtocolHandlerMap* protocol_handlers, |
| 898 content::ProtocolHandlerScopedVector protocol_interceptors) const { |
| 895 // The basic logic is implemented here. The specific initialization | 899 // The basic logic is implemented here. The specific initialization |
| 896 // is done in InitializeInternal(), implemented by subtypes. Static helper | 900 // is done in InitializeInternal(), implemented by subtypes. Static helper |
| 897 // functions have been provided to assist in common operations. | 901 // functions have been provided to assist in common operations. |
| 898 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 902 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 899 DCHECK(!initialized_); | 903 DCHECK(!initialized_); |
| 900 | 904 |
| 901 startup_metric_utils::ScopedSlowStartupUMA | 905 startup_metric_utils::ScopedSlowStartupUMA |
| 902 scoped_timer("Startup.SlowStartupProfileIODataInit"); | 906 scoped_timer("Startup.SlowStartupProfileIODataInit"); |
| 903 | 907 |
| 904 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. | 908 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 main_request_context_->set_cert_verifier(cert_verifier_.get()); | 989 main_request_context_->set_cert_verifier(cert_verifier_.get()); |
| 986 } else { | 990 } else { |
| 987 main_request_context_->set_cert_verifier( | 991 main_request_context_->set_cert_verifier( |
| 988 new net::MultiThreadedCertVerifier(verify_proc.get())); | 992 new net::MultiThreadedCertVerifier(verify_proc.get())); |
| 989 } | 993 } |
| 990 #else | 994 #else |
| 991 main_request_context_->set_cert_verifier( | 995 main_request_context_->set_cert_verifier( |
| 992 io_thread_globals->cert_verifier.get()); | 996 io_thread_globals->cert_verifier.get()); |
| 993 #endif | 997 #endif |
| 994 | 998 |
| 995 InitializeInternal(profile_params_.get(), protocol_handlers); | 999 InitializeInternal(profile_params_.get(), |
| 1000 protocol_handlers, |
| 1001 protocol_interceptors.Pass()); |
| 996 | 1002 |
| 997 profile_params_.reset(); | 1003 profile_params_.reset(); |
| 998 initialized_ = true; | 1004 initialized_ = true; |
| 999 } | 1005 } |
| 1000 | 1006 |
| 1001 void ProfileIOData::ApplyProfileParamsToContext( | 1007 void ProfileIOData::ApplyProfileParamsToContext( |
| 1002 ChromeURLRequestContext* context) const { | 1008 ChromeURLRequestContext* context) const { |
| 1003 context->set_http_user_agent_settings( | 1009 context->set_http_user_agent_settings( |
| 1004 chrome_http_user_agent_settings_.get()); | 1010 chrome_http_user_agent_settings_.get()); |
| 1005 context->set_ssl_config_service(profile_params_->ssl_config_service.get()); | 1011 context->set_ssl_config_service(profile_params_->ssl_config_service.get()); |
| 1006 } | 1012 } |
| 1007 | 1013 |
| 1008 scoped_ptr<net::URLRequestJobFactory> ProfileIOData::SetUpJobFactoryDefaults( | 1014 scoped_ptr<net::URLRequestJobFactory> ProfileIOData::SetUpJobFactoryDefaults( |
| 1009 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory, | 1015 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory, |
| 1016 content::ProtocolHandlerScopedVector protocol_interceptors, |
| 1010 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 1017 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 1011 protocol_handler_interceptor, | 1018 protocol_handler_interceptor, |
| 1012 net::NetworkDelegate* network_delegate, | 1019 net::NetworkDelegate* network_delegate, |
| 1013 net::FtpTransactionFactory* ftp_transaction_factory) const { | 1020 net::FtpTransactionFactory* ftp_transaction_factory) const { |
| 1014 // NOTE(willchan): Keep these protocol handlers in sync with | 1021 // NOTE(willchan): Keep these protocol handlers in sync with |
| 1015 // ProfileIOData::IsHandledProtocol(). | 1022 // ProfileIOData::IsHandledProtocol(). |
| 1016 bool set_protocol = job_factory->SetProtocolHandler( | 1023 bool set_protocol = job_factory->SetProtocolHandler( |
| 1017 content::kFileScheme, | 1024 content::kFileScheme, |
| 1018 new net::FileProtocolHandler( | 1025 new net::FileProtocolHandler( |
| 1019 content::BrowserThread::GetBlockingPool()-> | 1026 content::BrowserThread::GetBlockingPool()-> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1046 job_factory->SetProtocolHandler( | 1053 job_factory->SetProtocolHandler( |
| 1047 chrome::kAboutScheme, | 1054 chrome::kAboutScheme, |
| 1048 new chrome_browser_net::AboutProtocolHandler()); | 1055 new chrome_browser_net::AboutProtocolHandler()); |
| 1049 #if !defined(DISABLE_FTP_SUPPORT) | 1056 #if !defined(DISABLE_FTP_SUPPORT) |
| 1050 DCHECK(ftp_transaction_factory); | 1057 DCHECK(ftp_transaction_factory); |
| 1051 job_factory->SetProtocolHandler( | 1058 job_factory->SetProtocolHandler( |
| 1052 content::kFtpScheme, | 1059 content::kFtpScheme, |
| 1053 new net::FtpProtocolHandler(ftp_transaction_factory)); | 1060 new net::FtpProtocolHandler(ftp_transaction_factory)); |
| 1054 #endif // !defined(DISABLE_FTP_SUPPORT) | 1061 #endif // !defined(DISABLE_FTP_SUPPORT) |
| 1055 | 1062 |
| 1063 #if defined(DEBUG_DEVTOOLS) |
| 1064 protocol_interceptors.push_back(new DebugDevToolsInterceptor); |
| 1065 #endif |
| 1066 |
| 1067 // Setup iterators in the reverse order. |
| 1056 scoped_ptr<net::URLRequestJobFactory> top_job_factory = | 1068 scoped_ptr<net::URLRequestJobFactory> top_job_factory = |
| 1057 job_factory.PassAs<net::URLRequestJobFactory>(); | 1069 job_factory.PassAs<net::URLRequestJobFactory>(); |
| 1058 #if defined(DEBUG_DEVTOOLS) | 1070 for (content::ProtocolHandlerScopedVector::reverse_iterator i = |
| 1059 top_job_factory.reset(new net::ProtocolInterceptJobFactory( | 1071 protocol_interceptors.rbegin(); |
| 1060 top_job_factory.Pass(), | 1072 i != protocol_interceptors.rend(); ++i) { |
| 1061 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>( | 1073 top_job_factory.reset( |
| 1062 new DebugDevToolsInterceptor))); | 1074 new net::ProtocolInterceptJobFactory( |
| 1063 #endif | 1075 top_job_factory.Pass(), |
| 1076 make_scoped_ptr(*i))); |
| 1077 } |
| 1078 protocol_interceptors.weak_clear(); |
| 1064 | 1079 |
| 1065 if (protocol_handler_interceptor) { | 1080 if (protocol_handler_interceptor) { |
| 1066 protocol_handler_interceptor->Chain(top_job_factory.Pass()); | 1081 protocol_handler_interceptor->Chain(top_job_factory.Pass()); |
| 1067 return protocol_handler_interceptor.PassAs<net::URLRequestJobFactory>(); | 1082 return protocol_handler_interceptor.PassAs<net::URLRequestJobFactory>(); |
| 1068 } else { | 1083 } else { |
| 1069 return top_job_factory.Pass(); | 1084 return top_job_factory.Pass(); |
| 1070 } | 1085 } |
| 1071 } | 1086 } |
| 1072 | 1087 |
| 1073 void ProfileIOData::ShutdownOnUIThread() { | 1088 void ProfileIOData::ShutdownOnUIThread() { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1143 void ProfileIOData::SetCookieSettingsForTesting( | 1158 void ProfileIOData::SetCookieSettingsForTesting( |
| 1144 CookieSettings* cookie_settings) { | 1159 CookieSettings* cookie_settings) { |
| 1145 DCHECK(!cookie_settings_.get()); | 1160 DCHECK(!cookie_settings_.get()); |
| 1146 cookie_settings_ = cookie_settings; | 1161 cookie_settings_ = cookie_settings; |
| 1147 } | 1162 } |
| 1148 | 1163 |
| 1149 void ProfileIOData::set_signin_names_for_testing( | 1164 void ProfileIOData::set_signin_names_for_testing( |
| 1150 SigninNamesOnIOThread* signin_names) { | 1165 SigninNamesOnIOThread* signin_names) { |
| 1151 signin_names_.reset(signin_names); | 1166 signin_names_.reset(signin_names); |
| 1152 } | 1167 } |
| OLD | NEW |