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

Unified Diff: base/values.cc

Issue 2865963002: Use MakeUnique() in base/values.cc. (Closed)
Patch Set: address comments Created 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/values.cc
diff --git a/base/values.cc b/base/values.cc
index 768e3f790b4c8b1870f070118e5782640e6ce12a..5bed467320afd7af9d944b3d5772cb55c6f4d503 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -49,7 +49,7 @@ std::unique_ptr<DictionaryValue> CopyDictionaryWithoutEmptyChildren(
std::unique_ptr<Value> child_copy = CopyWithoutEmptyChildren(it.value());
if (child_copy) {
if (!copy)
- copy.reset(new DictionaryValue);
+ copy = MakeUnique<DictionaryValue>();
copy->SetWithoutPathExpansion(it.key(), std::move(child_copy));
}
}
@@ -624,9 +624,8 @@ Value* DictionaryValue::Set(StringPiece path, std::unique_ptr<Value> in_value) {
StringPiece key = current_path.substr(0, delimiter_position);
DictionaryValue* child_dictionary = nullptr;
if (!current_dictionary->GetDictionary(key, &child_dictionary)) {
- child_dictionary = new DictionaryValue;
- current_dictionary->SetWithoutPathExpansion(
- key, base::WrapUnique(child_dictionary));
+ child_dictionary = current_dictionary->SetDictionaryWithoutPathExpansion(
+ key, MakeUnique<DictionaryValue>());
}
current_dictionary = child_dictionary;
@@ -642,23 +641,23 @@ Value* DictionaryValue::Set(StringPiece path, Value* in_value) {
}
Value* DictionaryValue::SetBoolean(StringPiece path, bool in_value) {
- return Set(path, new Value(in_value));
+ return Set(path, MakeUnique<Value>(in_value));
}
Value* DictionaryValue::SetInteger(StringPiece path, int in_value) {
- return Set(path, new Value(in_value));
+ return Set(path, MakeUnique<Value>(in_value));
}
Value* DictionaryValue::SetDouble(StringPiece path, double in_value) {
- return Set(path, new Value(in_value));
+ return Set(path, MakeUnique<Value>(in_value));
}
Value* DictionaryValue::SetString(StringPiece path, StringPiece in_value) {
- return Set(path, new Value(in_value));
+ return Set(path, MakeUnique<Value>(in_value));
}
Value* DictionaryValue::SetString(StringPiece path, const string16& in_value) {
- return Set(path, new Value(in_value));
+ return Set(path, MakeUnique<Value>(in_value));
}
DictionaryValue* DictionaryValue::SetDictionary(
@@ -685,28 +684,28 @@ Value* DictionaryValue::SetWithoutPathExpansion(StringPiece key,
Value* DictionaryValue::SetBooleanWithoutPathExpansion(StringPiece path,
bool in_value) {
- return SetWithoutPathExpansion(path, base::MakeUnique<base::Value>(in_value));
+ return SetWithoutPathExpansion(path, MakeUnique<Value>(in_value));
}
Value* DictionaryValue::SetIntegerWithoutPathExpansion(StringPiece path,
int in_value) {
- return SetWithoutPathExpansion(path, base::MakeUnique<base::Value>(in_value));
+ return SetWithoutPathExpansion(path, MakeUnique<Value>(in_value));
}
Value* DictionaryValue::SetDoubleWithoutPathExpansion(StringPiece path,
double in_value) {
- return SetWithoutPathExpansion(path, base::MakeUnique<base::Value>(in_value));
+ return SetWithoutPathExpansion(path, MakeUnique<Value>(in_value));
}
Value* DictionaryValue::SetStringWithoutPathExpansion(StringPiece path,
StringPiece in_value) {
- return SetWithoutPathExpansion(path, base::MakeUnique<base::Value>(in_value));
+ return SetWithoutPathExpansion(path, MakeUnique<Value>(in_value));
}
Value* DictionaryValue::SetStringWithoutPathExpansion(
StringPiece path,
const string16& in_value) {
- return SetWithoutPathExpansion(path, base::MakeUnique<base::Value>(in_value));
+ return SetWithoutPathExpansion(path, MakeUnique<Value>(in_value));
}
DictionaryValue* DictionaryValue::SetDictionaryWithoutPathExpansion(
@@ -1030,7 +1029,7 @@ std::unique_ptr<DictionaryValue> DictionaryValue::DeepCopyWithoutEmptyChildren()
std::unique_ptr<DictionaryValue> copy =
CopyDictionaryWithoutEmptyChildren(*this);
if (!copy)
- copy.reset(new DictionaryValue);
+ copy = MakeUnique<DictionaryValue>();
return copy;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698