| Index: ppapi/proxy/tcp_socket_resource.cc
|
| diff --git a/ppapi/proxy/tcp_socket_resource.cc b/ppapi/proxy/tcp_socket_resource.cc
|
| index 085aab3cf335bc16c2ff6dd03a6290511deb4f50..03c5016eaafa02bcc2b69933bf3f65af039399ec 100644
|
| --- a/ppapi/proxy/tcp_socket_resource.cc
|
| +++ b/ppapi/proxy/tcp_socket_resource.cc
|
| @@ -5,6 +5,7 @@
|
| #include "ppapi/proxy/tcp_socket_resource.h"
|
|
|
| #include "ppapi/proxy/ppapi_messages.h"
|
| +#include "ppapi/shared_impl/ppb_tcp_socket_shared.h"
|
| #include "ppapi/thunk/enter.h"
|
| #include "ppapi/thunk/ppb_net_address_api.h"
|
|
|
| @@ -20,18 +21,50 @@ typedef thunk::EnterResourceNoLock<thunk::PPB_NetAddress_API>
|
|
|
| TCPSocketResource::TCPSocketResource(Connection connection,
|
| PP_Instance instance)
|
| - : TCPSocketResourceBase(connection, instance, false) {
|
| - SendCreate(BROWSER, PpapiHostMsg_TCPSocket_Create());
|
| + : TCPSocketResourceBase(connection, instance, TCP_SOCKET_VERSION_1_0) {
|
| + SendCreate(BROWSER,
|
| + PpapiHostMsg_TCPSocket_Create(
|
| + TCP_SOCKET_VERSION_1_0, PP_NETADDRESS_FAMILY_UNSPECIFIED));
|
| +}
|
| +
|
| +TCPSocketResource::TCPSocketResource(Connection connection,
|
| + PP_Instance instance,
|
| + PP_NetAddress_Family family)
|
| + : TCPSocketResourceBase(connection, instance,
|
| + TCP_SOCKET_VERSION_1_1_OR_ABOVE) {
|
| + SendCreate(BROWSER,
|
| + PpapiHostMsg_TCPSocket_Create(
|
| + TCP_SOCKET_VERSION_1_1_OR_ABOVE, family));
|
| +}
|
| +
|
| +TCPSocketResource::TCPSocketResource(Connection connection,
|
| + PP_Instance instance,
|
| + int pending_host_id,
|
| + const PP_NetAddress_Private& local_addr,
|
| + const PP_NetAddress_Private& remote_addr)
|
| + : TCPSocketResourceBase(connection, instance,
|
| + TCP_SOCKET_VERSION_1_1_OR_ABOVE, local_addr,
|
| + remote_addr) {
|
| + AttachToPendingHost(BROWSER, pending_host_id);
|
| }
|
|
|
| TCPSocketResource::~TCPSocketResource() {
|
| - DisconnectImpl();
|
| + CloseImpl();
|
| }
|
|
|
| thunk::PPB_TCPSocket_API* TCPSocketResource::AsPPB_TCPSocket_API() {
|
| return this;
|
| }
|
|
|
| +int32_t TCPSocketResource::Bind(PP_Resource addr,
|
| + scoped_refptr<TrackedCallback> callback) {
|
| + EnterNetAddressNoLock enter(addr, true);
|
| + if (enter.failed())
|
| + return PP_ERROR_BADARGUMENT;
|
| +
|
| + return BindImpl(&enter.object()->GetNetAddressPrivate(), callback);
|
| +}
|
| +
|
| int32_t TCPSocketResource::Connect(PP_Resource addr,
|
| scoped_refptr<TrackedCallback> callback) {
|
| EnterNetAddressNoLock enter(addr, true);
|
| @@ -78,8 +111,18 @@ int32_t TCPSocketResource::Write(const char* buffer,
|
| return WriteImpl(buffer, bytes_to_write, callback);
|
| }
|
|
|
| +int32_t TCPSocketResource::Listen(int32_t backlog,
|
| + scoped_refptr<TrackedCallback> callback) {
|
| + return ListenImpl(backlog, callback);
|
| +}
|
| +
|
| +int32_t TCPSocketResource::Accept(PP_Resource* accepted_tcp_socket,
|
| + scoped_refptr<TrackedCallback> callback) {
|
| + return AcceptImpl(accepted_tcp_socket, callback);
|
| +}
|
| +
|
| void TCPSocketResource::Close() {
|
| - DisconnectImpl();
|
| + CloseImpl();
|
| }
|
|
|
| int32_t TCPSocketResource::SetOption(PP_TCPSocket_Option name,
|
| @@ -88,5 +131,13 @@ int32_t TCPSocketResource::SetOption(PP_TCPSocket_Option name,
|
| return SetOptionImpl(name, value, callback);
|
| }
|
|
|
| +PP_Resource TCPSocketResource::CreateAcceptedSocket(
|
| + int pending_host_id,
|
| + const PP_NetAddress_Private& local_addr,
|
| + const PP_NetAddress_Private& remote_addr) {
|
| + return (new TCPSocketResource(connection(), pp_instance(), pending_host_id,
|
| + local_addr, remote_addr))->GetReference();
|
| +}
|
| +
|
| } // namespace proxy
|
| } // namespace ppapi
|
|
|