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

Side by Side Diff: net/dns/mojo_host_struct_traits.h

Issue 2083463002: Replace //net TypeConverters with StructTraits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@type-converter-cleanup--gurl
Patch Set: rebase Created 4 years, 2 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef NET_DNS_MOJO_HOST_STRUCT_TRAITS_H_
6 #define NET_DNS_MOJO_HOST_STRUCT_TRAITS_H_
7
8 #include "base/strings/string_piece.h"
9 #include "mojo/public/cpp/bindings/enum_traits.h"
10 #include "mojo/public/cpp/bindings/struct_traits.h"
11 #include "net/dns/host_resolver.h"
12 #include "net/interfaces/host_resolver_service.mojom.h"
13
14 namespace mojo {
15
16 template <>
17 struct EnumTraits<net::interfaces::AddressFamily, net::AddressFamily> {
18 static net::interfaces::AddressFamily ToMojom(
19 net::AddressFamily address_family);
20 static bool FromMojom(net::interfaces::AddressFamily address_family,
21 net::AddressFamily* out);
22 };
23
24 template <>
25 struct StructTraits<net::interfaces::HostResolverRequestInfoDataView,
26 std::unique_ptr<net::HostResolver::RequestInfo>> {
27 static base::StringPiece host(
28 const std::unique_ptr<net::HostResolver::RequestInfo>& obj) {
29 return obj->hostname();
30 }
31
32 static uint16_t port(
33 const std::unique_ptr<net::HostResolver::RequestInfo>& obj) {
34 return obj->port();
35 }
36
37 static net::AddressFamily address_family(
38 const std::unique_ptr<net::HostResolver::RequestInfo>& obj) {
39 return obj->address_family();
40 }
41
42 static bool is_my_ip_address(
43 const std::unique_ptr<net::HostResolver::RequestInfo>& obj) {
44 return obj->is_my_ip_address();
45 }
46
47 static bool Read(net::interfaces::HostResolverRequestInfoDataView obj,
48 std::unique_ptr<net::HostResolver::RequestInfo>* output);
49 };
50
51 template <>
52 struct StructTraits<net::interfaces::IPEndPointDataView, net::IPEndPoint> {
53 static const std::vector<uint8_t>& address(const net::IPEndPoint& obj) {
54 return obj.address().bytes();
55 }
56 static uint16_t port(const net::IPEndPoint& obj) { return obj.port(); }
57
58 static bool Read(net::interfaces::IPEndPointDataView obj,
59 net::IPEndPoint* out);
60 };
61
62 template <>
63 struct StructTraits<net::interfaces::AddressListDataView, net::AddressList> {
64 static std::vector<net::IPEndPoint> addresses(const net::AddressList& obj) {
65 return obj.endpoints();
66 }
67
68 static bool Read(net::interfaces::AddressListDataView data,
69 net::AddressList* out);
70 };
71
72 } // namespace mojo
73
74 #endif // NET_DNS_MOJO_HOST_STRUCT_TRAITS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698