OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_CPP_DEV_NET_ADDRESS_DEV_H_ | 5 #ifndef PPAPI_CPP_NET_ADDRESS_H_ |
6 #define PPAPI_CPP_DEV_NET_ADDRESS_DEV_H_ | 6 #define PPAPI_CPP_NET_ADDRESS_H_ |
7 | 7 |
8 #include "ppapi/c/dev/ppb_net_address_dev.h" | 8 #include "ppapi/c/ppb_net_address.h" |
9 #include "ppapi/cpp/pass_ref.h" | 9 #include "ppapi/cpp/pass_ref.h" |
10 #include "ppapi/cpp/resource.h" | 10 #include "ppapi/cpp/resource.h" |
11 #include "ppapi/cpp/var.h" | 11 #include "ppapi/cpp/var.h" |
12 | 12 |
13 namespace pp { | 13 namespace pp { |
14 | 14 |
15 class InstanceHandle; | 15 class InstanceHandle; |
16 | 16 |
17 /// The <code>NetAddress_Dev</code> class represents a network address. | 17 /// The <code>NetAddress</code> class represents a network address. |
18 class NetAddress_Dev : public Resource { | 18 class NetAddress : public Resource { |
19 public: | 19 public: |
20 /// Default constructor for creating an is_null() <code>NetAddress_Dev</code> | 20 /// Default constructor for creating an is_null() <code>NetAddress</code> |
21 /// object. | 21 /// object. |
22 NetAddress_Dev(); | 22 NetAddress(); |
23 | 23 |
24 /// A constructor used when you have received a <code>PP_Resource</code> as a | 24 /// A constructor used when you have received a <code>PP_Resource</code> as a |
25 /// return value that has had 1 ref added for you. | 25 /// return value that has had 1 ref added for you. |
26 /// | 26 /// |
27 /// @param[in] resource A <code>PPB_NetAddress_Dev</code> resource. | 27 /// @param[in] resource A <code>PPB_NetAddress</code> resource. |
28 NetAddress_Dev(PassRef, PP_Resource resource); | 28 NetAddress(PassRef, PP_Resource resource); |
29 | 29 |
30 /// A constructor used to create a <code>NetAddress_Dev</code> object with the | 30 /// A constructor used to create a <code>NetAddress</code> object with the |
31 /// specified IPv4 address. | 31 /// specified IPv4 address. |
32 /// | 32 /// |
33 /// @param[in] instance The instance with which this resource will be | 33 /// @param[in] instance The instance with which this resource will be |
34 /// associated. | 34 /// associated. |
35 /// @param[in] ipv4_addr An IPv4 address. | 35 /// @param[in] ipv4_addr An IPv4 address. |
36 NetAddress_Dev(const InstanceHandle& instance, | 36 NetAddress(const InstanceHandle& instance, |
37 const PP_NetAddress_IPv4_Dev& ipv4_addr); | 37 const PP_NetAddress_IPv4& ipv4_addr); |
38 | 38 |
39 /// A constructor used to create a <code>NetAddress_Dev</code> object with the | 39 /// A constructor used to create a <code>NetAddress</code> object with the |
40 /// specified IPv6 address. | 40 /// specified IPv6 address. |
41 /// | 41 /// |
42 /// @param[in] instance The instance with which this resource will be | 42 /// @param[in] instance The instance with which this resource will be |
43 /// associated. | 43 /// associated. |
44 /// @param[in] ipv6_addr An IPv6 address. | 44 /// @param[in] ipv6_addr An IPv6 address. |
45 NetAddress_Dev(const InstanceHandle& instance, | 45 NetAddress(const InstanceHandle& instance, |
46 const PP_NetAddress_IPv6_Dev& ipv6_addr); | 46 const PP_NetAddress_IPv6& ipv6_addr); |
47 | 47 |
48 /// The copy constructor for <code>NetAddress_Dev</code>. | 48 /// The copy constructor for <code>NetAddress</code>. |
49 /// | 49 /// |
50 /// @param[in] other A reference to another <code>NetAddress_Dev</code>. | 50 /// @param[in] other A reference to another <code>NetAddress</code>. |
51 NetAddress_Dev(const NetAddress_Dev& other); | 51 NetAddress(const NetAddress& other); |
52 | 52 |
53 /// The destructor. | 53 /// The destructor. |
54 virtual ~NetAddress_Dev(); | 54 virtual ~NetAddress(); |
55 | 55 |
56 /// The assignment operator for <code>NetAddress_Dev</code>. | 56 /// The assignment operator for <code>NetAddress</code>. |
57 /// | 57 /// |
58 /// @param[in] other A reference to another <code>NetAddress_Dev</code>. | 58 /// @param[in] other A reference to another <code>NetAddress</code>. |
59 /// | 59 /// |
60 /// @return A reference to this <code>NetAddress_Dev</code> object. | 60 /// @return A reference to this <code>NetAddress</code> object. |
61 NetAddress_Dev& operator=(const NetAddress_Dev& other); | 61 NetAddress& operator=(const NetAddress& other); |
62 | 62 |
63 /// Static function for determining whether the browser supports the | 63 /// Static function for determining whether the browser supports the |
64 /// <code>PPB_NetAddress_Dev</code> interface. | 64 /// <code>PPB_NetAddress</code> interface. |
65 /// | 65 /// |
66 /// @return true if the interface is available, false otherwise. | 66 /// @return true if the interface is available, false otherwise. |
67 static bool IsAvailable(); | 67 static bool IsAvailable(); |
68 | 68 |
69 /// Gets the address family. | 69 /// Gets the address family. |
70 /// | 70 /// |
71 /// @return The address family on success; | 71 /// @return The address family on success; |
72 /// <code>PP_NETADDRESS_FAMILY_UNSPECIFIED</code> on failure. | 72 /// <code>PP_NETADDRESS_FAMILY_UNSPECIFIED</code> on failure. |
73 PP_NetAddress_Family_Dev GetFamily() const; | 73 PP_NetAddress_Family GetFamily() const; |
74 | 74 |
75 /// Returns a human-readable description of the network address. The | 75 /// Returns a human-readable description of the network address. The |
76 /// description is in the form of host [ ":" port ] and conforms to | 76 /// description is in the form of host [ ":" port ] and conforms to |
77 /// http://tools.ietf.org/html/rfc3986#section-3.2 for IPv4 and IPv6 addresses | 77 /// http://tools.ietf.org/html/rfc3986#section-3.2 for IPv4 and IPv6 addresses |
78 /// (e.g., "192.168.0.1", "192.168.0.1:99", or "[::1]:80"). | 78 /// (e.g., "192.168.0.1", "192.168.0.1:99", or "[::1]:80"). |
79 /// | 79 /// |
80 /// @param[in] include_port Whether to include the port number in the | 80 /// @param[in] include_port Whether to include the port number in the |
81 /// description. | 81 /// description. |
82 /// | 82 /// |
83 /// @return A string <code>Var</code> on success; an undefined | 83 /// @return A string <code>Var</code> on success; an undefined |
84 /// <code>Var</code> on failure. | 84 /// <code>Var</code> on failure. |
85 Var DescribeAsString(bool include_port) const; | 85 Var DescribeAsString(bool include_port) const; |
86 | 86 |
87 /// Fills a <code>PP_NetAddress_IPv4_Dev</code> structure if the network | 87 /// Fills a <code>PP_NetAddress_IPv4</code> structure if the network address |
88 /// address is of <code>PP_NETADDRESS_FAMILY_IPV4</code> address family. | 88 /// is of <code>PP_NETADDRESS_FAMILY_IPV4</code> address family. |
89 /// Note that passing a network address of | 89 /// Note that passing a network address of |
90 /// <code>PP_NETADDRESS_FAMILY_IPV6</code> address family will fail even if | 90 /// <code>PP_NETADDRESS_FAMILY_IPV6</code> address family will fail even if |
91 /// the address is an IPv4-mapped IPv6 address. | 91 /// the address is an IPv4-mapped IPv6 address. |
92 /// | 92 /// |
93 /// @param[out] ipv4_addr A <code>PP_NetAddress_IPv4_Dev</code> structure to | 93 /// @param[out] ipv4_addr A <code>PP_NetAddress_IPv4</code> structure to store |
94 /// store the result. | 94 /// the result. |
95 /// | 95 /// |
96 /// @return A boolean value indicating whether the operation succeeded. | 96 /// @return A boolean value indicating whether the operation succeeded. |
97 bool DescribeAsIPv4Address(PP_NetAddress_IPv4_Dev* ipv4_addr) const; | 97 bool DescribeAsIPv4Address(PP_NetAddress_IPv4* ipv4_addr) const; |
98 | 98 |
99 /// Fills a <code>PP_NetAddress_IPv6_Dev</code> structure if the network | 99 /// Fills a <code>PP_NetAddress_IPv6</code> structure if the network address |
100 /// address is of <code>PP_NETADDRESS_FAMILY_IPV6</code> address family. | 100 /// is of <code>PP_NETADDRESS_FAMILY_IPV6</code> address family. |
101 /// Note that passing a network address of | 101 /// Note that passing a network address of |
102 /// <code>PP_NETADDRESS_FAMILY_IPV4</code> address family will fail - this | 102 /// <code>PP_NETADDRESS_FAMILY_IPV4</code> address family will fail - this |
103 /// method doesn't map it to an IPv6 address. | 103 /// method doesn't map it to an IPv6 address. |
104 /// | 104 /// |
105 /// @param[out] ipv6_addr A <code>PP_NetAddress_IPv6_Dev</code> structure to | 105 /// @param[out] ipv6_addr A <code>PP_NetAddress_IPv6</code> structure to store |
106 /// store the result. | 106 /// the result. |
107 /// | 107 /// |
108 /// @return A boolean value indicating whether the operation succeeded. | 108 /// @return A boolean value indicating whether the operation succeeded. |
109 bool DescribeAsIPv6Address(PP_NetAddress_IPv6_Dev* ipv6_addr) const; | 109 bool DescribeAsIPv6Address(PP_NetAddress_IPv6* ipv6_addr) const; |
110 }; | 110 }; |
111 | 111 |
112 } // namespace pp | 112 } // namespace pp |
113 | 113 |
114 #endif // PPAPI_CPP_DEV_NET_ADDRESS_DEV_H_ | 114 #endif // PPAPI_CPP_NET_ADDRESS_H_ |
OLD | NEW |