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 /** | 6 /** |
7 * This file defines the <code>PPB_HostResolver_Dev</code> interface. | 7 * This file defines the <code>PPB_HostResolver_Dev</code> interface. |
8 * TODO(yzshen): Tidy up the document. | |
9 */ | 8 */ |
10 | 9 |
11 [generate_thunk] | 10 [generate_thunk] |
12 | 11 |
13 label Chrome { | 12 label Chrome { |
14 M29 = 0.1 | 13 M29 = 0.1 |
15 }; | 14 }; |
16 | 15 |
17 /** | 16 /** |
18 * The <code>PP_HostResolver_Flags_Dev</code> is an enumeration of the | 17 * <code>PP_HostResolver_Flags_Dev</code> is an enumeration of flags which can |
19 * different types of flags, that can be OR-ed and passed to host | 18 * be OR-ed and passed to the host resolver. Currently there is only one flag |
20 * resolver. Currently there is only one flag defined. | 19 * defined. |
21 */ | 20 */ |
22 [assert_size(4)] | 21 [assert_size(4)] |
23 enum PP_HostResolver_Flags_Dev { | 22 enum PP_HostResolver_Flags_Dev { |
24 /** | 23 /** |
25 * AI_CANONNAME | 24 * Hint to request the canonical name of the host, which can be retrieved by |
| 25 * <code>GetCanonicalName()</code>. |
26 */ | 26 */ |
27 PP_HOSTRESOLVER_FLAGS_CANONNAME = 1 << 0 | 27 PP_HOSTRESOLVER_FLAGS_CANONNAME = 1 << 0 |
28 }; | 28 }; |
29 | 29 |
| 30 /** |
| 31 * <code>PP_HostResolver_Hint_Dev</code> represents hints for host resolution. |
| 32 */ |
30 [assert_size(8)] | 33 [assert_size(8)] |
31 struct PP_HostResolver_Hint_Dev { | 34 struct PP_HostResolver_Hint_Dev { |
| 35 /** |
| 36 * Network address family. |
| 37 */ |
32 PP_NetAddress_Family_Dev family; | 38 PP_NetAddress_Family_Dev family; |
| 39 /** |
| 40 * Combination of flags from <code>PP_HostResolver_Flags_Dev</code>. |
| 41 */ |
33 int32_t flags; | 42 int32_t flags; |
34 }; | 43 }; |
35 | 44 |
| 45 /** |
| 46 * The <code>PPB_HostResolver_Dev</code> interface supports host name |
| 47 * resolution. |
| 48 * |
| 49 * Permissions: In order to run <code>Resolve()</code>, apps permission |
| 50 * <code>socket</code> with subrule <code>resolve-host</code> is required. |
| 51 * For more details about network communication permissions, please see: |
| 52 * http://developer.chrome.com/apps/app_network.html |
| 53 */ |
36 interface PPB_HostResolver_Dev { | 54 interface PPB_HostResolver_Dev { |
37 /** | 55 /** |
38 * Allocates a Host Resolver resource. | 56 * Creates a host resolver resource. |
| 57 * |
| 58 * @param[in] instance A <code>PP_Instance</code> identifying one instance of |
| 59 * a module. |
| 60 * |
| 61 * @return A <code>PP_Resource</code> corresponding to a host reslover or 0 |
| 62 * on failure. |
39 */ | 63 */ |
40 PP_Resource Create([in] PP_Instance instance); | 64 PP_Resource Create([in] PP_Instance instance); |
41 | 65 |
42 /** | 66 /** |
43 * Determines if a given resource is a Host Resolver. | 67 * Determines if a given resource is a host resolver. |
| 68 * |
| 69 * @param[in] resource A <code>PP_Resource</code> to check. |
| 70 * |
| 71 * @return <code>PP_TRUE</code> if the input is a |
| 72 * <code>PPB_HostResolver_Dev</code> resource; <code>PP_FALSE</code> |
| 73 * otherwise. |
44 */ | 74 */ |
45 PP_Bool IsHostResolver([in] PP_Resource resource); | 75 PP_Bool IsHostResolver([in] PP_Resource resource); |
46 | 76 |
47 /** | 77 /** |
48 * Creates a new request to Host Resolver. |callback| is invoked when request | 78 * Requests resolution of a host name. If the call completes successfully, the |
49 * is processed and a list of network addresses is obtained. These addresses | 79 * results can be retrieved by <code>GetCanonicalName()</code>, |
50 * can be used in Connect, Bind or Listen calls to connect to a given |host| | 80 * <code>GetNetAddressCount()</code> and <code>GetNetAddress()</code>. |
51 * and |port|. | 81 * |
| 82 * @param[in] host_resolver A <code>PP_Resource</code> corresponding to a host |
| 83 * resolver. |
| 84 * @param[in] host The host name (or IP address literal) to resolve. |
| 85 * @param[in] port The port number to be set in the resulting network |
| 86 * addresses. |
| 87 * @param[in] hint A <code>PP_HostResolver_Hint_Dev</code> structure providing |
| 88 * hints for host resolution. |
| 89 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon |
| 90 * completion. |
| 91 * |
| 92 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 93 * <code>PP_ERROR_NOACCESS</code> will be returned if the caller doesn't have |
| 94 * required permissions. <code>PP_ERROR_NAME_NOT_RESOLVED</code> will be |
| 95 * returned if the host name couldn't be resolved. |
52 */ | 96 */ |
53 int32_t Resolve([in] PP_Resource host_resolver, | 97 int32_t Resolve([in] PP_Resource host_resolver, |
54 [in] str_t host, | 98 [in] str_t host, |
55 [in] uint16_t port, | 99 [in] uint16_t port, |
56 [in] PP_HostResolver_Hint_Dev hint, | 100 [in] PP_HostResolver_Hint_Dev hint, |
57 [in] PP_CompletionCallback callback); | 101 [in] PP_CompletionCallback callback); |
58 | 102 |
59 /** | 103 /** |
60 * Gets canonical name of host. Returns an undefined var if there is a pending | 104 * Gets the canonical name of the host. |
61 * Resolve call or the previous Resolve call failed. | 105 * |
| 106 * @param[in] host_resolver A <code>PP_Resource</code> corresponding to a host |
| 107 * resolver. |
| 108 * |
| 109 * @return A string <code>PP_Var</code> on success, which is an empty string |
| 110 * if <code>PP_HOSTRESOLVER_FLAGS_CANONNAME</code> is not set in the hint |
| 111 * flags when calling <code>Resolve()</code>; an undefined <code>PP_Var</code> |
| 112 * if there is a pending <code>Resolve()</code> call or the previous |
| 113 * <code>Resolve()</code> call failed. |
62 */ | 114 */ |
63 PP_Var GetCanonicalName([in] PP_Resource host_resolver); | 115 PP_Var GetCanonicalName([in] PP_Resource host_resolver); |
64 | 116 |
65 /** | 117 /** |
66 * Gets number of network addresses obtained after Resolve call. Returns 0 if | 118 * Gets the number of network addresses. |
67 * there is a pending Resolve call or the previous Resolve call failed. | 119 * |
| 120 * @param[in] host_resolver A <code>PP_Resource</code> corresponding to a host |
| 121 * resolver. |
| 122 * |
| 123 * @return The number of available network addresses on success; 0 if there is |
| 124 * a pending <code>Resolve()</code> call or the previous |
| 125 * <code>Resolve()</code> call failed. |
68 */ | 126 */ |
69 uint32_t GetNetAddressCount([in] PP_Resource host_resolver); | 127 uint32_t GetNetAddressCount([in] PP_Resource host_resolver); |
70 | 128 |
71 /** | 129 /** |
72 * Gets the |index|-th network address. | 130 * Gets a network address. |
73 * Returns 0 if there is a pending Resolve call or the previous Resolve call | 131 * |
74 * failed, or |index| is not less than the number of available addresses. | 132 * @param[in] host_resolver A <code>PP_Resource</code> corresponding to a host |
| 133 * resolver. |
| 134 * @param[in] index An index indicating which address to return. |
| 135 * |
| 136 * @return A <code>PPB_NetAddress_Dev</code> resource on success; 0 if there |
| 137 * is a pending <code>Resolve()</code> call or the previous |
| 138 * <code>Resolve()</code> call failed, or the specified index is out of range. |
75 */ | 139 */ |
76 PP_Resource GetNetAddress([in] PP_Resource host_resolver, | 140 PP_Resource GetNetAddress([in] PP_Resource host_resolver, |
77 [in] uint32_t index); | 141 [in] uint32_t index); |
78 }; | 142 }; |
OLD | NEW |