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 | 5 |
6 /* From dev/ppb_host_resolver_dev.idl modified Mon Jun 10 13:42:25 2013. */ | 6 /* From dev/ppb_host_resolver_dev.idl modified Thu Jun 20 12:08:29 2013. */ |
7 | 7 |
8 #ifndef PPAPI_C_DEV_PPB_HOST_RESOLVER_DEV_H_ | 8 #ifndef PPAPI_C_DEV_PPB_HOST_RESOLVER_DEV_H_ |
9 #define PPAPI_C_DEV_PPB_HOST_RESOLVER_DEV_H_ | 9 #define PPAPI_C_DEV_PPB_HOST_RESOLVER_DEV_H_ |
10 | 10 |
11 #include "ppapi/c/dev/ppb_net_address_dev.h" | 11 #include "ppapi/c/dev/ppb_net_address_dev.h" |
12 #include "ppapi/c/pp_bool.h" | 12 #include "ppapi/c/pp_bool.h" |
13 #include "ppapi/c/pp_completion_callback.h" | 13 #include "ppapi/c/pp_completion_callback.h" |
14 #include "ppapi/c/pp_instance.h" | 14 #include "ppapi/c/pp_instance.h" |
15 #include "ppapi/c/pp_macros.h" | 15 #include "ppapi/c/pp_macros.h" |
16 #include "ppapi/c/pp_resource.h" | 16 #include "ppapi/c/pp_resource.h" |
17 #include "ppapi/c/pp_stdint.h" | 17 #include "ppapi/c/pp_stdint.h" |
18 #include "ppapi/c/pp_var.h" | 18 #include "ppapi/c/pp_var.h" |
19 | 19 |
20 #define PPB_HOSTRESOLVER_DEV_INTERFACE_0_1 "PPB_HostResolver(Dev);0.1" | 20 #define PPB_HOSTRESOLVER_DEV_INTERFACE_0_1 "PPB_HostResolver(Dev);0.1" |
21 #define PPB_HOSTRESOLVER_DEV_INTERFACE PPB_HOSTRESOLVER_DEV_INTERFACE_0_1 | 21 #define PPB_HOSTRESOLVER_DEV_INTERFACE PPB_HOSTRESOLVER_DEV_INTERFACE_0_1 |
22 | 22 |
23 /** | 23 /** |
24 * @file | 24 * @file |
25 * This file defines the <code>PPB_HostResolver_Dev</code> interface. | 25 * This file defines the <code>PPB_HostResolver_Dev</code> interface. |
26 * TODO(yzshen): Tidy up the document. | |
27 */ | 26 */ |
28 | 27 |
29 | 28 |
30 /** | 29 /** |
31 * @addtogroup Enums | 30 * @addtogroup Enums |
32 * @{ | 31 * @{ |
33 */ | 32 */ |
34 /** | 33 /** |
35 * The <code>PP_HostResolver_Flags_Dev</code> is an enumeration of the | 34 * <code>PP_HostResolver_Flags_Dev</code> is an enumeration of flags which can |
36 * different types of flags, that can be OR-ed and passed to host | 35 * be OR-ed and passed to the host resolver. Currently there is only one flag |
37 * resolver. | 36 * defined. |
38 */ | 37 */ |
39 typedef enum { | 38 typedef enum { |
40 /** | 39 /** |
41 * AI_CANONNAME | 40 * Hint to request the canonical name of the host, which can be retrieved by |
| 41 * <code>GetCanonicalName()</code>. |
42 */ | 42 */ |
43 PP_HOSTRESOLVER_FLAGS_CANONNAME = 1 << 0, | 43 PP_HOSTRESOLVER_FLAGS_CANONNAME = 1 << 0 |
44 /** | |
45 * Hint to the resolver that only loopback addresses are configured. | |
46 */ | |
47 PP_HOSTRESOLVER_FLAGS_LOOPBACK_ONLY = 1 << 1 | |
48 } PP_HostResolver_Flags_Dev; | 44 } PP_HostResolver_Flags_Dev; |
49 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_HostResolver_Flags_Dev, 4); | 45 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_HostResolver_Flags_Dev, 4); |
50 /** | 46 /** |
51 * @} | 47 * @} |
52 */ | 48 */ |
53 | 49 |
54 /** | 50 /** |
55 * @addtogroup Structs | 51 * @addtogroup Structs |
56 * @{ | 52 * @{ |
57 */ | 53 */ |
| 54 /** |
| 55 * <code>PP_HostResolver_Hint_Dev</code> represents hints for host resolution. |
| 56 */ |
58 struct PP_HostResolver_Hint_Dev { | 57 struct PP_HostResolver_Hint_Dev { |
| 58 /** |
| 59 * Network address family. |
| 60 */ |
59 PP_NetAddress_Family_Dev family; | 61 PP_NetAddress_Family_Dev family; |
| 62 /** |
| 63 * Combination of flags from <code>PP_HostResolver_Flags_Dev</code>. |
| 64 */ |
60 int32_t flags; | 65 int32_t flags; |
61 }; | 66 }; |
62 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_HostResolver_Hint_Dev, 8); | 67 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_HostResolver_Hint_Dev, 8); |
63 /** | 68 /** |
64 * @} | 69 * @} |
65 */ | 70 */ |
66 | 71 |
67 /** | 72 /** |
68 * @addtogroup Interfaces | 73 * @addtogroup Interfaces |
69 * @{ | 74 * @{ |
70 */ | 75 */ |
| 76 /** |
| 77 * The <code>PPB_HostResolver_Dev</code> interface supports host name |
| 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 */ |
71 struct PPB_HostResolver_Dev_0_1 { | 85 struct PPB_HostResolver_Dev_0_1 { |
72 /** | 86 /** |
73 * Allocates a Host Resolver resource. | 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. |
74 */ | 94 */ |
75 PP_Resource (*Create)(PP_Instance instance); | 95 PP_Resource (*Create)(PP_Instance instance); |
76 /** | 96 /** |
77 * Determines if a given resource is a Host Resolver. | 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 |
| 102 * <code>PPB_HostResolver_Dev</code> resource; <code>PP_FALSE</code> |
| 103 * otherwise. |
78 */ | 104 */ |
79 PP_Bool (*IsHostResolver)(PP_Resource resource); | 105 PP_Bool (*IsHostResolver)(PP_Resource resource); |
80 /** | 106 /** |
81 * Creates a new request to Host Resolver. |callback| is invoked when request | 107 * Requests resolution of a host name. If the call completes successfully, the |
82 * is processed and a list of network addresses is obtained. These addresses | 108 * results can be retrieved by <code>GetCanonicalName()</code>, |
83 * can be used in Connect, Bind or Listen calls to connect to a given |host| | 109 * <code>GetNetAddressCount()</code> and <code>GetNetAddress()</code>. |
84 * and |port|. | 110 * |
| 111 * @param[in] host_resolver A <code>PP_Resource</code> corresponding to a host |
| 112 * resolver. |
| 113 * @param[in] host The host name (or IP address literal) to resolve. |
| 114 * @param[in] port The port number to be set in the resulting network |
| 115 * addresses. |
| 116 * @param[in] hint A <code>PP_HostResolver_Hint_Dev</code> structure providing |
| 117 * hints for host resolution. |
| 118 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon |
| 119 * completion. |
| 120 * |
| 121 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 122 * <code>PP_ERROR_NOACCESS</code> will be returned if the caller doesn't have |
| 123 * required permissions. <code>PP_ERROR_NAME_NOT_RESOLVED</code> will be |
| 124 * returned if the host name couldn't be resolved. |
85 */ | 125 */ |
86 int32_t (*Resolve)(PP_Resource host_resolver, | 126 int32_t (*Resolve)(PP_Resource host_resolver, |
87 const char* host, | 127 const char* host, |
88 uint16_t port, | 128 uint16_t port, |
89 const struct PP_HostResolver_Hint_Dev* hint, | 129 const struct PP_HostResolver_Hint_Dev* hint, |
90 struct PP_CompletionCallback callback); | 130 struct PP_CompletionCallback callback); |
91 /** | 131 /** |
92 * Gets canonical name of host. Returns an undefined var if there is a pending | 132 * Gets the canonical name of the host. |
93 * Resolve call or the previous Resolve call failed. | 133 * |
| 134 * @param[in] host_resolver A <code>PP_Resource</code> corresponding to a host |
| 135 * resolver. |
| 136 * |
| 137 * @return A string <code>PP_Var</code> on success, which is an empty string |
| 138 * if <code>PP_HOSTRESOLVER_FLAGS_CANONNAME</code> is not set in the hint |
| 139 * flags when calling <code>Resolve()</code>; an undefined <code>PP_Var</code> |
| 140 * if there is a pending <code>Resolve()</code> call or the previous |
| 141 * <code>Resolve()</code> call failed. |
94 */ | 142 */ |
95 struct PP_Var (*GetCanonicalName)(PP_Resource host_resolver); | 143 struct PP_Var (*GetCanonicalName)(PP_Resource host_resolver); |
96 /** | 144 /** |
97 * Gets number of network addresses obtained after Resolve call. Returns 0 if | 145 * Gets the number of network addresses. |
98 * there is a pending Resolve call or the previous Resolve call failed. | 146 * |
| 147 * @param[in] host_resolver A <code>PP_Resource</code> corresponding to a host |
| 148 * resolver. |
| 149 * |
| 150 * @return The number of available network addresses on success; 0 if there is |
| 151 * a pending <code>Resolve()</code> call or the previous |
| 152 * <code>Resolve()</code> call failed. |
99 */ | 153 */ |
100 uint32_t (*GetNetAddressCount)(PP_Resource host_resolver); | 154 uint32_t (*GetNetAddressCount)(PP_Resource host_resolver); |
101 /** | 155 /** |
102 * Gets the |index|-th network address. | 156 * Gets a network address. |
103 * Returns 0 if there is a pending Resolve call or the previous Resolve call | 157 * |
104 * failed, or |index| is not less than the number of available addresses. | 158 * @param[in] host_resolver A <code>PP_Resource</code> corresponding to a host |
| 159 * resolver. |
| 160 * @param[in] index An index indicating which address to return. |
| 161 * |
| 162 * @return A <code>PPB_NetAddress_Dev</code> resource on success; 0 if there |
| 163 * is a pending <code>Resolve()</code> call or the previous |
| 164 * <code>Resolve()</code> call failed, or the specified index is out of range. |
105 */ | 165 */ |
106 PP_Resource (*GetNetAddress)(PP_Resource host_resolver, uint32_t index); | 166 PP_Resource (*GetNetAddress)(PP_Resource host_resolver, uint32_t index); |
107 }; | 167 }; |
108 | 168 |
109 typedef struct PPB_HostResolver_Dev_0_1 PPB_HostResolver_Dev; | 169 typedef struct PPB_HostResolver_Dev_0_1 PPB_HostResolver_Dev; |
110 /** | 170 /** |
111 * @} | 171 * @} |
112 */ | 172 */ |
113 | 173 |
114 #endif /* PPAPI_C_DEV_PPB_HOST_RESOLVER_DEV_H_ */ | 174 #endif /* PPAPI_C_DEV_PPB_HOST_RESOLVER_DEV_H_ */ |
115 | 175 |
OLD | NEW |