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

Side by Side Diff: ppapi/proxy/udp_socket_private_resource.h

Issue 16282005: Introduce PPB_UDPSocket_Dev. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/resource_creation_proxy.cc ('k') | ppapi/proxy/udp_socket_private_resource.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 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 #ifndef PPAPI_PROXY_UDP_SOCKET_PRIVATE_RESOURCE_H_ 5 #ifndef PPAPI_PROXY_UDP_SOCKET_PRIVATE_RESOURCE_H_
6 #define PPAPI_PROXY_UDP_SOCKET_PRIVATE_RESOURCE_H_ 6 #define PPAPI_PROXY_UDP_SOCKET_PRIVATE_RESOURCE_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "ppapi/proxy/plugin_resource.h"
11 #include "ppapi/proxy/ppapi_proxy_export.h" 10 #include "ppapi/proxy/ppapi_proxy_export.h"
12 #include "ppapi/shared_impl/tracked_callback.h" 11 #include "ppapi/proxy/udp_socket_resource_base.h"
13 #include "ppapi/thunk/ppb_udp_socket_private_api.h" 12 #include "ppapi/thunk/ppb_udp_socket_private_api.h"
14 13
15 namespace ppapi { 14 namespace ppapi {
16 namespace proxy { 15 namespace proxy {
17 16
18 class PPAPI_PROXY_EXPORT UDPSocketPrivateResource 17 class PPAPI_PROXY_EXPORT UDPSocketPrivateResource
19 : public PluginResource, 18 : public UDPSocketResourceBase,
20 public thunk::PPB_UDPSocket_Private_API { 19 public thunk::PPB_UDPSocket_Private_API {
21 public: 20 public:
22 UDPSocketPrivateResource(Connection connection, 21 UDPSocketPrivateResource(Connection connection, PP_Instance instance);
23 PP_Instance instance);
24 virtual ~UDPSocketPrivateResource(); 22 virtual ~UDPSocketPrivateResource();
25 23
26 // The maximum number of bytes that each PpapiHostMsg_PPBUDPSocket_RecvFrom
27 // message is allowed to request.
28 static const int32_t kMaxReadSize;
29 // The maximum number of bytes that each PpapiHostMsg_PPBUDPSocket_SendTo
30 // message is allowed to carry.
31 static const int32_t kMaxWriteSize;
32
33 // PluginResource implementation. 24 // PluginResource implementation.
34 virtual thunk::PPB_UDPSocket_Private_API* 25 virtual thunk::PPB_UDPSocket_Private_API*
35 AsPPB_UDPSocket_Private_API() OVERRIDE; 26 AsPPB_UDPSocket_Private_API() OVERRIDE;
36 27
37 // PPB_UDPSocket_Private_API implementation. 28 // PPB_UDPSocket_Private_API implementation.
38 virtual int32_t SetSocketFeature(PP_UDPSocketFeature_Private name, 29 virtual int32_t SetSocketFeature(PP_UDPSocketFeature_Private name,
39 PP_Var value) OVERRIDE; 30 PP_Var value) OVERRIDE;
40 virtual int32_t Bind(const PP_NetAddress_Private* addr, 31 virtual int32_t Bind(const PP_NetAddress_Private* addr,
41 scoped_refptr<TrackedCallback> callback) OVERRIDE; 32 scoped_refptr<TrackedCallback> callback) OVERRIDE;
42 virtual PP_Bool GetBoundAddress(PP_NetAddress_Private* addr) OVERRIDE; 33 virtual PP_Bool GetBoundAddress(PP_NetAddress_Private* addr) OVERRIDE;
43 virtual int32_t RecvFrom(char* buffer, 34 virtual int32_t RecvFrom(char* buffer,
44 int32_t num_bytes, 35 int32_t num_bytes,
45 scoped_refptr<TrackedCallback> callback) OVERRIDE; 36 scoped_refptr<TrackedCallback> callback) OVERRIDE;
46 virtual PP_Bool GetRecvFromAddress(PP_NetAddress_Private* addr) OVERRIDE; 37 virtual PP_Bool GetRecvFromAddress(PP_NetAddress_Private* addr) OVERRIDE;
47 virtual int32_t SendTo(const char* buffer, 38 virtual int32_t SendTo(const char* buffer,
48 int32_t num_bytes, 39 int32_t num_bytes,
49 const PP_NetAddress_Private* addr, 40 const PP_NetAddress_Private* addr,
50 scoped_refptr<TrackedCallback> callback) OVERRIDE; 41 scoped_refptr<TrackedCallback> callback) OVERRIDE;
51 virtual void Close() OVERRIDE; 42 virtual void Close() OVERRIDE;
52 43
53 private: 44 private:
54 void PostAbortIfNecessary(scoped_refptr<TrackedCallback>* callback);
55
56 void SendBoolSocketFeature(int32_t name, bool value);
57 void SendBind(const PP_NetAddress_Private& addr);
58 void SendRecvFrom(int32_t num_bytes);
59 void SendSendTo(const std::string& buffer,
60 const PP_NetAddress_Private& addr);
61 void SendClose();
62
63 // IPC message handlers.
64 void OnPluginMsgBindReply(const ResourceMessageReplyParams& params,
65 const PP_NetAddress_Private& bound_addr);
66 void OnPluginMsgRecvFromReply(const ResourceMessageReplyParams& params,
67 const std::string& data,
68 const PP_NetAddress_Private& addr);
69 void OnPluginMsgSendToReply(const ResourceMessageReplyParams& params,
70 int32_t bytes_written);
71
72 bool bound_;
73 bool closed_;
74
75 scoped_refptr<TrackedCallback> bind_callback_;
76 scoped_refptr<TrackedCallback> recvfrom_callback_;
77 scoped_refptr<TrackedCallback> sendto_callback_;
78
79 char* read_buffer_;
80 int32_t bytes_to_read_;
81
82 PP_NetAddress_Private recvfrom_addr_;
83 PP_NetAddress_Private bound_addr_;
84
85 DISALLOW_COPY_AND_ASSIGN(UDPSocketPrivateResource); 45 DISALLOW_COPY_AND_ASSIGN(UDPSocketPrivateResource);
86 }; 46 };
87 47
88 } // namespace proxy 48 } // namespace proxy
89 } // namespace ppapi 49 } // namespace ppapi
90 50
91 #endif // PPAPI_PROXY_UDP_SOCKET_PRIVATE_RESOURCE_H_ 51 #endif // PPAPI_PROXY_UDP_SOCKET_PRIVATE_RESOURCE_H_
OLDNEW
« no previous file with comments | « ppapi/proxy/resource_creation_proxy.cc ('k') | ppapi/proxy/udp_socket_private_resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698