summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-24 21:17:59 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-24 21:17:59 +0000
commit9b5f56b43a17fbee9f595a42f4733b4ccb1b7095 (patch)
treed3e5067ecf4173cc49909bdd16e0eab354f2c918 /chrome/common
parentdb3fecb2745b58baaa1fec2f170453e75746fc20 (diff)
downloadchromium_src-9b5f56b43a17fbee9f595a42f4733b4ccb1b7095.zip
chromium_src-9b5f56b43a17fbee9f595a42f4733b4ccb1b7095.tar.gz
chromium_src-9b5f56b43a17fbee9f595a42f4733b4ccb1b7095.tar.bz2
Reverts debugging code added in hopes of tracking crash. This also
reverts 97997 as it was only needed with this debugging code. I'm TBRing this as it's just a revert (well, two reverts). BUG=91396 TEST=none R=brettw@chromium.org,mnissler@chromium.org,ben@chromium.org TBR=brettw@chromium.org,mnissler@chromium.org,ben@chromium.org Review URL: http://codereview.chromium.org/7714038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98115 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/json_pref_store.cc81
-rw-r--r--chrome/common/json_pref_store.h39
-rw-r--r--chrome/common/persistent_pref_store.h4
3 files changed, 27 insertions, 97 deletions
diff --git a/chrome/common/json_pref_store.cc b/chrome/common/json_pref_store.cc
index 8767fc5..f3bd776 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;
- }
-}
diff --git a/chrome/common/json_pref_store.h b/chrome/common/json_pref_store.h
index 3cbd352..b94030d 100644
--- a/chrome/common/json_pref_store.h
+++ b/chrome/common/json_pref_store.h
@@ -42,19 +42,17 @@ class JsonPrefStore : public PersistentPrefStore,
// PersistentPrefStore overrides:
virtual ReadResult GetMutableValue(const std::string& key,
- base::Value** result) OVERRIDE;
- virtual void SetValue(const std::string& key, base::Value* value) OVERRIDE;
- virtual void SetValueSilently(const std::string& key,
- base::Value* value) OVERRIDE;
- virtual void RemoveValue(const std::string& key) OVERRIDE;
- virtual bool ReadOnly() const OVERRIDE;
- virtual PrefReadError ReadPrefs() OVERRIDE;
- virtual void ReadPrefsAsync(ReadErrorDelegate* error_delegate) OVERRIDE;
- virtual bool WritePrefs() OVERRIDE;
- virtual void ScheduleWritePrefs() OVERRIDE;
- virtual void CommitPendingWrite() OVERRIDE;
- virtual void ReportValueChanged(const std::string& key) OVERRIDE;
- virtual void CheckIfValueDestroyed(const std::string& key) OVERRIDE;
+ base::Value** result);
+ virtual void SetValue(const std::string& key, base::Value* value);
+ virtual void SetValueSilently(const std::string& key, base::Value* value);
+ virtual void RemoveValue(const std::string& key);
+ virtual bool ReadOnly() const;
+ virtual PrefReadError ReadPrefs();
+ virtual void ReadPrefsAsync(ReadErrorDelegate* error_delegate);
+ virtual bool WritePrefs();
+ virtual void ScheduleWritePrefs();
+ virtual void CommitPendingWrite();
+ virtual void ReportValueChanged(const std::string& key);
// This method is called after JSON file has been read. Method takes
// ownership of the |value| pointer. Note, this method is used with
@@ -63,24 +61,9 @@ class JsonPrefStore : public PersistentPrefStore,
void OnFileRead(base::Value* value_owned, PrefReadError error, bool no_dir);
private:
- enum SetValueType {
- // Indicates observers should be notified of the change.
- SET_VALUE_NOTIFY,
-
- // Indicates observers should not be notified of the change.
- SET_VALUE_DONT_NOTIFY
- };
-
// ImportantFileWriter::DataSerializer overrides:
virtual bool SerializeData(std::string* output);
- // Implementation of SetValue.
- void SetValueImpl(const std::string& key,
- base::Value* value,
- SetValueType type);
-
- static void ResetCheckIfValueDestroyed(base::Value* value);
-
FilePath path_;
scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy_;
diff --git a/chrome/common/persistent_pref_store.h b/chrome/common/persistent_pref_store.h
index 5a6c71a..b209716 100644
--- a/chrome/common/persistent_pref_store.h
+++ b/chrome/common/persistent_pref_store.h
@@ -87,10 +87,6 @@ class PersistentPrefStore : public PrefStore {
// Lands any pending writes to disk.
virtual void CommitPendingWrite() = 0;
-
- // TODO(sky): remove this. It's used in tracking 91396.
- // Used for debugging. Crashes if the value at |key| is unexpected deleted.
- virtual void CheckIfValueDestroyed(const std::string& key) = 0;
};
#endif // CHROME_COMMON_PERSISTENT_PREF_STORE_H_