OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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_BASE_MOJO_NET_BASE_STRUCT_TRAITS_H_ |
| 6 #define NET_BASE_MOJO_NET_BASE_STRUCT_TRAITS_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "net/base/host_port_pair.h" |
| 11 |
| 12 namespace mojo { |
| 13 |
| 14 template <> |
| 15 struct StructTraits<net::mojom::HostPortPair, net::HostPortPair> { |
| 16 static const std::string& host(const net::HostPortPair& r) { |
| 17 return r.host(); |
| 18 } |
| 19 static uint16_t port(const net::HostPortPair& r) { return r.port(); } |
| 20 static bool Read(net::mojom::HostPortPairDataView data, |
| 21 net::HostPortPair* out) { |
| 22 std::string host; |
| 23 if (!data.ReadHost(&host)) |
| 24 return false; |
| 25 out->set_host(host); |
| 26 |
| 27 out->set_port(data.port()); |
| 28 return true; |
| 29 } |
| 30 }; |
| 31 |
| 32 } // namespace mojo |
| 33 |
| 34 #endif // NET_BASE_MOJO_NET_BASE_STRUCT_TRAITS_H_ |
OLD | NEW |