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

Unified Diff: base/prefs/json_pref_store.cc

Issue 1136983004: Revert of Implement lossy pref behavior for JsonPrefStore. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@prefs-fix-flags
Patch Set: Created 5 years, 7 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 | « base/prefs/json_pref_store.h ('k') | base/prefs/json_pref_store_unittest.cc » ('j') | 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 40e3052836588dff6b22089ddb278be7f64d89af..8ce59745536d02fe4af6279a3d85312966a34937 100644
--- a/base/prefs/json_pref_store.cc
+++ b/base/prefs/json_pref_store.cc
@@ -158,7 +158,6 @@
pref_filter_(pref_filter.Pass()),
initialized_(false),
filtering_in_progress_(false),
- pending_lossy_write_(false),
read_error_(PREF_READ_ERROR_NONE),
write_count_histogram_(writer_.commit_interval(), path_) {
DCHECK(!path_.empty());
@@ -253,7 +252,8 @@
prefs_->Get(key, &old_value);
if (!old_value || !value->Equals(old_value)) {
prefs_->Set(key, new_value.release());
- ScheduleWrite(flags);
+ if (!read_only_)
+ writer_.ScheduleWrite(this);
}
}
@@ -268,7 +268,8 @@
DCHECK(CalledOnValidThread());
prefs_->RemovePath(key, NULL);
- ScheduleWrite(flags);
+ if (!read_only_)
+ writer_.ScheduleWrite(this);
}
bool JsonPrefStore::ReadOnly() const {
@@ -308,11 +309,6 @@
void JsonPrefStore::CommitPendingWrite() {
DCHECK(CalledOnValidThread());
- // Schedule a write for any lossy writes that are outstanding to ensure that
- // they get flushed when this function is called.
- if (pending_lossy_write_)
- writer_.ScheduleWrite(this);
-
if (writer_.HasPendingWrite() && !read_only_)
writer_.DoScheduledWrite();
}
@@ -325,7 +321,8 @@
FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key));
- ScheduleWrite(flags);
+ if (!read_only_)
+ writer_.ScheduleWrite(this);
}
void JsonPrefStore::RegisterOnNextSuccessfulWriteCallback(
@@ -404,8 +401,6 @@
bool JsonPrefStore::SerializeData(std::string* output) {
DCHECK(CalledOnValidThread());
- pending_lossy_write_ = false;
-
write_count_histogram_.RecordWriteOccured();
if (pref_filter_)
@@ -437,8 +432,8 @@
initialized_ = true;
- if (schedule_write)
- ScheduleWrite(DEFAULT_PREF_WRITE_FLAGS);
+ if (schedule_write && !read_only_)
+ writer_.ScheduleWrite(this);
if (error_delegate_ && read_error_ != PREF_READ_ERROR_NONE)
error_delegate_->OnError(read_error_);
@@ -448,16 +443,6 @@
OnInitializationCompleted(true));
return;
-}
-
-void JsonPrefStore::ScheduleWrite(uint32 flags) {
- if (read_only_)
- return;
-
- if (flags & LOSSY_PREF_WRITE_FLAG)
- pending_lossy_write_ = true;
- else
- writer_.ScheduleWrite(this);
}
// NOTE: This value should NOT be changed without renaming the histogram
« no previous file with comments | « base/prefs/json_pref_store.h ('k') | base/prefs/json_pref_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698