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

Unified Diff: components/policy/core/common/policy_test_utils.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: More fixes 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 side-by-side diff with in-line comments
Download patch
Index: components/policy/core/common/policy_test_utils.cc
diff --git a/components/policy/core/common/policy_test_utils.cc b/components/policy/core/common/policy_test_utils.cc
index 9d1a50dae2eb9367455743442c29afc1f88e4643..7aee218cac18afb56200e2d0021dedb6c2c46cca 100644
--- a/components/policy/core/common/policy_test_utils.cc
+++ b/components/policy/core/common/policy_test_utils.cc
@@ -55,21 +55,21 @@ bool PolicyServiceIsEmpty(const PolicyService* service) {
}
#if defined(OS_IOS) || defined(OS_MACOSX)
-CFPropertyListRef ValueToProperty(const base::Value* value) {
- switch (value->GetType()) {
+CFPropertyListRef ValueToProperty(const base::Value& value) {
+ switch (value.GetType()) {
case base::Value::TYPE_NULL:
return kCFNull;
case base::Value::TYPE_BOOLEAN: {
bool bool_value;
- if (value->GetAsBoolean(&bool_value))
+ if (value.GetAsBoolean(&bool_value))
return bool_value ? kCFBooleanTrue : kCFBooleanFalse;
break;
}
case base::Value::TYPE_INTEGER: {
int int_value;
- if (value->GetAsInteger(&int_value)) {
+ if (value.GetAsInteger(&int_value)) {
return CFNumberCreate(
kCFAllocatorDefault, kCFNumberIntType, &int_value);
}
@@ -78,7 +78,7 @@ CFPropertyListRef ValueToProperty(const base::Value* value) {
case base::Value::TYPE_DOUBLE: {
double double_value;
- if (value->GetAsDouble(&double_value)) {
+ if (value.GetAsDouble(&double_value)) {
return CFNumberCreate(
kCFAllocatorDefault, kCFNumberDoubleType, &double_value);
}
@@ -87,14 +87,14 @@ CFPropertyListRef ValueToProperty(const base::Value* value) {
case base::Value::TYPE_STRING: {
std::string string_value;
- if (value->GetAsString(&string_value))
+ if (value.GetAsString(&string_value))
return base::SysUTF8ToCFStringRef(string_value);
break;
}
case base::Value::TYPE_DICTIONARY: {
const base::DictionaryValue* dict_value;
- if (value->GetAsDictionary(&dict_value)) {
+ if (value.GetAsDictionary(&dict_value)) {
// |dict| is owned by the caller.
CFMutableDictionaryRef dict =
CFDictionaryCreateMutable(kCFAllocatorDefault,
@@ -108,7 +108,7 @@ CFPropertyListRef ValueToProperty(const base::Value* value) {
base::ScopedCFTypeRef<CFStringRef> key(
base::SysUTF8ToCFStringRef(iterator.key()));
base::ScopedCFTypeRef<CFPropertyListRef> cf_value(
- ValueToProperty(&iterator.value()));
+ ValueToProperty(iterator.value()));
if (cf_value)
CFDictionaryAddValue(dict, key, cf_value);
}
@@ -119,15 +119,14 @@ CFPropertyListRef ValueToProperty(const base::Value* value) {
case base::Value::TYPE_LIST: {
const base::ListValue* list;
- if (value->GetAsList(&list)) {
+ if (value.GetAsList(&list)) {
CFMutableArrayRef array =
CFArrayCreateMutable(NULL, list->GetSize(), &kCFTypeArrayCallBacks);
- for (base::ListValue::const_iterator it(list->begin());
- it != list->end(); ++it) {
- // CFArrayAppendValue() retains |value|, so make sure the reference
+ for (const auto& entry : *list) {
+ // CFArrayAppendValue() retains |cf_value|, so make sure the reference
// created by ValueToProperty() is released.
base::ScopedCFTypeRef<CFPropertyListRef> cf_value(
- ValueToProperty(*it));
+ ValueToProperty(*entry));
if (cf_value)
CFArrayAppendValue(array, cf_value);
}
« no previous file with comments | « components/policy/core/common/policy_test_utils.h ('k') | components/signin/core/browser/account_tracker_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698