summaryrefslogtreecommitdiffstats
path: root/base/values.cc
diff options
context:
space:
mode:
authorpneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-18 14:43:27 +0000
committerpneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-18 14:43:27 +0000
commita899c0b0e1020347c5fc4bfc9c6d83cf13e8bd4a (patch)
treeadf4d31e271ad9f54b6faf11be37acab769101c2 /base/values.cc
parentc622538f6219a0d9d10878a25e447081b3b3c72c (diff)
downloadchromium_src-a899c0b0e1020347c5fc4bfc9c6d83cf13e8bd4a.zip
chromium_src-a899c0b0e1020347c5fc4bfc9c6d83cf13e8bd4a.tar.gz
chromium_src-a899c0b0e1020347c5fc4bfc9c6d83cf13e8bd4a.tar.bz2
Replaced DictionaryValue::key_iterator by DictionaryValue::Iterator outside of chrome/browser.
Marked Iterator::HasNext() as deprecated and added a method Iterator::CanAdvance() as replacement. As DictionaryValue::Iterator is actually a const iterator, I had to add several missing const annotations, mostly, in json_schema_validator.* and command.* BUG=162611 TEST=No new tests. Only semantically equivalent refactorings. Review URL: https://chromiumcodereview.appspot.com/11418150 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177673 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/values.cc')
-rw-r--r--base/values.cc16
1 files changed, 6 insertions, 10 deletions
diff --git a/base/values.cc b/base/values.cc
index 4c8968f..9228ca9 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -18,11 +18,11 @@ namespace {
// Make a deep copy of |node|, but don't include empty lists or dictionaries
// in the copy. It's possible for this function to return NULL and it
// expects |node| to always be non-NULL.
-Value* CopyWithoutEmptyChildren(Value* node) {
+Value* CopyWithoutEmptyChildren(const Value* node) {
DCHECK(node);
switch (node->GetType()) {
case Value::TYPE_LIST: {
- ListValue* list = static_cast<ListValue*>(node);
+ const ListValue* list = static_cast<const ListValue*>(node);
ListValue* copy = new ListValue;
for (ListValue::const_iterator it = list->begin(); it != list->end();
++it) {
@@ -38,16 +38,12 @@ Value* CopyWithoutEmptyChildren(Value* node) {
}
case Value::TYPE_DICTIONARY: {
- DictionaryValue* dict = static_cast<DictionaryValue*>(node);
+ const DictionaryValue* dict = static_cast<const DictionaryValue*>(node);
DictionaryValue* copy = new DictionaryValue;
- for (DictionaryValue::key_iterator it = dict->begin_keys();
- it != dict->end_keys(); ++it) {
- Value* child = NULL;
- bool rv = dict->GetWithoutPathExpansion(*it, &child);
- DCHECK(rv);
- Value* child_copy = CopyWithoutEmptyChildren(child);
+ for (DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) {
+ Value* child_copy = CopyWithoutEmptyChildren(&it.value());
if (child_copy)
- copy->SetWithoutPathExpansion(*it, child_copy);
+ copy->SetWithoutPathExpansion(it.key(), child_copy);
}
if (!copy->empty())
return copy;