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 <stddef.h> | 7 #include <stddef.h> |
8 | |
9 #include <string> | 8 #include <string> |
| 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/debug/alias.h" | 16 #include "base/debug/alias.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/path_service.h" | 19 #include "base/path_service.h" |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 } | 358 } |
359 } | 359 } |
360 #endif // defined(OS_CHROMEOS) | 360 #endif // defined(OS_CHROMEOS) |
361 | 361 |
362 #if defined(USE_NSS_CERTS) | 362 #if defined(USE_NSS_CERTS) |
363 void InitializeAndPassKeygenHandler( | 363 void InitializeAndPassKeygenHandler( |
364 scoped_ptr<net::KeygenHandler> keygen_handler, | 364 scoped_ptr<net::KeygenHandler> keygen_handler, |
365 const base::Callback<void(scoped_ptr<net::KeygenHandler>)>& callback, | 365 const base::Callback<void(scoped_ptr<net::KeygenHandler>)>& callback, |
366 scoped_ptr<ChromeNSSCryptoModuleDelegate> delegate) { | 366 scoped_ptr<ChromeNSSCryptoModuleDelegate> delegate) { |
367 if (delegate) | 367 if (delegate) |
368 keygen_handler->set_crypto_module_delegate(delegate.Pass()); | 368 keygen_handler->set_crypto_module_delegate(std::move(delegate)); |
369 callback.Run(keygen_handler.Pass()); | 369 callback.Run(std::move(keygen_handler)); |
370 } | 370 } |
371 #endif // defined(USE_NSS_CERTS) | 371 #endif // defined(USE_NSS_CERTS) |
372 | 372 |
373 // For safe shutdown, must be called before the ProfileIOData is destroyed. | 373 // For safe shutdown, must be called before the ProfileIOData is destroyed. |
374 void NotifyContextGettersOfShutdownOnIO( | 374 void NotifyContextGettersOfShutdownOnIO( |
375 scoped_ptr<ProfileIOData::ChromeURLRequestContextGetterVector> getters) { | 375 scoped_ptr<ProfileIOData::ChromeURLRequestContextGetterVector> getters) { |
376 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 376 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
377 ProfileIOData::ChromeURLRequestContextGetterVector::iterator iter; | 377 ProfileIOData::ChromeURLRequestContextGetterVector::iterator iter; |
378 for (auto& chrome_context_getter : *getters) | 378 for (auto& chrome_context_getter : *getters) |
379 chrome_context_getter->NotifyContextShuttingDown(); | 379 chrome_context_getter->NotifyContextShuttingDown(); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 // are associated with each ResourceContext because we might post this | 552 // are associated with each ResourceContext because we might post this |
553 // object to the IO thread after this function. | 553 // object to the IO thread after this function. |
554 BrowserContext::EnsureResourceContextInitialized(profile); | 554 BrowserContext::EnsureResourceContextInitialized(profile); |
555 } | 555 } |
556 | 556 |
557 ProfileIOData::MediaRequestContext::MediaRequestContext() { | 557 ProfileIOData::MediaRequestContext::MediaRequestContext() { |
558 } | 558 } |
559 | 559 |
560 void ProfileIOData::MediaRequestContext::SetHttpTransactionFactory( | 560 void ProfileIOData::MediaRequestContext::SetHttpTransactionFactory( |
561 scoped_ptr<net::HttpTransactionFactory> http_factory) { | 561 scoped_ptr<net::HttpTransactionFactory> http_factory) { |
562 http_factory_ = http_factory.Pass(); | 562 http_factory_ = std::move(http_factory); |
563 set_http_transaction_factory(http_factory_.get()); | 563 set_http_transaction_factory(http_factory_.get()); |
564 } | 564 } |
565 | 565 |
566 ProfileIOData::MediaRequestContext::~MediaRequestContext() { | 566 ProfileIOData::MediaRequestContext::~MediaRequestContext() { |
567 AssertNoURLRequests(); | 567 AssertNoURLRequests(); |
568 } | 568 } |
569 | 569 |
570 ProfileIOData::AppRequestContext::AppRequestContext() { | 570 ProfileIOData::AppRequestContext::AppRequestContext() { |
571 } | 571 } |
572 | 572 |
573 void ProfileIOData::AppRequestContext::SetCookieStore( | 573 void ProfileIOData::AppRequestContext::SetCookieStore( |
574 net::CookieStore* cookie_store) { | 574 net::CookieStore* cookie_store) { |
575 cookie_store_ = cookie_store; | 575 cookie_store_ = cookie_store; |
576 set_cookie_store(cookie_store); | 576 set_cookie_store(cookie_store); |
577 } | 577 } |
578 | 578 |
579 void ProfileIOData::AppRequestContext::SetHttpTransactionFactory( | 579 void ProfileIOData::AppRequestContext::SetHttpTransactionFactory( |
580 scoped_ptr<net::HttpTransactionFactory> http_factory) { | 580 scoped_ptr<net::HttpTransactionFactory> http_factory) { |
581 http_factory_ = http_factory.Pass(); | 581 http_factory_ = std::move(http_factory); |
582 set_http_transaction_factory(http_factory_.get()); | 582 set_http_transaction_factory(http_factory_.get()); |
583 } | 583 } |
584 | 584 |
585 void ProfileIOData::AppRequestContext::SetJobFactory( | 585 void ProfileIOData::AppRequestContext::SetJobFactory( |
586 scoped_ptr<net::URLRequestJobFactory> job_factory) { | 586 scoped_ptr<net::URLRequestJobFactory> job_factory) { |
587 job_factory_ = job_factory.Pass(); | 587 job_factory_ = std::move(job_factory); |
588 set_job_factory(job_factory_.get()); | 588 set_job_factory(job_factory_.get()); |
589 } | 589 } |
590 | 590 |
591 ProfileIOData::AppRequestContext::~AppRequestContext() { | 591 ProfileIOData::AppRequestContext::~AppRequestContext() { |
592 AssertNoURLRequests(); | 592 AssertNoURLRequests(); |
593 } | 593 } |
594 | 594 |
595 ProfileIOData::ProfileParams::ProfileParams() | 595 ProfileIOData::ProfileParams::ProfileParams() |
596 : io_thread(NULL), | 596 : io_thread(NULL), |
597 #if defined(OS_CHROMEOS) | 597 #if defined(OS_CHROMEOS) |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 const StoragePartitionDescriptor& partition_descriptor, | 795 const StoragePartitionDescriptor& partition_descriptor, |
796 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 796 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
797 protocol_handler_interceptor, | 797 protocol_handler_interceptor, |
798 content::ProtocolHandlerMap* protocol_handlers, | 798 content::ProtocolHandlerMap* protocol_handlers, |
799 content::URLRequestInterceptorScopedVector request_interceptors) const { | 799 content::URLRequestInterceptorScopedVector request_interceptors) const { |
800 DCHECK(initialized_); | 800 DCHECK(initialized_); |
801 net::URLRequestContext* context = NULL; | 801 net::URLRequestContext* context = NULL; |
802 if (ContainsKey(app_request_context_map_, partition_descriptor)) { | 802 if (ContainsKey(app_request_context_map_, partition_descriptor)) { |
803 context = app_request_context_map_[partition_descriptor]; | 803 context = app_request_context_map_[partition_descriptor]; |
804 } else { | 804 } else { |
805 context = | 805 context = AcquireIsolatedAppRequestContext( |
806 AcquireIsolatedAppRequestContext(main_context, | 806 main_context, partition_descriptor, |
807 partition_descriptor, | 807 std::move(protocol_handler_interceptor), protocol_handlers, |
808 protocol_handler_interceptor.Pass(), | 808 std::move(request_interceptors)); |
809 protocol_handlers, | |
810 request_interceptors.Pass()); | |
811 app_request_context_map_[partition_descriptor] = context; | 809 app_request_context_map_[partition_descriptor] = context; |
812 } | 810 } |
813 DCHECK(context); | 811 DCHECK(context); |
814 return context; | 812 return context; |
815 } | 813 } |
816 | 814 |
817 net::URLRequestContext* ProfileIOData::GetIsolatedMediaRequestContext( | 815 net::URLRequestContext* ProfileIOData::GetIsolatedMediaRequestContext( |
818 net::URLRequestContext* app_context, | 816 net::URLRequestContext* app_context, |
819 const StoragePartitionDescriptor& partition_descriptor) const { | 817 const StoragePartitionDescriptor& partition_descriptor) const { |
820 DCHECK(initialized_); | 818 DCHECK(initialized_); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 } | 893 } |
896 | 894 |
897 bool ProfileIOData::IsDataReductionProxyEnabled() const { | 895 bool ProfileIOData::IsDataReductionProxyEnabled() const { |
898 return data_reduction_proxy_io_data() && | 896 return data_reduction_proxy_io_data() && |
899 data_reduction_proxy_io_data()->IsEnabled(); | 897 data_reduction_proxy_io_data()->IsEnabled(); |
900 } | 898 } |
901 | 899 |
902 void ProfileIOData::set_data_reduction_proxy_io_data( | 900 void ProfileIOData::set_data_reduction_proxy_io_data( |
903 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData> | 901 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData> |
904 data_reduction_proxy_io_data) const { | 902 data_reduction_proxy_io_data) const { |
905 data_reduction_proxy_io_data_ = data_reduction_proxy_io_data.Pass(); | 903 data_reduction_proxy_io_data_ = std::move(data_reduction_proxy_io_data); |
906 } | 904 } |
907 | 905 |
908 base::WeakPtr<net::HttpServerProperties> | 906 base::WeakPtr<net::HttpServerProperties> |
909 ProfileIOData::http_server_properties() const { | 907 ProfileIOData::http_server_properties() const { |
910 return http_server_properties_->GetWeakPtr(); | 908 return http_server_properties_->GetWeakPtr(); |
911 } | 909 } |
912 | 910 |
913 void ProfileIOData::set_http_server_properties( | 911 void ProfileIOData::set_http_server_properties( |
914 scoped_ptr<net::HttpServerProperties> http_server_properties) const { | 912 scoped_ptr<net::HttpServerProperties> http_server_properties) const { |
915 http_server_properties_ = http_server_properties.Pass(); | 913 http_server_properties_ = std::move(http_server_properties); |
916 } | 914 } |
917 | 915 |
918 ProfileIOData::ResourceContext::ResourceContext(ProfileIOData* io_data) | 916 ProfileIOData::ResourceContext::ResourceContext(ProfileIOData* io_data) |
919 : io_data_(io_data), | 917 : io_data_(io_data), |
920 host_resolver_(NULL), | 918 host_resolver_(NULL), |
921 request_context_(NULL) { | 919 request_context_(NULL) { |
922 DCHECK(io_data); | 920 DCHECK(io_data); |
923 } | 921 } |
924 | 922 |
925 ProfileIOData::ResourceContext::~ResourceContext() {} | 923 ProfileIOData::ResourceContext::~ResourceContext() {} |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 network_delegate->set_force_youtube_safety_mode(&force_youtube_safety_mode_); | 1047 network_delegate->set_force_youtube_safety_mode(&force_youtube_safety_mode_); |
1050 network_delegate->set_data_use_aggregator( | 1048 network_delegate->set_data_use_aggregator( |
1051 io_thread_globals->data_use_aggregator.get(), IsOffTheRecord()); | 1049 io_thread_globals->data_use_aggregator.get(), IsOffTheRecord()); |
1052 | 1050 |
1053 // NOTE: Proxy service uses the default io thread network delegate, not the | 1051 // NOTE: Proxy service uses the default io thread network delegate, not the |
1054 // delegate just created. | 1052 // delegate just created. |
1055 proxy_service_ = ProxyServiceFactory::CreateProxyService( | 1053 proxy_service_ = ProxyServiceFactory::CreateProxyService( |
1056 io_thread->net_log(), | 1054 io_thread->net_log(), |
1057 io_thread_globals->proxy_script_fetcher_context.get(), | 1055 io_thread_globals->proxy_script_fetcher_context.get(), |
1058 io_thread_globals->system_network_delegate.get(), | 1056 io_thread_globals->system_network_delegate.get(), |
1059 profile_params_->proxy_config_service.Pass(), command_line, | 1057 std::move(profile_params_->proxy_config_service), command_line, |
1060 quick_check_enabled_.GetValue()); | 1058 quick_check_enabled_.GetValue()); |
1061 transport_security_state_.reset(new net::TransportSecurityState()); | 1059 transport_security_state_.reset(new net::TransportSecurityState()); |
1062 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); | 1060 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); |
1063 transport_security_persister_.reset( | 1061 transport_security_persister_.reset( |
1064 new net::TransportSecurityPersister( | 1062 new net::TransportSecurityPersister( |
1065 transport_security_state_.get(), | 1063 transport_security_state_.get(), |
1066 profile_params_->path, | 1064 profile_params_->path, |
1067 pool->GetSequencedTaskRunnerWithShutdownBehavior( | 1065 pool->GetSequencedTaskRunnerWithShutdownBehavior( |
1068 pool->GetSequenceToken(), | 1066 pool->GetSequenceToken(), |
1069 base::SequencedWorkerPool::BLOCK_SHUTDOWN), | 1067 base::SequencedWorkerPool::BLOCK_SHUTDOWN), |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 // Install the New Tab Page Interceptor. | 1127 // Install the New Tab Page Interceptor. |
1130 if (profile_params_->new_tab_page_interceptor.get()) { | 1128 if (profile_params_->new_tab_page_interceptor.get()) { |
1131 request_interceptors.push_back( | 1129 request_interceptors.push_back( |
1132 profile_params_->new_tab_page_interceptor.release()); | 1130 profile_params_->new_tab_page_interceptor.release()); |
1133 } | 1131 } |
1134 | 1132 |
1135 scoped_ptr<net::MultiLogCTVerifier> ct_verifier( | 1133 scoped_ptr<net::MultiLogCTVerifier> ct_verifier( |
1136 new net::MultiLogCTVerifier()); | 1134 new net::MultiLogCTVerifier()); |
1137 ct_verifier->AddLogs(io_thread_globals->ct_logs); | 1135 ct_verifier->AddLogs(io_thread_globals->ct_logs); |
1138 main_request_context_->set_cert_transparency_verifier(ct_verifier.get()); | 1136 main_request_context_->set_cert_transparency_verifier(ct_verifier.get()); |
1139 cert_transparency_verifier_ = ct_verifier.Pass(); | 1137 cert_transparency_verifier_ = std::move(ct_verifier); |
1140 | 1138 |
1141 InitializeInternal( | 1139 InitializeInternal(std::move(network_delegate), profile_params_.get(), |
1142 network_delegate.Pass(), profile_params_.get(), | 1140 protocol_handlers, std::move(request_interceptors)); |
1143 protocol_handlers, request_interceptors.Pass()); | |
1144 | 1141 |
1145 profile_params_.reset(); | 1142 profile_params_.reset(); |
1146 initialized_ = true; | 1143 initialized_ = true; |
1147 } | 1144 } |
1148 | 1145 |
1149 void ProfileIOData::ApplyProfileParamsToContext( | 1146 void ProfileIOData::ApplyProfileParamsToContext( |
1150 net::URLRequestContext* context) const { | 1147 net::URLRequestContext* context) const { |
1151 context->set_http_user_agent_settings( | 1148 context->set_http_user_agent_settings( |
1152 chrome_http_user_agent_settings_.get()); | 1149 chrome_http_user_agent_settings_.get()); |
1153 context->set_ssl_config_service(profile_params_->ssl_config_service.get()); | 1150 context->set_ssl_config_service(profile_params_->ssl_config_service.get()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1213 job_factory->SetProtocolHandler( | 1210 job_factory->SetProtocolHandler( |
1214 url::kFtpScheme, | 1211 url::kFtpScheme, |
1215 make_scoped_ptr(new net::FtpProtocolHandler(ftp_transaction_factory))); | 1212 make_scoped_ptr(new net::FtpProtocolHandler(ftp_transaction_factory))); |
1216 #endif // !defined(DISABLE_FTP_SUPPORT) | 1213 #endif // !defined(DISABLE_FTP_SUPPORT) |
1217 | 1214 |
1218 #if defined(DEBUG_DEVTOOLS) | 1215 #if defined(DEBUG_DEVTOOLS) |
1219 request_interceptors.push_back(new DebugDevToolsInterceptor); | 1216 request_interceptors.push_back(new DebugDevToolsInterceptor); |
1220 #endif | 1217 #endif |
1221 | 1218 |
1222 // Set up interceptors in the reverse order. | 1219 // Set up interceptors in the reverse order. |
1223 scoped_ptr<net::URLRequestJobFactory> top_job_factory = job_factory.Pass(); | 1220 scoped_ptr<net::URLRequestJobFactory> top_job_factory = |
| 1221 std::move(job_factory); |
1224 for (content::URLRequestInterceptorScopedVector::reverse_iterator i = | 1222 for (content::URLRequestInterceptorScopedVector::reverse_iterator i = |
1225 request_interceptors.rbegin(); | 1223 request_interceptors.rbegin(); |
1226 i != request_interceptors.rend(); | 1224 i != request_interceptors.rend(); |
1227 ++i) { | 1225 ++i) { |
1228 top_job_factory.reset(new net::URLRequestInterceptingJobFactory( | 1226 top_job_factory.reset(new net::URLRequestInterceptingJobFactory( |
1229 top_job_factory.Pass(), make_scoped_ptr(*i))); | 1227 std::move(top_job_factory), make_scoped_ptr(*i))); |
1230 } | 1228 } |
1231 request_interceptors.weak_clear(); | 1229 request_interceptors.weak_clear(); |
1232 | 1230 |
1233 if (protocol_handler_interceptor) { | 1231 if (protocol_handler_interceptor) { |
1234 protocol_handler_interceptor->Chain(top_job_factory.Pass()); | 1232 protocol_handler_interceptor->Chain(std::move(top_job_factory)); |
1235 return protocol_handler_interceptor.Pass(); | 1233 return std::move(protocol_handler_interceptor); |
1236 } else { | 1234 } else { |
1237 return top_job_factory.Pass(); | 1235 return top_job_factory; |
1238 } | 1236 } |
1239 } | 1237 } |
1240 | 1238 |
1241 void ProfileIOData::ShutdownOnUIThread( | 1239 void ProfileIOData::ShutdownOnUIThread( |
1242 scoped_ptr<ChromeURLRequestContextGetterVector> context_getters) { | 1240 scoped_ptr<ChromeURLRequestContextGetterVector> context_getters) { |
1243 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1241 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1244 | 1242 |
1245 google_services_user_account_id_.Destroy(); | 1243 google_services_user_account_id_.Destroy(); |
1246 enable_referrers_.Destroy(); | 1244 enable_referrers_.Destroy(); |
1247 enable_do_not_track_.Destroy(); | 1245 enable_do_not_track_.Destroy(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1307 return scoped_ptr<net::HttpNetworkSession>( | 1305 return scoped_ptr<net::HttpNetworkSession>( |
1308 new net::HttpNetworkSession(params)); | 1306 new net::HttpNetworkSession(params)); |
1309 } | 1307 } |
1310 | 1308 |
1311 scoped_ptr<net::HttpCache> ProfileIOData::CreateMainHttpFactory( | 1309 scoped_ptr<net::HttpCache> ProfileIOData::CreateMainHttpFactory( |
1312 net::HttpNetworkSession* session, | 1310 net::HttpNetworkSession* session, |
1313 scoped_ptr<net::HttpCache::BackendFactory> main_backend) const { | 1311 scoped_ptr<net::HttpCache::BackendFactory> main_backend) const { |
1314 return make_scoped_ptr(new net::HttpCache( | 1312 return make_scoped_ptr(new net::HttpCache( |
1315 make_scoped_ptr(new DevToolsNetworkTransactionFactory( | 1313 make_scoped_ptr(new DevToolsNetworkTransactionFactory( |
1316 network_controller_handle_.GetController(), session)), | 1314 network_controller_handle_.GetController(), session)), |
1317 main_backend.Pass(), true /* set_up_quic_server_info */)); | 1315 std::move(main_backend), true /* set_up_quic_server_info */)); |
1318 } | 1316 } |
1319 | 1317 |
1320 scoped_ptr<net::HttpCache> ProfileIOData::CreateHttpFactory( | 1318 scoped_ptr<net::HttpCache> ProfileIOData::CreateHttpFactory( |
1321 net::HttpNetworkSession* shared_session, | 1319 net::HttpNetworkSession* shared_session, |
1322 scoped_ptr<net::HttpCache::BackendFactory> backend) const { | 1320 scoped_ptr<net::HttpCache::BackendFactory> backend) const { |
1323 return make_scoped_ptr(new net::HttpCache( | 1321 return make_scoped_ptr(new net::HttpCache( |
1324 make_scoped_ptr(new DevToolsNetworkTransactionFactory( | 1322 make_scoped_ptr(new DevToolsNetworkTransactionFactory( |
1325 network_controller_handle_.GetController(), shared_session)), | 1323 network_controller_handle_.GetController(), shared_session)), |
1326 backend.Pass(), true /* set_up_quic_server_info */)); | 1324 std::move(backend), true /* set_up_quic_server_info */)); |
1327 } | 1325 } |
1328 | 1326 |
1329 void ProfileIOData::SetCookieSettingsForTesting( | 1327 void ProfileIOData::SetCookieSettingsForTesting( |
1330 content_settings::CookieSettings* cookie_settings) { | 1328 content_settings::CookieSettings* cookie_settings) { |
1331 DCHECK(!cookie_settings_.get()); | 1329 DCHECK(!cookie_settings_.get()); |
1332 cookie_settings_ = cookie_settings; | 1330 cookie_settings_ = cookie_settings; |
1333 } | 1331 } |
OLD | NEW |