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.
5 #include "ppapi/cpp/private/host_resolver_private.h"
7 #include "ppapi/c/pp_bool.h"
8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/cpp/completion_callback.h"
10 #include "ppapi/cpp/instance_handle.h"
11 #include "ppapi/cpp/module.h"
12 #include "ppapi/cpp/module_impl.h"
13 #include "ppapi/cpp/pass_ref.h"
19 template <> const char* interface_name
<PPB_HostResolver_Private_0_1
>() {
20 return PPB_HOSTRESOLVER_PRIVATE_INTERFACE_0_1
;
25 HostResolverPrivate::HostResolverPrivate(const InstanceHandle
& instance
) {
26 if (has_interface
<PPB_HostResolver_Private_0_1
>()) {
27 PassRefFromConstructor(
28 get_interface
<PPB_HostResolver_Private_0_1
>()->Create(
29 instance
.pp_instance()));
34 bool HostResolverPrivate::IsAvailable() {
35 return has_interface
<PPB_HostResolver_Private_0_1
>();
38 int32_t HostResolverPrivate::Resolve(const std::string
& host
,
40 const PP_HostResolver_Private_Hint
& hint
,
41 const CompletionCallback
& callback
) {
42 if (!has_interface
<PPB_HostResolver_Private_0_1
>())
43 return callback
.MayForce(PP_ERROR_NOINTERFACE
);
44 return get_interface
<PPB_HostResolver_Private_0_1
>()->Resolve(
49 callback
.pp_completion_callback());
52 Var
HostResolverPrivate::GetCanonicalName() {
53 if (!has_interface
<PPB_HostResolver_Private_0_1
>())
54 return Var(Var::Null());
56 PP_Var pp_canonical_name
=
57 get_interface
<PPB_HostResolver_Private_0_1
>()->GetCanonicalName(
59 return Var(PASS_REF
, pp_canonical_name
);
62 uint32_t HostResolverPrivate::GetSize() {
63 if (!has_interface
<PPB_HostResolver_Private_0_1
>())
65 return get_interface
<PPB_HostResolver_Private_0_1
>()->GetSize(pp_resource());
68 bool HostResolverPrivate::GetNetAddress(uint32_t index
,
69 PP_NetAddress_Private
* address
) {
70 if (!has_interface
<PPB_HostResolver_Private_0_1
>())
72 PP_Bool result
= get_interface
<PPB_HostResolver_Private_0_1
>()->GetNetAddress(
73 pp_resource(), index
, address
);
74 return PP_ToBool(result
);