OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef PPAPI_SHARED_IMPL_PRIVATE_NET_ADDRESS_PRIVATE_IMPL_H_ | 5 #ifndef PPAPI_SHARED_IMPL_PRIVATE_NET_ADDRESS_PRIVATE_IMPL_H_ |
6 #define PPAPI_SHARED_IMPL_PRIVATE_NET_ADDRESS_PRIVATE_IMPL_H_ | 6 #define PPAPI_SHARED_IMPL_PRIVATE_NET_ADDRESS_PRIVATE_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "ppapi/c/dev/ppb_net_address_dev.h" | |
12 #include "ppapi/c/pp_stdint.h" | 13 #include "ppapi/c/pp_stdint.h" |
13 #include "ppapi/shared_impl/ppapi_shared_export.h" | 14 #include "ppapi/shared_impl/ppapi_shared_export.h" |
14 | 15 |
15 struct PP_NetAddress_Private; | 16 struct PP_NetAddress_Private; |
16 struct sockaddr; | 17 struct sockaddr; |
17 | 18 |
18 namespace ppapi { | 19 namespace ppapi { |
19 | 20 |
20 class PPAPI_SHARED_EXPORT NetAddressPrivateImpl { | 21 class PPAPI_SHARED_EXPORT NetAddressPrivateImpl { |
21 public: | 22 public: |
22 static bool ValidateNetAddress(const PP_NetAddress_Private& addr); | 23 static bool ValidateNetAddress(const PP_NetAddress_Private& addr); |
23 | 24 |
24 static bool SockaddrToNetAddress(const sockaddr* sa, | 25 static bool SockaddrToNetAddress(const sockaddr* sa, |
25 uint32_t sa_length, | 26 uint32_t sa_length, |
26 PP_NetAddress_Private* net_addr); | 27 PP_NetAddress_Private* net_addr); |
27 | 28 |
28 static bool IPEndPointToNetAddress(const std::vector<unsigned char>& address, | 29 static bool IPEndPointToNetAddress(const std::vector<unsigned char>& address, |
29 int port, | 30 int port, |
30 PP_NetAddress_Private* net_addr); | 31 PP_NetAddress_Private* net_addr); |
31 | 32 |
32 static bool NetAddressToIPEndPoint(const PP_NetAddress_Private& net_addr, | 33 static bool NetAddressToIPEndPoint(const PP_NetAddress_Private& net_addr, |
33 std::vector<unsigned char>* address, | 34 std::vector<unsigned char>* address, |
34 int* port); | 35 int* port); |
35 | 36 |
36 static std::string DescribeNetAddress(const PP_NetAddress_Private& addr, | 37 static std::string DescribeNetAddress(const PP_NetAddress_Private& addr, |
37 bool include_port); | 38 bool include_port); |
38 | 39 |
40 // Conversion methods to make PPB_NetAddress_Dev resource work with | |
41 // PP_NetAddress_Private. | |
42 // TODO(yzshen): Remove them once PPB_NetAddress_Dev resource doesn't use | |
43 // PP_NetAddress_Private as storage type. | |
44 static void CreateNetAddressPrivateFromIPv4Address( | |
bbudge
2013/06/06 19:01:10
Could we use method overloading to avoid the "From
yzshen1
2013/06/06 20:57:15
I think the style guide prefers not to use overloa
| |
45 const PP_NetAddress_IPv4_Dev& ipv4_addr, | |
46 PP_NetAddress_Private* addr); | |
47 static void CreateNetAddressPrivateFromIPv6Address( | |
48 const PP_NetAddress_IPv6_Dev& ipv6_addr, | |
49 PP_NetAddress_Private* addr); | |
50 static PP_NetAddress_Family_Dev GetFamilyFromNetAddressPrivate( | |
51 const PP_NetAddress_Private& addr); | |
52 static bool DescribeNetAddressPrivateAsIPv4Address( | |
53 const PP_NetAddress_Private& addr, | |
54 PP_NetAddress_IPv4_Dev* ipv4_addr); | |
55 static bool DescribeNetAddressPrivateAsIPv6Address( | |
56 const PP_NetAddress_Private& addr, | |
57 PP_NetAddress_IPv6_Dev* ipv6_addr); | |
58 | |
39 static const PP_NetAddress_Private kInvalidNetAddress; | 59 static const PP_NetAddress_Private kInvalidNetAddress; |
40 | 60 |
41 private: | 61 private: |
42 DISALLOW_IMPLICIT_CONSTRUCTORS(NetAddressPrivateImpl); | 62 DISALLOW_IMPLICIT_CONSTRUCTORS(NetAddressPrivateImpl); |
43 }; | 63 }; |
44 | 64 |
45 } // namespace ppapi | 65 } // namespace ppapi |
46 | 66 |
47 #endif // PPAPI_SHARED_IMPL_PRIVATE_NET_ADDRESS_PRIVATE_IMPL_H_ | 67 #endif // PPAPI_SHARED_IMPL_PRIVATE_NET_ADDRESS_PRIVATE_IMPL_H_ |
OLD | NEW |