Chromium Code Reviews| Index: content/public/common/common_param_traits.cc |
| diff --git a/content/public/common/common_param_traits.cc b/content/public/common/common_param_traits.cc |
| index ab16aea1c8b530928d47b4cbc092321bfb2608ab..ef5299a839adadeb9b4df6904287fc98f2bcfc9c 100644 |
| --- a/content/public/common/common_param_traits.cc |
| +++ b/content/public/common/common_param_traits.cc |
| @@ -10,6 +10,7 @@ |
| #include "content/public/common/page_state.h" |
| #include "content/public/common/referrer.h" |
| #include "net/base/host_port_pair.h" |
| +#include "net/base/ip_address.h" |
| #include "net/base/ip_endpoint.h" |
| namespace IPC { |
| @@ -139,6 +140,28 @@ void ParamTraits<net::IPEndPoint>::Log(const param_type& p, std::string* l) { |
| LogParam("IPEndPoint:" + p.ToString(), l); |
| } |
| +void ParamTraits<net::IPAddress>::Write(Message* m, const param_type& p) { |
| + WriteParam(m, p.bytes()); |
| +} |
| + |
| +bool ParamTraits<net::IPAddress>::Read(const Message* m, |
| + base::PickleIterator* iter, |
| + param_type* p) { |
| + std::vector<uint8_t> bytes; |
| + if (!ReadParam(m, iter, &bytes)) |
| + return false; |
| + net::IPAddress address(&bytes.front(), bytes.size()); |
|
eroman
2015/12/21 20:47:33
This is not correct. bytes might be empty, in whic
martijnc
2016/01/27 22:50:52
Handled in a separate CL.
|
| + if (address.size() && !address.IsIPv4() && !address.IsIPv6()) { |
| + return false; |
| + } |
| + *p = address; |
| + return true; |
| +} |
| + |
| +void ParamTraits<net::IPAddress>::Log(const param_type& p, std::string* l) { |
| + LogParam("IPAddress:" + p.ToString(), l); |
| +} |
| + |
| void ParamTraits<content::PageState>::Write( |
| Message* m, const param_type& p) { |
| WriteParam(m, p.ToEncodedData()); |