Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 #include "ppapi/cpp/private/host_resolver_private.h" | |
| 6 | |
| 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" | |
| 14 #include "ppapi/cpp/var.h" | |
| 15 | |
| 16 namespace pp { | |
| 17 | |
| 18 namespace { | |
| 19 | |
| 20 template <> const char* interface_name<PPB_HostResolver_Private>() { | |
|
yzshen1
2012/03/16 17:38:02
Wez is working on explicitly specifying version nu
ygorshenin1
2012/03/19 08:41:56
Done.
| |
| 21 return PPB_HOSTRESOLVER_PRIVATE_INTERFACE; | |
| 22 } | |
| 23 | |
| 24 } // namespace | |
| 25 | |
| 26 HostResolverPrivate::HostResolverPrivate(const InstanceHandle& instance) { | |
| 27 if (has_interface<PPB_HostResolver_Private>()) { | |
| 28 PassRefFromConstructor(get_interface<PPB_HostResolver_Private>()->Create( | |
| 29 instance.pp_instance())); | |
| 30 } | |
| 31 } | |
| 32 | |
| 33 // static | |
| 34 bool HostResolverPrivate::IsAvailable() { | |
| 35 return has_interface<PPB_HostResolver_Private>(); | |
| 36 } | |
| 37 | |
| 38 int32_t HostResolverPrivate::Resolve(const std::string& host, | |
| 39 uint16_t port, | |
| 40 const PP_HostResolver_Private_Hint& hint, | |
| 41 const CompletionCallback& callback) { | |
| 42 if (!has_interface<PPB_HostResolver_Private>()) | |
| 43 return callback.MayForce(PP_ERROR_NOINTERFACE); | |
| 44 return get_interface<PPB_HostResolver_Private>()->Resolve( | |
| 45 pp_resource(), | |
| 46 host.c_str(), | |
| 47 port, | |
| 48 &hint, | |
| 49 callback.pp_completion_callback()); | |
| 50 } | |
| 51 | |
| 52 void HostResolverPrivate::GetCanonicalName(std::string* canonical_name) { | |
| 53 if (!has_interface<PPB_HostResolver_Private>()) | |
| 54 return; | |
| 55 pp::Var pp_canonical_name( | |
| 56 pp::PassRef(), | |
| 57 get_interface<PPB_HostResolver_Private>()->GetCanonicalName( | |
| 58 pp_resource())); | |
| 59 *canonical_name = pp_canonical_name.AsString(); | |
| 60 } | |
| 61 | |
| 62 uint32_t HostResolverPrivate::GetSize() { | |
| 63 if (!has_interface<PPB_HostResolver_Private>()) | |
| 64 return 0; | |
| 65 return get_interface<PPB_HostResolver_Private>()->GetSize(pp_resource()); | |
| 66 } | |
| 67 | |
| 68 bool HostResolverPrivate::GetNetAddress(uint32_t index, | |
| 69 PP_NetAddress_Private* address) { | |
| 70 if (!has_interface<PPB_HostResolver_Private>()) | |
| 71 return false; | |
| 72 PP_Bool result = get_interface<PPB_HostResolver_Private>()->GetNetAddress( | |
| 73 pp_resource(), index, address); | |
| 74 return PP_ToBool(result); | |
| 75 } | |
| 76 | |
| 77 } // namespace pp | |
| OLD | NEW |