| OLD | NEW |
| 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_SHARED_IMPL_PRIVATE_UDP_SOCKET_PRIVATE_IMPL_H_ | 5 #ifndef PPAPI_SHARED_IMPL_PRIVATE_UDP_SOCKET_PRIVATE_IMPL_H_ |
| 6 #define PPAPI_SHARED_IMPL_PRIVATE_UDP_SOCKET_PRIVATE_IMPL_H_ | 6 #define PPAPI_SHARED_IMPL_PRIVATE_UDP_SOCKET_PRIVATE_IMPL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 // message is allowed to request. | 33 // message is allowed to request. |
| 34 static const int32_t kMaxReadSize; | 34 static const int32_t kMaxReadSize; |
| 35 // The maximum number of bytes that each PpapiHostMsg_PPBUDPSocket_SendTo | 35 // The maximum number of bytes that each PpapiHostMsg_PPBUDPSocket_SendTo |
| 36 // message is allowed to carry. | 36 // message is allowed to carry. |
| 37 static const int32_t kMaxWriteSize; | 37 static const int32_t kMaxWriteSize; |
| 38 | 38 |
| 39 // Resource overrides. | 39 // Resource overrides. |
| 40 virtual PPB_UDPSocket_Private_API* AsPPB_UDPSocket_Private_API() OVERRIDE; | 40 virtual PPB_UDPSocket_Private_API* AsPPB_UDPSocket_Private_API() OVERRIDE; |
| 41 | 41 |
| 42 // PPB_UDPSocket_Private_API implementation. | 42 // PPB_UDPSocket_Private_API implementation. |
| 43 virtual int32_t SetSocketFeature( |
| 44 PP_UDPSocketFeature_Private name, |
| 45 PP_Var value, |
| 46 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 43 virtual int32_t Bind(const PP_NetAddress_Private* addr, | 47 virtual int32_t Bind(const PP_NetAddress_Private* addr, |
| 44 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 48 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 45 virtual PP_Bool GetBoundAddress(PP_NetAddress_Private* addr) OVERRIDE; | 49 virtual PP_Bool GetBoundAddress(PP_NetAddress_Private* addr) OVERRIDE; |
| 46 virtual int32_t RecvFrom(char* buffer, | 50 virtual int32_t RecvFrom(char* buffer, |
| 47 int32_t num_bytes, | 51 int32_t num_bytes, |
| 48 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 52 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 49 virtual PP_Bool GetRecvFromAddress(PP_NetAddress_Private* addr) OVERRIDE; | 53 virtual PP_Bool GetRecvFromAddress(PP_NetAddress_Private* addr) OVERRIDE; |
| 50 virtual int32_t SendTo(const char* buffer, | 54 virtual int32_t SendTo(const char* buffer, |
| 51 int32_t num_bytes, | 55 int32_t num_bytes, |
| 52 const PP_NetAddress_Private* addr, | 56 const PP_NetAddress_Private* addr, |
| 53 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 57 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 54 virtual void Close() OVERRIDE; | 58 virtual void Close() OVERRIDE; |
| 55 | 59 |
| 56 // Notifications from the proxy. | 60 // Notifications from the proxy. |
| 61 void OnSetSocketFeatureCompleted(bool succeeded); |
| 57 void OnBindCompleted(bool succeeded, | 62 void OnBindCompleted(bool succeeded, |
| 58 const PP_NetAddress_Private& bound_addr); | 63 const PP_NetAddress_Private& bound_addr); |
| 59 void OnRecvFromCompleted(bool succeeded, | 64 void OnRecvFromCompleted(bool succeeded, |
| 60 const std::string& data, | 65 const std::string& data, |
| 61 const PP_NetAddress_Private& addr); | 66 const PP_NetAddress_Private& addr); |
| 62 void OnSendToCompleted(bool succeeded, int32_t bytes_written); | 67 void OnSendToCompleted(bool succeeded, int32_t bytes_written); |
| 63 | 68 |
| 64 // Send functions that need to be implemented differently for | 69 // Send functions that need to be implemented differently for |
| 65 // the proxied and non-proxied derived classes. | 70 // the proxied and non-proxied derived classes. |
| 71 virtual void SendSetSocketFeature(PP_UDPSocketFeature_Private name, |
| 72 PP_Var value) = 0; |
| 66 virtual void SendBind(const PP_NetAddress_Private& addr) = 0; | 73 virtual void SendBind(const PP_NetAddress_Private& addr) = 0; |
| 67 virtual void SendRecvFrom(int32_t num_bytes) = 0; | 74 virtual void SendRecvFrom(int32_t num_bytes) = 0; |
| 68 virtual void SendSendTo(const std::string& buffer, | 75 virtual void SendSendTo(const std::string& buffer, |
| 69 const PP_NetAddress_Private& addr) = 0; | 76 const PP_NetAddress_Private& addr) = 0; |
| 70 virtual void SendClose() = 0; | 77 virtual void SendClose() = 0; |
| 71 | 78 |
| 72 protected: | 79 protected: |
| 73 void Init(uint32 socket_id); | 80 void Init(uint32 socket_id); |
| 74 void PostAbortIfNecessary(scoped_refptr<TrackedCallback>* callback); | 81 void PostAbortIfNecessary(scoped_refptr<TrackedCallback>* callback); |
| 75 | 82 |
| 76 uint32 socket_id_; | 83 uint32 socket_id_; |
| 77 | 84 |
| 78 bool bound_; | 85 bool bound_; |
| 79 bool closed_; | 86 bool closed_; |
| 80 | 87 |
| 88 scoped_refptr<TrackedCallback> setsocketfeature_callback_; |
| 81 scoped_refptr<TrackedCallback> bind_callback_; | 89 scoped_refptr<TrackedCallback> bind_callback_; |
| 82 scoped_refptr<TrackedCallback> recvfrom_callback_; | 90 scoped_refptr<TrackedCallback> recvfrom_callback_; |
| 83 scoped_refptr<TrackedCallback> sendto_callback_; | 91 scoped_refptr<TrackedCallback> sendto_callback_; |
| 84 | 92 |
| 85 char* read_buffer_; | 93 char* read_buffer_; |
| 86 int32_t bytes_to_read_; | 94 int32_t bytes_to_read_; |
| 87 | 95 |
| 88 PP_NetAddress_Private recvfrom_addr_; | 96 PP_NetAddress_Private recvfrom_addr_; |
| 89 PP_NetAddress_Private bound_addr_; | 97 PP_NetAddress_Private bound_addr_; |
| 90 | 98 |
| 91 DISALLOW_COPY_AND_ASSIGN(UDPSocketPrivateImpl); | 99 DISALLOW_COPY_AND_ASSIGN(UDPSocketPrivateImpl); |
| 92 }; | 100 }; |
| 93 | 101 |
| 94 } // namespace ppapi | 102 } // namespace ppapi |
| 95 | 103 |
| 96 #endif // PPAPI_SHARED_IMPL_PRIVATE_UDP_SOCKET_PRIVATE_IMPL_H_ | 104 #endif // PPAPI_SHARED_IMPL_PRIVATE_UDP_SOCKET_PRIVATE_IMPL_H_ |
| OLD | NEW |