| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <cstdio> | 5 #include <cstdio> |
| 6 #include <iostream> | 6 #include <iostream> |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 " %i Some command line arguments are wrong.\n", | 77 " %i Some command line arguments are wrong.\n", |
| 78 kStatusValid, | 78 kStatusValid, |
| 79 kStatusWarnings, | 79 kStatusWarnings, |
| 80 kStatusInvalid, | 80 kStatusInvalid, |
| 81 kStatusJsonError, | 81 kStatusJsonError, |
| 82 kStatusArgumentError); | 82 kStatusArgumentError); |
| 83 } | 83 } |
| 84 | 84 |
| 85 scoped_ptr<base::DictionaryValue> ReadDictionary(std::string filename) { | 85 scoped_ptr<base::DictionaryValue> ReadDictionary(std::string filename) { |
| 86 base::FilePath path(filename); | 86 base::FilePath path(filename); |
| 87 JSONFileValueSerializer serializer(path); | 87 JSONFileValueDeserializer deserializer(path); |
| 88 serializer.set_allow_trailing_comma(true); | 88 deserializer.set_allow_trailing_comma(true); |
| 89 | 89 |
| 90 base::DictionaryValue* dict = NULL; | 90 base::DictionaryValue* dict = NULL; |
| 91 | 91 |
| 92 std::string json_error; | 92 std::string json_error; |
| 93 base::Value* value = serializer.Deserialize(NULL, &json_error); | 93 base::Value* value = deserializer.Deserialize(NULL, &json_error); |
| 94 if (!value) { | 94 if (!value) { |
| 95 LOG(ERROR) << "Couldn't json-deserialize file '" << filename | 95 LOG(ERROR) << "Couldn't json-deserialize file '" << filename |
| 96 << "': " << json_error; | 96 << "': " << json_error; |
| 97 return make_scoped_ptr(dict); | 97 return make_scoped_ptr(dict); |
| 98 } | 98 } |
| 99 | 99 |
| 100 if (!value->GetAsDictionary(&dict)) { | 100 if (!value->GetAsDictionary(&dict)) { |
| 101 LOG(ERROR) << "File '" << filename | 101 LOG(ERROR) << "File '" << filename |
| 102 << "' does not contain a dictionary as expected, but type " | 102 << "' does not contain a dictionary as expected, but type " |
| 103 << value->GetType(); | 103 << value->GetType(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 case chromeos::onc::Validator::VALID: | 155 case chromeos::onc::Validator::VALID: |
| 156 return kStatusValid; | 156 return kStatusValid; |
| 157 case chromeos::onc::Validator::VALID_WITH_WARNINGS: | 157 case chromeos::onc::Validator::VALID_WITH_WARNINGS: |
| 158 return kStatusWarnings; | 158 return kStatusWarnings; |
| 159 case chromeos::onc::Validator::INVALID: | 159 case chromeos::onc::Validator::INVALID: |
| 160 return kStatusInvalid; | 160 return kStatusInvalid; |
| 161 default: | 161 default: |
| 162 CHECK(false); | 162 CHECK(false); |
| 163 } | 163 } |
| 164 } | 164 } |
| OLD | NEW |