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

Unified Diff: components/prefs/json_pref_store.cc

Issue 2204943002: Integrate registry_hash_store_contents with the rest of tracked prefs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplify has_pending_write_reply/callback booleans and logic Created 4 years, 2 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 | « components/prefs/json_pref_store.h ('k') | components/user_prefs/tracked/dictionary_hash_store_contents.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/prefs/json_pref_store.cc
diff --git a/components/prefs/json_pref_store.cc b/components/prefs/json_pref_store.cc
index e91a4063f7bf4307486017741afe8b666a27c25d..b0ccf6be166451520d7fb1e72205e05bc93b556d 100644
--- a/components/prefs/json_pref_store.cc
+++ b/components/prefs/json_pref_store.cc
@@ -172,8 +172,7 @@ JsonPrefStore::JsonPrefStore(
filtering_in_progress_(false),
pending_lossy_write_(false),
read_error_(PREF_READ_ERROR_NONE),
- has_pending_successful_write_reply_(false),
- has_pending_write_callbacks_(false),
+ has_pending_write_reply_(false),
write_count_histogram_(writer_.commit_interval(), path_) {
DCHECK(!path_.empty());
}
@@ -330,13 +329,14 @@ void JsonPrefStore::RunOrScheduleNextSuccessfulWriteCallback(
bool write_success) {
DCHECK(CalledOnValidThread());
- has_pending_write_callbacks_ = false;
- if (has_pending_successful_write_reply_) {
- has_pending_successful_write_reply_ = false;
+ has_pending_write_reply_ = false;
+ if (!on_next_successful_write_reply_.is_null()) {
+ base::Closure on_successful_write = on_next_successful_write_reply_;
proberge 2016/10/04 20:17:58 is this fine? I need to clear on_next_successful_r
gab 2016/10/04 20:25:13 Yes except do: base::Closure on_successful_write
proberge 2016/10/04 20:40:49 Done.
+ on_next_successful_write_reply_ = base::Closure();
gab 2016/10/04 20:25:40 And of course the move makes this line not be requ
proberge 2016/10/04 20:40:49 Done.
if (write_success) {
- on_next_successful_write_reply_.Run();
+ on_successful_write.Run();
} else {
- RegisterOnNextSuccessfulWriteReply(on_next_successful_write_reply_);
+ RegisterOnNextSuccessfulWriteReply(on_successful_write);
}
}
}
@@ -359,15 +359,15 @@ void JsonPrefStore::PostWriteCallback(
void JsonPrefStore::RegisterOnNextSuccessfulWriteReply(
const base::Closure& on_next_successful_write_reply) {
DCHECK(CalledOnValidThread());
- DCHECK(!has_pending_successful_write_reply_);
+ DCHECK(on_next_successful_write_reply_.is_null());
- has_pending_successful_write_reply_ = true;
on_next_successful_write_reply_ = on_next_successful_write_reply;
// If there are pending callbacks, avoid erasing them; the reply will be used
// as we set |on_next_successful_write_reply_|. Otherwise, setup a reply with
// an empty callback.
- if (!has_pending_write_callbacks_) {
+ if (!has_pending_write_reply_) {
+ has_pending_write_reply_ = true;
writer_.RegisterOnNextWriteCallbacks(
base::Closure(),
base::Bind(
@@ -382,9 +382,8 @@ void JsonPrefStore::RegisterOnNextSuccessfulWriteReply(
void JsonPrefStore::RegisterOnNextWriteSynchronousCallbacks(
OnWriteCallbackPair callbacks) {
DCHECK(CalledOnValidThread());
- DCHECK(!has_pending_write_callbacks_);
- has_pending_write_callbacks_ = true;
+ has_pending_write_reply_ = true;
writer_.RegisterOnNextWriteCallbacks(
callbacks.first,
« no previous file with comments | « components/prefs/json_pref_store.h ('k') | components/user_prefs/tracked/dictionary_hash_store_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698