| Index: chrome/common/pref_service.cc
|
| diff --git a/chrome/common/pref_service.cc b/chrome/common/pref_service.cc
|
| index 8f3322a00986e0bf5e2952a7f376a6c4de7c71c9..870e79e0b111fb9eaf12b6f7c501e99e3e34bc3b 100644
|
| --- a/chrome/common/pref_service.cc
|
| +++ b/chrome/common/pref_service.cc
|
| @@ -136,38 +136,34 @@ bool PrefService::LoadPersistentPrefs(const std::wstring& file_path) {
|
| DCHECK(CalledOnValidThread());
|
|
|
| JSONFileValueSerializer serializer(file_path);
|
| - Value* root = NULL;
|
| - if (serializer.Deserialize(&root, NULL)) {
|
| - // Preferences should always have a dictionary root.
|
| - if (!root->IsType(Value::TYPE_DICTIONARY)) {
|
| - delete root;
|
| - return false;
|
| - }
|
| + scoped_ptr<Value> root(serializer.Deserialize(NULL));
|
| + if (!root.get())
|
| + return false;
|
|
|
| - persistent_.reset(static_cast<DictionaryValue*>(root));
|
| - return true;
|
| - }
|
| + // Preferences should always have a dictionary root.
|
| + if (!root->IsType(Value::TYPE_DICTIONARY))
|
| + return false;
|
|
|
| - return false;
|
| + persistent_.reset(static_cast<DictionaryValue*>(root.release()));
|
| + return true;
|
| }
|
|
|
| void PrefService::ReloadPersistentPrefs() {
|
| DCHECK(CalledOnValidThread());
|
|
|
| JSONFileValueSerializer serializer(pref_filename_);
|
| - Value* root;
|
| - if (serializer.Deserialize(&root, NULL)) {
|
| - // Preferences should always have a dictionary root.
|
| - if (!root->IsType(Value::TYPE_DICTIONARY)) {
|
| - delete root;
|
| - return;
|
| - }
|
| + scoped_ptr<Value> root(serializer.Deserialize(NULL));
|
| + if (!root.get())
|
| + return;
|
|
|
| - persistent_.reset(static_cast<DictionaryValue*>(root));
|
| - for (PreferenceSet::iterator it = prefs_.begin();
|
| - it != prefs_.end(); ++it) {
|
| - (*it)->root_pref_ = persistent_.get();
|
| - }
|
| + // Preferences should always have a dictionary root.
|
| + if (!root->IsType(Value::TYPE_DICTIONARY))
|
| + return;
|
| +
|
| + persistent_.reset(static_cast<DictionaryValue*>(root.release()));
|
| + for (PreferenceSet::iterator it = prefs_.begin();
|
| + it != prefs_.end(); ++it) {
|
| + (*it)->root_pref_ = persistent_.get();
|
| }
|
| }
|
|
|
|
|