[email protected] | 0edbfc8 | 2013-06-14 06:15:39 | [diff] [blame] | 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 | |
[email protected] | c54f81b | 2013-06-24 06:05:39 | [diff] [blame] | 6 | /* From ppb_host_resolver.idl modified Sat Jun 22 11:11:38 2013. */ |
[email protected] | 0edbfc8 | 2013-06-14 06:15:39 | [diff] [blame] | 7 | |
[email protected] | c54f81b | 2013-06-24 06:05:39 | [diff] [blame] | 8 | #ifndef PPAPI_C_PPB_HOST_RESOLVER_H_ |
| 9 | #define PPAPI_C_PPB_HOST_RESOLVER_H_ |
[email protected] | 0edbfc8 | 2013-06-14 06:15:39 | [diff] [blame] | 10 | |
[email protected] | 0edbfc8 | 2013-06-14 06:15:39 | [diff] [blame] | 11 | #include "ppapi/c/pp_bool.h" |
| 12 | #include "ppapi/c/pp_completion_callback.h" |
| 13 | #include "ppapi/c/pp_instance.h" |
| 14 | #include "ppapi/c/pp_macros.h" |
| 15 | #include "ppapi/c/pp_resource.h" |
| 16 | #include "ppapi/c/pp_stdint.h" |
| 17 | #include "ppapi/c/pp_var.h" |
[email protected] | ee51755 | 2013-06-22 20:07:50 | [diff] [blame] | 18 | #include "ppapi/c/ppb_net_address.h" |
[email protected] | 0edbfc8 | 2013-06-14 06:15:39 | [diff] [blame] | 19 | |
[email protected] | c54f81b | 2013-06-24 06:05:39 | [diff] [blame] | 20 | #define PPB_HOSTRESOLVER_INTERFACE_1_0 "PPB_HostResolver;1.0" |
| 21 | #define PPB_HOSTRESOLVER_INTERFACE PPB_HOSTRESOLVER_INTERFACE_1_0 |
[email protected] | 0edbfc8 | 2013-06-14 06:15:39 | [diff] [blame] | 22 | |
| 23 | /** |
| 24 | * @file |
[email protected] | c54f81b | 2013-06-24 06:05:39 | [diff] [blame] | 25 | * This file defines the <code>PPB_HostResolver</code> interface. |
[email protected] | 0edbfc8 | 2013-06-14 06:15:39 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | |
| 29 | /** |
| 30 | * @addtogroup Enums |
| 31 | * @{ |
| 32 | */ |
| 33 | /** |
[email protected] | c54f81b | 2013-06-24 06:05:39 | [diff] [blame] | 34 | * <code>PP_HostResolver_Flag</code> is an enumeration of flags which can be |
| 35 | * OR-ed and passed to the host resolver. Currently there is only one flag |
[email protected] | a58eae87 | 2013-06-22 14:29:02 | [diff] [blame] | 36 | * defined. |
[email protected] | 0edbfc8 | 2013-06-14 06:15:39 | [diff] [blame] | 37 | */ |
| 38 | typedef enum { |
| 39 | /** |
[email protected] | a58eae87 | 2013-06-22 14:29:02 | [diff] [blame] | 40 | * Hint to request the canonical name of the host, which can be retrieved by |
| 41 | * <code>GetCanonicalName()</code>. |
[email protected] | 0edbfc8 | 2013-06-14 06:15:39 | [diff] [blame] | 42 | */ |
[email protected] | c54f81b | 2013-06-24 06:05:39 | [diff] [blame] | 43 | PP_HOSTRESOLVER_FLAG_CANONNAME = 1 << 0 |
| 44 | } PP_HostResolver_Flag; |
| 45 | PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_HostResolver_Flag, 4); |
[email protected] | 0edbfc8 | 2013-06-14 06:15:39 | [diff] [blame] | 46 | /** |
| 47 | * @} |
| 48 | */ |
| 49 | |
| 50 | /** |
| 51 | * @addtogroup Structs |
| 52 | * @{ |
| 53 | */ |
[email protected] | a58eae87 | 2013-06-22 14:29:02 | [diff] [blame] | 54 | /** |
[email protected] | c54f81b | 2013-06-24 06:05:39 | [diff] [blame] | 55 | * <code>PP_HostResolver_Hint</code> represents hints for host resolution. |
[email protected] | a58eae87 | 2013-06-22 14:29:02 | [diff] [blame] | 56 | */ |
[email protected] | c54f81b | 2013-06-24 06:05:39 | [diff] [blame] | 57 | struct PP_HostResolver_Hint { |
[email protected] | a58eae87 | 2013-06-22 14:29:02 | [diff] [blame] | 58 | /** |
| 59 | * Network address family. |
| 60 | */ |
[email protected] | ee51755 | 2013-06-22 20:07:50 | [diff] [blame] | 61 | PP_NetAddress_Family family; |
[email protected] | a58eae87 | 2013-06-22 14:29:02 | [diff] [blame] | 62 | /** |
[email protected] | c54f81b | 2013-06-24 06:05:39 | [diff] [blame] | 63 | * Combination of flags from <code>PP_HostResolver_Flag</code>. |
[email protected] | a58eae87 | 2013-06-22 14:29:02 | [diff] [blame] | 64 | */ |
[email protected] | 0edbfc8 | 2013-06-14 06:15:39 | [diff] [blame] | 65 | int32_t flags; |
| 66 | }; |
[email protected] | c54f81b | 2013-06-24 06:05:39 | [diff] [blame] | 67 | PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_HostResolver_Hint, 8); |
[email protected] | 0edbfc8 | 2013-06-14 06:15:39 | [diff] [blame] | 68 | /** |
| 69 | * @} |
| 70 | */ |
| 71 | |
| 72 | /** |
| 73 | * @addtogroup Interfaces |
| 74 | * @{ |
| 75 | */ |
[email protected] | a58eae87 | 2013-06-22 14:29:02 | [diff] [blame] | 76 | /** |
[email protected] | c54f81b | 2013-06-24 06:05:39 | [diff] [blame] | 77 | * The <code>PPB_HostResolver</code> interface supports host name |
[email protected] | a58eae87 | 2013-06-22 14:29:02 | [diff] [blame] | 78 | * resolution. |
| 79 | * |
| 80 | * Permissions: In order to run <code>Resolve()</code>, apps permission |
| 81 | * <code>socket</code> with subrule <code>resolve-host</code> is required. |
| 82 | * For more details about network communication permissions, please see: |
| 83 | * http://developer.chrome.com/apps/app_network.html |
| 84 | */ |
[email protected] | c54f81b | 2013-06-24 06:05:39 | [diff] [blame] | 85 | struct PPB_HostResolver_1_0 { |
[email protected] | 0edbfc8 | 2013-06-14 06:15:39 | [diff] [blame] | 86 | /** |
[email protected] | a58eae87 | 2013-06-22 14:29:02 | [diff] [blame] | 87 | * Creates a host resolver resource. |
| 88 | * |
| 89 | * @param[in] instance A <code>PP_Instance</code> identifying one instance of |
| 90 | * a module. |
| 91 | * |
| 92 | * @return A <code>PP_Resource</code> corresponding to a host reslover or 0 |
| 93 | * on failure. |
[email protected] | 0edbfc8 | 2013-06-14 06:15:39 | [diff] [blame] | 94 | */ |
| 95 | PP_Resource (*Create)(PP_Instance instance); |
| 96 | /** |
[email protected] | a58eae87 | 2013-06-22 14:29:02 | [diff] [blame] | 97 | * Determines if a given resource is a host resolver. |
| 98 | * |
| 99 | * @param[in] resource A <code>PP_Resource</code> to check. |
| 100 | * |
| 101 | * @return <code>PP_TRUE</code> if the input is a |
[email protected] | c54f81b | 2013-06-24 06:05:39 | [diff] [blame] | 102 | * <code>PPB_HostResolver</code> resource; <code>PP_FALSE</code> otherwise. |
[email protected] | 0edbfc8 | 2013-06-14 06:15:39 | [diff] [blame] | 103 | */ |
| 104 | PP_Bool (*IsHostResolver)(PP_Resource resource); |
| 105 | /** |
[email protected] | a58eae87 | 2013-06-22 14:29:02 | [diff] [blame] | 106 | * Requests resolution of a host name. If the call completes successfully, the |
| 107 | * results can be retrieved by <code>GetCanonicalName()</code>, |
| 108 | * <code>GetNetAddressCount()</code> and <code>GetNetAddress()</code>. |
| 109 | * |
| 110 | * @param[in] host_resolver A <code>PP_Resource</code> corresponding to a host |
| 111 | * resolver. |
| 112 | * @param[in] host The host name (or IP address literal) to resolve. |
| 113 | * @param[in] port The port number to be set in the resulting network |
| 114 | * addresses. |
[email protected] | c54f81b | 2013-06-24 06:05:39 | [diff] [blame] | 115 | * @param[in] hint A <code>PP_HostResolver_Hint</code> structure providing |
[email protected] | a58eae87 | 2013-06-22 14:29:02 | [diff] [blame] | 116 | * hints for host resolution. |
| 117 | * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon |
| 118 | * completion. |
| 119 | * |
| 120 | * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 121 | * <code>PP_ERROR_NOACCESS</code> will be returned if the caller doesn't have |
| 122 | * required permissions. <code>PP_ERROR_NAME_NOT_RESOLVED</code> will be |
| 123 | * returned if the host name couldn't be resolved. |
[email protected] | 0edbfc8 | 2013-06-14 06:15:39 | [diff] [blame] | 124 | */ |
| 125 | int32_t (*Resolve)(PP_Resource host_resolver, |
| 126 | const char* host, |
| 127 | uint16_t port, |
[email protected] | c54f81b | 2013-06-24 06:05:39 | [diff] [blame] | 128 | const struct PP_HostResolver_Hint* hint, |
[email protected] | 0edbfc8 | 2013-06-14 06:15:39 | [diff] [blame] | 129 | struct PP_CompletionCallback callback); |
| 130 | /** |
[email protected] | a58eae87 | 2013-06-22 14:29:02 | [diff] [blame] | 131 | * Gets the canonical name of the host. |
| 132 | * |
| 133 | * @param[in] host_resolver A <code>PP_Resource</code> corresponding to a host |
| 134 | * resolver. |
| 135 | * |
| 136 | * @return A string <code>PP_Var</code> on success, which is an empty string |
[email protected] | c54f81b | 2013-06-24 06:05:39 | [diff] [blame] | 137 | * if <code>PP_HOSTRESOLVER_FLAG_CANONNAME</code> is not set in the hint flags |
| 138 | * when calling <code>Resolve()</code>; an undefined <code>PP_Var</code> if |
| 139 | * there is a pending <code>Resolve()</code> call or the previous |
[email protected] | a58eae87 | 2013-06-22 14:29:02 | [diff] [blame] | 140 | * <code>Resolve()</code> call failed. |
[email protected] | 0edbfc8 | 2013-06-14 06:15:39 | [diff] [blame] | 141 | */ |
| 142 | struct PP_Var (*GetCanonicalName)(PP_Resource host_resolver); |
| 143 | /** |
[email protected] | a58eae87 | 2013-06-22 14:29:02 | [diff] [blame] | 144 | * Gets the number of network addresses. |
| 145 | * |
| 146 | * @param[in] host_resolver A <code>PP_Resource</code> corresponding to a host |
| 147 | * resolver. |
| 148 | * |
| 149 | * @return The number of available network addresses on success; 0 if there is |
| 150 | * a pending <code>Resolve()</code> call or the previous |
| 151 | * <code>Resolve()</code> call failed. |
[email protected] | 0edbfc8 | 2013-06-14 06:15:39 | [diff] [blame] | 152 | */ |
| 153 | uint32_t (*GetNetAddressCount)(PP_Resource host_resolver); |
| 154 | /** |
[email protected] | a58eae87 | 2013-06-22 14:29:02 | [diff] [blame] | 155 | * Gets a network address. |
| 156 | * |
| 157 | * @param[in] host_resolver A <code>PP_Resource</code> corresponding to a host |
| 158 | * resolver. |
| 159 | * @param[in] index An index indicating which address to return. |
| 160 | * |
[email protected] | ee51755 | 2013-06-22 20:07:50 | [diff] [blame] | 161 | * @return A <code>PPB_NetAddress</code> resource on success; 0 if there is a |
| 162 | * pending <code>Resolve()</code> call or the previous <code>Resolve()</code> |
| 163 | * call failed, or the specified index is out of range. |
[email protected] | 0edbfc8 | 2013-06-14 06:15:39 | [diff] [blame] | 164 | */ |
| 165 | PP_Resource (*GetNetAddress)(PP_Resource host_resolver, uint32_t index); |
| 166 | }; |
| 167 | |
[email protected] | c54f81b | 2013-06-24 06:05:39 | [diff] [blame] | 168 | typedef struct PPB_HostResolver_1_0 PPB_HostResolver; |
[email protected] | 0edbfc8 | 2013-06-14 06:15:39 | [diff] [blame] | 169 | /** |
| 170 | * @} |
| 171 | */ |
| 172 | |
[email protected] | c54f81b | 2013-06-24 06:05:39 | [diff] [blame] | 173 | #endif /* PPAPI_C_PPB_HOST_RESOLVER_H_ */ |
[email protected] | 0edbfc8 | 2013-06-14 06:15:39 | [diff] [blame] | 174 | |