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

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

Issue 16959005: Implement PPB_UDPSocket_Dev: part 2 (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/udp_socket_resource.cc ('k') | ppapi/proxy/udp_socket_resource_base.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_SHARED_H_ 5 #ifndef PPAPI_PROXY_UDP_SOCKET_RESOURCE_BASE_H_
6 #define PPAPI_PROXY_UDP_SOCKET_SHARED_H_ 6 #define PPAPI_PROXY_UDP_SOCKET_RESOURCE_BASE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "ppapi/c/dev/ppb_udp_socket_dev.h"
13 #include "ppapi/c/private/ppb_net_address_private.h" 14 #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" 15 #include "ppapi/proxy/plugin_resource.h"
16 #include "ppapi/proxy/ppapi_proxy_export.h" 16 #include "ppapi/proxy/ppapi_proxy_export.h"
17 #include "ppapi/shared_impl/tracked_callback.h" 17 #include "ppapi/shared_impl/tracked_callback.h"
18 18
19 namespace ppapi { 19 namespace ppapi {
20 namespace proxy { 20 namespace proxy {
21 21
22 class ResourceMessageReplyParams; 22 class ResourceMessageReplyParams;
23 23
24 class PPAPI_PROXY_EXPORT UDPSocketResourceBase: public PluginResource { 24 class PPAPI_PROXY_EXPORT UDPSocketResourceBase: public PluginResource {
25 public: 25 public:
26 // The maximum number of bytes that each PpapiHostMsg_PPBUDPSocket_RecvFrom 26 // The maximum number of bytes that each PpapiHostMsg_PPBUDPSocket_RecvFrom
27 // message is allowed to request. 27 // message is allowed to request.
28 static const int32_t kMaxReadSize; 28 static const int32_t kMaxReadSize;
29 // The maximum number of bytes that each PpapiHostMsg_PPBUDPSocket_SendTo 29 // The maximum number of bytes that each PpapiHostMsg_PPBUDPSocket_SendTo
30 // message is allowed to carry. 30 // message is allowed to carry.
31 static const int32_t kMaxWriteSize; 31 static const int32_t kMaxWriteSize;
32 32
33 // The maximum number that we allow for setting
34 // PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE. This number is only for input
35 // argument sanity check, it doesn't mean the browser guarantees to support
36 // such a buffer size.
37 static const int32_t kMaxSendBufferSize;
38 // The maximum number that we allow for setting
39 // PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE. This number is only for input
40 // argument sanity check, it doesn't mean the browser guarantees to support
41 // such a buffer size.
42 static const int32_t kMaxReceiveBufferSize;
43
33 protected: 44 protected:
34 UDPSocketResourceBase(Connection connection, PP_Instance instance); 45 UDPSocketResourceBase(Connection connection,
46 PP_Instance instance,
47 bool private_api);
35 virtual ~UDPSocketResourceBase(); 48 virtual ~UDPSocketResourceBase();
36 49
37 int32_t SetSocketFeatureImpl(PP_UDPSocketFeature_Private name, 50 int32_t SetOptionImpl(PP_UDPSocket_Option_Dev name,
38 const PP_Var& value); 51 const PP_Var& value,
52 scoped_refptr<TrackedCallback> callback);
39 int32_t BindImpl(const PP_NetAddress_Private* addr, 53 int32_t BindImpl(const PP_NetAddress_Private* addr,
40 scoped_refptr<TrackedCallback> callback); 54 scoped_refptr<TrackedCallback> callback);
41 PP_Bool GetBoundAddressImpl(PP_NetAddress_Private* addr); 55 PP_Bool GetBoundAddressImpl(PP_NetAddress_Private* addr);
42 // |addr| could be NULL to indicate that an output value is not needed. 56 // |addr| could be NULL to indicate that an output value is not needed.
43 int32_t RecvFromImpl(char* buffer, 57 int32_t RecvFromImpl(char* buffer,
44 int32_t num_bytes, 58 int32_t num_bytes,
45 PP_Resource* addr, 59 PP_Resource* addr,
46 scoped_refptr<TrackedCallback> callback); 60 scoped_refptr<TrackedCallback> callback);
47 PP_Bool GetRecvFromAddressImpl(PP_NetAddress_Private* addr); 61 PP_Bool GetRecvFromAddressImpl(PP_NetAddress_Private* addr);
48 int32_t SendToImpl(const char* buffer, 62 int32_t SendToImpl(const char* buffer,
49 int32_t num_bytes, 63 int32_t num_bytes,
50 const PP_NetAddress_Private* addr, 64 const PP_NetAddress_Private* addr,
51 scoped_refptr<TrackedCallback> callback); 65 scoped_refptr<TrackedCallback> callback);
52 void CloseImpl(); 66 void CloseImpl();
53 67
54 private: 68 private:
55 void PostAbortIfNecessary(scoped_refptr<TrackedCallback>* callback); 69 void PostAbortIfNecessary(scoped_refptr<TrackedCallback>* callback);
56 70
57 // IPC message handlers. 71 // IPC message handlers.
72 void OnPluginMsgSetOptionReply(scoped_refptr<TrackedCallback> callback,
73 const ResourceMessageReplyParams& params);
58 void OnPluginMsgBindReply(const ResourceMessageReplyParams& params, 74 void OnPluginMsgBindReply(const ResourceMessageReplyParams& params,
59 const PP_NetAddress_Private& bound_addr); 75 const PP_NetAddress_Private& bound_addr);
60 void OnPluginMsgRecvFromReply(PP_Resource* output_addr, 76 void OnPluginMsgRecvFromReply(PP_Resource* output_addr,
61 const ResourceMessageReplyParams& params, 77 const ResourceMessageReplyParams& params,
62 const std::string& data, 78 const std::string& data,
63 const PP_NetAddress_Private& addr); 79 const PP_NetAddress_Private& addr);
64 void OnPluginMsgSendToReply(const ResourceMessageReplyParams& params, 80 void OnPluginMsgSendToReply(const ResourceMessageReplyParams& params,
65 int32_t bytes_written); 81 int32_t bytes_written);
66 82
83 bool private_api_;
67 bool bound_; 84 bool bound_;
68 bool closed_; 85 bool closed_;
69 86
70 scoped_refptr<TrackedCallback> bind_callback_; 87 scoped_refptr<TrackedCallback> bind_callback_;
71 scoped_refptr<TrackedCallback> recvfrom_callback_; 88 scoped_refptr<TrackedCallback> recvfrom_callback_;
72 scoped_refptr<TrackedCallback> sendto_callback_; 89 scoped_refptr<TrackedCallback> sendto_callback_;
73 90
74 char* read_buffer_; 91 char* read_buffer_;
75 int32_t bytes_to_read_; 92 int32_t bytes_to_read_;
76 93
77 PP_NetAddress_Private recvfrom_addr_; 94 PP_NetAddress_Private recvfrom_addr_;
78 PP_NetAddress_Private bound_addr_; 95 PP_NetAddress_Private bound_addr_;
79 96
80 DISALLOW_COPY_AND_ASSIGN(UDPSocketResourceBase); 97 DISALLOW_COPY_AND_ASSIGN(UDPSocketResourceBase);
81 }; 98 };
82 99
83 } // namespace proxy 100 } // namespace proxy
84 } // namespace ppapi 101 } // namespace ppapi
85 102
86 #endif // PPAPI_PROXY_UDP_SOCKET_SHARED_H_ 103 #endif // PPAPI_PROXY_UDP_SOCKET_RESOURCE_BASE_H_
OLDNEW
« no previous file with comments | « ppapi/proxy/udp_socket_resource.cc ('k') | ppapi/proxy/udp_socket_resource_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698