| 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 18 matching lines...) Expand all Loading... |
| 29 namespace chromeos { | 29 namespace chromeos { |
| 30 namespace onc { | 30 namespace onc { |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 std::unique_ptr<base::StringValue> ConvertValueToString( | 34 std::unique_ptr<base::StringValue> ConvertValueToString( |
| 35 const base::Value& value) { | 35 const base::Value& value) { |
| 36 std::string str; | 36 std::string str; |
| 37 if (!value.GetAsString(&str)) | 37 if (!value.GetAsString(&str)) |
| 38 base::JSONWriter::Write(value, &str); | 38 base::JSONWriter::Write(value, &str); |
| 39 return base::WrapUnique(new base::StringValue(str)); | 39 return base::MakeUnique<base::StringValue>(str); |
| 40 } | 40 } |
| 41 | 41 |
| 42 // This class is responsible to translate the local fields of the given | 42 // This class is responsible to translate the local fields of the given |
| 43 // |onc_object| according to |onc_signature| into |shill_dictionary|. This | 43 // |onc_object| according to |onc_signature| into |shill_dictionary|. This |
| 44 // translation should consider (if possible) only fields of this ONC object and | 44 // translation should consider (if possible) only fields of this ONC object and |
| 45 // not nested objects because recursion is handled by the calling function | 45 // not nested objects because recursion is handled by the calling function |
| 46 // TranslateONCHierarchy. | 46 // TranslateONCHierarchy. |
| 47 class LocalTranslator { | 47 class LocalTranslator { |
| 48 public: | 48 public: |
| 49 LocalTranslator(const OncValueSignature& onc_signature, | 49 LocalTranslator(const OncValueSignature& onc_signature, |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 const base::DictionaryValue& onc_object) { | 422 const base::DictionaryValue& onc_object) { |
| 423 CHECK(onc_signature != NULL); | 423 CHECK(onc_signature != NULL); |
| 424 std::unique_ptr<base::DictionaryValue> shill_dictionary( | 424 std::unique_ptr<base::DictionaryValue> shill_dictionary( |
| 425 new base::DictionaryValue); | 425 new base::DictionaryValue); |
| 426 TranslateONCHierarchy(*onc_signature, onc_object, shill_dictionary.get()); | 426 TranslateONCHierarchy(*onc_signature, onc_object, shill_dictionary.get()); |
| 427 return shill_dictionary; | 427 return shill_dictionary; |
| 428 } | 428 } |
| 429 | 429 |
| 430 } // namespace onc | 430 } // namespace onc |
| 431 } // namespace chromeos | 431 } // namespace chromeos |
| OLD | NEW |