| Index: net/proxy/mojo_proxy_struct_traits.h
|
| diff --git a/net/proxy/mojo_proxy_struct_traits.h b/net/proxy/mojo_proxy_struct_traits.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f48d7e8124f74e0ac26741740107d7300d4c4ba9
|
| --- /dev/null
|
| +++ b/net/proxy/mojo_proxy_struct_traits.h
|
| @@ -0,0 +1,70 @@
|
| +// Copyright 2015 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_PROXY_MOJO_PROXY_STRUCT_TRAITS_H_
|
| +#define NET_PROXY_MOJO_PROXY_STRUCT_TRAITS_H_
|
| +
|
| +#include "base/strings/string_piece.h"
|
| +#include "mojo/public/cpp/bindings/enum_traits.h"
|
| +#include "mojo/public/cpp/bindings/struct_traits.h"
|
| +#include "net/base/host_port_pair.h"
|
| +#include "net/interfaces/proxy_resolver_service.mojom.h"
|
| +#include "net/proxy/proxy_info.h"
|
| +#include "net/proxy/proxy_list.h"
|
| +#include "net/proxy/proxy_server.h"
|
| +
|
| +namespace net {
|
| +class ProxyInfo;
|
| +class ProxyServer;
|
| +}
|
| +
|
| +namespace mojo {
|
| +
|
| +template <>
|
| +struct EnumTraits<net::interfaces::ProxyScheme, net::ProxyServer::Scheme> {
|
| + static net::interfaces::ProxyScheme ToMojom(net::ProxyServer::Scheme scheme);
|
| + static bool FromMojom(net::interfaces::ProxyScheme scheme,
|
| + net::ProxyServer::Scheme* out);
|
| +};
|
| +
|
| +template <>
|
| +struct StructTraits<net::interfaces::ProxyServer, net::ProxyServer> {
|
| + static net::ProxyServer::Scheme scheme(const net::ProxyServer& s) {
|
| + return s.scheme();
|
| + }
|
| +
|
| + static base::StringPiece host(const net::ProxyServer& s) {
|
| + if (s.scheme() == net::ProxyServer::SCHEME_DIRECT ||
|
| + s.scheme() == net::ProxyServer::SCHEME_INVALID) {
|
| + return base::StringPiece();
|
| + }
|
| + return s.host_port_pair().host();
|
| + }
|
| +
|
| + static uint16_t port(const net::ProxyServer& s) {
|
| + if (s.scheme() == net::ProxyServer::SCHEME_DIRECT ||
|
| + s.scheme() == net::ProxyServer::SCHEME_INVALID) {
|
| + return 0;
|
| + }
|
| + return s.host_port_pair().port();
|
| + }
|
| +
|
| + static bool Read(net::interfaces::ProxyServerDataView data,
|
| + net::ProxyServer* out);
|
| +};
|
| +
|
| +template <>
|
| +struct StructTraits<net::interfaces::ProxyInfo, net::ProxyInfo> {
|
| + static const std::vector<net::ProxyServer>& proxy_servers(
|
| + const net::ProxyInfo& info) {
|
| + return info.proxy_list().GetAll();
|
| + }
|
| +
|
| + static bool Read(net::interfaces::ProxyInfoDataView data,
|
| + net::ProxyInfo* out);
|
| +};
|
| +
|
| +} // namespace mojo
|
| +
|
| +#endif // NET_PROXY_MOJO_PROXY_STRUCT_TRAITS_H_
|
|
|