| 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 "third_party/cros_system_api/dbus/service_constants.h" | 24 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 25 | 25 |
| 26 namespace chromeos { | 26 namespace chromeos { |
| 27 namespace onc { | 27 namespace onc { |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 scoped_ptr<base::StringValue> ConvertValueToString(const base::Value& value) { | 31 scoped_ptr<base::StringValue> ConvertValueToString(const base::Value& value) { |
| 32 std::string str; | 32 std::string str; |
| 33 if (!value.GetAsString(&str)) | 33 if (!value.GetAsString(&str)) |
| 34 base::JSONWriter::Write(&value, &str); | 34 base::JSONWriter::Write(value, &str); |
| 35 return make_scoped_ptr(new base::StringValue(str)); | 35 return make_scoped_ptr(new base::StringValue(str)); |
| 36 } | 36 } |
| 37 | 37 |
| 38 // This class is responsible to translate the local fields of the given | 38 // This class is responsible to translate the local fields of the given |
| 39 // |onc_object| according to |onc_signature| into |shill_dictionary|. This | 39 // |onc_object| according to |onc_signature| into |shill_dictionary|. This |
| 40 // translation should consider (if possible) only fields of this ONC object and | 40 // translation should consider (if possible) only fields of this ONC object and |
| 41 // not nested objects because recursion is handled by the calling function | 41 // not nested objects because recursion is handled by the calling function |
| 42 // TranslateONCHierarchy. | 42 // TranslateONCHierarchy. |
| 43 class LocalTranslator { | 43 class LocalTranslator { |
| 44 public: | 44 public: |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 const OncValueSignature* onc_signature, | 401 const OncValueSignature* onc_signature, |
| 402 const base::DictionaryValue& onc_object) { | 402 const base::DictionaryValue& onc_object) { |
| 403 CHECK(onc_signature != NULL); | 403 CHECK(onc_signature != NULL); |
| 404 scoped_ptr<base::DictionaryValue> shill_dictionary(new base::DictionaryValue); | 404 scoped_ptr<base::DictionaryValue> shill_dictionary(new base::DictionaryValue); |
| 405 TranslateONCHierarchy(*onc_signature, onc_object, shill_dictionary.get()); | 405 TranslateONCHierarchy(*onc_signature, onc_object, shill_dictionary.get()); |
| 406 return shill_dictionary.Pass(); | 406 return shill_dictionary.Pass(); |
| 407 } | 407 } |
| 408 | 408 |
| 409 } // namespace onc | 409 } // namespace onc |
| 410 } // namespace chromeos | 410 } // namespace chromeos |
| OLD | NEW |