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

Unified Diff: chrome/common/json_pref_store.cc

Issue 7714038: Reverts debugging code added in hopes of tracking crash. This also (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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 | « chrome/common/json_pref_store.h ('k') | chrome/common/persistent_pref_store.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/json_pref_store.cc
diff --git a/chrome/common/json_pref_store.cc b/chrome/common/json_pref_store.cc
index 8767fc56f321ca27a1d72c957afda860e092f90f..f3bd776dce11acb11d5dda4a116f3ce9ae683929 100644
--- a/chrome/common/json_pref_store.cc
+++ b/chrome/common/json_pref_store.cc
@@ -148,7 +148,6 @@ JsonPrefStore::JsonPrefStore(const FilePath& filename,
}
JsonPrefStore::~JsonPrefStore() {
- ResetCheckIfValueDestroyed(prefs_.get());
CommitPendingWrite();
}
@@ -181,20 +180,29 @@ PrefStore::ReadResult JsonPrefStore::GetMutableValue(const std::string& key,
}
void JsonPrefStore::SetValue(const std::string& key, Value* value) {
- SetValueImpl(key, value, SET_VALUE_NOTIFY);
+ DCHECK(value);
+ scoped_ptr<Value> new_value(value);
+ Value* old_value = NULL;
+ prefs_->Get(key, &old_value);
+ if (!old_value || !value->Equals(old_value)) {
+ prefs_->Set(key, new_value.release());
+ FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key));
+ }
}
void JsonPrefStore::SetValueSilently(const std::string& key, Value* value) {
- SetValueImpl(key, value, SET_VALUE_DONT_NOTIFY);
+ DCHECK(value);
+ scoped_ptr<Value> new_value(value);
+ Value* old_value = NULL;
+ prefs_->Get(key, &old_value);
+ if (!old_value || !value->Equals(old_value))
+ prefs_->Set(key, new_value.release());
}
void JsonPrefStore::RemoveValue(const std::string& key) {
- Value* value = NULL;
- bool path_existed = prefs_->Remove(key, &value);
- scoped_ptr<Value> owned_value(value);
- ResetCheckIfValueDestroyed(value);
- if (path_existed)
+ if (prefs_->Remove(key, NULL)) {
FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key));
+ }
}
bool JsonPrefStore::ReadOnly() const {
@@ -224,7 +232,6 @@ void JsonPrefStore::OnFileRead(Value* value_owned,
break;
case PREF_READ_ERROR_NONE:
DCHECK(value.get());
- ResetCheckIfValueDestroyed(prefs_.get());
prefs_.reset(static_cast<DictionaryValue*>(value.release()));
break;
case PREF_READ_ERROR_NO_FILE:
@@ -303,13 +310,6 @@ void JsonPrefStore::ReportValueChanged(const std::string& key) {
FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key));
}
-void JsonPrefStore::CheckIfValueDestroyed(const std::string& key) {
- Value* value = NULL;
- CHECK_EQ(READ_OK, GetMutableValue(key, &value));
- CHECK(value);
- value->set_check_on_delete(true);
-}
-
bool JsonPrefStore::SerializeData(std::string* output) {
// TODO(tc): Do we want to prune webkit preferences that match the default
// value?
@@ -318,52 +318,3 @@ bool JsonPrefStore::SerializeData(std::string* output) {
scoped_ptr<DictionaryValue> copy(prefs_->DeepCopyWithoutEmptyChildren());
return serializer.Serialize(*(copy.get()));
}
-
-void JsonPrefStore::SetValueImpl(const std::string& key,
- Value* value,
- SetValueType type) {
- DCHECK(value);
- scoped_ptr<Value> new_value(value);
- Value* old_value = NULL;
- prefs_->Get(key, &old_value);
- ResetCheckIfValueDestroyed(old_value);
- if (!old_value || !value->Equals(old_value)) {
- prefs_->Set(key, new_value.release());
- if (type == SET_VALUE_NOTIFY)
- ReportValueChanged(key);
- }
-}
-
-// static
-void JsonPrefStore::ResetCheckIfValueDestroyed(Value* value) {
- if (!value)
- return;
-
- value->set_check_on_delete(false);
-
- switch (value->GetType()) {
- case Value::TYPE_DICTIONARY: {
- DictionaryValue* dictionary = static_cast<DictionaryValue*>(value);
- for (DictionaryValue::key_iterator i = dictionary->begin_keys();
- i != dictionary->end_keys(); ++i) {
- Value* child_value = NULL;
- dictionary->GetWithoutPathExpansion(*i, &child_value);
- ResetCheckIfValueDestroyed(child_value);
- }
- break;
- }
-
- case Value::TYPE_LIST: {
- ListValue* list = static_cast<ListValue*>(value);
- for (size_t i = 0; i < list->GetSize(); ++i) {
- Value* child_value = NULL;
- list->Get(i, &child_value);
- ResetCheckIfValueDestroyed(child_value);
- }
- break;
- }
-
- default:
- break;
- }
-}
« no previous file with comments | « chrome/common/json_pref_store.h ('k') | chrome/common/persistent_pref_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698