diff options
author | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-06 13:33:04 +0000 |
---|---|---|
committer | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-06 13:33:04 +0000 |
commit | d814a88597a01bf8249e36983f55a5f880154642 (patch) | |
tree | b38b92bb3f3dd40285f1a5d652f3c8c6609e4279 /base/values.cc | |
parent | bc00c1d1ae16e1cd82430320d89daaaaea5ded67 (diff) | |
download | chromium_src-d814a88597a01bf8249e36983f55a5f880154642.zip chromium_src-d814a88597a01bf8249e36983f55a5f880154642.tar.gz chromium_src-d814a88597a01bf8249e36983f55a5f880154642.tar.bz2 |
Make element removal methods in DictionaryValue and ListValue take scoped_ptr's as outparams.
TBR=pneubeck@chromium.org,scottbyer@chromium.org
BUG=263894
Review URL: https://chromiumcodereview.appspot.com/21030009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215885 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/values.cc')
-rw-r--r-- | base/values.cc | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/base/values.cc b/base/values.cc index 712fff39..adfb980 100644 --- a/base/values.cc +++ b/base/values.cc @@ -719,7 +719,8 @@ bool DictionaryValue::GetListWithoutPathExpansion(const std::string& key, const_cast<const ListValue**>(out_value)); } -bool DictionaryValue::Remove(const std::string& path, Value** out_value) { +bool DictionaryValue::Remove(const std::string& path, + scoped_ptr<Value>* out_value) { DCHECK(IsStringUTF8(path)); std::string current_path(path); DictionaryValue* current_dictionary = this; @@ -736,7 +737,7 @@ bool DictionaryValue::Remove(const std::string& path, Value** out_value) { } bool DictionaryValue::RemoveWithoutPathExpansion(const std::string& key, - Value** out_value) { + scoped_ptr<Value>* out_value) { DCHECK(IsStringUTF8(key)); ValueMap::iterator entry_iterator = dictionary_.find(key); if (entry_iterator == dictionary_.end()) @@ -744,7 +745,7 @@ bool DictionaryValue::RemoveWithoutPathExpansion(const std::string& key, Value* entry = entry_iterator->second; if (out_value) - *out_value = entry; + out_value->reset(entry); else delete entry; dictionary_.erase(entry_iterator); @@ -958,12 +959,12 @@ bool ListValue::GetList(size_t index, ListValue** out_value) { const_cast<const ListValue**>(out_value)); } -bool ListValue::Remove(size_t index, Value** out_value) { +bool ListValue::Remove(size_t index, scoped_ptr<Value>* out_value) { if (index >= list_.size()) return false; if (out_value) - *out_value = list_[index]; + out_value->reset(list_[index]); else delete list_[index]; @@ -986,9 +987,10 @@ bool ListValue::Remove(const Value& value, size_t* index) { return false; } -ListValue::iterator ListValue::Erase(iterator iter, Value** out_value) { +ListValue::iterator ListValue::Erase(iterator iter, + scoped_ptr<Value>* out_value) { if (out_value) - *out_value = *iter; + out_value->reset(*iter); else delete *iter; |