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

Side by Side Diff: chromeos/tools/onc_validator/onc_validator.cc

Issue 1394993004: Make ValueDeserializer::Deserialize return scoped_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix and add todo about not failed trybot Created 5 years, 2 months 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/system/statistics_provider.cc ('k') | components/bookmarks/browser/bookmark_codec.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) 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"
11 #include "base/json/json_file_value_serializer.h" 11 #include "base/json/json_file_value_serializer.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chromeos/network/onc/onc_signature.h" 14 #include "chromeos/network/onc/onc_signature.h"
15 #include "chromeos/network/onc/onc_validator.h" 15 #include "chromeos/network/onc/onc_validator.h"
16 16
17 // TODO Check why this file do not fail on default trybots
18 // http://crbug.com/543919
19
17 // Command line switches. 20 // Command line switches.
18 const char kSwitchErrorOnUnknownField[] = "error-on-unknown-field"; 21 const char kSwitchErrorOnUnknownField[] = "error-on-unknown-field";
19 const char kSwitchErrorOnWrongRecommended[] = "error-on-wrong-recommended"; 22 const char kSwitchErrorOnWrongRecommended[] = "error-on-wrong-recommended";
20 const char kSwitchErrorOnMissingField[] = "error-on-missing-field"; 23 const char kSwitchErrorOnMissingField[] = "error-on-missing-field";
21 const char kSwitchManagedOnc[] = "managed-onc"; 24 const char kSwitchManagedOnc[] = "managed-onc";
22 const char kSwitchUserPolicy[] = "user-policy"; 25 const char kSwitchUserPolicy[] = "user-policy";
23 const char kSwitchDevicePolicy[] = "device-policy"; 26 const char kSwitchDevicePolicy[] = "device-policy";
24 const char kSwitchUserImport[] = "user-import"; 27 const char kSwitchUserImport[] = "user-import";
25 28
26 const char* kSwitches[] = { 29 const char* kSwitches[] = {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 86 }
84 87
85 scoped_ptr<base::DictionaryValue> ReadDictionary(const std::string& filename) { 88 scoped_ptr<base::DictionaryValue> ReadDictionary(const std::string& filename) {
86 base::FilePath path(filename); 89 base::FilePath path(filename);
87 JSONFileValueDeserializer deserializer(path); 90 JSONFileValueDeserializer deserializer(path);
88 deserializer.set_allow_trailing_comma(true); 91 deserializer.set_allow_trailing_comma(true);
89 92
90 base::DictionaryValue* dict = NULL; 93 base::DictionaryValue* dict = NULL;
91 94
92 std::string json_error; 95 std::string json_error;
93 base::Value* value = deserializer.Deserialize(NULL, &json_error); 96 base::Value* value = deserializer.Deserialize(NULL, &json_error).release();
97 // TODO(Olli Raula) possible memory leak http://crbug.com/543015
94 if (!value) { 98 if (!value) {
95 LOG(ERROR) << "Couldn't json-deserialize file '" << filename 99 LOG(ERROR) << "Couldn't json-deserialize file '" << filename
96 << "': " << json_error; 100 << "': " << json_error;
97 return make_scoped_ptr(dict); 101 return make_scoped_ptr(dict);
98 } 102 }
99 103
100 if (!value->GetAsDictionary(&dict)) { 104 if (!value->GetAsDictionary(&dict)) {
101 LOG(ERROR) << "File '" << filename 105 LOG(ERROR) << "File '" << filename
102 << "' does not contain a dictionary as expected, but type " 106 << "' does not contain a dictionary as expected, but type "
103 << value->GetType(); 107 << value->GetType();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 case chromeos::onc::Validator::VALID: 159 case chromeos::onc::Validator::VALID:
156 return kStatusValid; 160 return kStatusValid;
157 case chromeos::onc::Validator::VALID_WITH_WARNINGS: 161 case chromeos::onc::Validator::VALID_WITH_WARNINGS:
158 return kStatusWarnings; 162 return kStatusWarnings;
159 case chromeos::onc::Validator::INVALID: 163 case chromeos::onc::Validator::INVALID:
160 return kStatusInvalid; 164 return kStatusInvalid;
161 default: 165 default:
162 CHECK(false); 166 CHECK(false);
163 } 167 }
164 } 168 }
OLDNEW
« no previous file with comments | « chromeos/system/statistics_provider.cc ('k') | components/bookmarks/browser/bookmark_codec.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698