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