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

Unified Diff: net/interfaces/ip_address_struct_traits.h

Issue 2745643002: [net] Add a typemap for net::IPAddress (Closed)
Patch Set: resolve code review comments from dcheng Created 3 years, 9 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
Index: net/interfaces/ip_address_struct_traits.h
diff --git a/net/interfaces/ip_address_struct_traits.h b/net/interfaces/ip_address_struct_traits.h
new file mode 100644
index 0000000000000000000000000000000000000000..9c97baf8f6f11a02510769c9a406bb364d51f48a
--- /dev/null
+++ b/net/interfaces/ip_address_struct_traits.h
@@ -0,0 +1,24 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_INTERFACES_IP_ADDRESS_STRUCT_TRAITS_H_
+#define NET_INTERFACES_IP_ADDRESS_STRUCT_TRAITS_H_
+
+#include "mojo/public/cpp/bindings/struct_traits.h"
+#include "net/base/ip_address.h"
+#include "net/interfaces/ip_address.mojom.h"
+
+namespace mojo {
+template <>
+struct StructTraits<net::interfaces::IPAddressDataView, net::IPAddress> {
+ static const std::vector<uint8_t>& address(const net::IPAddress& ip_address) {
+ return ip_address.bytes();
+ }
+
+ static bool Read(net::interfaces::IPAddressDataView obj, net::IPAddress* out);
+};
+
+} // namespace mojo
+
+#endif // NET_INTERFACES_IP_ADDRESS_STRUCT_TRAITS_H_

Powered by Google App Engine
This is Rietveld 408576698