Index: ipc/ipc_message_utils.cc |
diff --git a/ipc/ipc_message_utils.cc b/ipc/ipc_message_utils.cc |
index 0060f867277aa207fb106a937d292acab0723155..acd147048cbd1f5f4e4163ff0036c2dd4a63c195 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" |
@@ -636,6 +637,51 @@ void ParamTraits<base::DictionaryValue>::Log(const param_type& p, |
l->append(json); |
} |
+void ParamTraits<std::unique_ptr<base::Value>>::GetSize( |
+ base::PickleSizer* sizer, |
+ const param_type& p) { |
+ bool valid = !!p; |
+ GetParamSize(sizer, valid); |
+ if (valid) |
+ GetValueSize(sizer, p.get(), 0); |
+} |
+ |
+void ParamTraits<std::unique_ptr<base::Value>>::Write(base::Pickle* m, |
+ const param_type& p) { |
+ bool valid = !!p; |
+ WriteParam(m, valid); |
+ if (valid) |
+ WriteValue(m, p.get(), 0); |
+} |
+ |
+bool ParamTraits<std::unique_ptr<base::Value>>::Read(const base::Pickle* m, |
+ base::PickleIterator* iter, |
+ param_type* r) { |
+ bool valid = false; |
+ if (!ReadParam(m, iter, &valid)) |
+ return false; |
+ |
+ if (!valid) { |
+ r->reset(); |
+ return true; |
+ } |
+ |
+ base::Value* temp = nullptr; |
+ if (!ReadValue(m, iter, &temp, 0)) |
+ return false; |
+ |
+ *r = base::WrapUnique(temp); |
+ return true; |
+} |
+ |
+void ParamTraits<std::unique_ptr<base::Value>>::Log(const param_type& p, |
+ std::string* l) { |
+ std::string json = "nullptr"; |
yzshen1
2016/11/03 21:59:24
nit: maybe default to empty and only set "nullptr"
|
+ if (p.get()) |
+ base::JSONWriter::Write(*p, &json); |
+ l->append(json); |
+} |
+ |
#if defined(OS_POSIX) |
void ParamTraits<base::FileDescriptor>::GetSize(base::PickleSizer* sizer, |
const param_type& p) { |