| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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 // TODO(viettrungluu): See the comment in corresponding .h file. | |
| 6 | |
| 7 #include "ppapi/cpp/private/flash_net_address.h" | |
| 8 | |
| 9 #include "ppapi/c/pp_bool.h" | |
| 10 #include "ppapi/cpp/module.h" | |
| 11 #include "ppapi/cpp/module_impl.h" | |
| 12 #include "ppapi/cpp/var.h" | |
| 13 #include "ppapi/c/private/ppb_flash_net_address.h" | |
| 14 | |
| 15 namespace pp { | |
| 16 | |
| 17 namespace { | |
| 18 | |
| 19 template <> const char* interface_name<PPB_Flash_NetAddress>() { | |
| 20 return PPB_FLASH_NETADDRESS_INTERFACE; | |
| 21 } | |
| 22 | |
| 23 } // namespace | |
| 24 | |
| 25 namespace flash { | |
| 26 | |
| 27 // static | |
| 28 bool NetAddress::AreEqual(const PP_Flash_NetAddress& addr1, | |
| 29 const PP_Flash_NetAddress& addr2) { | |
| 30 if (!has_interface<PPB_Flash_NetAddress>()) | |
| 31 return false; | |
| 32 return !!get_interface<PPB_Flash_NetAddress>()->AreEqual(&addr1, &addr2); | |
| 33 } | |
| 34 | |
| 35 // static | |
| 36 bool NetAddress::AreHostsEqual(const PP_Flash_NetAddress& addr1, | |
| 37 const PP_Flash_NetAddress& addr2) { | |
| 38 if (!has_interface<PPB_Flash_NetAddress>()) | |
| 39 return false; | |
| 40 return !!get_interface<PPB_Flash_NetAddress>()->AreHostsEqual(&addr1, &addr2); | |
| 41 } | |
| 42 | |
| 43 // static | |
| 44 std::string NetAddress::Describe(const PP_Flash_NetAddress& addr, | |
| 45 bool include_port) { | |
| 46 if (!has_interface<PPB_Flash_NetAddress>()) | |
| 47 return std::string(); | |
| 48 | |
| 49 Module* module = Module::Get(); | |
| 50 if (!module) | |
| 51 return std::string(); | |
| 52 | |
| 53 Var result(Var::PassRef(), | |
| 54 get_interface<PPB_Flash_NetAddress>()->Describe( | |
| 55 module->pp_module(), | |
| 56 &addr, | |
| 57 PP_FromBool(include_port))); | |
| 58 return result.is_string() ? result.AsString() : std::string(); | |
| 59 } | |
| 60 | |
| 61 // static | |
| 62 bool NetAddress::ReplacePort(const PP_Flash_NetAddress& addr_in, | |
| 63 uint16_t port, | |
| 64 PP_Flash_NetAddress* addr_out) { | |
| 65 if (!has_interface<PPB_Flash_NetAddress>()) | |
| 66 return false; | |
| 67 return !!get_interface<PPB_Flash_NetAddress>()->ReplacePort(&addr_in, | |
| 68 port, | |
| 69 addr_out); | |
| 70 } | |
| 71 | |
| 72 // static | |
| 73 void NetAddress::GetAnyAddress(bool is_ipv6, PP_Flash_NetAddress* addr) { | |
| 74 if (!has_interface<PPB_Flash_NetAddress>()) | |
| 75 return; | |
| 76 get_interface<PPB_Flash_NetAddress>()->GetAnyAddress(PP_FromBool(is_ipv6), | |
| 77 addr); | |
| 78 } | |
| 79 | |
| 80 } // namespace flash | |
| 81 } // namespace pp | |
| OLD | NEW |