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

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

Issue 11469026: Extending ONC validator's logging. Completing toplevel validation. (Closed) Base URL: http://git.chromium.org/chromium/src.git@add_error_handling_to_validator
Patch Set: Rebased. Created 8 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_normalizer.h ('k') | chromeos/network/onc/onc_signature.h » ('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 "chromeos/network/onc/onc_normalizer.h" 5 #include "chromeos/network/onc/onc_normalizer.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chromeos/network/onc/onc_constants.h" 11 #include "chromeos/network/onc/onc_constants.h"
12 #include "chromeos/network/onc/onc_signature.h" 12 #include "chromeos/network/onc/onc_signature.h"
13 13
14 namespace chromeos { 14 namespace chromeos {
15 namespace onc { 15 namespace onc {
16 16
17 Normalizer::Normalizer(bool remove_recommended_fields) 17 Normalizer::Normalizer(bool remove_recommended_fields)
18 : remove_recommended_fields_(remove_recommended_fields) { 18 : remove_recommended_fields_(remove_recommended_fields) {
19 } 19 }
20 20
21 Normalizer::~Normalizer() { 21 Normalizer::~Normalizer() {
22 } 22 }
23 23
24 scoped_ptr<base::DictionaryValue> Normalizer::NormalizeObject( 24 scoped_ptr<base::DictionaryValue> Normalizer::NormalizeObject(
25 const OncValueSignature* object_signature, 25 const OncValueSignature* object_signature,
26 const base::DictionaryValue& onc_object) { 26 const base::DictionaryValue& onc_object) {
27 CHECK(object_signature != NULL); 27 CHECK(object_signature != NULL);
28 return MapObject(*object_signature, onc_object); 28 bool error = false;
29 scoped_ptr<base::DictionaryValue> result =
30 MapObject(*object_signature, onc_object, &error);
31 DCHECK(!error);
32 return result.Pass();
29 } 33 }
30 34
31 scoped_ptr<base::DictionaryValue> Normalizer::MapObject( 35 scoped_ptr<base::DictionaryValue> Normalizer::MapObject(
32 const OncValueSignature& signature, 36 const OncValueSignature& signature,
33 const base::DictionaryValue& onc_object) { 37 const base::DictionaryValue& onc_object,
38 bool* error) {
34 scoped_ptr<base::DictionaryValue> normalized = 39 scoped_ptr<base::DictionaryValue> normalized =
35 Mapper::MapObject(signature, onc_object); 40 Mapper::MapObject(signature, onc_object, error);
36 41
37 if (normalized.get() == NULL) 42 if (normalized.get() == NULL)
38 return scoped_ptr<base::DictionaryValue>(); 43 return scoped_ptr<base::DictionaryValue>();
39 44
40 if (remove_recommended_fields_) 45 if (remove_recommended_fields_)
41 normalized->RemoveWithoutPathExpansion(kRecommended, NULL); 46 normalized->RemoveWithoutPathExpansion(kRecommended, NULL);
42 47
43 if (&signature == &kNetworkConfigurationSignature) 48 if (&signature == &kNetworkConfigurationSignature)
44 NormalizeNetworkConfiguration(normalized.get()); 49 NormalizeNetworkConfiguration(normalized.get());
45 else if (&signature == &kVPNSignature) 50 else if (&signature == &kVPNSignature)
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 void Normalizer::NormalizeNetworkConfiguration(base::DictionaryValue* network) { 100 void Normalizer::NormalizeNetworkConfiguration(base::DictionaryValue* network) {
96 std::string type; 101 std::string type;
97 network->GetStringWithoutPathExpansion(kType, &type); 102 network->GetStringWithoutPathExpansion(kType, &type);
98 RemoveEntryUnless(network, kEthernet, type == kEthernet); 103 RemoveEntryUnless(network, kEthernet, type == kEthernet);
99 RemoveEntryUnless(network, kVPN, type == kVPN); 104 RemoveEntryUnless(network, kVPN, type == kVPN);
100 RemoveEntryUnless(network, kWiFi, type == kWiFi); 105 RemoveEntryUnless(network, kWiFi, type == kWiFi);
101 } 106 }
102 107
103 } // namespace onc 108 } // namespace onc
104 } // namespace chromeos 109 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/onc/onc_normalizer.h ('k') | chromeos/network/onc/onc_signature.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698