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

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

Issue 2539363004: Make base::Value::TYPE a scoped enum. (Closed)
Patch Set: Rebase Created 4 years 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
« no previous file with comments | « chromeos/network/onc/onc_signature.cc ('k') | chromeos/network/onc/onc_validator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <string> 5 #include <string>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 14 matching lines...) Expand all
25 namespace chromeos { 25 namespace chromeos {
26 namespace onc { 26 namespace onc {
27 27
28 namespace { 28 namespace {
29 29
30 // Converts |str| to a base::Value of the given |type|. If the conversion fails, 30 // Converts |str| to a base::Value of the given |type|. If the conversion fails,
31 // returns NULL. 31 // returns NULL.
32 std::unique_ptr<base::Value> ConvertStringToValue(const std::string& str, 32 std::unique_ptr<base::Value> ConvertStringToValue(const std::string& str,
33 base::Value::Type type) { 33 base::Value::Type type) {
34 std::unique_ptr<base::Value> value; 34 std::unique_ptr<base::Value> value;
35 if (type == base::Value::TYPE_STRING) { 35 if (type == base::Value::Type::STRING) {
36 value.reset(new base::StringValue(str)); 36 value.reset(new base::StringValue(str));
37 } else { 37 } else {
38 value = base::JSONReader::Read(str); 38 value = base::JSONReader::Read(str);
39 } 39 }
40 if (value && value->GetType() != type) 40 if (value && value->GetType() != type)
41 return nullptr; 41 return nullptr;
42 42
43 return value; 43 return value;
44 } 44 }
45 45
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 onc_object_->SetWithoutPathExpansion(onc_dictionary_name, nested); 665 onc_object_->SetWithoutPathExpansion(onc_dictionary_name, nested);
666 } 666 }
667 nested->SetWithoutPathExpansion(onc_field_name, value.DeepCopy()); 667 nested->SetWithoutPathExpansion(onc_field_name, value.DeepCopy());
668 } 668 }
669 669
670 void ShillToONCTranslator::TranslateAndAddListOfObjects( 670 void ShillToONCTranslator::TranslateAndAddListOfObjects(
671 const std::string& onc_field_name, 671 const std::string& onc_field_name,
672 const base::ListValue& list) { 672 const base::ListValue& list) {
673 const OncFieldSignature* field_signature = 673 const OncFieldSignature* field_signature =
674 GetFieldSignature(*onc_signature_, onc_field_name); 674 GetFieldSignature(*onc_signature_, onc_field_name);
675 if (field_signature->value_signature->onc_type != base::Value::TYPE_LIST) { 675 if (field_signature->value_signature->onc_type != base::Value::Type::LIST) {
676 LOG(ERROR) << "ONC Field name: '" << onc_field_name << "' has type '" 676 LOG(ERROR) << "ONC Field name: '" << onc_field_name << "' has type '"
677 << field_signature->value_signature->onc_type 677 << field_signature->value_signature->onc_type
678 << "', expected: base::Value::TYPE_LIST: " << GetName(); 678 << "', expected: base::Value::Type::LIST: " << GetName();
679 return; 679 return;
680 } 680 }
681 DCHECK(field_signature->value_signature->onc_array_entry_signature); 681 DCHECK(field_signature->value_signature->onc_array_entry_signature);
682 std::unique_ptr<base::ListValue> result(new base::ListValue()); 682 std::unique_ptr<base::ListValue> result(new base::ListValue());
683 for (base::ListValue::const_iterator it = list.begin(); it != list.end(); 683 for (base::ListValue::const_iterator it = list.begin(); it != list.end();
684 ++it) { 684 ++it) {
685 const base::DictionaryValue* shill_value = NULL; 685 const base::DictionaryValue* shill_value = NULL;
686 if (!(*it)->GetAsDictionary(&shill_value)) 686 if (!(*it)->GetAsDictionary(&shill_value))
687 continue; 687 continue;
688 ShillToONCTranslator nested_translator( 688 ShillToONCTranslator nested_translator(
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 const NetworkState* network_state) { 778 const NetworkState* network_state) {
779 CHECK(onc_signature != NULL); 779 CHECK(onc_signature != NULL);
780 780
781 ShillToONCTranslator translator(shill_dictionary, onc_source, *onc_signature, 781 ShillToONCTranslator translator(shill_dictionary, onc_source, *onc_signature,
782 network_state); 782 network_state);
783 return translator.CreateTranslatedONCObject(); 783 return translator.CreateTranslatedONCObject();
784 } 784 }
785 785
786 } // namespace onc 786 } // namespace onc
787 } // namespace chromeos 787 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/onc/onc_signature.cc ('k') | chromeos/network/onc/onc_validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698