| 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
|
|
|