OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> |
| 6 |
5 #include "mojo/services/network/net_address_type_converters.h" | 7 #include "mojo/services/network/net_address_type_converters.h" |
6 | 8 |
7 namespace mojo { | 9 namespace mojo { |
8 | 10 |
9 // static | 11 // static |
10 net::IPEndPoint TypeConverter<net::IPEndPoint, NetAddressPtr>::Convert( | 12 net::IPEndPoint TypeConverter<net::IPEndPoint, NetAddressPtr>::Convert( |
11 const NetAddressPtr& obj) { | 13 const NetAddressPtr& obj) { |
12 if (!obj) | 14 if (!obj) |
13 return net::IPEndPoint(); | 15 return net::IPEndPoint(); |
14 | 16 |
(...skipping 17 matching lines...) Expand all Loading... |
32 | 34 |
33 // static | 35 // static |
34 NetAddressPtr TypeConverter<NetAddressPtr, net::IPEndPoint>::Convert( | 36 NetAddressPtr TypeConverter<NetAddressPtr, net::IPEndPoint>::Convert( |
35 const net::IPEndPoint& obj) { | 37 const net::IPEndPoint& obj) { |
36 NetAddressPtr net_address(NetAddress::New()); | 38 NetAddressPtr net_address(NetAddress::New()); |
37 | 39 |
38 switch (obj.GetFamily()) { | 40 switch (obj.GetFamily()) { |
39 case net::ADDRESS_FAMILY_IPV4: | 41 case net::ADDRESS_FAMILY_IPV4: |
40 net_address->family = NET_ADDRESS_FAMILY_IPV4; | 42 net_address->family = NET_ADDRESS_FAMILY_IPV4; |
41 net_address->ipv4 = NetAddressIPv4::New(); | 43 net_address->ipv4 = NetAddressIPv4::New(); |
42 net_address->ipv4->port = static_cast<uint16>(obj.port()); | 44 net_address->ipv4->port = static_cast<uint16_t>(obj.port()); |
43 net_address->ipv4->addr = Array<uint8_t>::From(obj.address()); | 45 net_address->ipv4->addr = Array<uint8_t>::From(obj.address()); |
44 break; | 46 break; |
45 case NET_ADDRESS_FAMILY_IPV6: | 47 case NET_ADDRESS_FAMILY_IPV6: |
46 net_address->ipv6 = NetAddressIPv6::New(); | 48 net_address->ipv6 = NetAddressIPv6::New(); |
47 net_address->family = NET_ADDRESS_FAMILY_IPV6; | 49 net_address->family = NET_ADDRESS_FAMILY_IPV6; |
48 net_address->ipv6->port = static_cast<uint16>(obj.port()); | 50 net_address->ipv6->port = static_cast<uint16_t>(obj.port()); |
49 net_address->ipv6->addr = Array<uint8_t>::From(obj.address()); | 51 net_address->ipv6->addr = Array<uint8_t>::From(obj.address()); |
50 break; | 52 break; |
51 default: | 53 default: |
52 break; | 54 break; |
53 } | 55 } |
54 | 56 |
55 return net_address; | 57 return net_address; |
56 } | 58 } |
57 | 59 |
58 } // namespace mojo | 60 } // namespace mojo |
OLD | NEW |