OLD | NEW |
1 // Copyright (c) 2011 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 : ::ppapi::UDPSocketPrivateImpl(instance, socket_id) { |
18 } | 18 } |
19 | 19 |
20 PPB_UDPSocket_Private_Impl::~PPB_UDPSocket_Private_Impl() { | 20 PPB_UDPSocket_Private_Impl::~PPB_UDPSocket_Private_Impl() { |
21 Close(); | 21 Close(); |
22 } | 22 } |
23 | 23 |
24 PP_Resource PPB_UDPSocket_Private_Impl::CreateResource(PP_Instance instance) { | 24 PP_Resource PPB_UDPSocket_Private_Impl::CreateResource(PP_Instance instance) { |
25 PluginInstance* plugin_instance = HostGlobals::Get()->GetInstance(instance); | 25 PluginInstance* plugin_instance = HostGlobals::Get()->GetInstance(instance); |
26 if (!plugin_instance) | 26 if (!plugin_instance) |
27 return 0; | 27 return 0; |
28 | 28 |
29 PluginDelegate* pluign_delegate = plugin_instance->delegate(); | 29 PluginDelegate* plugin_delegate = plugin_instance->delegate(); |
30 uint32 socket_id = pluign_delegate->UDPSocketCreate(); | 30 uint32 socket_id = plugin_delegate->UDPSocketCreate(); |
31 if (!socket_id) | 31 if (!socket_id) |
32 return 0; | 32 return 0; |
33 | 33 |
34 return (new PPB_UDPSocket_Private_Impl(instance, socket_id))->GetReference(); | 34 return (new PPB_UDPSocket_Private_Impl(instance, socket_id))->GetReference(); |
35 } | 35 } |
36 | 36 |
37 void PPB_UDPSocket_Private_Impl::SendBind(const PP_NetAddress_Private& addr) { | 37 void PPB_UDPSocket_Private_Impl::SendBoolSocketFeature(int32_t name, |
38 PluginDelegate* pluign_delegate = ResourceHelper::GetPluginDelegate(this); | 38 bool value) { |
39 if (!pluign_delegate) | 39 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); |
| 40 if (!plugin_delegate) |
40 return; | 41 return; |
41 | 42 |
42 pluign_delegate->UDPSocketBind(this, socket_id_, addr); | 43 plugin_delegate->UDPSocketSetBoolSocketFeature(this, socket_id_, name, value); |
| 44 } |
| 45 |
| 46 void PPB_UDPSocket_Private_Impl::SendBind(const PP_NetAddress_Private& addr) { |
| 47 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); |
| 48 if (!plugin_delegate) |
| 49 return; |
| 50 |
| 51 plugin_delegate->UDPSocketBind(this, socket_id_, addr); |
43 } | 52 } |
44 | 53 |
45 void PPB_UDPSocket_Private_Impl::SendRecvFrom(int32_t num_bytes) { | 54 void PPB_UDPSocket_Private_Impl::SendRecvFrom(int32_t num_bytes) { |
46 PluginDelegate* pluign_delegate = ResourceHelper::GetPluginDelegate(this); | 55 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); |
47 if (!pluign_delegate) | 56 if (!plugin_delegate) |
48 return; | 57 return; |
49 | 58 |
50 pluign_delegate->UDPSocketRecvFrom(socket_id_, num_bytes); | 59 plugin_delegate->UDPSocketRecvFrom(socket_id_, num_bytes); |
51 } | 60 } |
52 | 61 |
53 void PPB_UDPSocket_Private_Impl::SendSendTo(const std::string& buffer, | 62 void PPB_UDPSocket_Private_Impl::SendSendTo(const std::string& buffer, |
54 const PP_NetAddress_Private& addr) { | 63 const PP_NetAddress_Private& addr) { |
55 PluginDelegate* pluign_delegate = ResourceHelper::GetPluginDelegate(this); | 64 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); |
56 if (!pluign_delegate) | 65 if (!plugin_delegate) |
57 return; | 66 return; |
58 | 67 |
59 pluign_delegate->UDPSocketSendTo(socket_id_, buffer, addr); | 68 plugin_delegate->UDPSocketSendTo(socket_id_, buffer, addr); |
60 } | 69 } |
61 | 70 |
62 void PPB_UDPSocket_Private_Impl::SendClose() { | 71 void PPB_UDPSocket_Private_Impl::SendClose() { |
63 PluginDelegate* pluign_delegate = ResourceHelper::GetPluginDelegate(this); | 72 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); |
64 if (!pluign_delegate) | 73 if (!plugin_delegate) |
65 return; | 74 return; |
66 | 75 |
67 pluign_delegate->UDPSocketClose(socket_id_); | 76 plugin_delegate->UDPSocketClose(socket_id_); |
68 } | 77 } |
69 | 78 |
70 } // namespace ppapi | 79 } // namespace ppapi |
71 } // namespace webkit | 80 } // namespace webkit |
OLD | NEW |