• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 // From ppb_host_resolver.idl modified Tue Aug 20 08:13:36 2013.
6 
7 #include "ppapi/c/pp_completion_callback.h"
8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/c/ppb_host_resolver.h"
10 #include "ppapi/shared_impl/tracked_callback.h"
11 #include "ppapi/thunk/enter.h"
12 #include "ppapi/thunk/ppapi_thunk_export.h"
13 #include "ppapi/thunk/ppb_host_resolver_api.h"
14 
15 namespace ppapi {
16 namespace thunk {
17 
18 namespace {
19 
Create(PP_Instance instance)20 PP_Resource Create(PP_Instance instance) {
21   VLOG(4) << "PPB_HostResolver::Create()";
22   EnterResourceCreation enter(instance);
23   if (enter.failed())
24     return 0;
25   return enter.functions()->CreateHostResolver(instance);
26 }
27 
IsHostResolver(PP_Resource resource)28 PP_Bool IsHostResolver(PP_Resource resource) {
29   VLOG(4) << "PPB_HostResolver::IsHostResolver()";
30   EnterResource<PPB_HostResolver_API> enter(resource, false);
31   return PP_FromBool(enter.succeeded());
32 }
33 
Resolve(PP_Resource host_resolver,const char * host,uint16_t port,const struct PP_HostResolver_Hint * hint,struct PP_CompletionCallback callback)34 int32_t Resolve(PP_Resource host_resolver,
35                 const char* host,
36                 uint16_t port,
37                 const struct PP_HostResolver_Hint* hint,
38                 struct PP_CompletionCallback callback) {
39   VLOG(4) << "PPB_HostResolver::Resolve()";
40   EnterResource<PPB_HostResolver_API> enter(host_resolver, callback, true);
41   if (enter.failed())
42     return enter.retval();
43   return enter.SetResult(enter.object()->Resolve(host,
44                                                  port,
45                                                  hint,
46                                                  enter.callback()));
47 }
48 
GetCanonicalName(PP_Resource host_resolver)49 struct PP_Var GetCanonicalName(PP_Resource host_resolver) {
50   VLOG(4) << "PPB_HostResolver::GetCanonicalName()";
51   EnterResource<PPB_HostResolver_API> enter(host_resolver, true);
52   if (enter.failed())
53     return PP_MakeUndefined();
54   return enter.object()->GetCanonicalName();
55 }
56 
GetNetAddressCount(PP_Resource host_resolver)57 uint32_t GetNetAddressCount(PP_Resource host_resolver) {
58   VLOG(4) << "PPB_HostResolver::GetNetAddressCount()";
59   EnterResource<PPB_HostResolver_API> enter(host_resolver, true);
60   if (enter.failed())
61     return 0;
62   return enter.object()->GetNetAddressCount();
63 }
64 
GetNetAddress(PP_Resource host_resolver,uint32_t index)65 PP_Resource GetNetAddress(PP_Resource host_resolver, uint32_t index) {
66   VLOG(4) << "PPB_HostResolver::GetNetAddress()";
67   EnterResource<PPB_HostResolver_API> enter(host_resolver, true);
68   if (enter.failed())
69     return 0;
70   return enter.object()->GetNetAddress(index);
71 }
72 
73 const PPB_HostResolver_1_0 g_ppb_hostresolver_thunk_1_0 = {
74   &Create,
75   &IsHostResolver,
76   &Resolve,
77   &GetCanonicalName,
78   &GetNetAddressCount,
79   &GetNetAddress
80 };
81 
82 }  // namespace
83 
84 PPAPI_THUNK_EXPORT const PPB_HostResolver_1_0*
GetPPB_HostResolver_1_0_Thunk()85     GetPPB_HostResolver_1_0_Thunk() {
86   return &g_ppb_hostresolver_thunk_1_0;
87 }
88 
89 }  // namespace thunk
90 }  // namespace ppapi
91