diff options
author | acolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-07 21:09:09 +0000 |
---|---|---|
committer | acolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-07 21:09:09 +0000 |
commit | cad3e6430684e3831575855e8af5fde28c120699 (patch) | |
tree | 3213301e092b999ba2aa3022537f4d06bc9ea401 | |
parent | 1709e5f8404719876fef918d9e48c2ce6de0e4a0 (diff) | |
download | chromium_src-cad3e6430684e3831575855e8af5fde28c120699.zip chromium_src-cad3e6430684e3831575855e8af5fde28c120699.tar.gz chromium_src-cad3e6430684e3831575855e8af5fde28c120699.tar.bz2 |
Revert 104510 - Automatically schedule saving preferences on change.
We suspect this change is breaking ChromeOS.
BUG=99459
TEST=none
Review URL: http://codereview.chromium.org/8200003
TBR=bauerb@chromium.org
Review URL: http://codereview.chromium.org/8199023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104560 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/common/json_pref_store.cc | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/chrome/common/json_pref_store.cc b/chrome/common/json_pref_store.cc index ac4a780..83c8187 100644 --- a/chrome/common/json_pref_store.cc +++ b/chrome/common/json_pref_store.cc @@ -186,7 +186,7 @@ void JsonPrefStore::SetValue(const std::string& key, Value* value) { prefs_->Get(key, &old_value); if (!old_value || !value->Equals(old_value)) { prefs_->Set(key, new_value.release()); - ReportValueChanged(key); + FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key)); } } @@ -195,16 +195,14 @@ void JsonPrefStore::SetValueSilently(const std::string& key, Value* value) { scoped_ptr<Value> new_value(value); Value* old_value = NULL; prefs_->Get(key, &old_value); - if (!old_value || !value->Equals(old_value)) { + if (!old_value || !value->Equals(old_value)) prefs_->Set(key, new_value.release()); - if (!read_only_) - writer_.ScheduleWrite(this); - } } void JsonPrefStore::RemoveValue(const std::string& key) { - if (prefs_->Remove(key, NULL)) - ReportValueChanged(key); + if (prefs_->Remove(key, NULL)) { + FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key)); + } } bool JsonPrefStore::ReadOnly() const { @@ -288,19 +286,19 @@ bool JsonPrefStore::WritePrefs() { if (!SerializeData(&data)) return false; - // Don't actually write prefs if we're read-only or don't have any pending - // writes. - // TODO(bauerb): Make callers of this method call CommitPendingWrite directly. - if (writer_.HasPendingWrite() && !read_only_) - writer_.WriteNow(data); + // Lie about our ability to save. + if (read_only_) + return true; + writer_.WriteNow(data); return true; } void JsonPrefStore::ScheduleWritePrefs() { - // Writing prefs should be scheduled automatically, so this is a no-op - // for now. - // TODO(bauerb): Remove calls to this method. + if (read_only_) + return; + + writer_.ScheduleWrite(this); } void JsonPrefStore::CommitPendingWrite() { @@ -310,8 +308,6 @@ void JsonPrefStore::CommitPendingWrite() { void JsonPrefStore::ReportValueChanged(const std::string& key) { FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key)); - if (!read_only_) - writer_.ScheduleWrite(this); } bool JsonPrefStore::SerializeData(std::string* output) { |