| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/cpp/private/flash_udp_socket.h" | 5 #include "ppapi/cpp/private/flash_udp_socket.h" |
| 6 | 6 |
| 7 #include "ppapi/c/pp_bool.h" | 7 #include "ppapi/c/pp_bool.h" |
| 8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
| 9 #include "ppapi/cpp/completion_callback.h" | 9 #include "ppapi/cpp/completion_callback.h" |
| 10 #include "ppapi/cpp/instance.h" | 10 #include "ppapi/cpp/instance.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 namespace flash { | 24 namespace flash { |
| 25 | 25 |
| 26 UDPSocket::UDPSocket(Instance* instance) { | 26 UDPSocket::UDPSocket(Instance* instance) { |
| 27 if (has_interface<PPB_Flash_UDPSocket>() && instance) { | 27 if (has_interface<PPB_Flash_UDPSocket>() && instance) { |
| 28 PassRefFromConstructor(get_interface<PPB_Flash_UDPSocket>()->Create( | 28 PassRefFromConstructor(get_interface<PPB_Flash_UDPSocket>()->Create( |
| 29 instance->pp_instance())); | 29 instance->pp_instance())); |
| 30 } | 30 } |
| 31 } | 31 } |
| 32 | 32 |
| 33 int32_t UDPSocket::Bind(const PP_Flash_NetAddress* addr, | 33 int32_t UDPSocket::Bind(const PP_NetAddress_Private* addr, |
| 34 const CompletionCallback& callback) { | 34 const CompletionCallback& callback) { |
| 35 if (!has_interface<PPB_Flash_UDPSocket>()) | 35 if (!has_interface<PPB_Flash_UDPSocket>()) |
| 36 return PP_ERROR_NOINTERFACE; | 36 return PP_ERROR_NOINTERFACE; |
| 37 return get_interface<PPB_Flash_UDPSocket>()->Bind( | 37 return get_interface<PPB_Flash_UDPSocket>()->Bind( |
| 38 pp_resource(), addr, callback.pp_completion_callback()); | 38 pp_resource(), addr, callback.pp_completion_callback()); |
| 39 } | 39 } |
| 40 | 40 |
| 41 int32_t UDPSocket::RecvFrom(char* buffer, | 41 int32_t UDPSocket::RecvFrom(char* buffer, |
| 42 int32_t num_bytes, | 42 int32_t num_bytes, |
| 43 const CompletionCallback& callback) { | 43 const CompletionCallback& callback) { |
| 44 if (!has_interface<PPB_Flash_UDPSocket>()) | 44 if (!has_interface<PPB_Flash_UDPSocket>()) |
| 45 return PP_ERROR_NOINTERFACE; | 45 return PP_ERROR_NOINTERFACE; |
| 46 return get_interface<PPB_Flash_UDPSocket>()->RecvFrom( | 46 return get_interface<PPB_Flash_UDPSocket>()->RecvFrom( |
| 47 pp_resource(), buffer, num_bytes, callback.pp_completion_callback()); | 47 pp_resource(), buffer, num_bytes, callback.pp_completion_callback()); |
| 48 } | 48 } |
| 49 | 49 |
| 50 bool UDPSocket::GetRecvFromAddress(PP_Flash_NetAddress* addr) { | 50 bool UDPSocket::GetRecvFromAddress(PP_NetAddress_Private* addr) { |
| 51 if (!has_interface<PPB_Flash_UDPSocket>()) | 51 if (!has_interface<PPB_Flash_UDPSocket>()) |
| 52 return false; | 52 return false; |
| 53 | 53 |
| 54 PP_Bool result = get_interface<PPB_Flash_UDPSocket>()->GetRecvFromAddress( | 54 PP_Bool result = get_interface<PPB_Flash_UDPSocket>()->GetRecvFromAddress( |
| 55 pp_resource(), addr); | 55 pp_resource(), addr); |
| 56 return PP_ToBool(result); | 56 return PP_ToBool(result); |
| 57 } | 57 } |
| 58 | 58 |
| 59 int32_t UDPSocket::SendTo(const char* buffer, | 59 int32_t UDPSocket::SendTo(const char* buffer, |
| 60 int32_t num_bytes, | 60 int32_t num_bytes, |
| 61 const struct PP_Flash_NetAddress* addr, | 61 const PP_NetAddress_Private* addr, |
| 62 const CompletionCallback& callback) { | 62 const CompletionCallback& callback) { |
| 63 if (!has_interface<PPB_Flash_UDPSocket>()) | 63 if (!has_interface<PPB_Flash_UDPSocket>()) |
| 64 return PP_ERROR_NOINTERFACE; | 64 return PP_ERROR_NOINTERFACE; |
| 65 return get_interface<PPB_Flash_UDPSocket>()->SendTo( | 65 return get_interface<PPB_Flash_UDPSocket>()->SendTo( |
| 66 pp_resource(), buffer, num_bytes, addr, | 66 pp_resource(), buffer, num_bytes, addr, |
| 67 callback.pp_completion_callback()); | 67 callback.pp_completion_callback()); |
| 68 } | 68 } |
| 69 | 69 |
| 70 } // namespace flash | 70 } // namespace flash |
| 71 } // namespace pp | 71 } // namespace pp |
| 72 | 72 |
| OLD | NEW |