diff options
author | estade <estade@chromium.org> | 2015-01-06 12:06:50 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-06 20:08:35 +0000 |
commit | ca798484cbd3b3b305bc02454d17d88d751c453c (patch) | |
tree | d85e6406e26bfb539c22540c06e94e96a93824af /base/values.cc | |
parent | ce64d99fa095ed688c06e3f0791e7d393ad9e691 (diff) | |
download | chromium_src-ca798484cbd3b3b305bc02454d17d88d751c453c.zip chromium_src-ca798484cbd3b3b305bc02454d17d88d751c453c.tar.gz chromium_src-ca798484cbd3b3b305bc02454d17d88d751c453c.tar.bz2 |
Add DictionaryValue::Set and ::SetWithoutPathExpansion functions
that take scoped_ptr.
Mark the non-scoped_ptr versions as deprecated. Update tests. Update one client.
BUG=446238
Review URL: https://codereview.chromium.org/829333004
Cr-Commit-Position: refs/heads/master@{#310121}
Diffstat (limited to 'base/values.cc')
-rw-r--r-- | base/values.cc | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/base/values.cc b/base/values.cc index 5d45ec3..b478b62 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)); |