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

Side by Side Diff: ppapi/shared_impl/private/udp_socket_private_impl.h

Issue 8804006: Reland 8688002: PPB_TCPSocket_Private/PPB_UDPSocket_Private are exposed to Browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix destruction issue 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 | Annotate | Revision Log
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 #ifndef PPAPI_SHARED_IMPL_PRIVATE_UDP_SOCKET_PRIVATE_IMPL_H_
6 #define PPAPI_SHARED_IMPL_PRIVATE_UDP_SOCKET_PRIVATE_IMPL_H_
7
8 #include <string>
9
10 #include "base/compiler_specific.h"
11 #include "ppapi/shared_impl/resource.h"
12 #include "ppapi/thunk/ppb_udp_socket_private_api.h"
13
14 namespace ppapi {
15
16 // This class provides the shared implementation of a
17 // PPB_UDPSocket_Private. The functions that actually send messages
18 // to browser are implemented differently for the proxied and
19 // non-proxied derived classes.
20 class PPAPI_SHARED_EXPORT UDPSocketPrivateImpl
21 : public thunk::PPB_UDPSocket_Private_API,
22 public Resource {
23 public:
24 // C-tor used in Impl case.
25 UDPSocketPrivateImpl(PP_Instance instance, uint32 socket_id);
26 // C-tor used in Proxy case.
27 UDPSocketPrivateImpl(const HostResource& resource, uint32 socket_id);
28
29 virtual ~UDPSocketPrivateImpl();
30
31 // The maximum number of bytes that each PpapiHostMsg_PPBUDPSocket_RecvFrom
32 // message is allowed to request.
33 static const int32_t kMaxReadSize;
34 // The maximum number of bytes that each PpapiHostMsg_PPBUDPSocket_SendTo
35 // message is allowed to carry.
36 static const int32_t kMaxWriteSize;
37
38 // Resource overrides.
39 virtual PPB_UDPSocket_Private_API* AsPPB_UDPSocket_Private_API() OVERRIDE;
40
41 // PPB_UDPSocket_Private_API implementation.
42 virtual int32_t Bind(const PP_NetAddress_Private* addr,
43 PP_CompletionCallback callback) OVERRIDE;
44 virtual int32_t RecvFrom(char* buffer,
45 int32_t num_bytes,
46 PP_CompletionCallback callback) OVERRIDE;
47 virtual PP_Bool GetRecvFromAddress(PP_NetAddress_Private* addr) OVERRIDE;
48 virtual int32_t SendTo(const char* buffer,
49 int32_t num_bytes,
50 const PP_NetAddress_Private* addr,
51 PP_CompletionCallback callback) OVERRIDE;
52 virtual void Close() OVERRIDE;
53
54 // Notifications from the proxy.
55 void OnBindCompleted(bool succeeded);
56 void OnRecvFromCompleted(bool succeeded,
57 const std::string& data,
58 const PP_NetAddress_Private& addr);
59 void OnSendToCompleted(bool succeeded, int32_t bytes_written);
60
61 // Send functions that need to be implemented differently for
62 // the proxied and non-proxied derived classes.
63 virtual void SendBind(const PP_NetAddress_Private& addr) = 0;
64 virtual void SendRecvFrom(int32_t num_bytes) = 0;
65 virtual void SendSendTo(const std::string& buffer,
66 const PP_NetAddress_Private& addr) = 0;
67 virtual void SendClose() = 0;
68
69 protected:
70 void Init(uint32 socket_id);
71 void PostAbortAndClearIfNecessary(PP_CompletionCallback* callback);
72
73 uint32 socket_id_;
74
75 bool bound_;
76 bool closed_;
77
78 PP_CompletionCallback bind_callback_;
79 PP_CompletionCallback recvfrom_callback_;
80 PP_CompletionCallback sendto_callback_;
81
82 char* read_buffer_;
83 int32_t bytes_to_read_;
84
85 PP_NetAddress_Private recvfrom_addr_;
86
87 DISALLOW_COPY_AND_ASSIGN(UDPSocketPrivateImpl);
88 };
89
90 } // namespace ppapi
91
92 #endif // PPAPI_SHARED_IMPL_PRIVATE_UDP_SOCKET_PRIVATE_IMPL_H_
OLDNEW
« no previous file with comments | « ppapi/shared_impl/private/tcp_socket_private_impl.cc ('k') | ppapi/shared_impl/private/udp_socket_private_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698