OLD | NEW |
| (Empty) |
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 | |
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* plugin_delegate = plugin_instance->delegate(); | |
30 uint32 socket_id = plugin_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::SendBoolSocketFeature(int32_t name, | |
38 bool value) { | |
39 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); | |
40 if (!plugin_delegate) | |
41 return; | |
42 | |
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); | |
52 } | |
53 | |
54 void PPB_UDPSocket_Private_Impl::SendRecvFrom(int32_t num_bytes) { | |
55 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); | |
56 if (!plugin_delegate) | |
57 return; | |
58 | |
59 plugin_delegate->UDPSocketRecvFrom(socket_id_, num_bytes); | |
60 } | |
61 | |
62 void PPB_UDPSocket_Private_Impl::SendSendTo(const std::string& buffer, | |
63 const PP_NetAddress_Private& addr) { | |
64 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); | |
65 if (!plugin_delegate) | |
66 return; | |
67 | |
68 plugin_delegate->UDPSocketSendTo(socket_id_, buffer, addr); | |
69 } | |
70 | |
71 void PPB_UDPSocket_Private_Impl::SendClose() { | |
72 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); | |
73 if (!plugin_delegate) | |
74 return; | |
75 | |
76 plugin_delegate->UDPSocketClose(socket_id_); | |
77 } | |
78 | |
79 } // namespace ppapi | |
80 } // namespace webkit | |
OLD | NEW |