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

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

Issue 8688002: PPB_TCPSocket_Private/PPB_UDPSocket_Private are exposed to Browser (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Added PPAPI_IN_PROCESS TCP and UDP tests. Created 9 years 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
(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 "base/bind.h"
8 #include "base/message_loop.h"
9 #include "base/task.h"
10 #include "ppapi/c/pp_completion_callback.h"
11 #include "webkit/plugins/ppapi/host_globals.h"
12 #include "webkit/plugins/ppapi/plugin_delegate.h"
13 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
14 #include "webkit/plugins/ppapi/resource_helper.h"
15
16 namespace webkit {
17 namespace ppapi {
18
19 namespace {
20
21 void AbortCallback(PP_CompletionCallback callback) {
22 PP_RunCompletionCallback(&callback, PP_ERROR_ABORTED);
23 }
24
25 } // namespace
26
27 PPB_UDPSocket_Private_Impl::PPB_UDPSocket_Private_Impl(
28 PP_Instance instance, uint32 socket_id)
29 : ::ppapi::UDPSocketImpl(instance, socket_id) {
30 }
31
32 PPB_UDPSocket_Private_Impl::~PPB_UDPSocket_Private_Impl() {
33 Close();
34 }
35
36 PP_Resource PPB_UDPSocket_Private_Impl::CreateResource(PP_Instance instance) {
37 PluginInstance* plugin_instance = HostGlobals::Get()->GetInstance(instance);
38 if (!plugin_instance)
39 return 0;
40
41 PluginDelegate* pluign_delegate = plugin_instance->delegate();
42 uint32 socket_id = pluign_delegate->UDPSocketCreate();
43 if (!socket_id)
44 return 0;
45
46 return (new PPB_UDPSocket_Private_Impl(instance, socket_id))->GetReference();
47 }
48
49 void PPB_UDPSocket_Private_Impl::SendBind(const PP_NetAddress_Private& addr) {
50 PluginDelegate* pluign_delegate = ResourceHelper::GetPluginDelegate(this);
51 if (!pluign_delegate)
52 return;
53
54 pluign_delegate->UDPSocketBind(this, socket_id_, addr);
55 }
56
57 void PPB_UDPSocket_Private_Impl::SendRecvFrom(int32_t num_bytes) {
58 PluginDelegate* pluign_delegate = ResourceHelper::GetPluginDelegate(this);
59 if (!pluign_delegate)
60 return;
61
62 pluign_delegate->UDPSocketRecvFrom(socket_id_, num_bytes);
63 }
64
65 void PPB_UDPSocket_Private_Impl::SendSendTo(const std::string& buffer,
66 const PP_NetAddress_Private& addr) {
67 PluginDelegate* pluign_delegate = ResourceHelper::GetPluginDelegate(this);
68 if (!pluign_delegate)
69 return;
70
71 pluign_delegate->UDPSocketSendTo(socket_id_, buffer, addr);
72 }
73
74 void PPB_UDPSocket_Private_Impl::SendClose() {
75 PluginDelegate* pluign_delegate = ResourceHelper::GetPluginDelegate(this);
76 if (!pluign_delegate)
77 return;
78
79 pluign_delegate->UDPSocketClose(socket_id_);
80 }
81
82 void PPB_UDPSocket_Private_Impl::PostAbort(PP_CompletionCallback callback) {
83 MessageLoop::current()->PostTask(FROM_HERE,
84 base::Bind(&AbortCallback, callback));
85 }
86
87 } // namespace ppapi
88 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698