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

Unified Diff: ipc/ipc_message_utils.cc

Issue 2838893002: Remove base::ListValue::Set(size_t, base::Value*) (Closed)
Patch Set: Fix Compilation Error 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 | « ipc/ipc_message_unittest.cc ('k') | tools/ipc_fuzzer/fuzzer/fuzzer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_message_utils.cc
diff --git a/ipc/ipc_message_utils.cc b/ipc/ipc_message_utils.cc
index 9a8630dcc574a7819fb9f38414b66ef65acc5e61..8053318110d78f2eda9b81f9721a9070c59f6c29 100644
--- a/ipc/ipc_message_utils.cc
+++ b/ipc/ipc_message_utils.cc
@@ -9,6 +9,7 @@
#include "base/files/file_path.h"
#include "base/json/json_writer.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/nullable_string16.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
@@ -71,7 +72,7 @@ void LogBytes(const std::vector<CharType>& data, std::string* out) {
bool ReadValue(const base::Pickle* m,
base::PickleIterator* iter,
- base::Value** value,
+ std::unique_ptr<base::Value>* value,
int recursion);
void GetValueSize(base::PickleSizer* sizer,
@@ -218,11 +219,11 @@ bool ReadDictionaryValue(const base::Pickle* m,
for (int i = 0; i < size; ++i) {
std::string key;
- base::Value* subval;
+ std::unique_ptr<base::Value> subval;
if (!ReadParam(m, iter, &key) ||
!ReadValue(m, iter, &subval, recursion + 1))
return false;
- value->SetWithoutPathExpansion(key, subval);
+ value->SetWithoutPathExpansion(key, std::move(subval));
}
return true;
@@ -239,10 +240,10 @@ bool ReadListValue(const base::Pickle* m,
return false;
for (int i = 0; i < size; ++i) {
- base::Value* subval;
+ std::unique_ptr<base::Value> subval;
if (!ReadValue(m, iter, &subval, recursion + 1))
return false;
- value->Set(i, subval);
+ value->Set(i, std::move(subval));
}
return true;
@@ -250,7 +251,7 @@ bool ReadListValue(const base::Pickle* m,
bool ReadValue(const base::Pickle* m,
base::PickleIterator* iter,
- base::Value** value,
+ std::unique_ptr<base::Value>* value,
int recursion) {
if (recursion > kMaxRecursionDepth) {
LOG(ERROR) << "Max recursion depth hit in ReadValue.";
@@ -263,34 +264,34 @@ bool ReadValue(const base::Pickle* m,
switch (static_cast<base::Value::Type>(type)) {
case base::Value::Type::NONE:
- *value = new base::Value();
+ *value = base::MakeUnique<base::Value>();
break;
case base::Value::Type::BOOLEAN: {
bool val;
if (!ReadParam(m, iter, &val))
return false;
- *value = new base::Value(val);
+ *value = base::MakeUnique<base::Value>(val);
break;
}
case base::Value::Type::INTEGER: {
int val;
if (!ReadParam(m, iter, &val))
return false;
- *value = new base::Value(val);
+ *value = base::MakeUnique<base::Value>(val);
break;
}
case base::Value::Type::DOUBLE: {
double val;
if (!ReadParam(m, iter, &val))
return false;
- *value = new base::Value(val);
+ *value = base::MakeUnique<base::Value>(val);
break;
}
case base::Value::Type::STRING: {
std::string val;
if (!ReadParam(m, iter, &val))
return false;
- *value = new base::Value(val);
+ *value = base::MakeUnique<base::Value>(std::move(val));
break;
}
case base::Value::Type::BINARY: {
@@ -298,23 +299,21 @@ bool ReadValue(const base::Pickle* m,
int length;
if (!iter->ReadData(&data, &length))
return false;
- std::unique_ptr<base::Value> val =
- base::Value::CreateWithCopiedBuffer(data, length);
- *value = val.release();
+ *value = base::Value::CreateWithCopiedBuffer(data, length);
break;
}
case base::Value::Type::DICTIONARY: {
- std::unique_ptr<base::DictionaryValue> val(new base::DictionaryValue());
- if (!ReadDictionaryValue(m, iter, val.get(), recursion))
+ base::DictionaryValue val;
+ if (!ReadDictionaryValue(m, iter, &val, recursion))
return false;
- *value = val.release();
+ *value = base::MakeUnique<base::Value>(std::move(val));
break;
}
case base::Value::Type::LIST: {
- std::unique_ptr<base::ListValue> val(new base::ListValue());
- if (!ReadListValue(m, iter, val.get(), recursion))
+ base::ListValue val;
+ if (!ReadListValue(m, iter, &val, recursion))
return false;
- *value = val.release();
+ *value = base::MakeUnique<base::Value>(std::move(val));
break;
}
default:
« no previous file with comments | « ipc/ipc_message_unittest.cc ('k') | tools/ipc_fuzzer/fuzzer/fuzzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698