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

Unified Diff: base/prefs/json_pref_store.cc

Issue 409223006: Weakly bind JsonPrefStore's async read task to avoid it coming back after shutdown has been initiat… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/prefs/json_pref_store.cc
diff --git a/base/prefs/json_pref_store.cc b/base/prefs/json_pref_store.cc
index f615933f8f5c385c181b937af88d617535ee00e0..5275ce101f3497a6aa1c65d6e2b996d98e3ff919 100644
--- a/base/prefs/json_pref_store.cc
+++ b/base/prefs/json_pref_store.cc
@@ -280,11 +280,12 @@ void JsonPrefStore::ReadPrefsAsync(ReadErrorDelegate* error_delegate) {
return;
}
+ // Weakly binds the read task so that it doesn't kick in during shutdown.
base::PostTaskAndReplyWithResult(
sequenced_task_runner_,
FROM_HERE,
base::Bind(&ReadPrefsFromDisk, path_, alternate_path_),
- base::Bind(&JsonPrefStore::OnFileRead, this));
+ base::Bind(&JsonPrefStore::OnFileRead, AsWeakPtr()));
}
void JsonPrefStore::CommitPendingWrite() {
@@ -366,7 +367,8 @@ void JsonPrefStore::OnFileRead(scoped_ptr<ReadResult> read_result) {
filtering_in_progress_ = true;
const PrefFilter::PostFilterOnLoadCallback post_filter_on_load_callback(
base::Bind(
- &JsonPrefStore::FinalizeFileRead, this, initialization_successful));
+ &JsonPrefStore::FinalizeFileRead, AsWeakPtr(),
+ initialization_successful));
pref_filter_->FilterOnLoad(post_filter_on_load_callback,
unfiltered_prefs.Pass());
} else {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698