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

Unified Diff: remoting/host/chromoting_param_traits.cc

Issue 1853643007: Migrate remoting to net::IPAddress. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments wez Created 4 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 | « remoting/host/chromoting_param_traits.h ('k') | remoting/host/daemon_process.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a440c3492754ed8fc028e2c38249067c94514323 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,55 @@ 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;
+
+ net::IPAddress address(bytes);
+ if (address.empty() || address.IsValid()) {
+ *p = address;
+ return true;
+ }
+ return false;
+}
+
+// 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;
+
+ *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
« no previous file with comments | « remoting/host/chromoting_param_traits.h ('k') | remoting/host/daemon_process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698