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_impl_io_data.h" | 5 #include "chrome/browser/profiles/profile_impl_io_data.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 164 |
165 lazy_params->cookie_path = cookie_path; | 165 lazy_params->cookie_path = cookie_path; |
166 lazy_params->channel_id_path = channel_id_path; | 166 lazy_params->channel_id_path = channel_id_path; |
167 lazy_params->cache_path = cache_path; | 167 lazy_params->cache_path = cache_path; |
168 lazy_params->cache_max_size = cache_max_size; | 168 lazy_params->cache_max_size = cache_max_size; |
169 lazy_params->media_cache_path = media_cache_path; | 169 lazy_params->media_cache_path = media_cache_path; |
170 lazy_params->media_cache_max_size = media_cache_max_size; | 170 lazy_params->media_cache_max_size = media_cache_max_size; |
171 lazy_params->extensions_cookie_path = extensions_cookie_path; | 171 lazy_params->extensions_cookie_path = extensions_cookie_path; |
172 lazy_params->session_cookie_mode = session_cookie_mode; | 172 lazy_params->session_cookie_mode = session_cookie_mode; |
173 lazy_params->special_storage_policy = special_storage_policy; | 173 lazy_params->special_storage_policy = special_storage_policy; |
| 174 lazy_params->domain_reliability_monitor = |
| 175 std::move(domain_reliability_monitor); |
174 | 176 |
175 PrefService* pref_service = profile_->GetPrefs(); | 177 PrefService* pref_service = profile_->GetPrefs(); |
176 lazy_params->http_server_properties_manager.reset( | 178 lazy_params->http_server_properties_manager.reset( |
177 chrome_browser_net::HttpServerPropertiesManagerFactory::CreateManager( | 179 chrome_browser_net::HttpServerPropertiesManagerFactory::CreateManager( |
178 pref_service)); | 180 pref_service)); |
179 io_data_->http_server_properties_manager_ = | 181 io_data_->http_server_properties_manager_ = |
180 lazy_params->http_server_properties_manager.get(); | 182 lazy_params->http_server_properties_manager.get(); |
181 | 183 |
182 io_data_->lazy_params_.reset(lazy_params); | 184 io_data_->lazy_params_.reset(lazy_params); |
183 | 185 |
184 // Keep track of profile path and cache sizes separately so we can use them | 186 // Keep track of profile path and cache sizes separately so we can use them |
185 // on demand when creating storage isolated URLRequestContextGetters. | 187 // on demand when creating storage isolated URLRequestContextGetters. |
186 io_data_->profile_path_ = profile_path; | 188 io_data_->profile_path_ = profile_path; |
187 io_data_->app_cache_max_size_ = cache_max_size; | 189 io_data_->app_cache_max_size_ = cache_max_size; |
188 io_data_->app_media_cache_max_size_ = media_cache_max_size; | 190 io_data_->app_media_cache_max_size_ = media_cache_max_size; |
189 | 191 |
190 io_data_->predictor_.reset(predictor); | 192 io_data_->predictor_.reset(predictor); |
191 io_data_->domain_reliability_monitor_ = std::move(domain_reliability_monitor); | |
192 | 193 |
193 io_data_->InitializeMetricsEnabledStateOnUIThread(); | 194 io_data_->InitializeMetricsEnabledStateOnUIThread(); |
194 if (io_data_->domain_reliability_monitor_) | 195 if (io_data_->lazy_params_->domain_reliability_monitor) |
195 io_data_->domain_reliability_monitor_->MoveToNetworkThread(); | 196 io_data_->lazy_params_->domain_reliability_monitor->MoveToNetworkThread(); |
196 | 197 |
197 io_data_->previews_io_data_ = base::MakeUnique<previews::PreviewsIOData>( | 198 io_data_->previews_io_data_ = base::MakeUnique<previews::PreviewsIOData>( |
198 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), | 199 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), |
199 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); | 200 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); |
200 PreviewsServiceFactory::GetForProfile(profile_)->Initialize( | 201 PreviewsServiceFactory::GetForProfile(profile_)->Initialize( |
201 io_data_->previews_io_data_.get(), | 202 io_data_->previews_io_data_.get(), |
202 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), profile_path); | 203 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), profile_path); |
203 | 204 |
204 io_data_->set_data_reduction_proxy_io_data( | 205 io_data_->set_data_reduction_proxy_io_data( |
205 CreateDataReductionProxyChromeIOData( | 206 CreateDataReductionProxyChromeIOData( |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 : cache_max_size(0), | 420 : cache_max_size(0), |
420 media_cache_max_size(0), | 421 media_cache_max_size(0), |
421 session_cookie_mode( | 422 session_cookie_mode( |
422 content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES) {} | 423 content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES) {} |
423 | 424 |
424 ProfileImplIOData::LazyParams::~LazyParams() {} | 425 ProfileImplIOData::LazyParams::~LazyParams() {} |
425 | 426 |
426 ProfileImplIOData::ProfileImplIOData() | 427 ProfileImplIOData::ProfileImplIOData() |
427 : ProfileIOData(Profile::REGULAR_PROFILE), | 428 : ProfileIOData(Profile::REGULAR_PROFILE), |
428 http_server_properties_manager_(NULL), | 429 http_server_properties_manager_(NULL), |
| 430 domain_reliability_monitor_(nullptr), |
429 app_cache_max_size_(0), | 431 app_cache_max_size_(0), |
430 app_media_cache_max_size_(0) { | 432 app_media_cache_max_size_(0) { |
431 } | 433 } |
432 | 434 |
433 ProfileImplIOData::~ProfileImplIOData() { | 435 ProfileImplIOData::~ProfileImplIOData() { |
| 436 if (domain_reliability_monitor_) |
| 437 domain_reliability_monitor_->Shutdown(); |
| 438 |
434 DestroyResourceContext(); | 439 DestroyResourceContext(); |
435 | 440 |
436 if (media_request_context_) | 441 if (media_request_context_) |
437 media_request_context_->AssertNoURLRequests(); | 442 media_request_context_->AssertNoURLRequests(); |
438 } | 443 } |
439 | 444 |
440 void ProfileImplIOData::InitializeInternal( | 445 void ProfileImplIOData::InitializeInternal( |
441 std::unique_ptr<ChromeNetworkDelegate> chrome_network_delegate, | 446 std::unique_ptr<ChromeNetworkDelegate> chrome_network_delegate, |
442 ProfileParams* profile_params, | 447 ProfileParams* profile_params, |
443 content::ProtocolHandlerMap* protocol_handlers, | 448 content::ProtocolHandlerMap* protocol_handlers, |
444 content::URLRequestInterceptorScopedVector request_interceptors) const { | 449 content::URLRequestInterceptorScopedVector request_interceptors) const { |
445 // Set up a persistent store for use by the network stack on the IO thread. | 450 // Set up a persistent store for use by the network stack on the IO thread. |
446 base::FilePath network_json_store_filepath( | 451 base::FilePath network_json_store_filepath( |
447 profile_path_.Append(chrome::kNetworkPersistentStateFilename)); | 452 profile_path_.Append(chrome::kNetworkPersistentStateFilename)); |
448 network_json_store_ = new JsonPrefStore( | 453 network_json_store_ = new JsonPrefStore( |
449 network_json_store_filepath, | 454 network_json_store_filepath, |
450 JsonPrefStore::GetTaskRunnerForFile(network_json_store_filepath, | 455 JsonPrefStore::GetTaskRunnerForFile(network_json_store_filepath, |
451 BrowserThread::GetBlockingPool()), | 456 BrowserThread::GetBlockingPool()), |
452 std::unique_ptr<PrefFilter>()); | 457 std::unique_ptr<PrefFilter>()); |
453 network_json_store_->ReadPrefsAsync(nullptr); | 458 network_json_store_->ReadPrefsAsync(nullptr); |
454 | 459 |
455 net::URLRequestContext* main_context = main_request_context(); | 460 net::URLRequestContext* main_context = main_request_context(); |
456 net::URLRequestContextStorage* main_context_storage = | 461 net::URLRequestContextStorage* main_context_storage = |
457 main_request_context_storage(); | 462 main_request_context_storage(); |
458 | 463 |
459 IOThread* const io_thread = profile_params->io_thread; | 464 IOThread* const io_thread = profile_params->io_thread; |
460 IOThread::Globals* const io_thread_globals = io_thread->globals(); | 465 IOThread::Globals* const io_thread_globals = io_thread->globals(); |
461 | 466 |
462 if (domain_reliability_monitor_) { | 467 if (lazy_params_->domain_reliability_monitor) { |
463 domain_reliability::DomainReliabilityMonitor* monitor = | 468 // Hold on to a raw pointer to call Shutdown() in ~ProfileImplIOData. |
464 domain_reliability_monitor_.get(); | 469 domain_reliability_monitor_ = |
465 monitor->InitURLRequestContext(main_context); | 470 lazy_params_->domain_reliability_monitor.get(); |
466 monitor->AddBakedInConfigs(); | 471 |
467 monitor->SetDiscardUploads(!GetMetricsEnabledStateOnIOThread()); | 472 domain_reliability_monitor_->InitURLRequestContext(main_context); |
468 chrome_network_delegate->set_domain_reliability_monitor(monitor); | 473 domain_reliability_monitor_->AddBakedInConfigs(); |
| 474 domain_reliability_monitor_->SetDiscardUploads( |
| 475 !GetMetricsEnabledStateOnIOThread()); |
| 476 |
| 477 chrome_network_delegate->set_domain_reliability_monitor( |
| 478 std::move(lazy_params_->domain_reliability_monitor)); |
469 } | 479 } |
470 | 480 |
471 ApplyProfileParamsToContext(main_context); | 481 ApplyProfileParamsToContext(main_context); |
472 | 482 |
473 if (lazy_params_->http_server_properties_manager) { | 483 if (lazy_params_->http_server_properties_manager) { |
474 lazy_params_->http_server_properties_manager->InitializeOnNetworkThread(); | 484 lazy_params_->http_server_properties_manager->InitializeOnNetworkThread(); |
475 main_context_storage->set_http_server_properties( | 485 main_context_storage->set_http_server_properties( |
476 std::move(lazy_params_->http_server_properties_manager)); | 486 std::move(lazy_params_->http_server_properties_manager)); |
477 } | 487 } |
478 | 488 |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 const base::Closure& completion) { | 815 const base::Closure& completion) { |
806 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 816 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
807 DCHECK(initialized()); | 817 DCHECK(initialized()); |
808 | 818 |
809 DCHECK(transport_security_state()); | 819 DCHECK(transport_security_state()); |
810 // Completes synchronously. | 820 // Completes synchronously. |
811 transport_security_state()->DeleteAllDynamicDataSince(time); | 821 transport_security_state()->DeleteAllDynamicDataSince(time); |
812 DCHECK(http_server_properties_manager_); | 822 DCHECK(http_server_properties_manager_); |
813 http_server_properties_manager_->Clear(completion); | 823 http_server_properties_manager_->Clear(completion); |
814 } | 824 } |
OLD | NEW |