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

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

Issue 21030009: Make element removal methods in DictionaryValue and ListValue take scoped_ptr's as outparams. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 7 years, 4 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 | Annotate | Revision Log
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 <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 230
231 return ValidateRecommendedField(signature, result); 231 return ValidateRecommendedField(signature, result);
232 } 232 }
233 233
234 bool Validator::ValidateRecommendedField( 234 bool Validator::ValidateRecommendedField(
235 const OncValueSignature& object_signature, 235 const OncValueSignature& object_signature,
236 base::DictionaryValue* result) { 236 base::DictionaryValue* result) {
237 CHECK(result != NULL); 237 CHECK(result != NULL);
238 238
239 scoped_ptr<base::ListValue> recommended; 239 scoped_ptr<base::ListValue> recommended;
240 base::Value* recommended_value = NULL; 240 scoped_ptr<base::Value> recommended_value;
241 // This remove passes ownership to |recommended_value|. 241 // This remove passes ownership to |recommended_value|.
242 if (!result->RemoveWithoutPathExpansion(onc::kRecommended, 242 if (!result->RemoveWithoutPathExpansion(onc::kRecommended,
243 &recommended_value)) { 243 &recommended_value)) {
244 return true; 244 return true;
245 } 245 }
246 base::ListValue* recommended_list = NULL; 246 base::ListValue* recommended_list = NULL;
247 recommended_value->GetAsList(&recommended_list); 247 recommended_value.release()->GetAsList(&recommended_list);
248 CHECK(recommended_list != NULL); 248 CHECK(recommended_list);
249 249
250 recommended.reset(recommended_list); 250 recommended.reset(recommended_list);
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 '" << onc::kRecommended 254 LOG(WARNING) << MessageHeader() << "Found the field '" << onc::kRecommended
255 << "' in an unmanaged ONC. Removing it."; 255 << "' in an unmanaged ONC. Removing it.";
256 return true; 256 return true;
257 } 257 }
258 258
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 } 777 }
778 778
779 std::string Validator::MessageHeader() { 779 std::string Validator::MessageHeader() {
780 std::string path = path_.empty() ? "toplevel" : JoinString(path_, "."); 780 std::string path = path_.empty() ? "toplevel" : JoinString(path_, ".");
781 std::string message = "At " + path + ": "; 781 std::string message = "At " + path + ": ";
782 return message; 782 return message;
783 } 783 }
784 784
785 } // namespace onc 785 } // namespace onc
786 } // namespace chromeos 786 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/onc/onc_certificate_importer_impl_unittest.cc ('k') | cloud_print/service/win/chrome_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698