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

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

Issue 2199683002: Reland of Further reduction of feature_compiler.py generated code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@test-with-leiz
Patch Set: Created 4 years, 4 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/json_feature_provider.h" 5 #include "extensions/common/features/json_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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 if (parse_error) 109 if (parse_error)
110 continue; 110 continue;
111 111
112 AddFeature(iter.key(), std::move(feature)); 112 AddFeature(iter.key(), std::move(feature));
113 } else if (iter.value().GetType() == base::Value::TYPE_LIST) { 113 } else if (iter.value().GetType() == base::Value::TYPE_LIST) {
114 // This is a complex feature. 114 // This is a complex feature.
115 const base::ListValue* list = 115 const base::ListValue* list =
116 static_cast<const base::ListValue*>(&iter.value()); 116 static_cast<const base::ListValue*>(&iter.value());
117 CHECK_GT(list->GetSize(), 0UL); 117 CHECK_GT(list->GetSize(), 0UL);
118 118
119 std::unique_ptr<ComplexFeature::FeatureList> features( 119 std::vector<Feature*> features;
120 new ComplexFeature::FeatureList());
121 120
122 // Parse and add all SimpleFeatures from the list. 121 // Parse and add all SimpleFeatures from the list.
123 for (const auto& entry : *list) { 122 for (const auto& entry : *list) {
124 base::DictionaryValue* dict; 123 base::DictionaryValue* dict;
125 if (!entry->GetAsDictionary(&dict)) { 124 if (!entry->GetAsDictionary(&dict)) {
126 LOG(ERROR) << iter.key() << ": Feature rules must be dictionaries."; 125 LOG(ERROR) << iter.key() << ": Feature rules must be dictionaries.";
127 continue; 126 continue;
128 } 127 }
129 128
130 std::unique_ptr<SimpleFeature> feature((*factory_)()); 129 std::unique_ptr<SimpleFeature> feature((*factory_)());
131 if (!ParseFeature(dict, iter.key(), feature.get())) 130 if (!ParseFeature(dict, iter.key(), feature.get()))
132 continue; 131 continue;
133 132
134 features->push_back(std::move(feature)); 133 features.push_back(feature.release());
135 } 134 }
136 135
137 std::unique_ptr<ComplexFeature> feature( 136 std::unique_ptr<ComplexFeature> feature(new ComplexFeature(&features));
138 new ComplexFeature(std::move(features)));
139 feature->set_name(iter.key()); 137 feature->set_name(iter.key());
140 138
141 AddFeature(iter.key(), std::move(feature)); 139 AddFeature(iter.key(), feature.release());
142 } else { 140 } else {
143 LOG(ERROR) << iter.key() << ": Feature description must be dictionary or" 141 LOG(ERROR) << iter.key() << ": Feature description must be dictionary or"
144 << " list of dictionaries."; 142 << " list of dictionaries.";
145 } 143 }
146 } 144 }
147 } 145 }
148 146
149 JSONFeatureProvider::~JSONFeatureProvider() {} 147 JSONFeatureProvider::~JSONFeatureProvider() {}
150 148
151 } // namespace extensions 149 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/features/complex_feature_unittest.cc ('k') | extensions/common/features/simple_feature_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698