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