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

Side by Side Diff: net/proxy/mojo_proxy_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_PROXY_MOJO_PROXY_STRUCT_TRAITS_H_
6 #define NET_PROXY_MOJO_PROXY_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/base/host_port_pair.h"
12 #include "net/interfaces/proxy_resolver_service.mojom.h"
13 #include "net/proxy/proxy_info.h"
14 #include "net/proxy/proxy_list.h"
15 #include "net/proxy/proxy_server.h"
16
17 namespace net {
18 class ProxyInfo;
19 class ProxyServer;
20 }
21
22 namespace mojo {
23
24 template <>
25 struct EnumTraits<net::interfaces::ProxyScheme, net::ProxyServer::Scheme> {
26 static net::interfaces::ProxyScheme ToMojom(net::ProxyServer::Scheme scheme);
27 static bool FromMojom(net::interfaces::ProxyScheme scheme,
28 net::ProxyServer::Scheme* out);
29 };
30
31 template <>
32 struct StructTraits<net::interfaces::ProxyServerDataView, net::ProxyServer> {
33 static net::ProxyServer::Scheme scheme(const net::ProxyServer& s) {
34 return s.scheme();
35 }
36
37 static base::StringPiece host(const net::ProxyServer& s);
38 static uint16_t port(const net::ProxyServer& s);
39
40 static bool Read(net::interfaces::ProxyServerDataView data,
41 net::ProxyServer* out);
42 };
43
44 template <>
45 struct StructTraits<net::interfaces::ProxyInfoDataView, net::ProxyInfo> {
46 static const std::vector<net::ProxyServer>& proxy_servers(
47 const net::ProxyInfo& info) {
48 return info.proxy_list().GetAll();
49 }
50
51 static bool Read(net::interfaces::ProxyInfoDataView data,
52 net::ProxyInfo* out);
53 };
54
55 } // namespace mojo
56
57 #endif // NET_PROXY_MOJO_PROXY_STRUCT_TRAITS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698