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

Side by Side Diff: chromeos/network/onc/onc_translator_onc_to_shill.cc

Issue 11414101: This adds ManagedNetworkConfigurationHandler first pass (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: upload after merge Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // The implementation of TranslateONCObjectToShill is structured in two parts: 5 // The implementation of TranslateONCObjectToShill is structured in two parts:
6 // - The recursion through the existing ONC hierarchy 6 // - The recursion through the existing ONC hierarchy
7 // see TranslateONCHierarchy 7 // see TranslateONCHierarchy
8 // - The local translation of an object depending on the associated signature 8 // - The local translation of an object depending on the associated signature
9 // see LocalTranslator::TranslateFields 9 // see LocalTranslator::TranslateFields
10 10
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 make_scoped_ptr(it.value().DeepCopy())); 183 make_scoped_ptr(it.value().DeepCopy()));
184 } 184 }
185 } 185 }
186 186
187 void LocalTranslator::AddValueAccordingToSignature( 187 void LocalTranslator::AddValueAccordingToSignature(
188 const std::string& onc_name, 188 const std::string& onc_name,
189 scoped_ptr<base::Value> value) { 189 scoped_ptr<base::Value> value) {
190 if (value.get() == NULL) 190 if (value.get() == NULL)
191 return; 191 return;
192 const OncFieldSignature* field_signature = 192 const OncFieldSignature* field_signature =
193 GetFieldSignature(*onc_signature_, onc_name); 193 GetOncFieldSignature(*onc_signature_, onc_name);
194 DCHECK(field_signature != NULL); 194 DCHECK(field_signature != NULL);
195 if (field_signature == NULL || field_signature->shill_property_name == NULL) 195 if (field_signature == NULL || field_signature->shill_property_name == NULL)
196 return; 196 return;
197 197
198 shill_dictionary_->SetWithoutPathExpansion( 198 shill_dictionary_->SetWithoutPathExpansion(
199 field_signature->shill_property_name, value.release()); 199 field_signature->shill_property_name, value.release());
200 } 200 }
201 201
202 void LocalTranslator::TranslateWithTableAndSet( 202 void LocalTranslator::TranslateWithTableAndSet(
203 const std::string& onc_value, 203 const std::string& onc_value,
(...skipping 24 matching lines...) Expand all
228 translator.TranslateFields(); 228 translator.TranslateFields();
229 229
230 // Recurse into nested objects. 230 // Recurse into nested objects.
231 for (base::DictionaryValue::Iterator it(onc_object); it.HasNext(); 231 for (base::DictionaryValue::Iterator it(onc_object); it.HasNext();
232 it.Advance()) { 232 it.Advance()) {
233 const base::DictionaryValue* inner_object = NULL; 233 const base::DictionaryValue* inner_object = NULL;
234 if (!it.value().GetAsDictionary(&inner_object)) 234 if (!it.value().GetAsDictionary(&inner_object))
235 continue; 235 continue;
236 236
237 const OncFieldSignature* field_signature = 237 const OncFieldSignature* field_signature =
238 GetFieldSignature(signature, it.key()); 238 GetOncFieldSignature(signature, it.key());
239 239
240 TranslateONCHierarchy(*field_signature->value_signature, *inner_object, 240 TranslateONCHierarchy(*field_signature->value_signature, *inner_object,
241 shill_dictionary); 241 shill_dictionary);
242 } 242 }
243 } 243 }
244 244
245 } // namespace 245 } // namespace
246 246
247 std::vector<std::string> TranslateONCPropertyNamesToShill(
248 const std::vector<std::string>& onc_names,
249 const OncValueSignature* signature) {
250 std::vector<std::string> result;
251 for (std::vector<std::string>::const_iterator iter = onc_names.begin();
252 iter != onc_names.end(); ++iter) {
253 const OncFieldSignature* field_signature =
254 GetOncFieldSignature(*signature, *iter);
255 DCHECK(field_signature != NULL);
256 if (field_signature == NULL || field_signature->shill_property_name == NULL)
257 continue;
258 result.push_back(field_signature->shill_property_name);
259 }
260 return result;
261 }
262
247 scoped_ptr<base::DictionaryValue> TranslateONCObjectToShill( 263 scoped_ptr<base::DictionaryValue> TranslateONCObjectToShill(
248 const OncValueSignature* onc_signature, 264 const base::DictionaryValue& onc_object,
249 const base::DictionaryValue& onc_object) { 265 const OncValueSignature* onc_signature) {
250 CHECK(onc_signature != NULL); 266 CHECK(onc_signature != NULL);
251 scoped_ptr<base::DictionaryValue> shill_dictionary(new base::DictionaryValue); 267 scoped_ptr<base::DictionaryValue> shill_dictionary(new base::DictionaryValue);
252 TranslateONCHierarchy(*onc_signature, onc_object, shill_dictionary.get()); 268 TranslateONCHierarchy(*onc_signature, onc_object, shill_dictionary.get());
253 return shill_dictionary.Pass(); 269 return shill_dictionary.Pass();
254 } 270 }
255 271
256 } // namespace onc 272 } // namespace onc
257 } // namespace chromeos 273 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/onc/onc_translator.h ('k') | chromeos/network/onc/onc_translator_shill_to_onc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698