Update V8 to version 4.7.21.
[chromium-blink-merge.git] / ppapi / c / ppb_host_resolver.h
blobcc66ffacc6dfddd033984a94893201167776a607
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 */
6 /* From ppb_host_resolver.idl modified Sat Jun 22 11:11:38 2013. */
8 #ifndef PPAPI_C_PPB_HOST_RESOLVER_H_
9 #define PPAPI_C_PPB_HOST_RESOLVER_H_
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"
18 #include "ppapi/c/ppb_net_address.h"
20 #define PPB_HOSTRESOLVER_INTERFACE_1_0 "PPB_HostResolver;1.0"
21 #define PPB_HOSTRESOLVER_INTERFACE PPB_HOSTRESOLVER_INTERFACE_1_0
23 /**
24 * @file
25 * This file defines the <code>PPB_HostResolver</code> interface.
29 /**
30 * @addtogroup Enums
31 * @{
33 /**
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
36 * defined.
38 typedef enum {
39 /**
40 * Hint to request the canonical name of the host, which can be retrieved by
41 * <code>GetCanonicalName()</code>.
43 PP_HOSTRESOLVER_FLAG_CANONNAME = 1 << 0
44 } PP_HostResolver_Flag;
45 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_HostResolver_Flag, 4);
46 /**
47 * @}
50 /**
51 * @addtogroup Structs
52 * @{
54 /**
55 * <code>PP_HostResolver_Hint</code> represents hints for host resolution.
57 struct PP_HostResolver_Hint {
58 /**
59 * Network address family.
61 PP_NetAddress_Family family;
62 /**
63 * Combination of flags from <code>PP_HostResolver_Flag</code>.
65 int32_t flags;
67 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_HostResolver_Hint, 8);
68 /**
69 * @}
72 /**
73 * @addtogroup Interfaces
74 * @{
76 /**
77 * The <code>PPB_HostResolver</code> interface supports host name
78 * resolution.
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
85 struct PPB_HostResolver_1_0 {
86 /**
87 * Creates a host resolver resource.
89 * @param[in] instance A <code>PP_Instance</code> identifying one instance of
90 * a module.
92 * @return A <code>PP_Resource</code> corresponding to a host reslover or 0
93 * on failure.
95 PP_Resource (*Create)(PP_Instance instance);
96 /**
97 * Determines if a given resource is a host resolver.
99 * @param[in] resource A <code>PP_Resource</code> to check.
101 * @return <code>PP_TRUE</code> if the input is a
102 * <code>PPB_HostResolver</code> resource; <code>PP_FALSE</code> otherwise.
104 PP_Bool (*IsHostResolver)(PP_Resource resource);
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>.
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.
115 * @param[in] hint A <code>PP_HostResolver_Hint</code> structure providing
116 * hints for host resolution.
117 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
118 * completion.
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.
125 int32_t (*Resolve)(PP_Resource host_resolver,
126 const char* host,
127 uint16_t port,
128 const struct PP_HostResolver_Hint* hint,
129 struct PP_CompletionCallback callback);
131 * Gets the canonical name of the host.
133 * @param[in] host_resolver A <code>PP_Resource</code> corresponding to a host
134 * resolver.
136 * @return A string <code>PP_Var</code> on success, which is an empty string
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
140 * <code>Resolve()</code> call failed.
142 struct PP_Var (*GetCanonicalName)(PP_Resource host_resolver);
144 * Gets the number of network addresses.
146 * @param[in] host_resolver A <code>PP_Resource</code> corresponding to a host
147 * resolver.
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.
153 uint32_t (*GetNetAddressCount)(PP_Resource host_resolver);
155 * Gets a network address.
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.
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.
165 PP_Resource (*GetNetAddress)(PP_Resource host_resolver, uint32_t index);
168 typedef struct PPB_HostResolver_1_0 PPB_HostResolver;
170 * @}
173 #endif /* PPAPI_C_PPB_HOST_RESOLVER_H_ */