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 #include "webkit/plugins/ppapi/ppb_udp_socket_private_impl.h" |
| 6 |
| 7 #include "webkit/plugins/ppapi/host_globals.h" |
| 8 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 9 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 10 #include "webkit/plugins/ppapi/resource_helper.h" |
| 11 |
| 12 namespace webkit { |
| 13 namespace ppapi { |
| 14 |
| 15 PPB_UDPSocket_Private_Impl::PPB_UDPSocket_Private_Impl( |
| 16 PP_Instance instance, uint32 socket_id) |
| 17 : ::ppapi::UDPSocketPrivateImpl(instance, socket_id) { |
| 18 } |
| 19 |
| 20 PPB_UDPSocket_Private_Impl::~PPB_UDPSocket_Private_Impl() { |
| 21 Close(); |
| 22 } |
| 23 |
| 24 PP_Resource PPB_UDPSocket_Private_Impl::CreateResource(PP_Instance instance) { |
| 25 PluginInstance* plugin_instance = HostGlobals::Get()->GetInstance(instance); |
| 26 if (!plugin_instance) |
| 27 return 0; |
| 28 |
| 29 PluginDelegate* pluign_delegate = plugin_instance->delegate(); |
| 30 uint32 socket_id = pluign_delegate->UDPSocketCreate(); |
| 31 if (!socket_id) |
| 32 return 0; |
| 33 |
| 34 return (new PPB_UDPSocket_Private_Impl(instance, socket_id))->GetReference(); |
| 35 } |
| 36 |
| 37 void PPB_UDPSocket_Private_Impl::SendBind(const PP_NetAddress_Private& addr) { |
| 38 PluginDelegate* pluign_delegate = ResourceHelper::GetPluginDelegate(this); |
| 39 if (!pluign_delegate) |
| 40 return; |
| 41 |
| 42 pluign_delegate->UDPSocketBind(this, socket_id_, addr); |
| 43 } |
| 44 |
| 45 void PPB_UDPSocket_Private_Impl::SendRecvFrom(int32_t num_bytes) { |
| 46 PluginDelegate* pluign_delegate = ResourceHelper::GetPluginDelegate(this); |
| 47 if (!pluign_delegate) |
| 48 return; |
| 49 |
| 50 pluign_delegate->UDPSocketRecvFrom(socket_id_, num_bytes); |
| 51 } |
| 52 |
| 53 void PPB_UDPSocket_Private_Impl::SendSendTo(const std::string& buffer, |
| 54 const PP_NetAddress_Private& addr) { |
| 55 PluginDelegate* pluign_delegate = ResourceHelper::GetPluginDelegate(this); |
| 56 if (!pluign_delegate) |
| 57 return; |
| 58 |
| 59 pluign_delegate->UDPSocketSendTo(socket_id_, buffer, addr); |
| 60 } |
| 61 |
| 62 void PPB_UDPSocket_Private_Impl::SendClose() { |
| 63 PluginDelegate* pluign_delegate = ResourceHelper::GetPluginDelegate(this); |
| 64 if (!pluign_delegate) |
| 65 return; |
| 66 |
| 67 pluign_delegate->UDPSocketClose(socket_id_); |
| 68 } |
| 69 |
| 70 } // namespace ppapi |
| 71 } // namespace webkit |
OLD | NEW |