Chromium Code Reviews| Index: ppapi/cpp/private/flash_udp_socket.cc |
| diff --git a/ppapi/cpp/private/flash_udp_socket.cc b/ppapi/cpp/private/flash_udp_socket.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..35fce55ef1ae3eea150840093ac9e25d46a57f55 |
| --- /dev/null |
| +++ b/ppapi/cpp/private/flash_udp_socket.cc |
| @@ -0,0 +1,71 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ppapi/cpp/private/flash_udp_socket.h" |
| + |
| +#include "ppapi/c/pp_bool.h" |
| +#include "ppapi/c/pp_errors.h" |
| +#include "ppapi/cpp/completion_callback.h" |
| +#include "ppapi/cpp/instance.h" |
| +#include "ppapi/cpp/module.h" |
| +#include "ppapi/cpp/module_impl.h" |
| + |
| +namespace pp { |
| + |
| +namespace { |
| + |
| +template <> const char* interface_name<PPB_Flash_UDPSocket>() { |
| + return PPB_FLASH_UDPSOCKET_INTERFACE; |
| +} |
| + |
| +} // namespace |
| + |
| +namespace flash { |
| + |
| +UDPSocket::UDPSocket(Instance* instance, int32_t family) { |
| + if (has_interface<PPB_Flash_UDPSocket>() && instance) { |
| + PassRefFromConstructor(get_interface<PPB_Flash_UDPSocket>()->Create( |
| + instance->pp_instance(), family)); |
| + } |
| +} |
| + |
| +int32_t UDPSocket::Bind(const PP_Flash_NetAddress* addr, |
| + const CompletionCallback& callback) { |
| + if (!has_interface<PPB_Flash_UDPSocket>()) |
|
yzshen1
2011/09/17 02:10:07
Wrong indent.
mtilburg
2011/09/21 01:46:43
Done.
|
| + return PP_ERROR_NOINTERFACE; |
| + return get_interface<PPB_Flash_UDPSocket>()->Bind( |
| + pp_resource(), addr, callback.pp_completion_callback()); |
| +} |
| + |
| +int32_t UDPSocket::RecvFrom(char *buffer, |
|
yzshen1
2011/09/17 02:10:07
Style nit: * position.
mtilburg
2011/09/21 01:46:43
Done.
|
| + int32_t num_bytes, |
| + const CompletionCallback& callback) { |
| + if (!has_interface<PPB_Flash_UDPSocket>()) |
| + return PP_ERROR_NOINTERFACE; |
| + return get_interface<PPB_Flash_UDPSocket>()->RecvFrom( |
| + pp_resource(), buffer, num_bytes, callback.pp_completion_callback()); |
|
yzshen1
2011/09/17 02:10:07
Wrong indent.
mtilburg
2011/09/21 01:46:43
Done.
|
| +} |
| + |
| +bool UDPSocket::GetRecvFromAddress(PP_Flash_NetAddress* addr) { |
| + if (!has_interface<PPB_Flash_UDPSocket>()) |
| + return false; |
| + |
| + PP_Bool result = get_interface<PPB_Flash_UDPSocket>()->GetRecvFromAddress( |
| + pp_resource(), addr); |
| + return PP_ToBool(result); |
| +} |
| + |
| +int32_t UDPSocket::SendTo(const char* buffer, |
| + int32_t num_bytes, |
| + const struct PP_Flash_NetAddress* addr, |
| + const CompletionCallback& callback) { |
| + if (!has_interface<PPB_Flash_UDPSocket>()) |
| + return PP_ERROR_NOINTERFACE; |
| + return get_interface<PPB_Flash_UDPSocket>()->SendTo( |
| + pp_resource(), buffer, num_bytes, addr, callback.pp_completion_callback()); |
|
yzshen1
2011/09/17 02:10:07
Wrong indent.
mtilburg
2011/09/21 01:46:43
Done.
|
| +} |
| + |
| +} // namespace flash |
| +} // namespace pp |
| + |