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

Unified Diff: base/values.cc

Issue 2850773002: Make base::DictionaryValue::Set* return pointers (Closed)
Patch Set: Add SetDictionary* and SetList* Created 3 years, 8 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 | « base/values.h ('k') | base/values_unittest.cc » ('j') | 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 aa3407fdaa04a100b1d337bd2a90376ecf9f2742..768e3f790b4c8b1870f070118e5782640e6ce12a 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -611,7 +611,7 @@ void DictionaryValue::Clear() {
dict_->clear();
}
-void DictionaryValue::Set(StringPiece path, std::unique_ptr<Value> in_value) {
+Value* DictionaryValue::Set(StringPiece path, std::unique_ptr<Value> in_value) {
DCHECK(IsStringUTF8(path));
DCHECK(in_value);
@@ -633,67 +633,94 @@ void DictionaryValue::Set(StringPiece path, std::unique_ptr<Value> in_value) {
current_path = current_path.substr(delimiter_position + 1);
}
- current_dictionary->SetWithoutPathExpansion(current_path,
- std::move(in_value));
+ return current_dictionary->SetWithoutPathExpansion(current_path,
+ std::move(in_value));
}
-void DictionaryValue::Set(StringPiece path, Value* in_value) {
- Set(path, WrapUnique(in_value));
+Value* DictionaryValue::Set(StringPiece path, Value* in_value) {
+ return Set(path, WrapUnique(in_value));
}
-void DictionaryValue::SetBoolean(StringPiece path, bool in_value) {
- Set(path, new Value(in_value));
+Value* DictionaryValue::SetBoolean(StringPiece path, bool in_value) {
+ return Set(path, new Value(in_value));
}
-void DictionaryValue::SetInteger(StringPiece path, int in_value) {
- Set(path, new Value(in_value));
+Value* DictionaryValue::SetInteger(StringPiece path, int in_value) {
+ return Set(path, new Value(in_value));
}
-void DictionaryValue::SetDouble(StringPiece path, double in_value) {
- Set(path, new Value(in_value));
+Value* DictionaryValue::SetDouble(StringPiece path, double in_value) {
+ return Set(path, new Value(in_value));
}
-void DictionaryValue::SetString(StringPiece path, StringPiece in_value) {
- Set(path, new Value(in_value));
+Value* DictionaryValue::SetString(StringPiece path, StringPiece in_value) {
+ return Set(path, new Value(in_value));
}
-void DictionaryValue::SetString(StringPiece path, const string16& in_value) {
- Set(path, new Value(in_value));
+Value* DictionaryValue::SetString(StringPiece path, const string16& in_value) {
+ return Set(path, new Value(in_value));
}
-void DictionaryValue::SetWithoutPathExpansion(StringPiece key,
- std::unique_ptr<Value> in_value) {
- (*dict_)[key.as_string()] = std::move(in_value);
+DictionaryValue* DictionaryValue::SetDictionary(
+ StringPiece path,
+ std::unique_ptr<DictionaryValue> in_value) {
+ return static_cast<DictionaryValue*>(Set(path, std::move(in_value)));
}
-void DictionaryValue::SetWithoutPathExpansion(StringPiece key,
- Value* in_value) {
- SetWithoutPathExpansion(key, WrapUnique(in_value));
+ListValue* DictionaryValue::SetList(StringPiece path,
+ std::unique_ptr<ListValue> in_value) {
+ return static_cast<ListValue*>(Set(path, std::move(in_value)));
}
-void DictionaryValue::SetBooleanWithoutPathExpansion(StringPiece path,
- bool in_value) {
- SetWithoutPathExpansion(path, base::MakeUnique<base::Value>(in_value));
+Value* DictionaryValue::SetWithoutPathExpansion(
+ StringPiece key,
+ std::unique_ptr<Value> in_value) {
+ return ((*dict_)[key.as_string()] = std::move(in_value)).get();
+}
+
+Value* DictionaryValue::SetWithoutPathExpansion(StringPiece key,
+ Value* in_value) {
+ return SetWithoutPathExpansion(key, WrapUnique(in_value));
+}
+
+Value* DictionaryValue::SetBooleanWithoutPathExpansion(StringPiece path,
+ bool in_value) {
+ return SetWithoutPathExpansion(path, base::MakeUnique<base::Value>(in_value));
+}
+
+Value* DictionaryValue::SetIntegerWithoutPathExpansion(StringPiece path,
+ int in_value) {
+ return SetWithoutPathExpansion(path, base::MakeUnique<base::Value>(in_value));
+}
+
+Value* DictionaryValue::SetDoubleWithoutPathExpansion(StringPiece path,
+ double in_value) {
+ return SetWithoutPathExpansion(path, base::MakeUnique<base::Value>(in_value));
}
-void DictionaryValue::SetIntegerWithoutPathExpansion(StringPiece path,
- int in_value) {
- SetWithoutPathExpansion(path, base::MakeUnique<base::Value>(in_value));
+Value* DictionaryValue::SetStringWithoutPathExpansion(StringPiece path,
+ StringPiece in_value) {
+ return SetWithoutPathExpansion(path, base::MakeUnique<base::Value>(in_value));
}
-void DictionaryValue::SetDoubleWithoutPathExpansion(StringPiece path,
- double in_value) {
- SetWithoutPathExpansion(path, base::MakeUnique<base::Value>(in_value));
+Value* DictionaryValue::SetStringWithoutPathExpansion(
+ StringPiece path,
+ const string16& in_value) {
+ return SetWithoutPathExpansion(path, base::MakeUnique<base::Value>(in_value));
}
-void DictionaryValue::SetStringWithoutPathExpansion(StringPiece path,
- StringPiece in_value) {
- SetWithoutPathExpansion(path, base::MakeUnique<base::Value>(in_value));
+DictionaryValue* DictionaryValue::SetDictionaryWithoutPathExpansion(
+ StringPiece path,
+ std::unique_ptr<DictionaryValue> in_value) {
+ return static_cast<DictionaryValue*>(
+ SetWithoutPathExpansion(path, std::move(in_value)));
}
-void DictionaryValue::SetStringWithoutPathExpansion(StringPiece path,
- const string16& in_value) {
- SetWithoutPathExpansion(path, base::MakeUnique<base::Value>(in_value));
+ListValue* DictionaryValue::SetListWithoutPathExpansion(
+ StringPiece path,
+ std::unique_ptr<ListValue> in_value) {
+ return static_cast<ListValue*>(
+ SetWithoutPathExpansion(path, std::move(in_value)));
}
bool DictionaryValue::Get(StringPiece path,
« no previous file with comments | « base/values.h ('k') | base/values_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698