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

Unified Diff: base/values.cc

Issue 839143002: Roll Chrome into Mojo. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Rebase Created 5 years, 11 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 5d45ec36c5551b6e72083d1f5f5736d69dd5bebc..b478b620ca56b0e2a3ed13ff2a007841dd5d9de7 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -371,7 +371,7 @@ void DictionaryValue::Clear() {
dictionary_.clear();
}
-void DictionaryValue::Set(const std::string& path, Value* in_value) {
+void DictionaryValue::Set(const std::string& path, scoped_ptr<Value> in_value) {
DCHECK(IsStringUTF8(path));
DCHECK(in_value);
@@ -392,7 +392,11 @@ void DictionaryValue::Set(const std::string& path, Value* in_value) {
current_path.erase(0, delimiter_position + 1);
}
- current_dictionary->SetWithoutPathExpansion(current_path, in_value);
+ current_dictionary->SetWithoutPathExpansion(current_path, in_value.Pass());
+}
+
+void DictionaryValue::Set(const std::string& path, Value* in_value) {
+ Set(path, make_scoped_ptr(in_value));
}
void DictionaryValue::SetBoolean(const std::string& path, bool in_value) {
@@ -418,18 +422,24 @@ void DictionaryValue::SetString(const std::string& path,
}
void DictionaryValue::SetWithoutPathExpansion(const std::string& key,
- Value* in_value) {
+ scoped_ptr<Value> in_value) {
+ Value* bare_ptr = in_value.release();
// If there's an existing value here, we need to delete it, because
// we own all our children.
std::pair<ValueMap::iterator, bool> ins_res =
- dictionary_.insert(std::make_pair(key, in_value));
+ dictionary_.insert(std::make_pair(key, bare_ptr));
if (!ins_res.second) {
- DCHECK_NE(ins_res.first->second, in_value); // This would be bogus
+ DCHECK_NE(ins_res.first->second, bare_ptr); // This would be bogus
delete ins_res.first->second;
- ins_res.first->second = in_value;
+ ins_res.first->second = bare_ptr;
}
}
+void DictionaryValue::SetWithoutPathExpansion(const std::string& key,
+ Value* in_value) {
+ SetWithoutPathExpansion(key, make_scoped_ptr(in_value));
+}
+
void DictionaryValue::SetBooleanWithoutPathExpansion(
const std::string& path, bool in_value) {
SetWithoutPathExpansion(path, new FundamentalValue(in_value));
« 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