summaryrefslogtreecommitdiffstats
path: root/chrome/common/pref_service.cc
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-29 19:59:08 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-29 19:59:08 +0000
commitb4cebf87816cde49f6d4991ffa254e5ead97703b (patch)
treefb12e4b464a43af846f30bbd0dbe9484150373b0 /chrome/common/pref_service.cc
parent45ce59f19161b517c04a4e3bcd0890b938382b06 (diff)
downloadchromium_src-b4cebf87816cde49f6d4991ffa254e5ead97703b.zip
chromium_src-b4cebf87816cde49f6d4991ffa254e5ead97703b.tar.gz
chromium_src-b4cebf87816cde49f6d4991ffa254e5ead97703b.tar.bz2
Change the signature of JSONReader::Read() and related
methods to be more friendly to use with scoped_ptr. Change all the callsites. Review URL: http://codereview.chromium.org/16270 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7486 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/pref_service.cc')
-rw-r--r--chrome/common/pref_service.cc42
1 files changed, 19 insertions, 23 deletions
diff --git a/chrome/common/pref_service.cc b/chrome/common/pref_service.cc
index 8f3322a..870e79e 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();
}
}