Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Side by Side Diff: webkit/plugins/ppapi/ppb_udp_socket_private_impl.cc

Issue 10735056: AllowBroadcast() is exposed to NaCl. (Closed) Base URL: http://git.chromium.org/chromium/src.git@udp_broadcast
Patch Set: Deleted callbacks. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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::SendSetSocketFeature(
38 PluginDelegate* pluign_delegate = ResourceHelper::GetPluginDelegate(this); 38 PP_UDPSocketFeature_Private name,
39 if (!pluign_delegate) 39 PP_Var value) {
40 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this);
41 if (!plugin_delegate)
40 return; 42 return;
41 43
42 pluign_delegate->UDPSocketBind(this, socket_id_, addr); 44 plugin_delegate->UDPSocketSetSocketFeature(this, socket_id_, name, value);
45 }
46
47 void PPB_UDPSocket_Private_Impl::SendBind(const PP_NetAddress_Private& addr) {
48 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this);
49 if (!plugin_delegate)
50 return;
51
52 plugin_delegate->UDPSocketBind(this, socket_id_, addr);
43 } 53 }
44 54
45 void PPB_UDPSocket_Private_Impl::SendRecvFrom(int32_t num_bytes) { 55 void PPB_UDPSocket_Private_Impl::SendRecvFrom(int32_t num_bytes) {
46 PluginDelegate* pluign_delegate = ResourceHelper::GetPluginDelegate(this); 56 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this);
47 if (!pluign_delegate) 57 if (!plugin_delegate)
48 return; 58 return;
49 59
50 pluign_delegate->UDPSocketRecvFrom(socket_id_, num_bytes); 60 plugin_delegate->UDPSocketRecvFrom(socket_id_, num_bytes);
51 } 61 }
52 62
53 void PPB_UDPSocket_Private_Impl::SendSendTo(const std::string& buffer, 63 void PPB_UDPSocket_Private_Impl::SendSendTo(const std::string& buffer,
54 const PP_NetAddress_Private& addr) { 64 const PP_NetAddress_Private& addr) {
55 PluginDelegate* pluign_delegate = ResourceHelper::GetPluginDelegate(this); 65 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this);
56 if (!pluign_delegate) 66 if (!plugin_delegate)
57 return; 67 return;
58 68
59 pluign_delegate->UDPSocketSendTo(socket_id_, buffer, addr); 69 plugin_delegate->UDPSocketSendTo(socket_id_, buffer, addr);
60 } 70 }
61 71
62 void PPB_UDPSocket_Private_Impl::SendClose() { 72 void PPB_UDPSocket_Private_Impl::SendClose() {
63 PluginDelegate* pluign_delegate = ResourceHelper::GetPluginDelegate(this); 73 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this);
64 if (!pluign_delegate) 74 if (!plugin_delegate)
65 return; 75 return;
66 76
67 pluign_delegate->UDPSocketClose(socket_id_); 77 plugin_delegate->UDPSocketClose(socket_id_);
68 } 78 }
69 79
70 } // namespace ppapi 80 } // namespace ppapi
71 } // namespace webkit 81 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698