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

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

Issue 2186893002: Reduce size of generated extension FeatureProviders. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
« no previous file with comments | « extensions/common/features/feature.cc ('k') | extensions/common/features/simple_feature.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 feature.get())) { 102 feature.get())) {
103 parse_error = true; 103 parse_error = true;
104 break; 104 break;
105 } 105 }
106 parse_stack.pop(); 106 parse_stack.pop();
107 } 107 }
108 108
109 if (parse_error) 109 if (parse_error)
110 continue; 110 continue;
111 111
112 features_[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::unique_ptr<ComplexFeature::FeatureList> features(
120 new ComplexFeature::FeatureList()); 120 new ComplexFeature::FeatureList());
121 121
122 // Parse and add all SimpleFeatures from the list. 122 // Parse and add all SimpleFeatures from the list.
123 for (const auto& entry : *list) { 123 for (const auto& entry : *list) {
124 base::DictionaryValue* dict; 124 base::DictionaryValue* dict;
125 if (!entry->GetAsDictionary(&dict)) { 125 if (!entry->GetAsDictionary(&dict)) {
126 LOG(ERROR) << iter.key() << ": Feature rules must be dictionaries."; 126 LOG(ERROR) << iter.key() << ": Feature rules must be dictionaries.";
127 continue; 127 continue;
128 } 128 }
129 129
130 std::unique_ptr<SimpleFeature> feature((*factory_)()); 130 std::unique_ptr<SimpleFeature> feature((*factory_)());
131 if (!ParseFeature(dict, iter.key(), feature.get())) 131 if (!ParseFeature(dict, iter.key(), feature.get()))
132 continue; 132 continue;
133 133
134 features->push_back(std::move(feature)); 134 features->push_back(std::move(feature));
135 } 135 }
136 136
137 std::unique_ptr<ComplexFeature> feature( 137 std::unique_ptr<ComplexFeature> feature(
138 new ComplexFeature(std::move(features))); 138 new ComplexFeature(std::move(features)));
139 feature->set_name(iter.key()); 139 feature->set_name(iter.key());
140 140
141 features_[iter.key()] = std::move(feature); 141 AddFeature(iter.key(), std::move(feature));
142 } else { 142 } else {
143 LOG(ERROR) << iter.key() << ": Feature description must be dictionary or" 143 LOG(ERROR) << iter.key() << ": Feature description must be dictionary or"
144 << " list of dictionaries."; 144 << " list of dictionaries.";
145 } 145 }
146 } 146 }
147 } 147 }
148 148
149 JSONFeatureProvider::~JSONFeatureProvider() {} 149 JSONFeatureProvider::~JSONFeatureProvider() {}
150 150
151 } // namespace extensions 151 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/features/feature.cc ('k') | extensions/common/features/simple_feature.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698