Chromium Code Reviews| Index: remoting/host/chromoting_param_traits.cc |
| diff --git a/remoting/host/chromoting_param_traits.cc b/remoting/host/chromoting_param_traits.cc |
| index 89918aa8d2fb846ce0efdb819acc1e8e6213d32b..4a55274f5d8b5aff56be2f7bbf31f4327bffbbd2 100644 |
| --- a/remoting/host/chromoting_param_traits.cc |
| +++ b/remoting/host/chromoting_param_traits.cc |
| @@ -7,6 +7,7 @@ |
| #include <stdint.h> |
| #include "base/strings/stringprintf.h" |
| +#include "ipc/ipc_message_utils.h" |
| #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
| namespace IPC { |
| @@ -188,5 +189,56 @@ void ParamTraits<remoting::ScreenResolution>::Log( |
| p.dpi().x(), p.dpi().y())); |
| } |
| +// static |
| +void ParamTraits<net::IPAddress>::Write(base::Pickle* m, const param_type& p) { |
| + WriteParam(m, p.bytes()); |
| +} |
| + |
| +// static |
| +bool ParamTraits<net::IPAddress>::Read(const base::Pickle* m, |
| + base::PickleIterator* iter, |
| + param_type* p) { |
| + std::vector<uint8_t> bytes; |
| + if (!ReadParam(m, iter, &bytes)) |
| + return false; |
| + if (bytes.size() && bytes.size() != net::IPAddress::kIPv4AddressSize && |
| + bytes.size() != net::IPAddress::kIPv6AddressSize) { |
|
Wez
2016/04/05 17:08:01
This would be more readable as:
if (bytes.empty()
martijnc
2016/04/05 20:08:48
Done.
|
| + return false; |
| + } |
| + *p = net::IPAddress(bytes); |
| + return true; |
| +} |
| + |
| +// static |
| +void ParamTraits<net::IPAddress>::Log(const param_type& p, std::string* l) { |
| + l->append("IPAddress:" + (p.empty() ? "(empty)" : p.ToString())); |
| +} |
| + |
| +// static |
| +void ParamTraits<net::IPEndPoint>::Write(base::Pickle* m, const param_type& p) { |
| + WriteParam(m, p.address()); |
| + WriteParam(m, p.port()); |
| +} |
| + |
| +// static |
| +bool ParamTraits<net::IPEndPoint>::Read(const base::Pickle* m, |
| + base::PickleIterator* iter, |
| + param_type* p) { |
| + net::IPAddress address; |
| + uint16_t port; |
| + if (!ReadParam(m, iter, &address) || !ReadParam(m, iter, &port)) |
| + return false; |
| + if (!address.empty() && !address.IsValid()) |
|
Wez
2016/04/05 17:08:01
Similarly, this is painful to parse; better to hav
martijnc
2016/04/05 20:08:48
Done.
(the IPAddress should always be valid (or e
Wez
2016/04/05 20:12:27
The IPAddress ParamTraits doesn't seem to do an Is
martijnc
2016/04/05 21:16:29
Done.
|
| + return false; |
| + |
| + *p = net::IPEndPoint(address, port); |
| + return true; |
| +} |
| + |
| +// static |
| +void ParamTraits<net::IPEndPoint>::Log(const param_type& p, std::string* l) { |
| + l->append("IPEndPoint: " + p.ToString()); |
| +} |
| + |
| } // namespace IPC |