| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "webkit/plugins/ppapi/ppb_udp_socket_private_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_udp_socket_private_impl.h" |
| 6 | 6 |
| 7 #include "webkit/plugins/ppapi/host_globals.h" | 7 #include "webkit/plugins/ppapi/host_globals.h" |
| 8 #include "webkit/plugins/ppapi/plugin_delegate.h" | 8 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 9 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 9 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 10 #include "webkit/plugins/ppapi/resource_helper.h" | 10 #include "webkit/plugins/ppapi/resource_helper.h" |
| 11 | 11 |
| 12 namespace webkit { | 12 namespace webkit { |
| 13 namespace ppapi { | 13 namespace ppapi { |
| 14 | 14 |
| 15 PPB_UDPSocket_Private_Impl::PPB_UDPSocket_Private_Impl( | 15 PPB_UDPSocket_Private_Impl::PPB_UDPSocket_Private_Impl( |
| 16 PP_Instance instance, uint32 socket_id) | 16 PP_Instance instance, uint32 socket_id) |
| 17 : ::ppapi::UDPSocketPrivateImpl(instance, socket_id) { | 17 : Resource(::ppapi::OBJECT_IS_IMPL, instance), |
| 18 socket_id_(socket_id) { |
| 18 } | 19 } |
| 19 | 20 |
| 20 PPB_UDPSocket_Private_Impl::~PPB_UDPSocket_Private_Impl() { | 21 PPB_UDPSocket_Private_Impl::~PPB_UDPSocket_Private_Impl() { |
| 21 Close(); | 22 Close(); |
| 22 } | 23 } |
| 23 | 24 |
| 24 PP_Resource PPB_UDPSocket_Private_Impl::CreateResource(PP_Instance instance) { | 25 PP_Resource PPB_UDPSocket_Private_Impl::CreateResource(PP_Instance instance) { |
| 25 PluginInstance* plugin_instance = HostGlobals::Get()->GetInstance(instance); | 26 PluginInstance* plugin_instance = HostGlobals::Get()->GetInstance(instance); |
| 26 if (!plugin_instance) | 27 if (!plugin_instance) |
| 27 return 0; | 28 return 0; |
| 28 | 29 |
| 29 PluginDelegate* plugin_delegate = plugin_instance->delegate(); | 30 PluginDelegate* plugin_delegate = plugin_instance->delegate(); |
| 30 uint32 socket_id = plugin_delegate->UDPSocketCreate(); | 31 uint32 socket_id = plugin_delegate->UDPSocketCreate(); |
| 31 if (!socket_id) | 32 if (!socket_id) |
| 32 return 0; | 33 return 0; |
| 33 | 34 |
| 34 return (new PPB_UDPSocket_Private_Impl(instance, socket_id))->GetReference(); | 35 return (new PPB_UDPSocket_Private_Impl(instance, socket_id))->GetReference(); |
| 35 } | 36 } |
| 36 | 37 |
| 38 ::ppapi::thunk::PPB_UDPSocket_Private_API* |
| 39 PPB_UDPSocket_Private_Impl::AsPPB_UDPSocket_Private_API() { |
| 40 return this; |
| 41 } |
| 42 |
| 37 void PPB_UDPSocket_Private_Impl::SendBoolSocketFeature(int32_t name, | 43 void PPB_UDPSocket_Private_Impl::SendBoolSocketFeature(int32_t name, |
| 38 bool value) { | 44 bool value) { |
| 39 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); | 45 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); |
| 40 if (!plugin_delegate) | 46 if (!plugin_delegate) |
| 41 return; | 47 return; |
| 42 | 48 |
| 43 plugin_delegate->UDPSocketSetBoolSocketFeature(this, socket_id_, name, value); | 49 plugin_delegate->UDPSocketSetBoolSocketFeature(this, socket_id_, name, value); |
| 44 } | 50 } |
| 45 | 51 |
| 46 void PPB_UDPSocket_Private_Impl::SendBind(const PP_NetAddress_Private& addr) { | 52 void PPB_UDPSocket_Private_Impl::SendBind(const PP_NetAddress_Private& addr) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 71 void PPB_UDPSocket_Private_Impl::SendClose() { | 77 void PPB_UDPSocket_Private_Impl::SendClose() { |
| 72 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); | 78 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); |
| 73 if (!plugin_delegate) | 79 if (!plugin_delegate) |
| 74 return; | 80 return; |
| 75 | 81 |
| 76 plugin_delegate->UDPSocketClose(socket_id_); | 82 plugin_delegate->UDPSocketClose(socket_id_); |
| 77 } | 83 } |
| 78 | 84 |
| 79 } // namespace ppapi | 85 } // namespace ppapi |
| 80 } // namespace webkit | 86 } // namespace webkit |
| OLD | NEW |