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

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: Win typo fix 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
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"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 84
85 scoped_ptr<base::DictionaryValue> ReadDictionary(const std::string& filename) { 85 scoped_ptr<base::DictionaryValue> ReadDictionary(const std::string& filename) {
86 base::FilePath path(filename); 86 base::FilePath path(filename);
87 JSONFileValueDeserializer deserializer(path); 87 JSONFileValueDeserializer deserializer(path);
88 deserializer.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 = deserializer.Deserialize(NULL, &json_error); 93 base::Value* value = deserializer.Deserialize(NULL, &json_error).release();
94 if (!value) { 94 TODO(Olli Raula)
Lei Zhang 2015/10/15 17:36:11 I think you forgot some slashes here. And again, "
95 possible memoryleak http : // crbug.com/543015
96 if (!value) {
95 LOG(ERROR) << "Couldn't json-deserialize file '" << filename 97 LOG(ERROR) << "Couldn't json-deserialize file '" << filename
96 << "': " << json_error; 98 << "': " << json_error;
97 return make_scoped_ptr(dict); 99 return make_scoped_ptr(dict);
98 } 100 }
99 101
100 if (!value->GetAsDictionary(&dict)) { 102 if (!value->GetAsDictionary(&dict)) {
101 LOG(ERROR) << "File '" << filename 103 LOG(ERROR) << "File '" << filename
102 << "' does not contain a dictionary as expected, but type " 104 << "' does not contain a dictionary as expected, but type "
103 << value->GetType(); 105 << value->GetType();
104 } 106 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 case chromeos::onc::Validator::VALID: 157 case chromeos::onc::Validator::VALID:
156 return kStatusValid; 158 return kStatusValid;
157 case chromeos::onc::Validator::VALID_WITH_WARNINGS: 159 case chromeos::onc::Validator::VALID_WITH_WARNINGS:
158 return kStatusWarnings; 160 return kStatusWarnings;
159 case chromeos::onc::Validator::INVALID: 161 case chromeos::onc::Validator::INVALID:
160 return kStatusInvalid; 162 return kStatusInvalid;
161 default: 163 default:
162 CHECK(false); 164 CHECK(false);
163 } 165 }
164 } 166 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698