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 = |
692 main_context, partition_descriptor, protocol_handler_interceptor.Pass(), | 693 AcquireIsolatedAppRequestContext(main_context, |
693 protocol_handlers); | 694 partition_descriptor, |
| 695 protocol_handler_interceptor.Pass(), |
| 696 protocol_handlers, |
| 697 protocol_interceptors.Pass()); |
694 app_request_context_map_[partition_descriptor] = context; | 698 app_request_context_map_[partition_descriptor] = context; |
695 } | 699 } |
696 DCHECK(context); | 700 DCHECK(context); |
697 return context; | 701 return context; |
698 } | 702 } |
699 | 703 |
700 ChromeURLRequestContext* ProfileIOData::GetIsolatedMediaRequestContext( | 704 ChromeURLRequestContext* ProfileIOData::GetIsolatedMediaRequestContext( |
701 ChromeURLRequestContext* app_context, | 705 ChromeURLRequestContext* app_context, |
702 const StoragePartitionDescriptor& partition_descriptor) const { | 706 const StoragePartitionDescriptor& partition_descriptor) const { |
703 DCHECK(initialized_); | 707 DCHECK(initialized_); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 std::string ProfileIOData::GetSSLSessionCacheShard() { | 888 std::string ProfileIOData::GetSSLSessionCacheShard() { |
885 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 889 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
886 // The SSL session cache is partitioned by setting a string. This returns a | 890 // 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 | 891 // 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 | 892 // new profile, we'll get a fresh SSL session cache which is separate from |
889 // the other profiles. | 893 // the other profiles. |
890 static unsigned ssl_session_cache_instance = 0; | 894 static unsigned ssl_session_cache_instance = 0; |
891 return base::StringPrintf("profile/%u", ssl_session_cache_instance++); | 895 return base::StringPrintf("profile/%u", ssl_session_cache_instance++); |
892 } | 896 } |
893 | 897 |
894 void ProfileIOData::Init(content::ProtocolHandlerMap* protocol_handlers) const { | 898 void ProfileIOData::Init( |
| 899 content::ProtocolHandlerMap* protocol_handlers, |
| 900 content::ProtocolHandlerScopedVector protocol_interceptors) const { |
895 // The basic logic is implemented here. The specific initialization | 901 // The basic logic is implemented here. The specific initialization |
896 // is done in InitializeInternal(), implemented by subtypes. Static helper | 902 // is done in InitializeInternal(), implemented by subtypes. Static helper |
897 // functions have been provided to assist in common operations. | 903 // functions have been provided to assist in common operations. |
898 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 904 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
899 DCHECK(!initialized_); | 905 DCHECK(!initialized_); |
900 | 906 |
901 startup_metric_utils::ScopedSlowStartupUMA | 907 startup_metric_utils::ScopedSlowStartupUMA |
902 scoped_timer("Startup.SlowStartupProfileIODataInit"); | 908 scoped_timer("Startup.SlowStartupProfileIODataInit"); |
903 | 909 |
904 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. | 910 // 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()); | 991 main_request_context_->set_cert_verifier(cert_verifier_.get()); |
986 } else { | 992 } else { |
987 main_request_context_->set_cert_verifier( | 993 main_request_context_->set_cert_verifier( |
988 new net::MultiThreadedCertVerifier(verify_proc.get())); | 994 new net::MultiThreadedCertVerifier(verify_proc.get())); |
989 } | 995 } |
990 #else | 996 #else |
991 main_request_context_->set_cert_verifier( | 997 main_request_context_->set_cert_verifier( |
992 io_thread_globals->cert_verifier.get()); | 998 io_thread_globals->cert_verifier.get()); |
993 #endif | 999 #endif |
994 | 1000 |
995 InitializeInternal(profile_params_.get(), protocol_handlers); | 1001 InitializeInternal( |
| 1002 profile_params_.get(), protocol_handlers, protocol_interceptors.Pass()); |
996 | 1003 |
997 profile_params_.reset(); | 1004 profile_params_.reset(); |
998 initialized_ = true; | 1005 initialized_ = true; |
999 } | 1006 } |
1000 | 1007 |
1001 void ProfileIOData::ApplyProfileParamsToContext( | 1008 void ProfileIOData::ApplyProfileParamsToContext( |
1002 ChromeURLRequestContext* context) const { | 1009 ChromeURLRequestContext* context) const { |
1003 context->set_http_user_agent_settings( | 1010 context->set_http_user_agent_settings( |
1004 chrome_http_user_agent_settings_.get()); | 1011 chrome_http_user_agent_settings_.get()); |
1005 context->set_ssl_config_service(profile_params_->ssl_config_service.get()); | 1012 context->set_ssl_config_service(profile_params_->ssl_config_service.get()); |
1006 } | 1013 } |
1007 | 1014 |
1008 scoped_ptr<net::URLRequestJobFactory> ProfileIOData::SetUpJobFactoryDefaults( | 1015 scoped_ptr<net::URLRequestJobFactory> ProfileIOData::SetUpJobFactoryDefaults( |
1009 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory, | 1016 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory, |
| 1017 content::ProtocolHandlerScopedVector protocol_interceptors, |
1010 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 1018 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
1011 protocol_handler_interceptor, | 1019 protocol_handler_interceptor, |
1012 net::NetworkDelegate* network_delegate, | 1020 net::NetworkDelegate* network_delegate, |
1013 net::FtpTransactionFactory* ftp_transaction_factory) const { | 1021 net::FtpTransactionFactory* ftp_transaction_factory) const { |
1014 // NOTE(willchan): Keep these protocol handlers in sync with | 1022 // NOTE(willchan): Keep these protocol handlers in sync with |
1015 // ProfileIOData::IsHandledProtocol(). | 1023 // ProfileIOData::IsHandledProtocol(). |
1016 bool set_protocol = job_factory->SetProtocolHandler( | 1024 bool set_protocol = job_factory->SetProtocolHandler( |
1017 content::kFileScheme, | 1025 content::kFileScheme, |
1018 new net::FileProtocolHandler( | 1026 new net::FileProtocolHandler( |
1019 content::BrowserThread::GetBlockingPool()-> | 1027 content::BrowserThread::GetBlockingPool()-> |
(...skipping 26 matching lines...) Expand all Loading... |
1046 job_factory->SetProtocolHandler( | 1054 job_factory->SetProtocolHandler( |
1047 chrome::kAboutScheme, | 1055 chrome::kAboutScheme, |
1048 new chrome_browser_net::AboutProtocolHandler()); | 1056 new chrome_browser_net::AboutProtocolHandler()); |
1049 #if !defined(DISABLE_FTP_SUPPORT) | 1057 #if !defined(DISABLE_FTP_SUPPORT) |
1050 DCHECK(ftp_transaction_factory); | 1058 DCHECK(ftp_transaction_factory); |
1051 job_factory->SetProtocolHandler( | 1059 job_factory->SetProtocolHandler( |
1052 content::kFtpScheme, | 1060 content::kFtpScheme, |
1053 new net::FtpProtocolHandler(ftp_transaction_factory)); | 1061 new net::FtpProtocolHandler(ftp_transaction_factory)); |
1054 #endif // !defined(DISABLE_FTP_SUPPORT) | 1062 #endif // !defined(DISABLE_FTP_SUPPORT) |
1055 | 1063 |
| 1064 #if defined(DEBUG_DEVTOOLS) |
| 1065 protocol_interceptors.push_back(new DebugDevToolsInterceptor); |
| 1066 #endif |
| 1067 |
| 1068 // Set up interceptors in the reverse order. |
1056 scoped_ptr<net::URLRequestJobFactory> top_job_factory = | 1069 scoped_ptr<net::URLRequestJobFactory> top_job_factory = |
1057 job_factory.PassAs<net::URLRequestJobFactory>(); | 1070 job_factory.PassAs<net::URLRequestJobFactory>(); |
1058 #if defined(DEBUG_DEVTOOLS) | 1071 for (content::ProtocolHandlerScopedVector::reverse_iterator i = |
1059 top_job_factory.reset(new net::ProtocolInterceptJobFactory( | 1072 protocol_interceptors.rbegin(); |
1060 top_job_factory.Pass(), | 1073 i != protocol_interceptors.rend(); |
1061 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>( | 1074 ++i) { |
1062 new DebugDevToolsInterceptor))); | 1075 top_job_factory.reset(new net::ProtocolInterceptJobFactory( |
1063 #endif | 1076 top_job_factory.Pass(), 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 |