| Index: content/renderer/pepper_plugin_delegate_impl.cc
|
| diff --git a/content/renderer/pepper_plugin_delegate_impl.cc b/content/renderer/pepper_plugin_delegate_impl.cc
|
| index e4129d6880b584330cc1c1b3b6771f7d87146618..ff3b80c51886b727f60363007cafe620a059e526 100644
|
| --- a/content/renderer/pepper_plugin_delegate_impl.cc
|
| +++ b/content/renderer/pepper_plugin_delegate_impl.cc
|
| @@ -5,7 +5,6 @@
|
| #include "content/renderer/pepper_plugin_delegate_impl.h"
|
|
|
| #include <cmath>
|
| -#include <queue>
|
|
|
| #include "base/bind.h"
|
| #include "base/callback.h"
|
| @@ -76,6 +75,7 @@
|
| #include "webkit/plugins/ppapi/ppb_broker_impl.h"
|
| #include "webkit/plugins/ppapi/ppb_flash_impl.h"
|
| #include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h"
|
| +#include "webkit/plugins/ppapi/ppb_tcp_server_socket_private_impl.h"
|
| #include "webkit/plugins/ppapi/ppb_tcp_socket_private_impl.h"
|
| #include "webkit/plugins/ppapi/ppb_udp_socket_private_impl.h"
|
| #include "webkit/plugins/ppapi/resource_helper.h"
|
| @@ -1663,7 +1663,7 @@ void PepperPluginDelegateImpl::TCPSocketConnect(
|
| uint32 socket_id,
|
| const std::string& host,
|
| uint16_t port) {
|
| - tcp_sockets_.AddWithID(socket, socket_id);
|
| + RegisterTCPSocket(socket, socket_id);
|
| render_view_->Send(
|
| new PpapiHostMsg_PPBTCPSocket_Connect(socket_id, host, port));
|
| }
|
| @@ -1672,7 +1672,7 @@ void PepperPluginDelegateImpl::TCPSocketConnectWithNetAddress(
|
| webkit::ppapi::PPB_TCPSocket_Private_Impl* socket,
|
| uint32 socket_id,
|
| const PP_NetAddress_Private& addr) {
|
| - tcp_sockets_.AddWithID(socket, socket_id);
|
| + RegisterTCPSocket(socket, socket_id);
|
| render_view_->Send(
|
| new PpapiHostMsg_PPBTCPSocket_ConnectWithNetAddress(socket_id, addr));
|
| }
|
| @@ -1707,6 +1707,12 @@ void PepperPluginDelegateImpl::TCPSocketDisconnect(uint32 socket_id) {
|
| tcp_sockets_.Remove(socket_id);
|
| }
|
|
|
| +void PepperPluginDelegateImpl::RegisterTCPSocket(
|
| + webkit::ppapi::PPB_TCPSocket_Private_Impl* socket,
|
| + uint32 socket_id) {
|
| + tcp_sockets_.AddWithID(socket, socket_id);
|
| +}
|
| +
|
| uint32 PepperPluginDelegateImpl::UDPSocketCreate() {
|
| if (!CanUseSocketAPIs())
|
| return 0;
|
| @@ -1748,6 +1754,52 @@ void PepperPluginDelegateImpl::UDPSocketClose(uint32 socket_id) {
|
| udp_sockets_.Remove(socket_id);
|
| }
|
|
|
| +bool PepperPluginDelegateImpl::TCPServerSocketInitialize(
|
| + webkit::ppapi::PPB_TCPServerSocket_Private_Impl* socket) {
|
| + DCHECK(socket != NULL);
|
| + if (!CanUseSocketAPIs())
|
| + return false;
|
| +
|
| + uninitialized_tcp_server_sockets_.push_back(socket);
|
| + tcp_server_sockets_positions_[socket] =
|
| + --uninitialized_tcp_server_sockets_.end();
|
| + render_view_->Send(new PpapiHostMsg_PPBTCPServerSocket_Initialize(
|
| + render_view_->routing_id(), 0));
|
| + return true;
|
| +}
|
| +
|
| +void PepperPluginDelegateImpl::TCPServerSocketListen(
|
| + webkit::ppapi::PPB_TCPServerSocket_Private_Impl* socket,
|
| + uint32 socket_id,
|
| + const PP_NetAddress_Private& addr,
|
| + int32_t backlog) {
|
| + tcp_server_sockets_.AddWithID(socket, socket_id);
|
| + render_view_->Send(
|
| + new PpapiHostMsg_PPBTCPServerSocket_Listen(socket_id, addr, backlog));
|
| +}
|
| +
|
| +void PepperPluginDelegateImpl::TCPServerSocketAccept(uint32 socket_id) {
|
| + DCHECK(tcp_server_sockets_.Lookup(socket_id));
|
| + render_view_->Send(new PpapiHostMsg_PPBTCPServerSocket_Accept(socket_id));
|
| +}
|
| +
|
| +void PepperPluginDelegateImpl::TCPServerSocketStopListening(uint32 socket_id) {
|
| + // There are no DCHECK(tcp_server_sockets_.Lookup(socket_id))
|
| + // because it can be called before TCPServerSocketListen is called.
|
| + render_view_->Send(
|
| + new PpapiHostMsg_PPBTCPServerSocket_StopListening(socket_id));
|
| + tcp_server_sockets_.Remove(socket_id);
|
| +}
|
| +
|
| +void PepperPluginDelegateImpl::CancelInitializationOfTCPServerSocket(
|
| + webkit::ppapi::PPB_TCPServerSocket_Private_Impl* socket) {
|
| + TCPServerSocketMap::iterator it = tcp_server_sockets_positions_.find(socket);
|
| + DCHECK(it != tcp_server_sockets_positions_.end());
|
| +
|
| + uninitialized_tcp_server_sockets_.erase(it->second);
|
| + tcp_server_sockets_positions_.erase(it);
|
| +}
|
| +
|
| int32_t PepperPluginDelegateImpl::ShowContextMenu(
|
| webkit::ppapi::PluginInstance* instance,
|
| webkit::ppapi::PPB_Flash_Menu_Impl* menu,
|
| @@ -1978,6 +2030,12 @@ bool PepperPluginDelegateImpl::OnMessageReceived(const IPC::Message& message) {
|
| IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_RecvFromACK,
|
| OnUDPSocketRecvFromACK)
|
| IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_SendToACK, OnUDPSocketSendToACK)
|
| + IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_InitializeACK,
|
| + OnTCPServerSocketInitializeACK)
|
| + IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_ListenACK,
|
| + OnTCPServerSocketListenACK)
|
| + IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_AcceptACK,
|
| + OnTCPServerSocketAcceptACK)
|
| IPC_MESSAGE_UNHANDLED(handled = false)
|
| IPC_END_MESSAGE_MAP()
|
| return handled;
|
| @@ -1999,6 +2057,8 @@ void PepperPluginDelegateImpl::OnTCPSocketConnectACK(
|
| tcp_sockets_.Lookup(socket_id);
|
| if (socket)
|
| socket->OnConnectCompleted(succeeded, local_addr, remote_addr);
|
| + if (!succeeded)
|
| + tcp_sockets_.Remove(socket_id);
|
| }
|
|
|
| void PepperPluginDelegateImpl::OnTCPSocketSSLHandshakeACK(
|
| @@ -2038,6 +2098,8 @@ void PepperPluginDelegateImpl::OnUDPSocketBindACK(uint32 plugin_dispatcher_id,
|
| udp_sockets_.Lookup(socket_id);
|
| if (socket)
|
| socket->OnBindCompleted(succeeded);
|
| + if (!succeeded)
|
| + udp_sockets_.Remove(socket_id);
|
| }
|
|
|
| void PepperPluginDelegateImpl::OnUDPSocketRecvFromACK(
|
| @@ -2062,6 +2124,52 @@ void PepperPluginDelegateImpl::OnUDPSocketSendToACK(uint32 plugin_dispatcher_id,
|
| socket->OnSendToCompleted(succeeded, bytes_written);
|
| }
|
|
|
| +void PepperPluginDelegateImpl::OnTCPServerSocketListenACK(
|
| + uint32 plugin_dispatcher_id,
|
| + uint32 socket_id,
|
| + bool succeeded) {
|
| + webkit::ppapi::PPB_TCPServerSocket_Private_Impl* socket =
|
| + tcp_server_sockets_.Lookup(socket_id);
|
| + if (socket)
|
| + socket->OnListenCompleted(succeeded);
|
| + if (!succeeded)
|
| + tcp_server_sockets_.Remove(socket_id);
|
| +}
|
| +
|
| +void PepperPluginDelegateImpl::OnTCPServerSocketInitializeACK(
|
| + uint32 plugin_dispatcher_id,
|
| + uint32 tcp_server_socket_id) {
|
| + if (!uninitialized_tcp_server_sockets_.empty()) {
|
| + webkit::ppapi::PPB_TCPServerSocket_Private_Impl* socket =
|
| + uninitialized_tcp_server_sockets_.front();
|
| + uninitialized_tcp_server_sockets_.pop_front();
|
| + tcp_server_sockets_positions_.erase(socket);
|
| + DCHECK(socket != NULL);
|
| + socket->OnInitializeCompleted(tcp_server_socket_id);
|
| + } else {
|
| + render_view_->Send(
|
| + new PpapiHostMsg_PPBTCPServerSocket_Destroy(
|
| + tcp_server_socket_id));
|
| + }
|
| +}
|
| +
|
| +void PepperPluginDelegateImpl::OnTCPServerSocketAcceptACK(
|
| + uint32 plugin_dispatcher_id,
|
| + uint32 tcp_server_socket_id,
|
| + uint32 tcp_socket_id,
|
| + const PP_NetAddress_Private& local_addr,
|
| + const PP_NetAddress_Private& remote_addr) {
|
| + webkit::ppapi::PPB_TCPServerSocket_Private_Impl* socket =
|
| + tcp_server_sockets_.Lookup(tcp_server_socket_id);
|
| + if (socket) {
|
| + bool succeeded = tcp_socket_id != 0;
|
| + socket->OnAcceptCompleted(succeeded,
|
| + tcp_socket_id,
|
| + local_addr,
|
| + remote_addr);
|
| + }
|
| +}
|
| +
|
| int PepperPluginDelegateImpl::GetRoutingId() const {
|
| return render_view_->routing_id();
|
| }
|
|
|