/* Copyright 2013 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /** * This file defines the PPB_HostResolver interface. */ [generate_thunk] label Chrome { M29 = 1.0 }; /** * PP_HostResolver_Flag is an enumeration of flags which can be * OR-ed and passed to the host resolver. Currently there is only one flag * defined. */ [assert_size(4)] enum PP_HostResolver_Flag { /** * Hint to request the canonical name of the host, which can be retrieved by * GetCanonicalName(). */ PP_HOSTRESOLVER_FLAG_CANONNAME = 1 << 0 }; /** * PP_HostResolver_Hint represents hints for host resolution. */ [assert_size(8)] struct PP_HostResolver_Hint { /** * Network address family. */ PP_NetAddress_Family family; /** * Combination of flags from PP_HostResolver_Flag. */ int32_t flags; }; /** * The PPB_HostResolver interface supports host name * resolution. * * Permissions: In order to run Resolve(), apps permission * socket with subrule resolve-host is required. * For more details about network communication permissions, please see: * http://developer.chrome.com/apps/app_network.html */ interface PPB_HostResolver { /** * Creates a host resolver resource. * * @param[in] instance A PP_Instance identifying one instance of * a module. * * @return A PP_Resource corresponding to a host reslover or 0 * on failure. */ PP_Resource Create([in] PP_Instance instance); /** * Determines if a given resource is a host resolver. * * @param[in] resource A PP_Resource to check. * * @return PP_TRUE if the input is a * PPB_HostResolver resource; PP_FALSE otherwise. */ PP_Bool IsHostResolver([in] PP_Resource resource); /** * Requests resolution of a host name. If the call completes successfully, the * results can be retrieved by GetCanonicalName(), * GetNetAddressCount() and GetNetAddress(). * * @param[in] host_resolver A PP_Resource corresponding to a host * resolver. * @param[in] host The host name (or IP address literal) to resolve. * @param[in] port The port number to be set in the resulting network * addresses. * @param[in] hint A PP_HostResolver_Hint structure providing * hints for host resolution. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return An int32_t containing an error code from pp_errors.h. * PP_ERROR_NOACCESS will be returned if the caller doesn't have * required permissions. PP_ERROR_NAME_NOT_RESOLVED will be * returned if the host name couldn't be resolved. */ int32_t Resolve([in] PP_Resource host_resolver, [in] str_t host, [in] uint16_t port, [in] PP_HostResolver_Hint hint, [in] PP_CompletionCallback callback); /** * Gets the canonical name of the host. * * @param[in] host_resolver A PP_Resource corresponding to a host * resolver. * * @return A string PP_Var on success, which is an empty string * if PP_HOSTRESOLVER_FLAG_CANONNAME is not set in the hint flags * when calling Resolve(); an undefined PP_Var if * there is a pending Resolve() call or the previous * Resolve() call failed. */ PP_Var GetCanonicalName([in] PP_Resource host_resolver); /** * Gets the number of network addresses. * * @param[in] host_resolver A PP_Resource corresponding to a host * resolver. * * @return The number of available network addresses on success; 0 if there is * a pending Resolve() call or the previous * Resolve() call failed. */ uint32_t GetNetAddressCount([in] PP_Resource host_resolver); /** * Gets a network address. * * @param[in] host_resolver A PP_Resource corresponding to a host * resolver. * @param[in] index An index indicating which address to return. * * @return A PPB_NetAddress resource on success; 0 if there is a * pending Resolve() call or the previous Resolve() * call failed, or the specified index is out of range. */ PP_Resource GetNetAddress([in] PP_Resource host_resolver, [in] uint32_t index); };