Home | History | Annotate | Download | only in private
      1 /* Copyright (c) 2012 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  */
      5 
      6 /* From private/ppb_host_resolver_private.idl,
      7  *   modified Mon Jun 24 09:49:40 2013.
      8  */
      9 
     10 #ifndef PPAPI_C_PRIVATE_PPB_HOST_RESOLVER_PRIVATE_H_
     11 #define PPAPI_C_PRIVATE_PPB_HOST_RESOLVER_PRIVATE_H_
     12 
     13 #include "ppapi/c/pp_bool.h"
     14 #include "ppapi/c/pp_completion_callback.h"
     15 #include "ppapi/c/pp_instance.h"
     16 #include "ppapi/c/pp_macros.h"
     17 #include "ppapi/c/pp_resource.h"
     18 #include "ppapi/c/pp_stdint.h"
     19 #include "ppapi/c/pp_var.h"
     20 #include "ppapi/c/private/ppb_net_address_private.h"
     21 
     22 #define PPB_HOSTRESOLVER_PRIVATE_INTERFACE_0_1 "PPB_HostResolver_Private;0.1"
     23 #define PPB_HOSTRESOLVER_PRIVATE_INTERFACE \
     24     PPB_HOSTRESOLVER_PRIVATE_INTERFACE_0_1
     25 
     26 /**
     27  * @file
     28  * This file defines the <code>PPB_HostResolver_Private</code> interface.
     29  */
     30 
     31 
     32 /**
     33  * @addtogroup Enums
     34  * @{
     35  */
     36 /**
     37  * The <code>PP_HostResolver_Flags</code> is an enumeration of the
     38  * different types of flags, that can be OR-ed and passed to host
     39  * resolver.
     40  */
     41 typedef enum {
     42   /**
     43    * AI_CANONNAME
     44    */
     45   PP_HOST_RESOLVER_PRIVATE_FLAGS_CANONNAME = 1 << 0,
     46   /**
     47    * Hint to the resolver that only loopback addresses are configured.
     48    */
     49   PP_HOST_RESOLVER_PRIVATE_FLAGS_LOOPBACK_ONLY = 1 << 1
     50 } PP_HostResolver_Private_Flags;
     51 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_HostResolver_Private_Flags, 4);
     52 /**
     53  * @}
     54  */
     55 
     56 /**
     57  * @addtogroup Structs
     58  * @{
     59  */
     60 struct PP_HostResolver_Private_Hint {
     61   PP_NetAddressFamily_Private family;
     62   int32_t flags;
     63 };
     64 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_HostResolver_Private_Hint, 8);
     65 /**
     66  * @}
     67  */
     68 
     69 /**
     70  * @addtogroup Interfaces
     71  * @{
     72  */
     73 struct PPB_HostResolver_Private_0_1 {
     74   /**
     75    * Allocates a Host Resolver resource.
     76    */
     77   PP_Resource (*Create)(PP_Instance instance);
     78   /**
     79    * Determines if a given resource is a Host Resolver.
     80    */
     81   PP_Bool (*IsHostResolver)(PP_Resource resource);
     82   /**
     83    * Creates a new request to Host Resolver. |callback| is invoked
     84    * when request is processed and a list of network addresses is
     85    * obtained. These addresses can be be used in Connect, Bind or
     86    * Listen calls to connect to a given |host| and |port|.
     87    */
     88   int32_t (*Resolve)(PP_Resource host_resolver,
     89                      const char* host,
     90                      uint16_t port,
     91                      const struct PP_HostResolver_Private_Hint* hint,
     92                      struct PP_CompletionCallback callback);
     93   /**
     94    * Returns canonical name of host.
     95    */
     96   struct PP_Var (*GetCanonicalName)(PP_Resource host_resolver);
     97   /**
     98    * Returns number of network addresses obtained after Resolve call.
     99    */
    100   uint32_t (*GetSize)(PP_Resource host_resolver);
    101   /**
    102    * Stores in the |addr| |index|-th network address. |addr| can't be
    103    * NULL. Returns PP_TRUE if success or PP_FALSE if the given
    104    * resource is not a Host Resolver or |index| exceeds number of
    105    * available addresses.
    106    */
    107   PP_Bool (*GetNetAddress)(PP_Resource host_resolver,
    108                            uint32_t index,
    109                            struct PP_NetAddress_Private* addr);
    110 };
    111 
    112 typedef struct PPB_HostResolver_Private_0_1 PPB_HostResolver_Private;
    113 /**
    114  * @}
    115  */
    116 
    117 #endif  /* PPAPI_C_PRIVATE_PPB_HOST_RESOLVER_PRIVATE_H_ */
    118 
    119