Index: ppapi/proxy/udp_socket_private_resource.h |
diff --git a/ppapi/shared_impl/private/udp_socket_private_impl.h b/ppapi/proxy/udp_socket_private_resource.h |
similarity index 51% |
rename from ppapi/shared_impl/private/udp_socket_private_impl.h |
rename to ppapi/proxy/udp_socket_private_resource.h |
index e8e3cb20e401045ff6a09b01ccc10d899beaed26..d49e08528fee888e51e5e86edb395744d7ada24c 100644 |
--- a/ppapi/shared_impl/private/udp_socket_private_impl.h |
+++ b/ppapi/proxy/udp_socket_private_resource.h |
@@ -2,32 +2,26 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef PPAPI_SHARED_IMPL_PRIVATE_UDP_SOCKET_PRIVATE_IMPL_H_ |
-#define PPAPI_SHARED_IMPL_PRIVATE_UDP_SOCKET_PRIVATE_IMPL_H_ |
- |
-#include <string> |
+#ifndef PPAPI_PROXY_UDP_SOCKET_PRIVATE_RESOURCE_H_ |
+#define PPAPI_PROXY_UDP_SOCKET_PRIVATE_RESOURCE_H_ |
+#include "base/basictypes.h" |
#include "base/compiler_specific.h" |
-#include "ppapi/shared_impl/resource.h" |
+#include "ppapi/proxy/plugin_resource.h" |
+#include "ppapi/proxy/ppapi_proxy_export.h" |
#include "ppapi/shared_impl/tracked_callback.h" |
#include "ppapi/thunk/ppb_udp_socket_private_api.h" |
namespace ppapi { |
+namespace proxy { |
-// This class provides the shared implementation of a |
-// PPB_UDPSocket_Private. The functions that actually send messages |
-// to browser are implemented differently for the proxied and |
-// non-proxied derived classes. |
-class PPAPI_SHARED_EXPORT UDPSocketPrivateImpl |
- : public thunk::PPB_UDPSocket_Private_API, |
- public Resource { |
+class PPAPI_PROXY_EXPORT UDPSocketPrivateResource |
+ : public PluginResource, |
+ public thunk::PPB_UDPSocket_Private_API { |
public: |
- // C-tor used in Impl case. |
- UDPSocketPrivateImpl(PP_Instance instance, uint32 socket_id); |
- // C-tor used in Proxy case. |
- UDPSocketPrivateImpl(const HostResource& resource, uint32 socket_id); |
- |
- virtual ~UDPSocketPrivateImpl(); |
+ UDPSocketPrivateResource(Connection connection, |
+ PP_Instance instance); |
+ virtual ~UDPSocketPrivateResource(); |
// The maximum number of bytes that each PpapiHostMsg_PPBUDPSocket_RecvFrom |
// message is allowed to request. |
@@ -36,8 +30,9 @@ class PPAPI_SHARED_EXPORT UDPSocketPrivateImpl |
// message is allowed to carry. |
static const int32_t kMaxWriteSize; |
- // Resource overrides. |
- virtual PPB_UDPSocket_Private_API* AsPPB_UDPSocket_Private_API() OVERRIDE; |
+ // PluginResource implementation. |
+ virtual thunk::PPB_UDPSocket_Private_API* |
+ AsPPB_UDPSocket_Private_API() OVERRIDE; |
// PPB_UDPSocket_Private_API implementation. |
virtual int32_t SetSocketFeature(PP_UDPSocketFeature_Private name, |
@@ -55,28 +50,27 @@ class PPAPI_SHARED_EXPORT UDPSocketPrivateImpl |
scoped_refptr<TrackedCallback> callback) OVERRIDE; |
virtual void Close() OVERRIDE; |
- // Notifications from the proxy. |
- void OnBindCompleted(bool succeeded, |
- const PP_NetAddress_Private& bound_addr); |
- void OnRecvFromCompleted(bool succeeded, |
- const std::string& data, |
- const PP_NetAddress_Private& addr); |
- void OnSendToCompleted(bool succeeded, int32_t bytes_written); |
- |
- // Send functions that need to be implemented differently for |
- // the proxied and non-proxied derived classes. |
- virtual void SendBoolSocketFeature(int32_t name, bool value) = 0; |
- virtual void SendBind(const PP_NetAddress_Private& addr) = 0; |
- virtual void SendRecvFrom(int32_t num_bytes) = 0; |
- virtual void SendSendTo(const std::string& buffer, |
- const PP_NetAddress_Private& addr) = 0; |
- virtual void SendClose() = 0; |
- |
- protected: |
- void Init(uint32 socket_id); |
+ private: |
void PostAbortIfNecessary(scoped_refptr<TrackedCallback>* callback); |
- uint32 socket_id_; |
+ void SendBoolSocketFeature(int32_t name, bool value); |
+ void SendBind(const PP_NetAddress_Private& addr); |
+ void SendRecvFrom(int32_t num_bytes); |
+ void SendSendTo(const std::string& buffer, |
+ const PP_NetAddress_Private& addr); |
+ void SendClose(); |
+ |
+ // IPC message handlers. |
+ void OnPluginMsgBindReply(const ResourceMessageReplyParams& params, |
+ bool succeeded, |
+ const PP_NetAddress_Private& bound_addr); |
+ void OnPluginMsgRecvFromReply(const ResourceMessageReplyParams& params, |
+ bool succeeded, |
+ const std::string& data, |
+ const PP_NetAddress_Private& addr); |
+ void OnPluginMsgSendToReply(const ResourceMessageReplyParams& params, |
+ bool succeeded, |
+ int32_t bytes_written); |
bool bound_; |
bool closed_; |
@@ -91,9 +85,10 @@ class PPAPI_SHARED_EXPORT UDPSocketPrivateImpl |
PP_NetAddress_Private recvfrom_addr_; |
PP_NetAddress_Private bound_addr_; |
- DISALLOW_COPY_AND_ASSIGN(UDPSocketPrivateImpl); |
+ DISALLOW_COPY_AND_ASSIGN(UDPSocketPrivateResource); |
}; |
+} // namespace proxy |
} // namespace ppapi |
-#endif // PPAPI_SHARED_IMPL_PRIVATE_UDP_SOCKET_PRIVATE_IMPL_H_ |
+#endif // PPAPI_PROXY_UDP_SOCKET_PRIVATE_RESOURCE_H_ |