Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1639)

Unified Diff: chrome/browser/profiles/profile_impl_io_data.cc

Issue 2336043007: Domain Reliability: Don't crash on shutdown with uploads pending (Closed)
Patch Set: No, really. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/profiles/profile_impl_io_data.cc
diff --git a/chrome/browser/profiles/profile_impl_io_data.cc b/chrome/browser/profiles/profile_impl_io_data.cc
index 87e8b891f3f9c6252b21302b33ba8d8a1b357873..5c2e39f263df46ba2243e2cc6369f9c0c19a2606 100644
--- a/chrome/browser/profiles/profile_impl_io_data.cc
+++ b/chrome/browser/profiles/profile_impl_io_data.cc
@@ -171,6 +171,8 @@ void ProfileImplIOData::Handle::Init(
lazy_params->extensions_cookie_path = extensions_cookie_path;
lazy_params->session_cookie_mode = session_cookie_mode;
lazy_params->special_storage_policy = special_storage_policy;
+ lazy_params->domain_reliability_monitor =
+ std::move(domain_reliability_monitor);
PrefService* pref_service = profile_->GetPrefs();
lazy_params->http_server_properties_manager.reset(
@@ -188,11 +190,10 @@ void ProfileImplIOData::Handle::Init(
io_data_->app_media_cache_max_size_ = media_cache_max_size;
io_data_->predictor_.reset(predictor);
- io_data_->domain_reliability_monitor_ = std::move(domain_reliability_monitor);
io_data_->InitializeMetricsEnabledStateOnUIThread();
- if (io_data_->domain_reliability_monitor_)
- io_data_->domain_reliability_monitor_->MoveToNetworkThread();
+ if (io_data_->lazy_params_->domain_reliability_monitor)
+ io_data_->lazy_params_->domain_reliability_monitor->MoveToNetworkThread();
io_data_->previews_io_data_ = base::MakeUnique<previews::PreviewsIOData>(
BrowserThread::GetTaskRunnerForThread(BrowserThread::UI),
@@ -426,11 +427,15 @@ ProfileImplIOData::LazyParams::~LazyParams() {}
ProfileImplIOData::ProfileImplIOData()
: ProfileIOData(Profile::REGULAR_PROFILE),
http_server_properties_manager_(NULL),
+ domain_reliability_monitor_(nullptr),
app_cache_max_size_(0),
app_media_cache_max_size_(0) {
}
ProfileImplIOData::~ProfileImplIOData() {
+ if (domain_reliability_monitor_)
+ domain_reliability_monitor_->Shutdown();
+
DestroyResourceContext();
if (media_request_context_)
@@ -459,13 +464,18 @@ void ProfileImplIOData::InitializeInternal(
IOThread* const io_thread = profile_params->io_thread;
IOThread::Globals* const io_thread_globals = io_thread->globals();
- if (domain_reliability_monitor_) {
- domain_reliability::DomainReliabilityMonitor* monitor =
- domain_reliability_monitor_.get();
+ if (lazy_params_->domain_reliability_monitor) {
+ std::unique_ptr<domain_reliability::DomainReliabilityMonitor> monitor =
+ std::move(lazy_params_->domain_reliability_monitor);
mmenke 2016/12/14 19:12:17 optional: Don't think you need this line / variabl
Julia Tuttle 2016/12/15 21:53:00 Done.
+
+ // Keep a raw pointer handy to call Shutdown() in the destructor.
+ domain_reliability_monitor_ = monitor.get();
+
monitor->InitURLRequestContext(main_context);
monitor->AddBakedInConfigs();
monitor->SetDiscardUploads(!GetMetricsEnabledStateOnIOThread());
- chrome_network_delegate->set_domain_reliability_monitor(monitor);
+ chrome_network_delegate->set_domain_reliability_monitor(
+ std::move(monitor));
}
ApplyProfileParamsToContext(main_context);

Powered by Google App Engine
This is Rietveld 408576698