OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 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_PROXY_UDP_SOCKET_SHARED_H_ | |
6 #define PPAPI_PROXY_UDP_SOCKET_SHARED_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/compiler_specific.h" | |
12 #include "base/memory/ref_counted.h" | |
13 #include "ppapi/c/private/ppb_net_address_private.h" | |
14 #include "ppapi/c/private/ppb_udp_socket_private.h" | |
15 #include "ppapi/proxy/plugin_resource.h" | |
16 #include "ppapi/proxy/ppapi_proxy_export.h" | |
17 #include "ppapi/shared_impl/tracked_callback.h" | |
18 | |
19 namespace ppapi { | |
20 namespace proxy { | |
21 | |
22 class ResourceMessageReplyParams; | |
23 | |
24 class PPAPI_PROXY_EXPORT UDPSocketShared: public PluginResource { | |
bbudge
2013/06/10 12:59:56
Naming: 'Shared' is slightly confusing, since we a
yzshen1
2013/06/10 22:10:35
Thanks! It sounds much better to be UDPSocketResou
| |
25 public: | |
26 UDPSocketShared(Connection connection, PP_Instance instance); | |
bbudge
2013/06/10 12:59:56
Is it ever OK to instantiate this class? If not, m
yzshen1
2013/06/10 22:10:35
Done.
On 2013/06/10 12:59:56, bbudge1 wrote:
| |
27 virtual ~UDPSocketShared(); | |
28 | |
29 // The maximum number of bytes that each PpapiHostMsg_PPBUDPSocket_RecvFrom | |
30 // message is allowed to request. | |
31 static const int32_t kMaxReadSize; | |
32 // The maximum number of bytes that each PpapiHostMsg_PPBUDPSocket_SendTo | |
33 // message is allowed to carry. | |
34 static const int32_t kMaxWriteSize; | |
35 | |
36 int32_t SetSocketFeatureImpl(PP_UDPSocketFeature_Private name, | |
37 const PP_Var& value); | |
38 int32_t BindImpl(const PP_NetAddress_Private* addr, | |
39 scoped_refptr<TrackedCallback> callback); | |
40 PP_Bool GetBoundAddressImpl(PP_NetAddress_Private* addr); | |
41 // |addr| could be NULL to indicate that an output value is not needed. | |
42 int32_t RecvFromImpl(char* buffer, | |
43 int32_t num_bytes, | |
44 PP_Resource* addr, | |
45 scoped_refptr<TrackedCallback> callback); | |
46 PP_Bool GetRecvFromAddressImpl(PP_NetAddress_Private* addr); | |
47 int32_t SendToImpl(const char* buffer, | |
48 int32_t num_bytes, | |
49 const PP_NetAddress_Private* addr, | |
50 scoped_refptr<TrackedCallback> callback); | |
51 void CloseImpl(); | |
52 | |
53 private: | |
54 void PostAbortIfNecessary(scoped_refptr<TrackedCallback>* callback); | |
55 | |
56 // IPC message handlers. | |
57 void OnPluginMsgBindReply(const ResourceMessageReplyParams& params, | |
58 const PP_NetAddress_Private& bound_addr); | |
59 void OnPluginMsgRecvFromReply(PP_Resource* output_addr, | |
60 const ResourceMessageReplyParams& params, | |
61 const std::string& data, | |
62 const PP_NetAddress_Private& addr); | |
63 void OnPluginMsgSendToReply(const ResourceMessageReplyParams& params, | |
64 int32_t bytes_written); | |
65 | |
66 bool bound_; | |
67 bool closed_; | |
68 | |
69 scoped_refptr<TrackedCallback> bind_callback_; | |
70 scoped_refptr<TrackedCallback> recvfrom_callback_; | |
71 scoped_refptr<TrackedCallback> sendto_callback_; | |
72 | |
73 char* read_buffer_; | |
74 int32_t bytes_to_read_; | |
75 | |
76 PP_NetAddress_Private recvfrom_addr_; | |
77 PP_NetAddress_Private bound_addr_; | |
78 | |
79 DISALLOW_COPY_AND_ASSIGN(UDPSocketShared); | |
80 }; | |
81 | |
82 } // namespace proxy | |
83 } // namespace ppapi | |
84 | |
85 #endif // PPAPI_PROXY_UDP_SOCKET_SHARED_H_ | |
OLD | NEW |