Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / ppapi / cpp / host_resolver.cc
blob656c743775f14d1966352d70c28f876f808a20db
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 #include "ppapi/cpp/host_resolver.h"
7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/cpp/completion_callback.h"
9 #include "ppapi/cpp/instance_handle.h"
10 #include "ppapi/cpp/module_impl.h"
12 namespace pp {
14 namespace {
16 template <> const char* interface_name<PPB_HostResolver_1_0>() {
17 return PPB_HOSTRESOLVER_INTERFACE_1_0;
20 } // namespace
22 HostResolver::HostResolver() {
25 HostResolver::HostResolver(const InstanceHandle& instance) {
26 if (has_interface<PPB_HostResolver_1_0>()) {
27 PassRefFromConstructor(get_interface<PPB_HostResolver_1_0>()->Create(
28 instance.pp_instance()));
32 HostResolver::HostResolver(PassRef, PP_Resource resource)
33 : Resource(PASS_REF, resource) {
36 HostResolver::HostResolver(const HostResolver& other) : Resource(other) {
39 HostResolver::~HostResolver() {
42 HostResolver& HostResolver::operator=(const HostResolver& other) {
43 Resource::operator=(other);
44 return *this;
47 // static
48 bool HostResolver::IsAvailable() {
49 return has_interface<PPB_HostResolver_1_0>();
52 int32_t HostResolver::Resolve(const char* host,
53 uint16_t port,
54 const PP_HostResolver_Hint& hint,
55 const CompletionCallback& callback) {
56 if (has_interface<PPB_HostResolver_1_0>()) {
57 return get_interface<PPB_HostResolver_1_0>()->Resolve(
58 pp_resource(), host, port, &hint, callback.pp_completion_callback());
61 return callback.MayForce(PP_ERROR_NOINTERFACE);
64 Var HostResolver::GetCanonicalName() const {
65 if (has_interface<PPB_HostResolver_1_0>()) {
66 return Var(PASS_REF,
67 get_interface<PPB_HostResolver_1_0>()->GetCanonicalName(
68 pp_resource()));
71 return Var();
74 uint32_t HostResolver::GetNetAddressCount() const {
75 if (has_interface<PPB_HostResolver_1_0>()) {
76 return get_interface<PPB_HostResolver_1_0>()->GetNetAddressCount(
77 pp_resource());
80 return 0;
83 NetAddress HostResolver::GetNetAddress(uint32_t index) const {
84 if (has_interface<PPB_HostResolver_1_0>()) {
85 return NetAddress(PASS_REF,
86 get_interface<PPB_HostResolver_1_0>()->GetNetAddress(
87 pp_resource(), index));
90 return NetAddress();
93 } // namespace pp