| OLD | NEW |
| 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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 base::DictionaryValue* target_shill_dictionary = shill_dictionary; | 346 base::DictionaryValue* target_shill_dictionary = shill_dictionary; |
| 347 std::vector<std::string> path_to_shill_dictionary = | 347 std::vector<std::string> path_to_shill_dictionary = |
| 348 GetPathToNestedShillDictionary(signature); | 348 GetPathToNestedShillDictionary(signature); |
| 349 for (std::vector<std::string>::const_iterator it = | 349 for (std::vector<std::string>::const_iterator it = |
| 350 path_to_shill_dictionary.begin(); | 350 path_to_shill_dictionary.begin(); |
| 351 it != path_to_shill_dictionary.end(); | 351 it != path_to_shill_dictionary.end(); |
| 352 ++it) { | 352 ++it) { |
| 353 base::DictionaryValue* nested_shill_dict = NULL; | 353 base::DictionaryValue* nested_shill_dict = NULL; |
| 354 target_shill_dictionary->GetDictionaryWithoutPathExpansion( | 354 target_shill_dictionary->GetDictionaryWithoutPathExpansion( |
| 355 *it, &nested_shill_dict); | 355 *it, &nested_shill_dict); |
| 356 if (!nested_shill_dict) | 356 if (!nested_shill_dict) { |
| 357 nested_shill_dict = new base::DictionaryValue; | 357 nested_shill_dict = new base::DictionaryValue; |
| 358 target_shill_dictionary->SetWithoutPathExpansion(*it, nested_shill_dict); | 358 target_shill_dictionary->SetWithoutPathExpansion(*it, nested_shill_dict); |
| 359 } |
| 359 target_shill_dictionary = nested_shill_dict; | 360 target_shill_dictionary = nested_shill_dict; |
| 360 } | 361 } |
| 361 // Translates fields of |onc_object| and writes them to | 362 // Translates fields of |onc_object| and writes them to |
| 362 // |target_shill_dictionary_| nested in |shill_dictionary|. | 363 // |target_shill_dictionary_| nested in |shill_dictionary|. |
| 363 LocalTranslator translator(signature, onc_object, target_shill_dictionary); | 364 LocalTranslator translator(signature, onc_object, target_shill_dictionary); |
| 364 translator.TranslateFields(); | 365 translator.TranslateFields(); |
| 365 | 366 |
| 366 // Recurse into nested objects. | 367 // Recurse into nested objects. |
| 367 for (base::DictionaryValue::Iterator it(onc_object); !it.IsAtEnd(); | 368 for (base::DictionaryValue::Iterator it(onc_object); !it.IsAtEnd(); |
| 368 it.Advance()) { | 369 it.Advance()) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 384 const OncValueSignature* onc_signature, | 385 const OncValueSignature* onc_signature, |
| 385 const base::DictionaryValue& onc_object) { | 386 const base::DictionaryValue& onc_object) { |
| 386 CHECK(onc_signature != NULL); | 387 CHECK(onc_signature != NULL); |
| 387 scoped_ptr<base::DictionaryValue> shill_dictionary(new base::DictionaryValue); | 388 scoped_ptr<base::DictionaryValue> shill_dictionary(new base::DictionaryValue); |
| 388 TranslateONCHierarchy(*onc_signature, onc_object, shill_dictionary.get()); | 389 TranslateONCHierarchy(*onc_signature, onc_object, shill_dictionary.get()); |
| 389 return shill_dictionary.Pass(); | 390 return shill_dictionary.Pass(); |
| 390 } | 391 } |
| 391 | 392 |
| 392 } // namespace onc | 393 } // namespace onc |
| 393 } // namespace chromeos | 394 } // namespace chromeos |
| OLD | NEW |