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

Unified Diff: content/public/common/common_param_traits.cc

Issue 1534583002: Migrate Local Discovery from net::IPAddressNumber to net::IPAddress. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
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());

Powered by Google App Engine
This is Rietveld 408576698