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

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

Issue 2000803003: Use std::unique_ptr for base::DictionaryValue and base::ListValue's internal store. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix various builds. Created 4 years, 7 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) 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_validator.h" 5 #include "chromeos/network/onc/onc_validator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 251
252 if (!managed_onc_) { 252 if (!managed_onc_) {
253 error_or_warning_found_ = true; 253 error_or_warning_found_ = true;
254 LOG(WARNING) << MessageHeader() << "Found the field '" 254 LOG(WARNING) << MessageHeader() << "Found the field '"
255 << ::onc::kRecommended 255 << ::onc::kRecommended
256 << "' in an unmanaged ONC. Removing it."; 256 << "' in an unmanaged ONC. Removing it.";
257 return true; 257 return true;
258 } 258 }
259 259
260 std::unique_ptr<base::ListValue> repaired_recommended(new base::ListValue); 260 std::unique_ptr<base::ListValue> repaired_recommended(new base::ListValue);
261 for (const base::Value* entry : *recommended_list) { 261 for (const auto& entry : *recommended_list) {
262 std::string field_name; 262 std::string field_name;
263 if (!entry->GetAsString(&field_name)) { 263 if (!entry->GetAsString(&field_name)) {
264 NOTREACHED(); // The types of field values are already verified. 264 NOTREACHED(); // The types of field values are already verified.
265 continue; 265 continue;
266 } 266 }
267 267
268 const OncFieldSignature* field_signature = 268 const OncFieldSignature* field_signature =
269 GetFieldSignature(object_signature, field_name); 269 GetFieldSignature(object_signature, field_name);
270 270
271 bool found_error = false; 271 bool found_error = false;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 return true; 411 return true;
412 } 412 }
413 413
414 bool Validator::ListFieldContainsValidValues( 414 bool Validator::ListFieldContainsValidValues(
415 const base::DictionaryValue& object, 415 const base::DictionaryValue& object,
416 const std::string& field_name, 416 const std::string& field_name,
417 const std::vector<const char*>& valid_values) { 417 const std::vector<const char*>& valid_values) {
418 const base::ListValue* list = NULL; 418 const base::ListValue* list = NULL;
419 if (object.GetListWithoutPathExpansion(field_name, &list)) { 419 if (object.GetListWithoutPathExpansion(field_name, &list)) {
420 path_.push_back(field_name); 420 path_.push_back(field_name);
421 for (const base::Value* entry : *list) { 421 for (const auto& entry : *list) {
422 std::string value; 422 std::string value;
423 if (!entry->GetAsString(&value)) { 423 if (!entry->GetAsString(&value)) {
424 NOTREACHED(); // The types of field values are already verified. 424 NOTREACHED(); // The types of field values are already verified.
425 continue; 425 continue;
426 } 426 }
427 if (!IsValidValue(value, valid_values)) { 427 if (!IsValidValue(value, valid_values)) {
428 path_.pop_back(); 428 path_.pop_back();
429 return false; 429 return false;
430 } 430 }
431 } 431 }
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 } 1033 }
1034 1034
1035 std::string Validator::MessageHeader() { 1035 std::string Validator::MessageHeader() {
1036 std::string path = path_.empty() ? "toplevel" : base::JoinString(path_, "."); 1036 std::string path = path_.empty() ? "toplevel" : base::JoinString(path_, ".");
1037 std::string message = "At " + path + ": "; 1037 std::string message = "At " + path + ": ";
1038 return message; 1038 return message;
1039 } 1039 }
1040 1040
1041 } // namespace onc 1041 } // namespace onc
1042 } // namespace chromeos 1042 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698