Chromium Code Reviews| 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 |
|
bbudge
2013/06/20 17:38:27
I think the last sentence is unnecessary.
yzshen1
2013/06/20 20:27:45
According to offline discussion, I will keep it as
| |
| 20 * resolver. | 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 * Requests the canonical name of the host, which can be retrieved by |
|
bbudge
2013/06/20 17:38:27
s/Requests/Hint to request/
yzshen1
2013/06/20 20:27:45
Done.
| |
| 25 * <code>GetCanonicalName()</code>. | |
| 26 */ | 26 */ |
| 27 PP_HOSTRESOLVER_FLAGS_CANONNAME = 1 << 0, | 27 PP_HOSTRESOLVER_FLAGS_CANONNAME = 1 << 0 |
| 28 /** | |
| 29 * Hint to the resolver that only loopback addresses are configured. | |
| 30 */ | |
| 31 PP_HOSTRESOLVER_FLAGS_LOOPBACK_ONLY = 1 << 1 | |
| 32 }; | 28 }; |
| 33 | 29 |
| 30 /** | |
| 31 * <code>PP_HostResolver_Hint_Dev</code> represents hints for host resolution. | |
| 32 */ | |
| 34 [assert_size(8)] | 33 [assert_size(8)] |
| 35 struct PP_HostResolver_Hint_Dev { | 34 struct PP_HostResolver_Hint_Dev { |
| 35 /** | |
| 36 * Network address family. | |
| 37 */ | |
| 36 PP_NetAddress_Family_Dev family; | 38 PP_NetAddress_Family_Dev family; |
| 39 /** | |
| 40 * Combination of flags from <code>PP_HostResolver_Flags_Dev</code>. | |
| 41 */ | |
| 37 int32_t flags; | 42 int32_t flags; |
| 38 }; | 43 }; |
| 39 | 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 */ | |
| 40 interface PPB_HostResolver_Dev { | 54 interface PPB_HostResolver_Dev { |
| 41 /** | 55 /** |
| 42 * 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. | |
| 43 */ | 63 */ |
| 44 PP_Resource Create([in] PP_Instance instance); | 64 PP_Resource Create([in] PP_Instance instance); |
| 45 | 65 |
| 46 /** | 66 /** |
| 47 * 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. | |
| 48 */ | 74 */ |
| 49 PP_Bool IsHostResolver([in] PP_Resource resource); | 75 PP_Bool IsHostResolver([in] PP_Resource resource); |
| 50 | 76 |
| 51 /** | 77 /** |
| 52 * Creates a new request to Host Resolver. |callback| is invoked when request | 78 * Requests to resolve a host name. When the call completes successfully, the |
|
bbudge
2013/06/20 17:38:27
s/Requests to resolve/Requests resolution of/
s/Wh
yzshen1
2013/06/20 20:27:45
Done.
| |
| 53 * is processed and a list of network addresses is obtained. These addresses | 79 * results can be retrieved by <code>GetCanonicalName()</code>, |
| 54 * can be used in Connect, Bind or Listen calls to connect to a given |host| | 80 * <code>GetNetAddressCount()</code> and <code>GetNetAddress()</code>. |
| 55 * 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. | |
|
bbudge
2013/06/20 17:38:27
PP_ERROR_FAILED on other browser errors, correct?
yzshen1
2013/06/20 20:27:45
There are quite a few, for example, FAILED, INPROG
bbudge
2013/06/20 21:02:32
OK
| |
| 56 */ | 96 */ |
| 57 int32_t Resolve([in] PP_Resource host_resolver, | 97 int32_t Resolve([in] PP_Resource host_resolver, |
| 58 [in] str_t host, | 98 [in] str_t host, |
| 59 [in] uint16_t port, | 99 [in] uint16_t port, |
| 60 [in] PP_HostResolver_Hint_Dev hint, | 100 [in] PP_HostResolver_Hint_Dev hint, |
| 61 [in] PP_CompletionCallback callback); | 101 [in] PP_CompletionCallback callback); |
| 62 | 102 |
| 63 /** | 103 /** |
| 64 * Gets canonical name of host. Returns an undefined var if there is a pending | 104 * Gets the canonical name of the host. |
| 65 * 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 specified when | |
|
bbudge
2013/06/20 17:38:27
s/specified/set in the hint flags/
yzshen1
2013/06/20 20:27:45
Done.
| |
| 111 * calling <code>Resolve()</code>; an undefined <code>PP_Var</code> if there | |
| 112 * is a pending <code>Resolve()</code> call or the previous | |
| 113 * <code>Resolve()</code> call failed. | |
| 66 */ | 114 */ |
| 67 PP_Var GetCanonicalName([in] PP_Resource host_resolver); | 115 PP_Var GetCanonicalName([in] PP_Resource host_resolver); |
| 68 | 116 |
| 69 /** | 117 /** |
| 70 * Gets number of network addresses obtained after Resolve call. Returns 0 if | 118 * Gets the number of network addresses. |
| 71 * 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. | |
| 72 */ | 126 */ |
| 73 uint32_t GetNetAddressCount([in] PP_Resource host_resolver); | 127 uint32_t GetNetAddressCount([in] PP_Resource host_resolver); |
| 74 | 128 |
| 75 /** | 129 /** |
| 76 * Gets the |index|-th network address. | 130 * Gets a network address. |
| 77 * Returns 0 if there is a pending Resolve call or the previous Resolve call | 131 * |
| 78 * 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. | |
| 79 */ | 139 */ |
| 80 PP_Resource GetNetAddress([in] PP_Resource host_resolver, | 140 PP_Resource GetNetAddress([in] PP_Resource host_resolver, |
| 81 [in] uint32_t index); | 141 [in] uint32_t index); |
| 82 }; | 142 }; |
| OLD | NEW |