Change a bug reference in a comment.
[chromium-blink-merge.git] / ppapi / thunk / ppb_host_resolver_thunk.cc
blob47d9ad09b6aff4502b2dd416cc0d2e0470ec383a
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.
5 // From ppb_host_resolver.idl modified Mon Jun 24 15:10:54 2013.
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"
15 namespace ppapi {
16 namespace thunk {
18 namespace {
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);
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());
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(
44 enter.object()->Resolve(host, port, hint, enter.callback()));
47 struct PP_Var GetCanonicalName(PP_Resource host_resolver) {
48 VLOG(4) << "PPB_HostResolver::GetCanonicalName()";
49 EnterResource<PPB_HostResolver_API> enter(host_resolver, true);
50 if (enter.failed())
51 return PP_MakeUndefined();
52 return enter.object()->GetCanonicalName();
55 uint32_t GetNetAddressCount(PP_Resource host_resolver) {
56 VLOG(4) << "PPB_HostResolver::GetNetAddressCount()";
57 EnterResource<PPB_HostResolver_API> enter(host_resolver, true);
58 if (enter.failed())
59 return 0;
60 return enter.object()->GetNetAddressCount();
63 PP_Resource GetNetAddress(PP_Resource host_resolver, uint32_t index) {
64 VLOG(4) << "PPB_HostResolver::GetNetAddress()";
65 EnterResource<PPB_HostResolver_API> enter(host_resolver, true);
66 if (enter.failed())
67 return 0;
68 return enter.object()->GetNetAddress(index);
71 const PPB_HostResolver_1_0 g_ppb_hostresolver_thunk_1_0 = {&Create,
72 &IsHostResolver,
73 &Resolve,
74 &GetCanonicalName,
75 &GetNetAddressCount,
76 &GetNetAddress};
78 } // namespace
80 PPAPI_THUNK_EXPORT const PPB_HostResolver_1_0* GetPPB_HostResolver_1_0_Thunk() {
81 return &g_ppb_hostresolver_thunk_1_0;
84 } // namespace thunk
85 } // namespace ppapi