OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/proxy/mojo_proxy_type_converters.h" | 5 #include "net/proxy/mojo_proxy_type_converters.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "net/base/host_port_pair.h" | 8 #include "net/base/host_port_pair.h" |
| 9 #include "net/proxy/proxy_info.h" |
9 #include "net/proxy/proxy_server.h" | 10 #include "net/proxy/proxy_server.h" |
10 | 11 |
11 namespace net { | 12 namespace net { |
12 namespace { | 13 namespace { |
13 | 14 |
14 interfaces::ProxyScheme ProxySchemeToMojo(ProxyServer::Scheme scheme) { | 15 interfaces::ProxyScheme ProxySchemeToMojo(ProxyServer::Scheme scheme) { |
15 switch (scheme) { | 16 switch (scheme) { |
16 case ProxyServer::SCHEME_INVALID: | 17 case ProxyServer::SCHEME_INVALID: |
17 return interfaces::PROXY_SCHEME_INVALID; | 18 return interfaces::PROXY_SCHEME_INVALID; |
18 case ProxyServer::SCHEME_DIRECT: | 19 case ProxyServer::SCHEME_DIRECT: |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 } | 74 } |
74 | 75 |
75 // static | 76 // static |
76 net::ProxyServer | 77 net::ProxyServer |
77 TypeConverter<net::ProxyServer, net::interfaces::ProxyServerPtr>::Convert( | 78 TypeConverter<net::ProxyServer, net::interfaces::ProxyServerPtr>::Convert( |
78 const net::interfaces::ProxyServerPtr& obj) { | 79 const net::interfaces::ProxyServerPtr& obj) { |
79 return net::ProxyServer(net::ProxySchemeFromMojo(obj->scheme), | 80 return net::ProxyServer(net::ProxySchemeFromMojo(obj->scheme), |
80 net::HostPortPair(obj->host, obj->port)); | 81 net::HostPortPair(obj->host, obj->port)); |
81 } | 82 } |
82 | 83 |
| 84 // static |
| 85 net::ProxyInfo |
| 86 TypeConverter<net::ProxyInfo, mojo::Array<net::interfaces::ProxyServerPtr>>:: |
| 87 Convert(const mojo::Array<net::interfaces::ProxyServerPtr>& obj) { |
| 88 net::ProxyList proxy_list; |
| 89 for (size_t i = 0; i < obj.size(); i++) { |
| 90 proxy_list.AddProxyServer(obj[i].To<net::ProxyServer>()); |
| 91 } |
| 92 net::ProxyInfo info; |
| 93 info.UseProxyList(proxy_list); |
| 94 return info; |
| 95 } |
| 96 |
83 } // namespace mojo | 97 } // namespace mojo |
OLD | NEW |