| OLD | NEW |
| 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 protected: | 33 protected: |
| 34 UDPSocketResourceBase(Connection connection, PP_Instance instance); | 34 UDPSocketResourceBase(Connection connection, |
| 35 PP_Instance instance, |
| 36 bool private_api); |
| 35 virtual ~UDPSocketResourceBase(); | 37 virtual ~UDPSocketResourceBase(); |
| 36 | 38 |
| 37 int32_t SetSocketFeatureImpl(PP_UDPSocketFeature_Private name, | 39 int32_t SetOptionImpl(PP_UDPSocket_Option_Dev name, |
| 38 const PP_Var& value); | 40 const PP_Var& value, |
| 41 scoped_refptr<TrackedCallback> callback); |
| 39 int32_t BindImpl(const PP_NetAddress_Private* addr, | 42 int32_t BindImpl(const PP_NetAddress_Private* addr, |
| 40 scoped_refptr<TrackedCallback> callback); | 43 scoped_refptr<TrackedCallback> callback); |
| 41 PP_Bool GetBoundAddressImpl(PP_NetAddress_Private* addr); | 44 PP_Bool GetBoundAddressImpl(PP_NetAddress_Private* addr); |
| 42 // |addr| could be NULL to indicate that an output value is not needed. | 45 // |addr| could be NULL to indicate that an output value is not needed. |
| 43 int32_t RecvFromImpl(char* buffer, | 46 int32_t RecvFromImpl(char* buffer, |
| 44 int32_t num_bytes, | 47 int32_t num_bytes, |
| 45 PP_Resource* addr, | 48 PP_Resource* addr, |
| 46 scoped_refptr<TrackedCallback> callback); | 49 scoped_refptr<TrackedCallback> callback); |
| 47 PP_Bool GetRecvFromAddressImpl(PP_NetAddress_Private* addr); | 50 PP_Bool GetRecvFromAddressImpl(PP_NetAddress_Private* addr); |
| 48 int32_t SendToImpl(const char* buffer, | 51 int32_t SendToImpl(const char* buffer, |
| 49 int32_t num_bytes, | 52 int32_t num_bytes, |
| 50 const PP_NetAddress_Private* addr, | 53 const PP_NetAddress_Private* addr, |
| 51 scoped_refptr<TrackedCallback> callback); | 54 scoped_refptr<TrackedCallback> callback); |
| 52 void CloseImpl(); | 55 void CloseImpl(); |
| 53 | 56 |
| 54 private: | 57 private: |
| 55 void PostAbortIfNecessary(scoped_refptr<TrackedCallback>* callback); | 58 void PostAbortIfNecessary(scoped_refptr<TrackedCallback>* callback); |
| 56 | 59 |
| 57 // IPC message handlers. | 60 // IPC message handlers. |
| 61 void OnPluginMsgSetOptionReply(scoped_refptr<TrackedCallback> callback, |
| 62 const ResourceMessageReplyParams& params); |
| 58 void OnPluginMsgBindReply(const ResourceMessageReplyParams& params, | 63 void OnPluginMsgBindReply(const ResourceMessageReplyParams& params, |
| 59 const PP_NetAddress_Private& bound_addr); | 64 const PP_NetAddress_Private& bound_addr); |
| 60 void OnPluginMsgRecvFromReply(PP_Resource* output_addr, | 65 void OnPluginMsgRecvFromReply(PP_Resource* output_addr, |
| 61 const ResourceMessageReplyParams& params, | 66 const ResourceMessageReplyParams& params, |
| 62 const std::string& data, | 67 const std::string& data, |
| 63 const PP_NetAddress_Private& addr); | 68 const PP_NetAddress_Private& addr); |
| 64 void OnPluginMsgSendToReply(const ResourceMessageReplyParams& params, | 69 void OnPluginMsgSendToReply(const ResourceMessageReplyParams& params, |
| 65 int32_t bytes_written); | 70 int32_t bytes_written); |
| 66 | 71 |
| 72 bool private_api_; |
| 67 bool bound_; | 73 bool bound_; |
| 68 bool closed_; | 74 bool closed_; |
| 69 | 75 |
| 70 scoped_refptr<TrackedCallback> bind_callback_; | 76 scoped_refptr<TrackedCallback> bind_callback_; |
| 71 scoped_refptr<TrackedCallback> recvfrom_callback_; | 77 scoped_refptr<TrackedCallback> recvfrom_callback_; |
| 72 scoped_refptr<TrackedCallback> sendto_callback_; | 78 scoped_refptr<TrackedCallback> sendto_callback_; |
| 73 | 79 |
| 74 char* read_buffer_; | 80 char* read_buffer_; |
| 75 int32_t bytes_to_read_; | 81 int32_t bytes_to_read_; |
| 76 | 82 |
| 77 PP_NetAddress_Private recvfrom_addr_; | 83 PP_NetAddress_Private recvfrom_addr_; |
| 78 PP_NetAddress_Private bound_addr_; | 84 PP_NetAddress_Private bound_addr_; |
| 79 | 85 |
| 80 DISALLOW_COPY_AND_ASSIGN(UDPSocketResourceBase); | 86 DISALLOW_COPY_AND_ASSIGN(UDPSocketResourceBase); |
| 81 }; | 87 }; |
| 82 | 88 |
| 83 } // namespace proxy | 89 } // namespace proxy |
| 84 } // namespace ppapi | 90 } // namespace ppapi |
| 85 | 91 |
| 86 #endif // PPAPI_PROXY_UDP_SOCKET_SHARED_H_ | 92 #endif // PPAPI_PROXY_UDP_SOCKET_RESOURCE_BASE_H_ |
| OLD | NEW |