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

Unified Diff: base/json/json_parser.cc

Issue 21030009: Make element removal methods in DictionaryValue and ListValue take scoped_ptr's as outparams. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 7 years, 4 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/debug/trace_event_unittest.cc ('k') | base/json/json_reader_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/json/json_parser.cc
diff --git a/base/json/json_parser.cc b/base/json/json_parser.cc
index 4eb9e9a66277ccc0f50fa325f8867e859123c855..f1f43337c408663f68bde52856616a07b259638a 100644
--- a/base/json/json_parser.cc
+++ b/base/json/json_parser.cc
@@ -56,7 +56,7 @@ class DictionaryHiddenRootValue : public base::DictionaryValue {
// the method below.
virtual bool RemoveWithoutPathExpansion(const std::string& key,
- Value** out) OVERRIDE {
+ scoped_ptr<Value>* out) OVERRIDE {
// If the caller won't take ownership of the removed value, just call up.
if (!out)
return DictionaryValue::RemoveWithoutPathExpansion(key, out);
@@ -65,12 +65,11 @@ class DictionaryHiddenRootValue : public base::DictionaryValue {
// Otherwise, remove the value while its still "owned" by this and copy it
// to convert any JSONStringValues to std::string.
- Value* out_owned = NULL;
+ scoped_ptr<Value> out_owned;
if (!DictionaryValue::RemoveWithoutPathExpansion(key, &out_owned))
return false;
- *out = out_owned->DeepCopy();
- delete out_owned;
+ out->reset(out_owned->DeepCopy());
return true;
}
@@ -103,7 +102,7 @@ class ListHiddenRootValue : public base::ListValue {
ListValue::Swap(copy.get());
}
- virtual bool Remove(size_t index, Value** out) OVERRIDE {
+ virtual bool Remove(size_t index, scoped_ptr<Value>* out) OVERRIDE {
// If the caller won't take ownership of the removed value, just call up.
if (!out)
return ListValue::Remove(index, out);
@@ -112,12 +111,11 @@ class ListHiddenRootValue : public base::ListValue {
// Otherwise, remove the value while its still "owned" by this and copy it
// to convert any JSONStringValues to std::string.
- Value* out_owned = NULL;
+ scoped_ptr<Value> out_owned;
if (!ListValue::Remove(index, &out_owned))
return false;
- *out = out_owned->DeepCopy();
- delete out_owned;
+ out->reset(out_owned->DeepCopy());
return true;
}
« no previous file with comments | « base/debug/trace_event_unittest.cc ('k') | base/json/json_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698