Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: extensions/common/features/base_feature_provider.cc

Issue 2000803003: Use std::unique_ptr for base::DictionaryValue and base::ListValue's internal store. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix various builds. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/common/features/base_feature_provider.h" 5 #include "extensions/common/features/base_feature_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <stack> 9 #include <stack>
10 #include <utility> 10 #include <utility>
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } else if (iter.value().GetType() == base::Value::TYPE_LIST) { 111 } else if (iter.value().GetType() == base::Value::TYPE_LIST) {
112 // This is a complex feature. 112 // This is a complex feature.
113 const base::ListValue* list = 113 const base::ListValue* list =
114 static_cast<const base::ListValue*>(&iter.value()); 114 static_cast<const base::ListValue*>(&iter.value());
115 CHECK_GT(list->GetSize(), 0UL); 115 CHECK_GT(list->GetSize(), 0UL);
116 116
117 std::unique_ptr<ComplexFeature::FeatureList> features( 117 std::unique_ptr<ComplexFeature::FeatureList> features(
118 new ComplexFeature::FeatureList()); 118 new ComplexFeature::FeatureList());
119 119
120 // Parse and add all SimpleFeatures from the list. 120 // Parse and add all SimpleFeatures from the list.
121 for (base::ListValue::const_iterator list_iter = list->begin(); 121 for (const auto& entry : *list) {
122 list_iter != list->end(); ++list_iter) { 122 base::DictionaryValue* dict;
123 if ((*list_iter)->GetType() != base::Value::TYPE_DICTIONARY) { 123 if (!entry->GetAsDictionary(&dict)) {
124 LOG(ERROR) << iter.key() << ": Feature rules must be dictionaries."; 124 LOG(ERROR) << iter.key() << ": Feature rules must be dictionaries.";
125 continue; 125 continue;
126 } 126 }
127 127
128 std::unique_ptr<SimpleFeature> feature((*factory_)()); 128 std::unique_ptr<SimpleFeature> feature((*factory_)());
129 if (!ParseFeature(static_cast<const base::DictionaryValue*>(*list_iter), 129 if (!ParseFeature(dict, iter.key(), feature.get()))
130 iter.key(),
131 feature.get()))
132 continue; 130 continue;
133 131
134 features->push_back(std::move(feature)); 132 features->push_back(std::move(feature));
135 } 133 }
136 134
137 std::unique_ptr<ComplexFeature> feature( 135 std::unique_ptr<ComplexFeature> feature(
138 new ComplexFeature(std::move(features))); 136 new ComplexFeature(std::move(features)));
139 feature->set_name(iter.key()); 137 feature->set_name(iter.key());
140 138
141 features_[iter.key()] = std::move(feature); 139 features_[iter.key()] = std::move(feature);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 std::vector<Feature*> result; 187 std::vector<Feature*> result;
190 result.reserve(std::distance(first_child, after_children)); 188 result.reserve(std::distance(first_child, after_children));
191 for (FeatureMap::const_iterator it = first_child; it != after_children; 189 for (FeatureMap::const_iterator it = first_child; it != after_children;
192 ++it) { 190 ++it) {
193 result.push_back(it->second.get()); 191 result.push_back(it->second.get());
194 } 192 }
195 return result; 193 return result;
196 } 194 }
197 195
198 } // namespace extensions 196 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698