diff options
author | dpolukhin@chromium.org <dpolukhin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-16 07:06:24 +0000 |
---|---|---|
committer | dpolukhin@chromium.org <dpolukhin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-16 07:06:24 +0000 |
commit | fb575bc7182f8ecde6ede7a4978b64a72434fd02 (patch) | |
tree | 61d8a21e588aca63d0713d35148aff12e9a2fe89 | |
parent | fe0eca5c30281ae58cef01593f0e4aab7fd560f2 (diff) | |
download | chromium_src-fb575bc7182f8ecde6ede7a4978b64a72434fd02.zip chromium_src-fb575bc7182f8ecde6ede7a4978b64a72434fd02.tar.gz chromium_src-fb575bc7182f8ecde6ede7a4978b64a72434fd02.tar.bz2 |
Remove 'Flash' from TCP/UDP Pepper interfaces names. This CL preserves old idl and C/C++ headers for backward compatibility. Also TCP interface should be returned by old name.
BUG=none
TEST=build
Review URL: http://codereview.chromium.org/8506016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110265 0039d316-1c4b-4281-b951-d872f2087c98
36 files changed, 1105 insertions, 463 deletions
diff --git a/content/browser/renderer_host/pepper_message_filter.cc b/content/browser/renderer_host/pepper_message_filter.cc index d985b6b..de155a5 100644 --- a/content/browser/renderer_host/pepper_message_filter.cc +++ b/content/browser/renderer_host/pepper_message_filter.cc @@ -43,7 +43,7 @@ #include "net/url_request/url_request_context.h" #include "ppapi/c/private/ppb_flash_net_connector.h" #include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/proxy/ppb_flash_tcp_socket_proxy.h" +#include "ppapi/proxy/ppb_tcp_socket_private_proxy.h" #include "ppapi/shared_impl/private/net_address_private_impl.h" #include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h" @@ -127,13 +127,13 @@ COMPILE_ASSERT(sizeof(reinterpret_cast<PP_NetAddress_Private*>(0)->data) >= const PP_NetAddress_Private kInvalidNetAddress = { 0 }; -class PepperMessageFilter::FlashTCPSocket { +class PepperMessageFilter::TCPSocket { public: - FlashTCPSocket(FlashTCPSocketManager* manager, - int32 routing_id, - uint32 plugin_dispatcher_id, - uint32 socket_id); - ~FlashTCPSocket(); + TCPSocket(TCPSocketManager* manager, + int32 routing_id, + uint32 plugin_dispatcher_id, + uint32 socket_id); + ~TCPSocket(); void Connect(const std::string& host, uint16_t port); void ConnectWithNetAddress(const PP_NetAddress_Private& net_addr); @@ -173,7 +173,7 @@ class PepperMessageFilter::FlashTCPSocket { bool IsConnected() const; - FlashTCPSocketManager* manager_; + TCPSocketManager* manager_; int32 routing_id_; uint32 plugin_dispatcher_id_; uint32 socket_id_; @@ -181,11 +181,11 @@ class PepperMessageFilter::FlashTCPSocket { ConnectionState connection_state_; bool end_of_file_reached_; - net::OldCompletionCallbackImpl<FlashTCPSocket> resolve_callback_; - net::OldCompletionCallbackImpl<FlashTCPSocket> connect_callback_; - net::OldCompletionCallbackImpl<FlashTCPSocket> ssl_handshake_callback_; - net::OldCompletionCallbackImpl<FlashTCPSocket> read_callback_; - net::OldCompletionCallbackImpl<FlashTCPSocket> write_callback_; + net::OldCompletionCallbackImpl<TCPSocket> resolve_callback_; + net::OldCompletionCallbackImpl<TCPSocket> connect_callback_; + net::OldCompletionCallbackImpl<TCPSocket> ssl_handshake_callback_; + net::OldCompletionCallbackImpl<TCPSocket> read_callback_; + net::OldCompletionCallbackImpl<TCPSocket> write_callback_; scoped_ptr<net::SingleRequestHostResolver> resolver_; net::AddressList address_list_; @@ -195,14 +195,14 @@ class PepperMessageFilter::FlashTCPSocket { scoped_refptr<net::IOBuffer> read_buffer_; scoped_refptr<net::IOBuffer> write_buffer_; - DISALLOW_COPY_AND_ASSIGN(FlashTCPSocket); + DISALLOW_COPY_AND_ASSIGN(TCPSocket); }; // Base class for TCP and UDP socket managers. template<class SocketType> -class PepperMessageFilter::FlashSocketManager { +class PepperMessageFilter::SocketManager { public: - explicit FlashSocketManager(PepperMessageFilter* pepper_message_filter); + explicit SocketManager(PepperMessageFilter* pepper_message_filter); protected: // |socket_id| will be set to 0 on failure, non-zero otherwise. @@ -211,13 +211,13 @@ class PepperMessageFilter::FlashSocketManager { uint32 next_socket_id_; PepperMessageFilter* pepper_message_filter_; - // SocketMap can hold either FlashTCPSocket or FlashUDPSocket. + // SocketMap can hold either TCPSocket or UDPSocket. typedef std::map<uint32, linked_ptr<SocketType> > SocketMap; SocketMap sockets_; }; template<class SocketType> -PepperMessageFilter::FlashSocketManager<SocketType>::FlashSocketManager( +PepperMessageFilter::SocketManager<SocketType>::SocketManager( PepperMessageFilter* pepper_message_filter) : next_socket_id_(1), pepper_message_filter_(pepper_message_filter) { @@ -225,14 +225,14 @@ PepperMessageFilter::FlashSocketManager<SocketType>::FlashSocketManager( } template<class SocketType> -bool PepperMessageFilter::FlashSocketManager<SocketType>::GenerateSocketID( +bool PepperMessageFilter::SocketManager<SocketType>::GenerateSocketID( uint32* socket_id) { // Generate a socket ID. For each process which sends us socket requests, IDs // of living sockets must be unique, to each socket type. TCP and UDP have // unique managers, so the socket ID can be the same in this case. // // However, it is safe to generate IDs based on the internal state of a single - // FlashSocketManager object, because for each plugin or renderer process, + // SocketManager object, because for each plugin or renderer process, // there is at most one PepperMessageFilter talking to it if (sockets_.size() >= std::numeric_limits<uint32>::max()) { @@ -250,12 +250,11 @@ bool PepperMessageFilter::FlashSocketManager<SocketType>::GenerateSocketID( return true; } -// FlashTCPSocketManager manages the mapping from socket IDs to FlashTCPSocket +// TCPSocketManager manages the mapping from socket IDs to TCPSocket // instances. -class PepperMessageFilter::FlashTCPSocketManager - : public FlashSocketManager<FlashTCPSocket> { +class PepperMessageFilter::TCPSocketManager : public SocketManager<TCPSocket> { public: - explicit FlashTCPSocketManager(PepperMessageFilter* pepper_message_filter); + explicit TCPSocketManager(PepperMessageFilter* pepper_message_filter); void OnMsgCreate(int32 routing_id, uint32 plugin_dispatcher_id, @@ -272,7 +271,7 @@ class PepperMessageFilter::FlashTCPSocketManager void OnMsgWrite(uint32 socket_id, const std::string& data); void OnMsgDisconnect(uint32 socket_id); - // Used by FlashTCPSocket. + // Used by TCPSocket. bool Send(IPC::Message* message) { return pepper_message_filter_->Send(message); } @@ -290,11 +289,11 @@ class PepperMessageFilter::FlashTCPSocketManager // This is lazily created. Users should use GetCertVerifier to retrieve it. scoped_ptr<net::CertVerifier> cert_verifier_; - DISALLOW_COPY_AND_ASSIGN(FlashTCPSocketManager); + DISALLOW_COPY_AND_ASSIGN(TCPSocketManager); }; -PepperMessageFilter::FlashTCPSocket::FlashTCPSocket( - FlashTCPSocketManager* manager, +PepperMessageFilter::TCPSocket::TCPSocket( + TCPSocketManager* manager, int32 routing_id, uint32 plugin_dispatcher_id, uint32 socket_id) @@ -305,27 +304,26 @@ PepperMessageFilter::FlashTCPSocket::FlashTCPSocket( connection_state_(BEFORE_CONNECT), end_of_file_reached_(false), ALLOW_THIS_IN_INITIALIZER_LIST( - resolve_callback_(this, &FlashTCPSocket::OnResolveCompleted)), + resolve_callback_(this, &TCPSocket::OnResolveCompleted)), ALLOW_THIS_IN_INITIALIZER_LIST( - connect_callback_(this, &FlashTCPSocket::OnConnectCompleted)), + connect_callback_(this, &TCPSocket::OnConnectCompleted)), ALLOW_THIS_IN_INITIALIZER_LIST( - ssl_handshake_callback_(this, - &FlashTCPSocket::OnSSLHandshakeCompleted)), + ssl_handshake_callback_(this, &TCPSocket::OnSSLHandshakeCompleted)), ALLOW_THIS_IN_INITIALIZER_LIST( - read_callback_(this, &FlashTCPSocket::OnReadCompleted)), + read_callback_(this, &TCPSocket::OnReadCompleted)), ALLOW_THIS_IN_INITIALIZER_LIST( - write_callback_(this, &FlashTCPSocket::OnWriteCompleted)) { + write_callback_(this, &TCPSocket::OnWriteCompleted)) { DCHECK(manager); } -PepperMessageFilter::FlashTCPSocket::~FlashTCPSocket() { +PepperMessageFilter::TCPSocket::~TCPSocket() { // Make sure no further callbacks from socket_. if (socket_.get()) socket_->Disconnect(); } -void PepperMessageFilter::FlashTCPSocket::Connect(const std::string& host, - uint16_t port) { +void PepperMessageFilter::TCPSocket::Connect(const std::string& host, + uint16_t port) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); if (connection_state_ != BEFORE_CONNECT) { @@ -343,7 +341,7 @@ void PepperMessageFilter::FlashTCPSocket::Connect(const std::string& host, OnResolveCompleted(result); } -void PepperMessageFilter::FlashTCPSocket::ConnectWithNetAddress( +void PepperMessageFilter::TCPSocket::ConnectWithNetAddress( const PP_NetAddress_Private& net_addr) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); @@ -357,7 +355,7 @@ void PepperMessageFilter::FlashTCPSocket::ConnectWithNetAddress( StartConnect(address_list_); } -void PepperMessageFilter::FlashTCPSocket::SSLHandshake( +void PepperMessageFilter::TCPSocket::SSLHandshake( const std::string& server_name, uint16_t server_port) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); @@ -393,7 +391,7 @@ void PepperMessageFilter::FlashTCPSocket::SSLHandshake( OnSSLHandshakeCompleted(result); } -void PepperMessageFilter::FlashTCPSocket::Read(int32 bytes_to_read) { +void PepperMessageFilter::TCPSocket::Read(int32 bytes_to_read) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); if (!IsConnected() || end_of_file_reached_ || read_buffer_.get() || @@ -402,9 +400,9 @@ void PepperMessageFilter::FlashTCPSocket::Read(int32 bytes_to_read) { return; } - if (bytes_to_read > ppapi::proxy::kFlashTCPSocketMaxReadSize) { + if (bytes_to_read > ppapi::proxy::kTCPSocketMaxReadSize) { NOTREACHED(); - bytes_to_read = ppapi::proxy::kFlashTCPSocketMaxReadSize; + bytes_to_read = ppapi::proxy::kTCPSocketMaxReadSize; } read_buffer_ = new net::IOBuffer(bytes_to_read); @@ -413,7 +411,7 @@ void PepperMessageFilter::FlashTCPSocket::Read(int32 bytes_to_read) { OnReadCompleted(result); } -void PepperMessageFilter::FlashTCPSocket::Write(const std::string& data) { +void PepperMessageFilter::TCPSocket::Write(const std::string& data) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); if (!IsConnected() || write_buffer_.get() || data.empty()) { @@ -422,9 +420,9 @@ void PepperMessageFilter::FlashTCPSocket::Write(const std::string& data) { } int data_size = data.size(); - if (data_size > ppapi::proxy::kFlashTCPSocketMaxWriteSize) { + if (data_size > ppapi::proxy::kTCPSocketMaxWriteSize) { NOTREACHED(); - data_size = ppapi::proxy::kFlashTCPSocketMaxWriteSize; + data_size = ppapi::proxy::kTCPSocketMaxWriteSize; } write_buffer_ = new net::IOBuffer(data_size); @@ -434,7 +432,7 @@ void PepperMessageFilter::FlashTCPSocket::Write(const std::string& data) { OnWriteCompleted(result); } -void PepperMessageFilter::FlashTCPSocket::StartConnect( +void PepperMessageFilter::TCPSocket::StartConnect( const net::AddressList& addresses) { DCHECK(connection_state_ == CONNECT_IN_PROGRESS); @@ -445,28 +443,28 @@ void PepperMessageFilter::FlashTCPSocket::StartConnect( OnConnectCompleted(result); } -void PepperMessageFilter::FlashTCPSocket::SendConnectACKError() { - manager_->Send(new PpapiMsg_PPBFlashTCPSocket_ConnectACK( +void PepperMessageFilter::TCPSocket::SendConnectACKError() { + manager_->Send(new PpapiMsg_PPBTCPSocket_ConnectACK( routing_id_, plugin_dispatcher_id_, socket_id_, false, kInvalidNetAddress, kInvalidNetAddress)); } -void PepperMessageFilter::FlashTCPSocket::SendReadACKError() { - manager_->Send(new PpapiMsg_PPBFlashTCPSocket_ReadACK( +void PepperMessageFilter::TCPSocket::SendReadACKError() { + manager_->Send(new PpapiMsg_PPBTCPSocket_ReadACK( routing_id_, plugin_dispatcher_id_, socket_id_, false, std::string())); } -void PepperMessageFilter::FlashTCPSocket::SendWriteACKError() { - manager_->Send(new PpapiMsg_PPBFlashTCPSocket_WriteACK( +void PepperMessageFilter::TCPSocket::SendWriteACKError() { + manager_->Send(new PpapiMsg_PPBTCPSocket_WriteACK( routing_id_, plugin_dispatcher_id_, socket_id_, false, 0)); } -void PepperMessageFilter::FlashTCPSocket::SendSSLHandshakeACK(bool succeeded) { - manager_->Send(new PpapiMsg_PPBFlashTCPSocket_SSLHandshakeACK( +void PepperMessageFilter::TCPSocket::SendSSLHandshakeACK(bool succeeded) { + manager_->Send(new PpapiMsg_PPBTCPSocket_SSLHandshakeACK( routing_id_, plugin_dispatcher_id_, socket_id_, succeeded)); } -void PepperMessageFilter::FlashTCPSocket::OnResolveCompleted(int result) { +void PepperMessageFilter::TCPSocket::OnResolveCompleted(int result) { DCHECK(connection_state_ == CONNECT_IN_PROGRESS); if (result != net::OK) { @@ -478,7 +476,7 @@ void PepperMessageFilter::FlashTCPSocket::OnResolveCompleted(int result) { StartConnect(address_list_); } -void PepperMessageFilter::FlashTCPSocket::OnConnectCompleted(int result) { +void PepperMessageFilter::TCPSocket::OnConnectCompleted(int result) { DCHECK(connection_state_ == CONNECT_IN_PROGRESS && socket_.get()); if (result != net::OK) { @@ -497,7 +495,7 @@ void PepperMessageFilter::FlashTCPSocket::OnConnectCompleted(int result) { SendConnectACKError(); connection_state_ = BEFORE_CONNECT; } else { - manager_->Send(new PpapiMsg_PPBFlashTCPSocket_ConnectACK( + manager_->Send(new PpapiMsg_PPBTCPSocket_ConnectACK( routing_id_, plugin_dispatcher_id_, socket_id_, true, local_addr, remote_addr)); connection_state_ = CONNECTED; @@ -505,7 +503,7 @@ void PepperMessageFilter::FlashTCPSocket::OnConnectCompleted(int result) { } } -void PepperMessageFilter::FlashTCPSocket::OnSSLHandshakeCompleted(int result) { +void PepperMessageFilter::TCPSocket::OnSSLHandshakeCompleted(int result) { DCHECK(connection_state_ == SSL_HANDSHAKE_IN_PROGRESS); bool succeeded = result == net::OK; @@ -513,16 +511,16 @@ void PepperMessageFilter::FlashTCPSocket::OnSSLHandshakeCompleted(int result) { connection_state_ = succeeded ? SSL_CONNECTED : SSL_HANDSHAKE_FAILED; } -void PepperMessageFilter::FlashTCPSocket::OnReadCompleted(int result) { +void PepperMessageFilter::TCPSocket::OnReadCompleted(int result) { DCHECK(read_buffer_.get()); if (result > 0) { - manager_->Send(new PpapiMsg_PPBFlashTCPSocket_ReadACK( + manager_->Send(new PpapiMsg_PPBTCPSocket_ReadACK( routing_id_, plugin_dispatcher_id_, socket_id_, true, std::string(read_buffer_->data(), result))); } else if (result == 0) { end_of_file_reached_ = true; - manager_->Send(new PpapiMsg_PPBFlashTCPSocket_ReadACK( + manager_->Send(new PpapiMsg_PPBTCPSocket_ReadACK( routing_id_, plugin_dispatcher_id_, socket_id_, true, std::string())); } else { SendReadACKError(); @@ -530,11 +528,11 @@ void PepperMessageFilter::FlashTCPSocket::OnReadCompleted(int result) { read_buffer_ = NULL; } -void PepperMessageFilter::FlashTCPSocket::OnWriteCompleted(int result) { +void PepperMessageFilter::TCPSocket::OnWriteCompleted(int result) { DCHECK(write_buffer_.get()); if (result >= 0) { - manager_->Send(new PpapiMsg_PPBFlashTCPSocket_WriteACK( + manager_->Send(new PpapiMsg_PPBTCPSocket_WriteACK( routing_id_, plugin_dispatcher_id_, socket_id_, true, result)); } else { SendWriteACKError(); @@ -542,18 +540,18 @@ void PepperMessageFilter::FlashTCPSocket::OnWriteCompleted(int result) { write_buffer_ = NULL; } -bool PepperMessageFilter::FlashTCPSocket::IsConnected() const { +bool PepperMessageFilter::TCPSocket::IsConnected() const { return connection_state_ == CONNECTED || connection_state_ == SSL_CONNECTED; } -class PepperMessageFilter::FlashUDPSocket { +class PepperMessageFilter::UDPSocket { public: - FlashUDPSocket(PepperMessageFilter* pepper_message_filter, - int32 routing_id, - uint32 plugin_dispatcher_id, - uint32 socket_id); - ~FlashUDPSocket(); + UDPSocket(PepperMessageFilter* pepper_message_filter, + int32 routing_id, + uint32 plugin_dispatcher_id, + uint32 socket_id); + ~UDPSocket(); void Bind(const PP_NetAddress_Private& addr); void RecvFrom(int32_t num_bytes); @@ -572,8 +570,8 @@ class PepperMessageFilter::FlashUDPSocket { uint32 plugin_dispatcher_id_; uint32 socket_id_; - net::OldCompletionCallbackImpl<FlashUDPSocket> recvfrom_callback_; - net::OldCompletionCallbackImpl<FlashUDPSocket> sendto_callback_; + net::OldCompletionCallbackImpl<UDPSocket> recvfrom_callback_; + net::OldCompletionCallbackImpl<UDPSocket> sendto_callback_; scoped_ptr<net::UDPServerSocket> socket_; @@ -582,10 +580,10 @@ class PepperMessageFilter::FlashUDPSocket { net::IPEndPoint recvfrom_address_; - DISALLOW_COPY_AND_ASSIGN(FlashUDPSocket); + DISALLOW_COPY_AND_ASSIGN(UDPSocket); }; -PepperMessageFilter::FlashUDPSocket::FlashUDPSocket( +PepperMessageFilter::UDPSocket::UDPSocket( PepperMessageFilter* pepper_message_filter, int32 routing_id, uint32 plugin_dispatcher_id, @@ -595,19 +593,19 @@ PepperMessageFilter::FlashUDPSocket::FlashUDPSocket( plugin_dispatcher_id_(plugin_dispatcher_id), socket_id_(socket_id), ALLOW_THIS_IN_INITIALIZER_LIST( - recvfrom_callback_(this, &FlashUDPSocket::OnRecvFromCompleted)), + recvfrom_callback_(this, &UDPSocket::OnRecvFromCompleted)), ALLOW_THIS_IN_INITIALIZER_LIST( - sendto_callback_(this, &FlashUDPSocket::OnSendToCompleted)) { + sendto_callback_(this, &UDPSocket::OnSendToCompleted)) { DCHECK(pepper_message_filter); } -PepperMessageFilter::FlashUDPSocket::~FlashUDPSocket() { +PepperMessageFilter::UDPSocket::~UDPSocket() { // Make sure there are no further callbacks from socket_. if (socket_.get()) socket_->Close(); } -void PepperMessageFilter::FlashUDPSocket::Bind( +void PepperMessageFilter::UDPSocket::Bind( const PP_NetAddress_Private& addr) { socket_.reset(new net::UDPServerSocket(NULL, net::NetLog::Source())); @@ -622,7 +620,7 @@ void PepperMessageFilter::FlashUDPSocket::Bind( SendBindACK(result == net::OK); } -void PepperMessageFilter::FlashUDPSocket::RecvFrom(int32_t num_bytes) { +void PepperMessageFilter::UDPSocket::RecvFrom(int32_t num_bytes) { if (recvfrom_buffer_.get()) { SendRecvFromACKError(); return; @@ -638,7 +636,7 @@ void PepperMessageFilter::FlashUDPSocket::RecvFrom(int32_t num_bytes) { OnRecvFromCompleted(result); } -void PepperMessageFilter::FlashUDPSocket::SendTo( +void PepperMessageFilter::UDPSocket::SendTo( const std::string& data, const PP_NetAddress_Private& addr) { if (sendto_buffer_.get() || data.empty()) { @@ -665,37 +663,37 @@ void PepperMessageFilter::FlashUDPSocket::SendTo( OnSendToCompleted(result); } -void PepperMessageFilter::FlashUDPSocket::SendRecvFromACKError() { +void PepperMessageFilter::UDPSocket::SendRecvFromACKError() { PP_NetAddress_Private addr = kInvalidNetAddress; pepper_message_filter_->Send( - new PpapiMsg_PPBFlashUDPSocket_RecvFromACK( + new PpapiMsg_PPBUDPSocket_RecvFromACK( routing_id_, plugin_dispatcher_id_, socket_id_, false, std::string(), addr)); } -void PepperMessageFilter::FlashUDPSocket::SendSendToACKError() { +void PepperMessageFilter::UDPSocket::SendSendToACKError() { pepper_message_filter_->Send( - new PpapiMsg_PPBFlashUDPSocket_SendToACK( + new PpapiMsg_PPBUDPSocket_SendToACK( routing_id_, plugin_dispatcher_id_, socket_id_, false, 0)); } -void PepperMessageFilter::FlashUDPSocket::SendBindACK(bool result) { +void PepperMessageFilter::UDPSocket::SendBindACK(bool result) { pepper_message_filter_->Send( - new PpapiMsg_PPBFlashUDPSocket_BindACK( + new PpapiMsg_PPBUDPSocket_BindACK( routing_id_, plugin_dispatcher_id_, socket_id_, result)); } -void PepperMessageFilter::FlashUDPSocket::OnRecvFromCompleted(int result) { +void PepperMessageFilter::UDPSocket::OnRecvFromCompleted(int result) { DCHECK(recvfrom_buffer_.get()); // Convert IPEndPoint we get back from RecvFrom to a PP_NetAddress_Private, - // to send back to Flash. + // to send back. PP_NetAddress_Private addr = kInvalidNetAddress; if (!IPEndPointToNetAddress(recvfrom_address_, &addr) || result < 0) { SendRecvFromACKError(); } else { pepper_message_filter_->Send( - new PpapiMsg_PPBFlashUDPSocket_RecvFromACK( + new PpapiMsg_PPBUDPSocket_RecvFromACK( routing_id_, plugin_dispatcher_id_, socket_id_, true, std::string(recvfrom_buffer_->data(), result), addr)); } @@ -703,33 +701,33 @@ void PepperMessageFilter::FlashUDPSocket::OnRecvFromCompleted(int result) { recvfrom_buffer_ = NULL; } -void PepperMessageFilter::FlashUDPSocket::OnSendToCompleted(int result) { +void PepperMessageFilter::UDPSocket::OnSendToCompleted(int result) { DCHECK(sendto_buffer_.get()); pepper_message_filter_->Send( - new PpapiMsg_PPBFlashUDPSocket_SendToACK( + new PpapiMsg_PPBUDPSocket_SendToACK( routing_id_, plugin_dispatcher_id_, socket_id_, true, result)); sendto_buffer_ = NULL; } -PepperMessageFilter::FlashTCPSocketManager::FlashTCPSocketManager( +PepperMessageFilter::TCPSocketManager::TCPSocketManager( PepperMessageFilter* pepper_message_filter) - : FlashSocketManager<FlashTCPSocket>(pepper_message_filter) { + : SocketManager<TCPSocket>(pepper_message_filter) { } -void PepperMessageFilter::FlashTCPSocketManager::OnMsgCreate( +void PepperMessageFilter::TCPSocketManager::OnMsgCreate( int32 routing_id, uint32 plugin_dispatcher_id, uint32* socket_id) { if (!GenerateSocketID(socket_id)) return; - sockets_[*socket_id] = linked_ptr<FlashTCPSocket>( - new FlashTCPSocket(this, routing_id, plugin_dispatcher_id, *socket_id)); + sockets_[*socket_id] = linked_ptr<TCPSocket>( + new TCPSocket(this, routing_id, plugin_dispatcher_id, *socket_id)); } -void PepperMessageFilter::FlashTCPSocketManager::OnMsgConnect( +void PepperMessageFilter::TCPSocketManager::OnMsgConnect( uint32 socket_id, const std::string& host, uint16_t port) { @@ -742,7 +740,7 @@ void PepperMessageFilter::FlashTCPSocketManager::OnMsgConnect( iter->second->Connect(host, port); } -void PepperMessageFilter::FlashTCPSocketManager::OnMsgConnectWithNetAddress( +void PepperMessageFilter::TCPSocketManager::OnMsgConnectWithNetAddress( uint32 socket_id, const PP_NetAddress_Private& net_addr) { SocketMap::iterator iter = sockets_.find(socket_id); @@ -754,7 +752,7 @@ void PepperMessageFilter::FlashTCPSocketManager::OnMsgConnectWithNetAddress( iter->second->ConnectWithNetAddress(net_addr); } -void PepperMessageFilter::FlashTCPSocketManager::OnMsgSSLHandshake( +void PepperMessageFilter::TCPSocketManager::OnMsgSSLHandshake( uint32 socket_id, const std::string& server_name, uint16_t server_port) { @@ -767,7 +765,7 @@ void PepperMessageFilter::FlashTCPSocketManager::OnMsgSSLHandshake( iter->second->SSLHandshake(server_name, server_port); } -void PepperMessageFilter::FlashTCPSocketManager::OnMsgRead( +void PepperMessageFilter::TCPSocketManager::OnMsgRead( uint32 socket_id, int32_t bytes_to_read) { SocketMap::iterator iter = sockets_.find(socket_id); @@ -779,7 +777,7 @@ void PepperMessageFilter::FlashTCPSocketManager::OnMsgRead( iter->second->Read(bytes_to_read); } -void PepperMessageFilter::FlashTCPSocketManager::OnMsgWrite( +void PepperMessageFilter::TCPSocketManager::OnMsgWrite( uint32 socket_id, const std::string& data) { SocketMap::iterator iter = sockets_.find(socket_id); @@ -791,7 +789,7 @@ void PepperMessageFilter::FlashTCPSocketManager::OnMsgWrite( iter->second->Write(data); } -void PepperMessageFilter::FlashTCPSocketManager::OnMsgDisconnect( +void PepperMessageFilter::TCPSocketManager::OnMsgDisconnect( uint32 socket_id) { SocketMap::iterator iter = sockets_.find(socket_id); if (iter == sockets_.end()) { @@ -799,26 +797,26 @@ void PepperMessageFilter::FlashTCPSocketManager::OnMsgDisconnect( return; } - // Destroy the FlashTCPSocket instance will cancel any pending completion + // Destroy the TCPSocket instance will cancel any pending completion // callback. From this point on, there won't be any messages associated with // this socket sent to the plugin side. sockets_.erase(iter); } net::CertVerifier* -PepperMessageFilter::FlashTCPSocketManager::GetCertVerifier() { +PepperMessageFilter::TCPSocketManager::GetCertVerifier() { if (!cert_verifier_.get()) cert_verifier_.reset(new net::CertVerifier()); return cert_verifier_.get(); } -// FlashUDPSocketManager manages the mapping from socket IDs to FlashUDPSocket +// UDPSocketManager manages the mapping from socket IDs to UDPSocket // instances. -class PepperMessageFilter::FlashUDPSocketManager - : public FlashSocketManager<FlashUDPSocket> { +class PepperMessageFilter::UDPSocketManager + : public SocketManager<UDPSocket> { public: - explicit FlashUDPSocketManager(PepperMessageFilter* pepper_message_filter); + explicit UDPSocketManager(PepperMessageFilter* pepper_message_filter); void OnMsgCreate(int32 routing_id, uint32 plugin_dispatcher_id, @@ -833,27 +831,27 @@ class PepperMessageFilter::FlashUDPSocketManager void OnMsgClose(uint32 socket_id); private: - DISALLOW_COPY_AND_ASSIGN(FlashUDPSocketManager); + DISALLOW_COPY_AND_ASSIGN(UDPSocketManager); }; -PepperMessageFilter::FlashUDPSocketManager::FlashUDPSocketManager( +PepperMessageFilter::UDPSocketManager::UDPSocketManager( PepperMessageFilter* pepper_message_filter) - : FlashSocketManager<FlashUDPSocket>(pepper_message_filter) { + : SocketManager<UDPSocket>(pepper_message_filter) { } -void PepperMessageFilter::FlashUDPSocketManager::OnMsgCreate( +void PepperMessageFilter::UDPSocketManager::OnMsgCreate( int32 routing_id, uint32 plugin_dispatcher_id, uint32* socket_id) { if (!GenerateSocketID(socket_id)) return; - sockets_[*socket_id] = linked_ptr<FlashUDPSocket>( - new FlashUDPSocket(pepper_message_filter_, routing_id, + sockets_[*socket_id] = linked_ptr<UDPSocket>( + new UDPSocket(pepper_message_filter_, routing_id, plugin_dispatcher_id, *socket_id)); } -void PepperMessageFilter::FlashUDPSocketManager::OnMsgBind( +void PepperMessageFilter::UDPSocketManager::OnMsgBind( uint32 socket_id, const PP_NetAddress_Private& addr) { SocketMap::iterator iter = sockets_.find(socket_id); @@ -865,7 +863,7 @@ void PepperMessageFilter::FlashUDPSocketManager::OnMsgBind( iter->second->Bind(addr); } -void PepperMessageFilter::FlashUDPSocketManager::OnMsgRecvFrom( +void PepperMessageFilter::UDPSocketManager::OnMsgRecvFrom( uint32 socket_id, int32_t num_bytes) { SocketMap::iterator iter = sockets_.find(socket_id); @@ -877,7 +875,7 @@ void PepperMessageFilter::FlashUDPSocketManager::OnMsgRecvFrom( iter->second->RecvFrom(num_bytes); } -void PepperMessageFilter::FlashUDPSocketManager::OnMsgSendTo( +void PepperMessageFilter::UDPSocketManager::OnMsgSendTo( uint32 socket_id, const std::string& data, const PP_NetAddress_Private& addr) { @@ -890,7 +888,7 @@ void PepperMessageFilter::FlashUDPSocketManager::OnMsgSendTo( iter->second->SendTo(data, addr); } -void PepperMessageFilter::FlashUDPSocketManager::OnMsgClose( +void PepperMessageFilter::UDPSocketManager::OnMsgClose( uint32 socket_id) { SocketMap::iterator iter = sockets_.find(socket_id); if (iter == sockets_.end()) { @@ -898,7 +896,7 @@ void PepperMessageFilter::FlashUDPSocketManager::OnMsgClose( return; } - // Destroy the FlashUDPSocket instance will cancel any pending completion + // Destroy the UDPSocket instance will cancel any pending completion // callback. From this point on, there won't be any messages associated with // this socket sent to the plugin side. sockets_.erase(iter); @@ -909,9 +907,9 @@ PepperMessageFilter::PepperMessageFilter( : resource_context_(resource_context), host_resolver_(NULL), ALLOW_THIS_IN_INITIALIZER_LIST( - socket_manager_tcp_(new FlashTCPSocketManager(this))), + socket_manager_tcp_(new TCPSocketManager(this))), ALLOW_THIS_IN_INITIALIZER_LIST( - socket_manager_udp_(new FlashUDPSocketManager(this))) { + socket_manager_udp_(new UDPSocketManager(this))) { DCHECK(resource_context_); } @@ -919,9 +917,9 @@ PepperMessageFilter::PepperMessageFilter(net::HostResolver* host_resolver) : resource_context_(NULL), host_resolver_(host_resolver), ALLOW_THIS_IN_INITIALIZER_LIST( - socket_manager_tcp_(new FlashTCPSocketManager(this))), + socket_manager_tcp_(new TCPSocketManager(this))), ALLOW_THIS_IN_INITIALIZER_LIST( - socket_manager_udp_(new FlashUDPSocketManager(this))) { + socket_manager_udp_(new UDPSocketManager(this))) { DCHECK(host_resolver); } @@ -940,45 +938,45 @@ bool PepperMessageFilter::OnMessageReceived(const IPC::Message& msg, IPC_MESSAGE_HANDLER_DELAY_REPLY(PpapiHostMsg_PPBFont_GetFontFamilies, OnGetFontFamilies) IPC_MESSAGE_FORWARD( - PpapiHostMsg_PPBFlashTCPSocket_Create, - socket_manager_tcp_.get(), FlashTCPSocketManager::OnMsgCreate) + PpapiHostMsg_PPBTCPSocket_Create, + socket_manager_tcp_.get(), TCPSocketManager::OnMsgCreate) IPC_MESSAGE_FORWARD( - PpapiHostMsg_PPBFlashTCPSocket_Connect, - socket_manager_tcp_.get(), FlashTCPSocketManager::OnMsgConnect) + PpapiHostMsg_PPBTCPSocket_Connect, + socket_manager_tcp_.get(), TCPSocketManager::OnMsgConnect) IPC_MESSAGE_FORWARD( - PpapiHostMsg_PPBFlashTCPSocket_ConnectWithNetAddress, + PpapiHostMsg_PPBTCPSocket_ConnectWithNetAddress, socket_manager_tcp_.get(), - FlashTCPSocketManager::OnMsgConnectWithNetAddress) + TCPSocketManager::OnMsgConnectWithNetAddress) IPC_MESSAGE_FORWARD( - PpapiHostMsg_PPBFlashTCPSocket_SSLHandshake, + PpapiHostMsg_PPBTCPSocket_SSLHandshake, socket_manager_tcp_.get(), - FlashTCPSocketManager::OnMsgSSLHandshake) + TCPSocketManager::OnMsgSSLHandshake) IPC_MESSAGE_FORWARD( - PpapiHostMsg_PPBFlashTCPSocket_Read, - socket_manager_tcp_.get(), FlashTCPSocketManager::OnMsgRead) + PpapiHostMsg_PPBTCPSocket_Read, + socket_manager_tcp_.get(), TCPSocketManager::OnMsgRead) IPC_MESSAGE_FORWARD( - PpapiHostMsg_PPBFlashTCPSocket_Write, - socket_manager_tcp_.get(), FlashTCPSocketManager::OnMsgWrite) + PpapiHostMsg_PPBTCPSocket_Write, + socket_manager_tcp_.get(), TCPSocketManager::OnMsgWrite) IPC_MESSAGE_FORWARD( - PpapiHostMsg_PPBFlashTCPSocket_Disconnect, - socket_manager_tcp_.get(), FlashTCPSocketManager::OnMsgDisconnect) + PpapiHostMsg_PPBTCPSocket_Disconnect, + socket_manager_tcp_.get(), TCPSocketManager::OnMsgDisconnect) // UDP IPC_MESSAGE_FORWARD( - PpapiHostMsg_PPBFlashUDPSocket_Create, - socket_manager_udp_.get(), FlashUDPSocketManager::OnMsgCreate) + PpapiHostMsg_PPBUDPSocket_Create, + socket_manager_udp_.get(), UDPSocketManager::OnMsgCreate) IPC_MESSAGE_FORWARD( - PpapiHostMsg_PPBFlashUDPSocket_Bind, - socket_manager_udp_.get(), FlashUDPSocketManager::OnMsgBind) + PpapiHostMsg_PPBUDPSocket_Bind, + socket_manager_udp_.get(), UDPSocketManager::OnMsgBind) IPC_MESSAGE_FORWARD( - PpapiHostMsg_PPBFlashUDPSocket_RecvFrom, - socket_manager_udp_.get(), FlashUDPSocketManager::OnMsgRecvFrom) + PpapiHostMsg_PPBUDPSocket_RecvFrom, + socket_manager_udp_.get(), UDPSocketManager::OnMsgRecvFrom) IPC_MESSAGE_FORWARD( - PpapiHostMsg_PPBFlashUDPSocket_SendTo, - socket_manager_udp_.get(), FlashUDPSocketManager::OnMsgSendTo) + PpapiHostMsg_PPBUDPSocket_SendTo, + socket_manager_udp_.get(), UDPSocketManager::OnMsgSendTo) IPC_MESSAGE_FORWARD( - PpapiHostMsg_PPBFlashUDPSocket_Close, - socket_manager_udp_.get(), FlashUDPSocketManager::OnMsgClose) + PpapiHostMsg_PPBUDPSocket_Close, + socket_manager_udp_.get(), UDPSocketManager::OnMsgClose) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP_EX() diff --git a/content/browser/renderer_host/pepper_message_filter.h b/content/browser/renderer_host/pepper_message_filter.h index 8aec438..a328a4a 100644 --- a/content/browser/renderer_host/pepper_message_filter.h +++ b/content/browser/renderer_host/pepper_message_filter.h @@ -42,11 +42,11 @@ class PepperMessageFilter : public BrowserMessageFilter { bool* message_was_ok); private: - template<class SocketType> class FlashSocketManager; - class FlashTCPSocket; - class FlashTCPSocketManager; - class FlashUDPSocket; - class FlashUDPSocketManager; + template<class SocketType> class SocketManager; + class TCPSocket; + class TCPSocketManager; + class UDPSocket; + class UDPSocketManager; #if defined(ENABLE_FLAPPER_HACKS) // Message handlers. @@ -98,8 +98,8 @@ class PepperMessageFilter : public BrowserMessageFilter { // GetHostResolver instead of accessing directly. net::HostResolver* host_resolver_; - scoped_ptr<FlashTCPSocketManager> socket_manager_tcp_; - scoped_ptr<FlashUDPSocketManager> socket_manager_udp_; + scoped_ptr<TCPSocketManager> socket_manager_tcp_; + scoped_ptr<UDPSocketManager> socket_manager_udp_; DISALLOW_COPY_AND_ASSIGN(PepperMessageFilter); }; diff --git a/content/ppapi_plugin/ppapi_thread.cc b/content/ppapi_plugin/ppapi_thread.cc index c2dc8c2..7b865bc 100644 --- a/content/ppapi_plugin/ppapi_thread.cc +++ b/content/ppapi_plugin/ppapi_thread.cc @@ -73,19 +73,19 @@ bool PpapiThread::OnMessageReceived(const IPC::Message& msg) { IPC_BEGIN_MESSAGE_MAP(PpapiThread, msg) IPC_MESSAGE_HANDLER(PpapiMsg_LoadPlugin, OnMsgLoadPlugin) IPC_MESSAGE_HANDLER(PpapiMsg_CreateChannel, OnMsgCreateChannel) - IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBFlashTCPSocket_ConnectACK, + IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBTCPSocket_ConnectACK, OnPluginDispatcherMessageReceived(msg)) - IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBFlashTCPSocket_SSLHandshakeACK, + IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBTCPSocket_SSLHandshakeACK, OnPluginDispatcherMessageReceived(msg)) - IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBFlashTCPSocket_ReadACK, + IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBTCPSocket_ReadACK, OnPluginDispatcherMessageReceived(msg)) - IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBFlashTCPSocket_WriteACK, + IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBTCPSocket_WriteACK, OnPluginDispatcherMessageReceived(msg)) - IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBFlashUDPSocket_RecvFromACK, + IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBUDPSocket_RecvFromACK, OnPluginDispatcherMessageReceived(msg)) - IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBFlashUDPSocket_SendToACK, + IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBUDPSocket_SendToACK, OnPluginDispatcherMessageReceived(msg)) - IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBFlashUDPSocket_BindACK, + IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBUDPSocket_BindACK, OnPluginDispatcherMessageReceived(msg)) IPC_MESSAGE_HANDLER(PpapiMsg_SetNetworkState, OnMsgSetNetworkState) IPC_END_MESSAGE_MAP() diff --git a/ppapi/api/private/ppb_tcp_socket_private.idl b/ppapi/api/private/ppb_tcp_socket_private.idl new file mode 100644 index 0000000..847df9f --- /dev/null +++ b/ppapi/api/private/ppb_tcp_socket_private.idl @@ -0,0 +1,114 @@ +/* Copyright (c) 2011 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/** + * This file defines the <code>PPB_TCPSocket_Private</code> interface. + */ + +label Chrome { + M17 = 0.3 +}; + +/** + * The <code>PPB_TCPSocket_Private</code> interface provides TCP socket + * operations. + */ +interface PPB_TCPSocket_Private { + /** + * Allocates a TCP socket resource. + */ + PP_Resource Create([in] PP_Instance instance); + + /** + * Determines if a given resource is TCP socket. + */ + PP_Bool IsTCPSocket([in] PP_Resource resource); + + /** + * Connects to a TCP port given as a host-port pair. + * When a proxy server is used, |host| and |port| refer to the proxy server + * instead of the destination server. + */ + int32_t Connect([in] PP_Resource tcp_socket, + [in] str_t host, + [in] uint16_t port, + [in] PP_CompletionCallback callback); + + /** + * Same as Connect(), but connecting to the address given by |addr|. A typical + * use-case would be for reconnections. + */ + int32_t ConnectWithNetAddress([in] PP_Resource tcp_socket, + [in] PP_NetAddress_Private addr, + [in] PP_CompletionCallback callback); + + /** + * Gets the local address of the socket, if it has been connected. + * Returns PP_TRUE on success. + */ + PP_Bool GetLocalAddress([in] PP_Resource tcp_socket, + [out] PP_NetAddress_Private local_addr); + + /** + * Gets the remote address of the socket, if it has been connected. + * Returns PP_TRUE on success. + */ + PP_Bool GetRemoteAddress([in] PP_Resource tcp_socket, + [out] PP_NetAddress_Private remote_addr); + + /** + * Does SSL handshake and moves to sending and receiving encrypted data. The + * socket must have been successfully connected. |server_name| will be + * compared with the name(s) in the server's certificate during the SSL + * handshake. |server_port| is only used to identify an SSL server in the SSL + * session cache. + * When a proxy server is used, |server_name| and |server_port| refer to the + * destination server. + * If the socket is not connected, or there are pending read/write requests, + * SSLHandshake() will fail without starting a handshake. Otherwise, any + * failure during the handshake process will cause the socket to be + * disconnected. + */ + int32_t SSLHandshake([in] PP_Resource tcp_socket, + [in] str_t server_name, + [in] uint16_t server_port, + [in] PP_CompletionCallback callback); + + /** + * Reads data from the socket. The size of |buffer| must be at least as large + * as |bytes_to_read|. May perform a partial read. Returns the number of bytes + * read or an error code. If the return value is 0, then it indicates that + * end-of-file was reached. + * This method won't return more than 1 megabyte, so if |bytes_to_read| + * exceeds 1 megabyte, it will always perform a partial read. + * Multiple outstanding read requests are not supported. + */ + int32_t Read([in] PP_Resource tcp_socket, + [out] str_t buffer, + [in] int32_t bytes_to_read, + [in] PP_CompletionCallback callback); + + /** + * Writes data to the socket. May perform a partial write. Returns the number + * of bytes written or an error code. + * This method won't write more than 1 megabyte, so if |bytes_to_write| + * exceeds 1 megabyte, it will always perform a partial write. + * Multiple outstanding write requests are not supported. + */ + int32_t Write([in] PP_Resource tcp_socket, + [in] str_t buffer, + [in] int32_t bytes_to_write, + [in] PP_CompletionCallback callback); + + /** + * Cancels any IO that may be pending, and disconnects the socket. Any pending + * callbacks will still run, reporting PP_Error_Aborted if pending IO was + * interrupted. It is NOT valid to call Connect() again after a call to this + * method. Note: If the socket is destroyed when it is still connected, then + * it will be implicitly disconnected, so you are not required to call this + * method. + */ + void Disconnect([in] PP_Resource tcp_socket); +}; diff --git a/ppapi/api/private/ppb_udp_socket_private.idl b/ppapi/api/private/ppb_udp_socket_private.idl new file mode 100644 index 0000000..82b7c3a --- /dev/null +++ b/ppapi/api/private/ppb_udp_socket_private.idl @@ -0,0 +1,58 @@ +/* Copyright (c) 2011 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/** + * This file defines the <code>PPB_UDPSocket_Private</code> interface. + */ + +label Chrome { + M17 = 0.2 +}; + +interface PPB_UDPSocket_Private { + /** + * Creates a UDP socket resource. + */ + PP_Resource Create([in] PP_Instance instance_id); + + /** + * Determines if a given resource is a UDP socket. + */ + PP_Bool IsUDPSocket([in] PP_Resource resource_id); + + /* Creates a socket and binds to the address given by |addr|. */ + int32_t Bind([in] PP_Resource udp_socket, + [in] PP_NetAddress_Private addr, + [in] PP_CompletionCallback callback); + + /* Performs a non-blocking recvfrom call on socket. + * Bind must be called first. |callback| is invoked when recvfrom + * reads data. You must call GetRecvFromAddress to recover the + * address the data was retrieved from. + */ + int32_t RecvFrom([in] PP_Resource udp_socket, + [out] str_t buffer, + [in] int32_t num_bytes, + [in] PP_CompletionCallback callback); + + /* Upon successful completion of RecvFrom, the address that the data + * was received from is stored in |addr|. + */ + PP_Bool GetRecvFromAddress([in] PP_Resource udp_socket, + [out] PP_NetAddress_Private addr); + + /* Performs a non-blocking sendto call on the socket created and + * bound(has already called Bind). The callback |callback| is + * invoked when sendto completes. + */ + int32_t SendTo([in] PP_Resource udp_socket, + [in] str_t buffer, + [in] int32_t num_bytes, + [in] PP_NetAddress_Private addr, + [in] PP_CompletionCallback callback); + + /* Cancels all pending reads and writes, and closes the socket. */ + void Close([in] PP_Resource udp_socket); +}; diff --git a/ppapi/c/private/ppb_tcp_socket_private.h b/ppapi/c/private/ppb_tcp_socket_private.h new file mode 100644 index 0000000..1515698 --- /dev/null +++ b/ppapi/c/private/ppb_tcp_socket_private.h @@ -0,0 +1,129 @@ +/* Copyright (c) 2011 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* From private/ppb_tcp_socket_private.idl modified Wed Nov 9 12:53:35 2011. */ + +#ifndef PPAPI_C_PRIVATE_PPB_TCP_SOCKET_PRIVATE_H_ +#define PPAPI_C_PRIVATE_PPB_TCP_SOCKET_PRIVATE_H_ + +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_macros.h" +#include "ppapi/c/pp_resource.h" +#include "ppapi/c/pp_stdint.h" +#include "ppapi/c/private/ppb_net_address_private.h" + +#define PPB_TCPSOCKET_PRIVATE_INTERFACE_0_3 "PPB_TCPSocket_Private;0.3" +#define PPB_TCPSOCKET_PRIVATE_INTERFACE PPB_TCPSOCKET_PRIVATE_INTERFACE_0_3 + +/** + * @file + * This file defines the <code>PPB_TCPSocket_Private</code> interface. + */ + + +/** + * @addtogroup Interfaces + * @{ + */ +/** + * The <code>PPB_TCPSocket_Private</code> interface provides TCP socket + * operations. + */ +struct PPB_TCPSocket_Private { + /** + * Allocates a TCP socket resource. + */ + PP_Resource (*Create)(PP_Instance instance); + /** + * Determines if a given resource is TCP socket. + */ + PP_Bool (*IsTCPSocket)(PP_Resource resource); + /** + * Connects to a TCP port given as a host-port pair. + * When a proxy server is used, |host| and |port| refer to the proxy server + * instead of the destination server. + */ + int32_t (*Connect)(PP_Resource tcp_socket, + const char* host, + uint16_t port, + struct PP_CompletionCallback callback); + /** + * Same as Connect(), but connecting to the address given by |addr|. A typical + * use-case would be for reconnections. + */ + int32_t (*ConnectWithNetAddress)(PP_Resource tcp_socket, + const struct PP_NetAddress_Private* addr, + struct PP_CompletionCallback callback); + /** + * Gets the local address of the socket, if it has been connected. + * Returns PP_TRUE on success. + */ + PP_Bool (*GetLocalAddress)(PP_Resource tcp_socket, + struct PP_NetAddress_Private* local_addr); + /** + * Gets the remote address of the socket, if it has been connected. + * Returns PP_TRUE on success. + */ + PP_Bool (*GetRemoteAddress)(PP_Resource tcp_socket, + struct PP_NetAddress_Private* remote_addr); + /** + * Does SSL handshake and moves to sending and receiving encrypted data. The + * socket must have been successfully connected. |server_name| will be + * compared with the name(s) in the server's certificate during the SSL + * handshake. |server_port| is only used to identify an SSL server in the SSL + * session cache. + * When a proxy server is used, |server_name| and |server_port| refer to the + * destination server. + * If the socket is not connected, or there are pending read/write requests, + * SSLHandshake() will fail without starting a handshake. Otherwise, any + * failure during the handshake process will cause the socket to be + * disconnected. + */ + int32_t (*SSLHandshake)(PP_Resource tcp_socket, + const char* server_name, + uint16_t server_port, + struct PP_CompletionCallback callback); + /** + * Reads data from the socket. The size of |buffer| must be at least as large + * as |bytes_to_read|. May perform a partial read. Returns the number of bytes + * read or an error code. If the return value is 0, then it indicates that + * end-of-file was reached. + * This method won't return more than 1 megabyte, so if |bytes_to_read| + * exceeds 1 megabyte, it will always perform a partial read. + * Multiple outstanding read requests are not supported. + */ + int32_t (*Read)(PP_Resource tcp_socket, + char* buffer, + int32_t bytes_to_read, + struct PP_CompletionCallback callback); + /** + * Writes data to the socket. May perform a partial write. Returns the number + * of bytes written or an error code. + * This method won't write more than 1 megabyte, so if |bytes_to_write| + * exceeds 1 megabyte, it will always perform a partial write. + * Multiple outstanding write requests are not supported. + */ + int32_t (*Write)(PP_Resource tcp_socket, + const char* buffer, + int32_t bytes_to_write, + struct PP_CompletionCallback callback); + /** + * Cancels any IO that may be pending, and disconnects the socket. Any pending + * callbacks will still run, reporting PP_Error_Aborted if pending IO was + * interrupted. It is NOT valid to call Connect() again after a call to this + * method. Note: If the socket is destroyed when it is still connected, then + * it will be implicitly disconnected, so you are not required to call this + * method. + */ + void (*Disconnect)(PP_Resource tcp_socket); +}; +/** + * @} + */ + +#endif /* PPAPI_C_PRIVATE_PPB_TCP_SOCKET_PRIVATE_H_ */ + diff --git a/ppapi/c/private/ppb_udp_socket_private.h b/ppapi/c/private/ppb_udp_socket_private.h new file mode 100644 index 0000000..9e6cd48 --- /dev/null +++ b/ppapi/c/private/ppb_udp_socket_private.h @@ -0,0 +1,76 @@ +/* Copyright (c) 2011 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* From private/ppb_udp_socket_private.idl modified Wed Nov 9 12:53:35 2011. */ + +#ifndef PPAPI_C_PRIVATE_PPB_UDP_SOCKET_PRIVATE_H_ +#define PPAPI_C_PRIVATE_PPB_UDP_SOCKET_PRIVATE_H_ + +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_macros.h" +#include "ppapi/c/pp_resource.h" +#include "ppapi/c/pp_stdint.h" +#include "ppapi/c/private/ppb_net_address_private.h" + +#define PPB_UDPSOCKET_PRIVATE_INTERFACE_0_2 "PPB_UDPSocket_Private;0.2" +#define PPB_UDPSOCKET_PRIVATE_INTERFACE PPB_UDPSOCKET_PRIVATE_INTERFACE_0_2 + +/** + * @file + * This file defines the <code>PPB_UDPSocket_Private</code> interface. + */ + + +/** + * @addtogroup Interfaces + * @{ + */ +struct PPB_UDPSocket_Private { + /** + * Creates a UDP socket resource. + */ + PP_Resource (*Create)(PP_Instance instance_id); + /** + * Determines if a given resource is a UDP socket. + */ + PP_Bool (*IsUDPSocket)(PP_Resource resource_id); + /* Creates a socket and binds to the address given by |addr|. */ + int32_t (*Bind)(PP_Resource udp_socket, + const struct PP_NetAddress_Private* addr, + struct PP_CompletionCallback callback); + /* Performs a non-blocking recvfrom call on socket. + * Bind must be called first. |callback| is invoked when recvfrom + * reads data. You must call GetRecvFromAddress to recover the + * address the data was retrieved from. + */ + int32_t (*RecvFrom)(PP_Resource udp_socket, + char* buffer, + int32_t num_bytes, + struct PP_CompletionCallback callback); + /* Upon successful completion of RecvFrom, the address that the data + * was received from is stored in |addr|. + */ + PP_Bool (*GetRecvFromAddress)(PP_Resource udp_socket, + struct PP_NetAddress_Private* addr); + /* Performs a non-blocking sendto call on the socket created and + * bound(has already called Bind). The callback |callback| is + * invoked when sendto completes. + */ + int32_t (*SendTo)(PP_Resource udp_socket, + const char* buffer, + int32_t num_bytes, + const struct PP_NetAddress_Private* addr, + struct PP_CompletionCallback callback); + /* Cancels all pending reads and writes, and closes the socket. */ + void (*Close)(PP_Resource udp_socket); +}; +/** + * @} + */ + +#endif /* PPAPI_C_PRIVATE_PPB_UDP_SOCKET_PRIVATE_H_ */ + diff --git a/ppapi/cpp/private/tcp_socket_private.cc b/ppapi/cpp/private/tcp_socket_private.cc new file mode 100644 index 0000000..17938b4 --- /dev/null +++ b/ppapi/cpp/private/tcp_socket_private.cc @@ -0,0 +1,105 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/cpp/private/tcp_socket_private.h" + +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/cpp/completion_callback.h" +#include "ppapi/cpp/instance.h" +#include "ppapi/cpp/module.h" +#include "ppapi/cpp/module_impl.h" + +namespace pp { + +namespace { + +template <> const char* interface_name<PPB_TCPSocket_Private>() { + return PPB_TCPSOCKET_PRIVATE_INTERFACE; +} + +} // namespace + +TCPSocketPrivate::TCPSocketPrivate(Instance* instance) { + if (has_interface<PPB_TCPSocket_Private>() && instance) { + PassRefFromConstructor(get_interface<PPB_TCPSocket_Private>()->Create( + instance->pp_instance())); + } +} + +// static +bool TCPSocketPrivate::IsAvailable() { + return has_interface<PPB_TCPSocket_Private>(); +} + +int32_t TCPSocketPrivate::Connect(const char* host, + uint16_t port, + const CompletionCallback& callback) { + if (!has_interface<PPB_TCPSocket_Private>()) + return callback.MayForce(PP_ERROR_NOINTERFACE); + return get_interface<PPB_TCPSocket_Private>()->Connect( + pp_resource(), host, port, callback.pp_completion_callback()); +} + +int32_t TCPSocketPrivate::ConnectWithNetAddress( + const PP_NetAddress_Private* addr, + const CompletionCallback& callback) { + if (!has_interface<PPB_TCPSocket_Private>()) + return callback.MayForce(PP_ERROR_NOINTERFACE); + return get_interface<PPB_TCPSocket_Private>()->ConnectWithNetAddress( + pp_resource(), addr, callback.pp_completion_callback()); +} + +bool TCPSocketPrivate::GetLocalAddress(PP_NetAddress_Private* local_addr) { + if (!has_interface<PPB_TCPSocket_Private>()) + return false; + + PP_Bool result = get_interface<PPB_TCPSocket_Private>()->GetLocalAddress( + pp_resource(), local_addr); + return PP_ToBool(result); +} + +bool TCPSocketPrivate::GetRemoteAddress(PP_NetAddress_Private* remote_addr) { + if (!has_interface<PPB_TCPSocket_Private>()) + return false; + PP_Bool result = get_interface<PPB_TCPSocket_Private>()->GetRemoteAddress( + pp_resource(), remote_addr); + return PP_ToBool(result); +} + +int32_t TCPSocketPrivate::SSLHandshake(const char* server_name, + uint16_t server_port, + const CompletionCallback& callback) { + if (!has_interface<PPB_TCPSocket_Private>()) + return callback.MayForce(PP_ERROR_NOINTERFACE); + return get_interface<PPB_TCPSocket_Private>()->SSLHandshake( + pp_resource(), server_name, server_port, + callback.pp_completion_callback()); +} + +int32_t TCPSocketPrivate::Read(char* buffer, + int32_t bytes_to_read, + const CompletionCallback& callback) { + if (!has_interface<PPB_TCPSocket_Private>()) + return callback.MayForce(PP_ERROR_NOINTERFACE); + return get_interface<PPB_TCPSocket_Private>()->Read( + pp_resource(), buffer, bytes_to_read, callback.pp_completion_callback()); +} + +int32_t TCPSocketPrivate::Write(const char* buffer, + int32_t bytes_to_write, + const CompletionCallback& callback) { + if (!has_interface<PPB_TCPSocket_Private>()) + return callback.MayForce(PP_ERROR_NOINTERFACE); + return get_interface<PPB_TCPSocket_Private>()->Write( + pp_resource(), buffer, bytes_to_write, callback.pp_completion_callback()); +} + +void TCPSocketPrivate::Disconnect() { + if (!has_interface<PPB_TCPSocket_Private>()) + return; + return get_interface<PPB_TCPSocket_Private>()->Disconnect(pp_resource()); +} + +} // namespace pp diff --git a/ppapi/cpp/private/tcp_socket_private.h b/ppapi/cpp/private/tcp_socket_private.h new file mode 100644 index 0000000..b8728b4 --- /dev/null +++ b/ppapi/cpp/private/tcp_socket_private.h @@ -0,0 +1,45 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_CPP_PRIVATE_TCP_SOCKET_PRIVATE_H_ +#define PPAPI_CPP_PRIVATE_TCP_SOCKET_PRIVATE_H_ + +#include "ppapi/c/pp_stdint.h" +#include "ppapi/c/private/ppb_tcp_socket_private.h" +#include "ppapi/cpp/resource.h" + +namespace pp { + +class CompletionCallback; +class Instance; + +class TCPSocketPrivate : public Resource { + public: + explicit TCPSocketPrivate(Instance* instance); + + // Returns true if the required interface is available. + static bool IsAvailable(); + + int32_t Connect(const char* host, + uint16_t port, + const CompletionCallback& callback); + int32_t ConnectWithNetAddress(const PP_NetAddress_Private* addr, + const CompletionCallback& callback); + bool GetLocalAddress(PP_NetAddress_Private* local_addr); + bool GetRemoteAddress(PP_NetAddress_Private* remote_addr); + int32_t SSLHandshake(const char* server_name, + uint16_t server_port, + const CompletionCallback& callback); + int32_t Read(char* buffer, + int32_t bytes_to_read, + const CompletionCallback& callback); + int32_t Write(const char* buffer, + int32_t bytes_to_write, + const CompletionCallback& callback); + void Disconnect(); +}; + +} // namespace pp + +#endif // PPAPI_CPP_PRIVATE_TCP_SOCKET_PRIVATE_H_ diff --git a/ppapi/cpp/private/udp_socket_private.cc b/ppapi/cpp/private/udp_socket_private.cc new file mode 100644 index 0000000..8bd49f2 --- /dev/null +++ b/ppapi/cpp/private/udp_socket_private.cc @@ -0,0 +1,69 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/cpp/private/udp_socket_private.h" + +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/cpp/completion_callback.h" +#include "ppapi/cpp/instance.h" +#include "ppapi/cpp/module.h" +#include "ppapi/cpp/module_impl.h" + +namespace pp { + +namespace { + +template <> const char* interface_name<PPB_UDPSocket_Private>() { + return PPB_UDPSOCKET_PRIVATE_INTERFACE; +} + +} // namespace + +UDPSocketPrivate::UDPSocketPrivate(Instance* instance) { + if (has_interface<PPB_UDPSocket_Private>() && instance) { + PassRefFromConstructor(get_interface<PPB_UDPSocket_Private>()->Create( + instance->pp_instance())); + } +} + +int32_t UDPSocketPrivate::Bind(const PP_NetAddress_Private* addr, + const CompletionCallback& callback) { + if (!has_interface<PPB_UDPSocket_Private>()) + return PP_ERROR_NOINTERFACE; + return get_interface<PPB_UDPSocket_Private>()->Bind( + pp_resource(), addr, callback.pp_completion_callback()); +} + +int32_t UDPSocketPrivate::RecvFrom(char* buffer, + int32_t num_bytes, + const CompletionCallback& callback) { + if (!has_interface<PPB_UDPSocket_Private>()) + return PP_ERROR_NOINTERFACE; + return get_interface<PPB_UDPSocket_Private>()->RecvFrom( + pp_resource(), buffer, num_bytes, callback.pp_completion_callback()); +} + +bool UDPSocketPrivate::GetRecvFromAddress(PP_NetAddress_Private* addr) { + if (!has_interface<PPB_UDPSocket_Private>()) + return false; + + PP_Bool result = get_interface<PPB_UDPSocket_Private>()->GetRecvFromAddress( + pp_resource(), addr); + return PP_ToBool(result); +} + +int32_t UDPSocketPrivate::SendTo(const char* buffer, + int32_t num_bytes, + const PP_NetAddress_Private* addr, + const CompletionCallback& callback) { + if (!has_interface<PPB_UDPSocket_Private>()) + return PP_ERROR_NOINTERFACE; + return get_interface<PPB_UDPSocket_Private>()->SendTo( + pp_resource(), buffer, num_bytes, addr, + callback.pp_completion_callback()); +} + +} // namespace pp + diff --git a/ppapi/cpp/private/udp_socket_private.h b/ppapi/cpp/private/udp_socket_private.h new file mode 100644 index 0000000..85bfb53 --- /dev/null +++ b/ppapi/cpp/private/udp_socket_private.h @@ -0,0 +1,37 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_CPP_PRIVATE_UDP_SOCKET_PRIVATE_H_ +#define PPAPI_CPP_PRIVATE_UDP_SOCKET_PRIVATE_H_ + +#include "ppapi/c/pp_stdint.h" +#include "ppapi/c/private/ppb_udp_socket_private.h" +#include "ppapi/cpp/resource.h" + +namespace pp { + +class CompletionCallback; +class Instance; + +class UDPSocketPrivate : public Resource { + public: + explicit UDPSocketPrivate(Instance* instance); + + int32_t Bind(const PP_NetAddress_Private* addr, + const CompletionCallback& callback); + int32_t RecvFrom(char* buffer, + int32_t num_bytes, + const CompletionCallback& callback); + bool GetRecvFromAddress(PP_NetAddress_Private* addr); + int32_t SendTo(const char* buffer, + int32_t num_bytes, + const PP_NetAddress_Private* addr, + const CompletionCallback& callback); + void Close(); +}; + +} // namespace pp + +#endif // PPAPI_CPP_PRIVATE_UDP_SOCKET_PRIVATE_H_ + diff --git a/ppapi/ppapi_cpp.gypi b/ppapi/ppapi_cpp.gypi index 0f0a88d..8f8ba1d 100644 --- a/ppapi/ppapi_cpp.gypi +++ b/ppapi/ppapi_cpp.gypi @@ -102,9 +102,12 @@ 'c/private/ppb_gpu_blacklist_private.h', 'c/private/ppb_instance_private.h', 'c/private/ppb_nacl_private.h', + 'c/private/ppb_net_address_private.h', 'c/private/ppb_pdf.h', 'c/private/ppb_proxy_private.h', 'c/private/ppp_instance_private.h', + 'c/private/ppb_tcp_socket_private.h', + 'c/private/ppb_udp_socket_private.h', # Deprecated interfaces. 'c/dev/deprecated_bool.h', @@ -255,6 +258,10 @@ 'cpp/private/instance_private.h', 'cpp/private/net_address_private.cc', 'cpp/private/net_address_private.h', + 'cpp/private/tcp_socket_private.cc', + 'cpp/private/tcp_socket_private.h', + 'cpp/private/udp_socket_private.cc', + 'cpp/private/udp_socket_private.h', 'cpp/private/var_private.cc', 'cpp/private/var_private.h', diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi index caab99f..955a5f8 100644 --- a/ppapi/ppapi_proxy.gypi +++ b/ppapi/ppapi_proxy.gypi @@ -84,10 +84,6 @@ 'proxy/ppb_flash_menu_proxy.h', 'proxy/ppb_flash_net_connector_proxy.cc', 'proxy/ppb_flash_net_connector_proxy.h', - 'proxy/ppb_flash_tcp_socket_proxy.cc', - 'proxy/ppb_flash_tcp_socket_proxy.h', - 'proxy/ppb_flash_udp_socket_proxy.cc', - 'proxy/ppb_flash_udp_socket_proxy.h', 'proxy/ppb_font_proxy.cc', 'proxy/ppb_font_proxy.h', 'proxy/ppb_graphics_2d_proxy.cc', @@ -102,10 +98,14 @@ 'proxy/ppb_pdf_proxy.h', 'proxy/ppb_surface_3d_proxy.cc', 'proxy/ppb_surface_3d_proxy.h', + 'proxy/ppb_tcp_socket_private_proxy.cc', + 'proxy/ppb_tcp_socket_private_proxy.h', 'proxy/ppb_testing_proxy.cc', 'proxy/ppb_testing_proxy.h', 'proxy/ppb_text_input_proxy.cc', 'proxy/ppb_text_input_proxy.h', + 'proxy/ppb_udp_socket_private_proxy.cc', + 'proxy/ppb_udp_socket_private_proxy.h', 'proxy/ppb_url_loader_proxy.cc', 'proxy/ppb_url_loader_proxy.h', 'proxy/ppb_url_response_info_proxy.cc', diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi index 9684560..a3f4806 100644 --- a/ppapi/ppapi_shared.gypi +++ b/ppapi/ppapi_shared.gypi @@ -133,10 +133,6 @@ 'thunk/ppb_flash_menu_thunk.cc', 'thunk/ppb_flash_net_connector_api.h', 'thunk/ppb_flash_net_connector_thunk.cc', - 'thunk/ppb_flash_tcp_socket_api.h', - 'thunk/ppb_flash_tcp_socket_thunk.cc', - 'thunk/ppb_flash_udp_socket_api.h', - 'thunk/ppb_flash_udp_socket_thunk.cc', 'thunk/ppb_font_api.h', 'thunk/ppb_font_thunk.cc', 'thunk/ppb_fullscreen_thunk.cc', @@ -160,10 +156,14 @@ 'thunk/ppb_scrollbar_thunk.cc', 'thunk/ppb_surface_3d_api.h', 'thunk/ppb_surface_3d_thunk.cc', + 'thunk/ppb_tcp_socket_private_api.h', + 'thunk/ppb_tcp_socket_private_thunk.cc', 'thunk/ppb_text_input_api.h', 'thunk/ppb_text_input_thunk.cc', 'thunk/ppb_transport_api.h', 'thunk/ppb_transport_thunk.cc', + 'thunk/ppb_udp_socket_private_api.h', + 'thunk/ppb_udp_socket_private_thunk.cc', 'thunk/ppb_url_loader_api.h', 'thunk/ppb_url_loader_thunk.cc', 'thunk/ppb_url_request_info_api.h', diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc index f855f90..0d654a5 100644 --- a/ppapi/proxy/interface_list.cc +++ b/ppapi/proxy/interface_list.cc @@ -48,9 +48,10 @@ #include "ppapi/c/private/ppb_flash_menu.h" #include "ppapi/c/private/ppb_flash_net_connector.h" #include "ppapi/c/private/ppb_flash_tcp_socket.h" -#include "ppapi/c/private/ppb_flash_udp_socket.h" #include "ppapi/c/private/ppb_net_address_private.h" #include "ppapi/c/private/ppb_pdf.h" +#include "ppapi/c/private/ppb_tcp_socket_private.h" +#include "ppapi/c/private/ppb_udp_socket_private.h" #include "ppapi/c/trusted/ppb_broker_trusted.h" #include "ppapi/c/trusted/ppb_url_loader_trusted.h" #include "ppapi/proxy/interface_proxy.h" @@ -68,8 +69,6 @@ #include "ppapi/proxy/ppb_flash_menu_proxy.h" #include "ppapi/proxy/ppb_flash_net_connector_proxy.h" #include "ppapi/proxy/ppb_flash_proxy.h" -#include "ppapi/proxy/ppb_flash_tcp_socket_proxy.h" -#include "ppapi/proxy/ppb_flash_udp_socket_proxy.h" #include "ppapi/proxy/ppb_font_proxy.h" #include "ppapi/proxy/ppb_graphics_2d_proxy.h" #include "ppapi/proxy/ppb_graphics_3d_proxy.h" @@ -77,8 +76,10 @@ #include "ppapi/proxy/ppb_instance_proxy.h" #include "ppapi/proxy/ppb_pdf_proxy.h" #include "ppapi/proxy/ppb_surface_3d_proxy.h" +#include "ppapi/proxy/ppb_tcp_socket_private_proxy.h" #include "ppapi/proxy/ppb_testing_proxy.h" #include "ppapi/proxy/ppb_text_input_proxy.h" +#include "ppapi/proxy/ppb_udp_socket_private_proxy.h" #include "ppapi/proxy/ppb_url_loader_proxy.h" #include "ppapi/proxy/ppb_url_response_info_proxy.h" #include "ppapi/proxy/ppb_var_deprecated_proxy.h" @@ -264,15 +265,9 @@ void InterfaceList::AddFlashInterfaces() { AddPPB(PPB_FLASH_MENU_INTERFACE, API_ID_PPB_FLASH_MENU, thunk::GetPPB_Flash_Menu_Thunk()); - AddProxy(API_ID_PPB_FLASH_TCPSOCKET, - &ProxyFactory<PPB_Flash_TCPSocket_Proxy>); - AddPPB(PPB_FLASH_TCPSOCKET_INTERFACE, API_ID_PPB_FLASH_TCPSOCKET, - thunk::GetPPB_Flash_TCPSocket_Thunk()); - - AddProxy(API_ID_PPB_FLASH_UDPSOCKET, - &ProxyFactory<PPB_Flash_UDPSocket_Proxy>); - AddPPB(PPB_FLASH_UDPSOCKET_INTERFACE, API_ID_PPB_FLASH_UDPSOCKET, - thunk::GetPPB_Flash_UDPSocket_Thunk()); + // Only add PPB because proxy for the this API ID was already added. + AddPPB(PPB_FLASH_TCPSOCKET_INTERFACE, API_ID_PPB_TCPSOCKET_PRIVATE, + thunk::GetPPB_TCPSocket_Private_Thunk()); #ifdef ENABLE_FLAPPER_HACKS AddProxy(API_ID_PPB_FLASH_NETCONNECTOR, diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index a66b2b2..6a41a38 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -29,7 +29,7 @@ #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/dev/pp_video_dev.h" -#include "ppapi/c/private/ppb_flash_tcp_socket.h" +#include "ppapi/c/private/ppb_tcp_socket_private.h" #include "ppapi/proxy/ppapi_param_traits.h" #include "ppapi/proxy/ppapi_proxy_export.h" #include "ppapi/proxy/serialized_flash_menu.h" @@ -251,40 +251,40 @@ IPC_MESSAGE_ROUTED5(PpapiMsg_PPBFlashNetConnector_ConnectACK, std::string /* local_addr_as_string */, std::string /* remote_addr_as_string */) -// PPB_Flash_TCPSocket. -IPC_MESSAGE_ROUTED5(PpapiMsg_PPBFlashTCPSocket_ConnectACK, +// PPB_TCPSocket_Private. +IPC_MESSAGE_ROUTED5(PpapiMsg_PPBTCPSocket_ConnectACK, uint32 /* plugin_dispatcher_id */, uint32 /* socket_id */, bool /* succeeded */, PP_NetAddress_Private /* local_addr */, PP_NetAddress_Private /* remote_addr */) -IPC_MESSAGE_ROUTED3(PpapiMsg_PPBFlashTCPSocket_SSLHandshakeACK, +IPC_MESSAGE_ROUTED3(PpapiMsg_PPBTCPSocket_SSLHandshakeACK, uint32 /* plugin_dispatcher_id */, uint32 /* socket_id */, bool /* succeeded */) -IPC_MESSAGE_ROUTED4(PpapiMsg_PPBFlashTCPSocket_ReadACK, +IPC_MESSAGE_ROUTED4(PpapiMsg_PPBTCPSocket_ReadACK, uint32 /* plugin_dispatcher_id */, uint32 /* socket_id */, bool /* succeeded */, std::string /* data */) -IPC_MESSAGE_ROUTED4(PpapiMsg_PPBFlashTCPSocket_WriteACK, +IPC_MESSAGE_ROUTED4(PpapiMsg_PPBTCPSocket_WriteACK, uint32 /* plugin_dispatcher_id */, uint32 /* socket_id */, bool /* succeeded */, int32_t /* bytes_written */) -// PPB_Flash_UDPSocket -IPC_MESSAGE_ROUTED3(PpapiMsg_PPBFlashUDPSocket_BindACK, +// PPB_UDPSocket_Private +IPC_MESSAGE_ROUTED3(PpapiMsg_PPBUDPSocket_BindACK, uint32 /* plugin_dispatcher_id */, uint32 /* socket_id */, bool /* succeeded */) -IPC_MESSAGE_ROUTED5(PpapiMsg_PPBFlashUDPSocket_RecvFromACK, +IPC_MESSAGE_ROUTED5(PpapiMsg_PPBUDPSocket_RecvFromACK, uint32 /* plugin_dispatcher_id */, uint32 /* socket_id */, bool /* succeeded */, std::string /* data */, PP_NetAddress_Private /* remote_addr */) -IPC_MESSAGE_ROUTED4(PpapiMsg_PPBFlashUDPSocket_SendToACK, +IPC_MESSAGE_ROUTED4(PpapiMsg_PPBUDPSocket_SendToACK, uint32 /* plugin_dispatcher_id */, uint32 /* socket_id */, bool /* succeeded */, @@ -737,47 +737,47 @@ IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBFlashNetConnector_ConnectTcpAddress, ppapi::HostResource /* connector */, std::string /* net_address_as_string */) -// PPB_Flash_TCPSocket. -IPC_SYNC_MESSAGE_CONTROL2_1(PpapiHostMsg_PPBFlashTCPSocket_Create, +// PPB_TCPSocket_Private. +IPC_SYNC_MESSAGE_CONTROL2_1(PpapiHostMsg_PPBTCPSocket_Create, int32 /* routing_id */, uint32 /* plugin_dispatcher_id */, uint32 /* socket_id */) -IPC_MESSAGE_CONTROL3(PpapiHostMsg_PPBFlashTCPSocket_Connect, +IPC_MESSAGE_CONTROL3(PpapiHostMsg_PPBTCPSocket_Connect, uint32 /* socket_id */, std::string /* host */, uint16_t /* port */) -IPC_MESSAGE_CONTROL2(PpapiHostMsg_PPBFlashTCPSocket_ConnectWithNetAddress, +IPC_MESSAGE_CONTROL2(PpapiHostMsg_PPBTCPSocket_ConnectWithNetAddress, uint32 /* socket_id */, PP_NetAddress_Private /* net_addr */) -IPC_MESSAGE_CONTROL3(PpapiHostMsg_PPBFlashTCPSocket_SSLHandshake, +IPC_MESSAGE_CONTROL3(PpapiHostMsg_PPBTCPSocket_SSLHandshake, uint32 /* socket_id */, std::string /* server_name */, uint16_t /* server_port */) -IPC_MESSAGE_CONTROL2(PpapiHostMsg_PPBFlashTCPSocket_Read, +IPC_MESSAGE_CONTROL2(PpapiHostMsg_PPBTCPSocket_Read, uint32 /* socket_id */, int32_t /* bytes_to_read */) -IPC_MESSAGE_CONTROL2(PpapiHostMsg_PPBFlashTCPSocket_Write, +IPC_MESSAGE_CONTROL2(PpapiHostMsg_PPBTCPSocket_Write, uint32 /* socket_id */, std::string /* data */) -IPC_MESSAGE_CONTROL1(PpapiHostMsg_PPBFlashTCPSocket_Disconnect, +IPC_MESSAGE_CONTROL1(PpapiHostMsg_PPBTCPSocket_Disconnect, uint32 /* socket_id */) -// PPB_Flash_UDPSocket -IPC_SYNC_MESSAGE_CONTROL2_1(PpapiHostMsg_PPBFlashUDPSocket_Create, +// PPB_UDPSocket_Private. +IPC_SYNC_MESSAGE_CONTROL2_1(PpapiHostMsg_PPBUDPSocket_Create, int32 /* routing_id */, uint32 /* plugin_dispatcher_id */, uint32 /* socket_id */) -IPC_MESSAGE_CONTROL2(PpapiHostMsg_PPBFlashUDPSocket_Bind, +IPC_MESSAGE_CONTROL2(PpapiHostMsg_PPBUDPSocket_Bind, uint32 /* socket_id */, PP_NetAddress_Private /* net_addr */) -IPC_MESSAGE_CONTROL2(PpapiHostMsg_PPBFlashUDPSocket_RecvFrom, +IPC_MESSAGE_CONTROL2(PpapiHostMsg_PPBUDPSocket_RecvFrom, uint32 /* socket_id */, int32_t /* num_bytes */) -IPC_MESSAGE_CONTROL3(PpapiHostMsg_PPBFlashUDPSocket_SendTo, +IPC_MESSAGE_CONTROL3(PpapiHostMsg_PPBUDPSocket_SendTo, uint32 /* socket_id */, std::string /* data */, PP_NetAddress_Private /* net_addr */) -IPC_MESSAGE_CONTROL1(PpapiHostMsg_PPBFlashUDPSocket_Close, +IPC_MESSAGE_CONTROL1(PpapiHostMsg_PPBUDPSocket_Close, uint32 /* socket_id */) // PPB_Font. diff --git a/ppapi/proxy/ppb_flash_tcp_socket_proxy.cc b/ppapi/proxy/ppb_tcp_socket_private_proxy.cc index dc1bd9a..555e833 100644 --- a/ppapi/proxy/ppb_flash_tcp_socket_proxy.cc +++ b/ppapi/proxy/ppb_tcp_socket_private_proxy.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ppapi/proxy/ppb_flash_tcp_socket_proxy.h" +#include "ppapi/proxy/ppb_tcp_socket_private_proxy.h" #include <algorithm> #include <cstring> @@ -17,22 +17,22 @@ #include "ppapi/proxy/plugin_resource_tracker.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/shared_impl/resource.h" -#include "ppapi/thunk/ppb_flash_tcp_socket_api.h" +#include "ppapi/thunk/ppb_tcp_socket_private_api.h" #include "ppapi/thunk/thunk.h" -using ppapi::thunk::PPB_Flash_TCPSocket_API; +using ppapi::thunk::PPB_TCPSocket_Private_API; namespace ppapi { namespace proxy { -const int32_t kFlashTCPSocketMaxReadSize = 1024 * 1024; -const int32_t kFlashTCPSocketMaxWriteSize = 1024 * 1024; +const int32_t kTCPSocketMaxReadSize = 1024 * 1024; +const int32_t kTCPSocketMaxWriteSize = 1024 * 1024; -class FlashTCPSocket; +class TCPSocket; namespace { -typedef std::map<uint32, FlashTCPSocket*> IDToSocketMap; +typedef std::map<uint32, TCPSocket*> IDToSocketMap; IDToSocketMap* g_id_to_socket = NULL; class AbortCallbackTask : public Task { @@ -51,16 +51,16 @@ class AbortCallbackTask : public Task { } // namespace -class FlashTCPSocket : public PPB_Flash_TCPSocket_API, - public Resource { +class TCPSocket : public PPB_TCPSocket_Private_API, + public Resource { public: - FlashTCPSocket(const HostResource& resource, uint32 socket_id); - virtual ~FlashTCPSocket(); + TCPSocket(const HostResource& resource, uint32 socket_id); + virtual ~TCPSocket(); // Resource overrides. - virtual PPB_Flash_TCPSocket_API* AsPPB_Flash_TCPSocket_API() OVERRIDE; + virtual PPB_TCPSocket_Private_API* AsPPB_TCPSocket_Private_API() OVERRIDE; - // PPB_Flash_TCPSocket_API implementation. + // PPB_TCPSocket_Private_API implementation. virtual int32_t Connect(const char* host, uint16_t port, PP_CompletionCallback callback) OVERRIDE; @@ -129,10 +129,10 @@ class FlashTCPSocket : public PPB_Flash_TCPSocket_API, PP_NetAddress_Private local_addr_; PP_NetAddress_Private remote_addr_; - DISALLOW_COPY_AND_ASSIGN(FlashTCPSocket); + DISALLOW_COPY_AND_ASSIGN(TCPSocket); }; -FlashTCPSocket::FlashTCPSocket(const HostResource& resource, uint32 socket_id) +TCPSocket::TCPSocket(const HostResource& resource, uint32 socket_id) : Resource(resource), socket_id_(socket_id), connection_state_(BEFORE_CONNECT), @@ -155,38 +155,38 @@ FlashTCPSocket::FlashTCPSocket(const HostResource& resource, uint32 socket_id) (*g_id_to_socket)[socket_id] = this; } -FlashTCPSocket::~FlashTCPSocket() { +TCPSocket::~TCPSocket() { Disconnect(); } -PPB_Flash_TCPSocket_API* FlashTCPSocket::AsPPB_Flash_TCPSocket_API() { +PPB_TCPSocket_Private_API* TCPSocket::AsPPB_TCPSocket_Private_API() { return this; } -int32_t FlashTCPSocket::Connect(const char* host, - uint16_t port, - PP_CompletionCallback callback) { +int32_t TCPSocket::Connect(const char* host, + uint16_t port, + PP_CompletionCallback callback) { if (!host) return PP_ERROR_BADARGUMENT; return ConnectWithMessage( - new PpapiHostMsg_PPBFlashTCPSocket_Connect(socket_id_, host, port), + new PpapiHostMsg_PPBTCPSocket_Connect(socket_id_, host, port), callback); } -int32_t FlashTCPSocket::ConnectWithNetAddress( +int32_t TCPSocket::ConnectWithNetAddress( const PP_NetAddress_Private* addr, PP_CompletionCallback callback) { if (!addr) return PP_ERROR_BADARGUMENT; return ConnectWithMessage( - new PpapiHostMsg_PPBFlashTCPSocket_ConnectWithNetAddress( + new PpapiHostMsg_PPBTCPSocket_ConnectWithNetAddress( socket_id_, *addr), callback); } -PP_Bool FlashTCPSocket::GetLocalAddress(PP_NetAddress_Private* local_addr) { +PP_Bool TCPSocket::GetLocalAddress(PP_NetAddress_Private* local_addr) { if (!IsConnected() || !local_addr) return PP_FALSE; @@ -194,7 +194,7 @@ PP_Bool FlashTCPSocket::GetLocalAddress(PP_NetAddress_Private* local_addr) { return PP_TRUE; } -PP_Bool FlashTCPSocket::GetRemoteAddress(PP_NetAddress_Private* remote_addr) { +PP_Bool TCPSocket::GetRemoteAddress(PP_NetAddress_Private* remote_addr) { if (!IsConnected() || !remote_addr) return PP_FALSE; @@ -202,9 +202,9 @@ PP_Bool FlashTCPSocket::GetRemoteAddress(PP_NetAddress_Private* remote_addr) { return PP_TRUE; } -int32_t FlashTCPSocket::SSLHandshake(const char* server_name, - uint16_t server_port, - PP_CompletionCallback callback) { +int32_t TCPSocket::SSLHandshake(const char* server_name, + uint16_t server_port, + PP_CompletionCallback callback) { if (!server_name) return PP_ERROR_BADARGUMENT; if (!callback.func) @@ -220,14 +220,14 @@ int32_t FlashTCPSocket::SSLHandshake(const char* server_name, // Send the request, the browser will call us back via SSLHandshakeACK. GetDispatcher()->SendToBrowser( - new PpapiHostMsg_PPBFlashTCPSocket_SSLHandshake( + new PpapiHostMsg_PPBTCPSocket_SSLHandshake( socket_id_, std::string(server_name), server_port)); return PP_OK_COMPLETIONPENDING; } -int32_t FlashTCPSocket::Read(char* buffer, - int32_t bytes_to_read, - PP_CompletionCallback callback) { +int32_t TCPSocket::Read(char* buffer, + int32_t bytes_to_read, + PP_CompletionCallback callback) { if (!buffer || bytes_to_read <= 0) return PP_ERROR_BADARGUMENT; if (!callback.func) @@ -239,18 +239,18 @@ int32_t FlashTCPSocket::Read(char* buffer, return PP_ERROR_INPROGRESS; read_buffer_ = buffer; - bytes_to_read_ = std::min(bytes_to_read, kFlashTCPSocketMaxReadSize); + bytes_to_read_ = std::min(bytes_to_read, kTCPSocketMaxReadSize); read_callback_ = callback; // Send the request, the browser will call us back via ReadACK. GetDispatcher()->SendToBrowser( - new PpapiHostMsg_PPBFlashTCPSocket_Read(socket_id_, bytes_to_read_)); + new PpapiHostMsg_PPBTCPSocket_Read(socket_id_, bytes_to_read_)); return PP_OK_COMPLETIONPENDING; } -int32_t FlashTCPSocket::Write(const char* buffer, - int32_t bytes_to_write, - PP_CompletionCallback callback) { +int32_t TCPSocket::Write(const char* buffer, + int32_t bytes_to_write, + PP_CompletionCallback callback) { if (!buffer || bytes_to_write <= 0) return PP_ERROR_BADARGUMENT; if (!callback.func) @@ -261,19 +261,19 @@ int32_t FlashTCPSocket::Write(const char* buffer, if (write_callback_.func || ssl_handshake_callback_.func) return PP_ERROR_INPROGRESS; - if (bytes_to_write > kFlashTCPSocketMaxWriteSize) - bytes_to_write = kFlashTCPSocketMaxWriteSize; + if (bytes_to_write > kTCPSocketMaxWriteSize) + bytes_to_write = kTCPSocketMaxWriteSize; write_callback_ = callback; // Send the request, the browser will call us back via WriteACK. GetDispatcher()->SendToBrowser( - new PpapiHostMsg_PPBFlashTCPSocket_Write( + new PpapiHostMsg_PPBTCPSocket_Write( socket_id_, std::string(buffer, bytes_to_write))); return PP_OK_COMPLETIONPENDING; } -void FlashTCPSocket::Disconnect() { +void TCPSocket::Disconnect() { if (connection_state_ == DISCONNECTED) return; @@ -284,7 +284,7 @@ void FlashTCPSocket::Disconnect() { g_id_to_socket->erase(socket_id_); GetDispatcher()->SendToBrowser( - new PpapiHostMsg_PPBFlashTCPSocket_Disconnect(socket_id_)); + new PpapiHostMsg_PPBTCPSocket_Disconnect(socket_id_)); socket_id_ = 0; PostAbortAndClearIfNecessary(&connect_callback_); @@ -295,7 +295,7 @@ void FlashTCPSocket::Disconnect() { bytes_to_read_ = -1; } -void FlashTCPSocket::OnConnectCompleted( +void TCPSocket::OnConnectCompleted( bool succeeded, const PP_NetAddress_Private& local_addr, const PP_NetAddress_Private& remote_addr) { @@ -313,7 +313,7 @@ void FlashTCPSocket::OnConnectCompleted( succeeded ? PP_OK : PP_ERROR_FAILED); } -void FlashTCPSocket::OnSSLHandshakeCompleted(bool succeeded) { +void TCPSocket::OnSSLHandshakeCompleted(bool succeeded) { if (connection_state_ != CONNECTED || !ssl_handshake_callback_.func) { NOTREACHED(); return; @@ -328,7 +328,7 @@ void FlashTCPSocket::OnSSLHandshakeCompleted(bool succeeded) { } } -void FlashTCPSocket::OnReadCompleted(bool succeeded, const std::string& data) { +void TCPSocket::OnReadCompleted(bool succeeded, const std::string& data) { if (!read_callback_.func || !read_buffer_) { NOTREACHED(); return; @@ -348,7 +348,7 @@ void FlashTCPSocket::OnReadCompleted(bool succeeded, const std::string& data) { static_cast<int32_t>(PP_ERROR_FAILED)); } -void FlashTCPSocket::OnWriteCompleted(bool succeeded, int32_t bytes_written) { +void TCPSocket::OnWriteCompleted(bool succeeded, int32_t bytes_written) { if (!write_callback_.func || (succeeded && bytes_written < 0)) { NOTREACHED(); return; @@ -359,12 +359,12 @@ void FlashTCPSocket::OnWriteCompleted(bool succeeded, int32_t bytes_written) { succeeded ? bytes_written : static_cast<int32_t>(PP_ERROR_FAILED)); } -bool FlashTCPSocket::IsConnected() const { +bool TCPSocket::IsConnected() const { return connection_state_ == CONNECTED || connection_state_ == SSL_CONNECTED; } -int32_t FlashTCPSocket::ConnectWithMessage(IPC::Message* msg, - PP_CompletionCallback callback) { +int32_t TCPSocket::ConnectWithMessage(IPC::Message* msg, + PP_CompletionCallback callback) { scoped_ptr<IPC::Message> msg_deletor(msg); if (!callback.func) return PP_ERROR_BLOCKS_MAIN_THREAD; @@ -379,7 +379,7 @@ int32_t FlashTCPSocket::ConnectWithMessage(IPC::Message* msg, return PP_OK_COMPLETIONPENDING; } -void FlashTCPSocket::PostAbortAndClearIfNecessary( +void TCPSocket::PostAbortAndClearIfNecessary( PP_CompletionCallback* callback) { DCHECK(callback); @@ -390,44 +390,45 @@ void FlashTCPSocket::PostAbortAndClearIfNecessary( } } -PPB_Flash_TCPSocket_Proxy::PPB_Flash_TCPSocket_Proxy(Dispatcher* dispatcher) +PPB_TCPSocket_Private_Proxy::PPB_TCPSocket_Private_Proxy(Dispatcher* dispatcher) : InterfaceProxy(dispatcher) { } -PPB_Flash_TCPSocket_Proxy::~PPB_Flash_TCPSocket_Proxy() { +PPB_TCPSocket_Private_Proxy::~PPB_TCPSocket_Private_Proxy() { } // static -PP_Resource PPB_Flash_TCPSocket_Proxy::CreateProxyResource( +PP_Resource PPB_TCPSocket_Private_Proxy::CreateProxyResource( PP_Instance instance) { PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); if (!dispatcher) return 0; uint32 socket_id = 0; - dispatcher->SendToBrowser(new PpapiHostMsg_PPBFlashTCPSocket_Create( - API_ID_PPB_FLASH_TCPSOCKET, dispatcher->plugin_dispatcher_id(), + dispatcher->SendToBrowser(new PpapiHostMsg_PPBTCPSocket_Create( + API_ID_PPB_TCPSOCKET_PRIVATE, dispatcher->plugin_dispatcher_id(), &socket_id)); if (socket_id == 0) return 0; - return (new FlashTCPSocket(HostResource::MakeInstanceOnly(instance), - socket_id))->GetReference(); + return (new TCPSocket(HostResource::MakeInstanceOnly(instance), + socket_id))->GetReference(); } -bool PPB_Flash_TCPSocket_Proxy::OnMessageReceived(const IPC::Message& msg) { +bool PPB_TCPSocket_Private_Proxy::OnMessageReceived(const IPC::Message& msg) { bool handled = true; - IPC_BEGIN_MESSAGE_MAP(PPB_Flash_TCPSocket_Proxy, msg) - IPC_MESSAGE_HANDLER(PpapiMsg_PPBFlashTCPSocket_ConnectACK, OnMsgConnectACK) - IPC_MESSAGE_HANDLER(PpapiMsg_PPBFlashTCPSocket_SSLHandshakeACK, + IPC_BEGIN_MESSAGE_MAP(PPB_TCPSocket_Private_Proxy, msg) + IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK, + OnMsgConnectACK) + IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK, OnMsgSSLHandshakeACK) - IPC_MESSAGE_HANDLER(PpapiMsg_PPBFlashTCPSocket_ReadACK, OnMsgReadACK) - IPC_MESSAGE_HANDLER(PpapiMsg_PPBFlashTCPSocket_WriteACK, OnMsgWriteACK) + IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnMsgReadACK) + IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnMsgWriteACK) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; } -void PPB_Flash_TCPSocket_Proxy::OnMsgConnectACK( +void PPB_TCPSocket_Private_Proxy::OnMsgConnectACK( uint32 /* plugin_dispatcher_id */, uint32 socket_id, bool succeeded, @@ -443,7 +444,7 @@ void PPB_Flash_TCPSocket_Proxy::OnMsgConnectACK( iter->second->OnConnectCompleted(succeeded, local_addr, remote_addr); } -void PPB_Flash_TCPSocket_Proxy::OnMsgSSLHandshakeACK( +void PPB_TCPSocket_Private_Proxy::OnMsgSSLHandshakeACK( uint32 /* plugin_dispatcher_id */, uint32 socket_id, bool succeeded) { @@ -457,10 +458,11 @@ void PPB_Flash_TCPSocket_Proxy::OnMsgSSLHandshakeACK( iter->second->OnSSLHandshakeCompleted(succeeded); } -void PPB_Flash_TCPSocket_Proxy::OnMsgReadACK(uint32 /* plugin_dispatcher_id */, - uint32 socket_id, - bool succeeded, - const std::string& data) { +void PPB_TCPSocket_Private_Proxy::OnMsgReadACK( + uint32 /* plugin_dispatcher_id */, + uint32 socket_id, + bool succeeded, + const std::string& data) { if (!g_id_to_socket) { NOTREACHED(); return; @@ -471,10 +473,11 @@ void PPB_Flash_TCPSocket_Proxy::OnMsgReadACK(uint32 /* plugin_dispatcher_id */, iter->second->OnReadCompleted(succeeded, data); } -void PPB_Flash_TCPSocket_Proxy::OnMsgWriteACK(uint32 /* plugin_dispatcher_id */, - uint32 socket_id, - bool succeeded, - int32_t bytes_written) { +void PPB_TCPSocket_Private_Proxy::OnMsgWriteACK( + uint32 /* plugin_dispatcher_id */, + uint32 socket_id, + bool succeeded, + int32_t bytes_written) { if (!g_id_to_socket) { NOTREACHED(); return; diff --git a/ppapi/proxy/ppb_flash_tcp_socket_proxy.h b/ppapi/proxy/ppb_tcp_socket_private_proxy.h index f20f15e..ec89fe2 100644 --- a/ppapi/proxy/ppb_flash_tcp_socket_proxy.h +++ b/ppapi/proxy/ppb_tcp_socket_private_proxy.h @@ -2,38 +2,40 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef PPAPI_PROXY_PPB_FLASH_TCP_SOCKET_PROXY_H_ -#define PPAPI_PROXY_PPB_FLASH_TCP_SOCKET_PROXY_H_ +#ifndef PPAPI_PROXY_PPB_TCP_SOCKET_PRIVATE_PROXY_H_ +#define PPAPI_PROXY_PPB_TCP_SOCKET_PRIVATE_PROXY_H_ #include <string> #include "base/basictypes.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" -#include "ppapi/c/private/ppb_flash_tcp_socket.h" +#include "ppapi/c/private/ppb_tcp_socket_private.h" #include "ppapi/proxy/interface_proxy.h" #include "ppapi/proxy/ppapi_proxy_export.h" namespace ppapi { namespace proxy { -// The maximum number of bytes that each PpapiHostMsg_PPBFlashTCPSocket_Read +// The maximum number of bytes that each PpapiHostMsg_PPBTCPSocket_Read // message is allowed to request. -PPAPI_PROXY_EXPORT extern const int32_t kFlashTCPSocketMaxReadSize; -// The maximum number of bytes that each PpapiHostMsg_PPBFlashTCPSocket_Write +PPAPI_PROXY_EXPORT extern const int32_t kTCPSocketMaxReadSize; +// The maximum number of bytes that each PpapiHostMsg_PPBTCPSocket_Write // message is allowed to carry. -PPAPI_PROXY_EXPORT extern const int32_t kFlashTCPSocketMaxWriteSize; +PPAPI_PROXY_EXPORT extern const int32_t kTCPSocketMaxWriteSize; -class PPB_Flash_TCPSocket_Proxy : public InterfaceProxy { +class PPB_TCPSocket_Private_Proxy : public InterfaceProxy { public: - PPB_Flash_TCPSocket_Proxy(Dispatcher* dispatcher); - virtual ~PPB_Flash_TCPSocket_Proxy(); + PPB_TCPSocket_Private_Proxy(Dispatcher* dispatcher); + virtual ~PPB_TCPSocket_Private_Proxy(); static PP_Resource CreateProxyResource(PP_Instance instance); // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); + static const ApiID kApiID = API_ID_PPB_TCPSOCKET_PRIVATE; + private: // Browser->plugin message handlers. void OnMsgConnectACK(uint32 plugin_dispatcher_id, @@ -53,10 +55,10 @@ class PPB_Flash_TCPSocket_Proxy : public InterfaceProxy { bool succeeded, int32_t bytes_written); - DISALLOW_COPY_AND_ASSIGN(PPB_Flash_TCPSocket_Proxy); + DISALLOW_COPY_AND_ASSIGN(PPB_TCPSocket_Private_Proxy); }; } // namespace proxy } // namespace ppapi -#endif // PPAPI_PROXY_PPB_FLASH_TCP_SOCKET_PROXY_H_ +#endif // PPAPI_PROXY_PPB_TCP_SOCKET_PRIVATE_PROXY_H_ diff --git a/ppapi/proxy/ppb_flash_udp_socket_proxy.cc b/ppapi/proxy/ppb_udp_socket_private_proxy.cc index 8988e87..1808fb0 100644 --- a/ppapi/proxy/ppb_flash_udp_socket_proxy.cc +++ b/ppapi/proxy/ppb_udp_socket_private_proxy.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ppapi/proxy/ppb_flash_udp_socket_proxy.h" +#include "ppapi/proxy/ppb_udp_socket_private_proxy.h" #include <algorithm> #include <cstring> @@ -17,22 +17,22 @@ #include "ppapi/proxy/plugin_resource_tracker.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/shared_impl/resource.h" -#include "ppapi/thunk/ppb_flash_udp_socket_api.h" +#include "ppapi/thunk/ppb_udp_socket_private_api.h" #include "ppapi/thunk/thunk.h" -using ppapi::thunk::PPB_Flash_UDPSocket_API; +using ppapi::thunk::PPB_UDPSocket_Private_API; namespace ppapi { namespace proxy { -const int32_t kFlashUDPSocketMaxReadSize = 1024 * 1024; -const int32_t kFlashUDPSocketMaxWriteSize = 1024 * 1024; +const int32_t kUDPSocketMaxReadSize = 1024 * 1024; +const int32_t kUDPSocketMaxWriteSize = 1024 * 1024; namespace { -class FlashUDPSocket; +class UDPSocket; -typedef std::map<uint32, FlashUDPSocket*> IDToSocketMap; +typedef std::map<uint32, UDPSocket*> IDToSocketMap; IDToSocketMap* g_id_to_socket = NULL; class AbortCallbackTask : public Task { @@ -49,16 +49,16 @@ class AbortCallbackTask : public Task { PP_CompletionCallback callback_; }; -class FlashUDPSocket : public PPB_Flash_UDPSocket_API, - public Resource { +class UDPSocket : public PPB_UDPSocket_Private_API, + public Resource { public: - FlashUDPSocket(const HostResource& resource, uint32 socket_id); - virtual ~FlashUDPSocket(); + UDPSocket(const HostResource& resource, uint32 socket_id); + virtual ~UDPSocket(); // ResourceObjectBase overrides. - virtual PPB_Flash_UDPSocket_API* AsPPB_Flash_UDPSocket_API() OVERRIDE; + virtual PPB_UDPSocket_Private_API* AsPPB_UDPSocket_Private_API() OVERRIDE; - // PPB_Flash_UDPSocket_API implementation. + // PPB_UDPSocket_Private_API implementation. virtual int32_t Bind(const PP_NetAddress_Private* addr, PP_CompletionCallback callback) OVERRIDE; virtual int32_t RecvFrom(char* buffer, @@ -101,11 +101,10 @@ class FlashUDPSocket : public PPB_Flash_UDPSocket_API, PP_NetAddress_Private recvfrom_addr_; - DISALLOW_COPY_AND_ASSIGN(FlashUDPSocket); + DISALLOW_COPY_AND_ASSIGN(UDPSocket); }; -FlashUDPSocket::FlashUDPSocket(const HostResource& resource, - uint32 socket_id) +UDPSocket::UDPSocket(const HostResource& resource, uint32 socket_id) : Resource(resource), socket_id_(socket_id), binded_(false), @@ -126,16 +125,16 @@ FlashUDPSocket::FlashUDPSocket(const HostResource& resource, (*g_id_to_socket)[socket_id] = this; } -FlashUDPSocket::~FlashUDPSocket() { +UDPSocket::~UDPSocket() { Close(); } -PPB_Flash_UDPSocket_API* FlashUDPSocket::AsPPB_Flash_UDPSocket_API() { +PPB_UDPSocket_Private_API* UDPSocket::AsPPB_UDPSocket_Private_API() { return this; } -int32_t FlashUDPSocket::Bind(const PP_NetAddress_Private* addr, - PP_CompletionCallback callback) { +int32_t UDPSocket::Bind(const PP_NetAddress_Private* addr, + PP_CompletionCallback callback) { if (!addr || !callback.func) return PP_ERROR_BADARGUMENT; if (binded_ || closed_) @@ -146,14 +145,14 @@ int32_t FlashUDPSocket::Bind(const PP_NetAddress_Private* addr, bind_callback_ = callback; GetDispatcher()->SendToBrowser( - new PpapiHostMsg_PPBFlashUDPSocket_Bind(socket_id_, *addr)); + new PpapiHostMsg_PPBUDPSocket_Bind(socket_id_, *addr)); return PP_OK_COMPLETIONPENDING; } -int32_t FlashUDPSocket::RecvFrom(char* buffer, - int32_t num_bytes, - PP_CompletionCallback callback) { +int32_t UDPSocket::RecvFrom(char* buffer, + int32_t num_bytes, + PP_CompletionCallback callback) { if (!buffer || num_bytes <= 0 || !callback.func) return PP_ERROR_BADARGUMENT; if (!binded_) @@ -162,17 +161,17 @@ int32_t FlashUDPSocket::RecvFrom(char* buffer, return PP_ERROR_INPROGRESS; read_buffer_ = buffer; - bytes_to_read_ = std::min(num_bytes, kFlashUDPSocketMaxReadSize); + bytes_to_read_ = std::min(num_bytes, kUDPSocketMaxReadSize); recvfrom_callback_ = callback; // Send the request, the browser will call us back via RecvFromACK. GetDispatcher()->SendToBrowser( - new PpapiHostMsg_PPBFlashUDPSocket_RecvFrom( + new PpapiHostMsg_PPBUDPSocket_RecvFrom( socket_id_, num_bytes)); return PP_OK_COMPLETIONPENDING; } -PP_Bool FlashUDPSocket::GetRecvFromAddress(PP_NetAddress_Private* addr) { +PP_Bool UDPSocket::GetRecvFromAddress(PP_NetAddress_Private* addr) { if (!addr) return PP_FALSE; @@ -180,10 +179,10 @@ PP_Bool FlashUDPSocket::GetRecvFromAddress(PP_NetAddress_Private* addr) { return PP_TRUE; } -int32_t FlashUDPSocket::SendTo(const char* buffer, - int32_t num_bytes, - const PP_NetAddress_Private* addr, - PP_CompletionCallback callback) { +int32_t UDPSocket::SendTo(const char* buffer, + int32_t num_bytes, + const PP_NetAddress_Private* addr, + PP_CompletionCallback callback) { if (!buffer || num_bytes <= 0 || !addr || !callback.func) return PP_ERROR_BADARGUMENT; if (!binded_) @@ -191,20 +190,20 @@ int32_t FlashUDPSocket::SendTo(const char* buffer, if (sendto_callback_.func) return PP_ERROR_INPROGRESS; - if (num_bytes > kFlashUDPSocketMaxWriteSize) - num_bytes = kFlashUDPSocketMaxWriteSize; + if (num_bytes > kUDPSocketMaxWriteSize) + num_bytes = kUDPSocketMaxWriteSize; sendto_callback_ = callback; // Send the request, the browser will call us back via SendToACK. GetDispatcher()->SendToBrowser( - new PpapiHostMsg_PPBFlashUDPSocket_SendTo( + new PpapiHostMsg_PPBUDPSocket_SendTo( socket_id_, std::string(buffer, num_bytes), *addr)); return PP_OK_COMPLETIONPENDING; } -void FlashUDPSocket::Close() { +void UDPSocket::Close() { if(closed_) return; @@ -217,7 +216,7 @@ void FlashUDPSocket::Close() { g_id_to_socket->erase(socket_id_); GetDispatcher()->SendToBrowser( - new PpapiHostMsg_PPBFlashUDPSocket_Close(socket_id_)); + new PpapiHostMsg_PPBUDPSocket_Close(socket_id_)); socket_id_ = 0; PostAbortAndClearIfNecessary(&bind_callback_); @@ -225,7 +224,7 @@ void FlashUDPSocket::Close() { PostAbortAndClearIfNecessary(&sendto_callback_); } -void FlashUDPSocket::OnBindCompleted(bool succeeded) { +void UDPSocket::OnBindCompleted(bool succeeded) { if (!bind_callback_.func) { NOTREACHED(); return; @@ -238,9 +237,9 @@ void FlashUDPSocket::OnBindCompleted(bool succeeded) { succeeded ? PP_OK : PP_ERROR_FAILED); } -void FlashUDPSocket::OnRecvFromCompleted(bool succeeded, - const std::string& data, - const PP_NetAddress_Private& addr) { +void UDPSocket::OnRecvFromCompleted(bool succeeded, + const std::string& data, + const PP_NetAddress_Private& addr) { if (!recvfrom_callback_.func || !read_buffer_) { NOTREACHED(); return; @@ -261,8 +260,7 @@ void FlashUDPSocket::OnRecvFromCompleted(bool succeeded, static_cast<int32_t>(PP_ERROR_FAILED)); } -void FlashUDPSocket::OnSendToCompleted(bool succeeded, - int32_t bytes_written) { +void UDPSocket::OnSendToCompleted(bool succeeded, int32_t bytes_written) { if (!sendto_callback_.func) { NOTREACHED(); return; @@ -273,7 +271,7 @@ void FlashUDPSocket::OnSendToCompleted(bool succeeded, succeeded ? bytes_written : static_cast<int32_t>(PP_ERROR_FAILED)); } -void FlashUDPSocket::PostAbortAndClearIfNecessary( +void UDPSocket::PostAbortAndClearIfNecessary( PP_CompletionCallback* callback) { DCHECK(callback); @@ -285,46 +283,46 @@ void FlashUDPSocket::PostAbortAndClearIfNecessary( } } // namespace -PPB_Flash_UDPSocket_Proxy::PPB_Flash_UDPSocket_Proxy(Dispatcher* dispatcher) +PPB_UDPSocket_Private_Proxy::PPB_UDPSocket_Private_Proxy(Dispatcher* dispatcher) : InterfaceProxy(dispatcher) { } -PPB_Flash_UDPSocket_Proxy::~PPB_Flash_UDPSocket_Proxy() { +PPB_UDPSocket_Private_Proxy::~PPB_UDPSocket_Private_Proxy() { } // static -PP_Resource PPB_Flash_UDPSocket_Proxy::CreateProxyResource( +PP_Resource PPB_UDPSocket_Private_Proxy::CreateProxyResource( PP_Instance instance) { PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); if (!dispatcher) return 0; uint32 socket_id = 0; - dispatcher->SendToBrowser(new PpapiHostMsg_PPBFlashUDPSocket_Create( - API_ID_PPB_FLASH_UDPSOCKET, dispatcher->plugin_dispatcher_id(), + dispatcher->SendToBrowser(new PpapiHostMsg_PPBUDPSocket_Create( + API_ID_PPB_UDPSOCKET_PRIVATE, dispatcher->plugin_dispatcher_id(), &socket_id)); if (socket_id == 0) return 0; - return (new FlashUDPSocket(HostResource::MakeInstanceOnly(instance), - socket_id))->GetReference(); + return (new UDPSocket(HostResource::MakeInstanceOnly(instance), + socket_id))->GetReference(); } -bool PPB_Flash_UDPSocket_Proxy::OnMessageReceived(const IPC::Message& msg) { +bool PPB_UDPSocket_Private_Proxy::OnMessageReceived(const IPC::Message& msg) { bool handled = true; - IPC_BEGIN_MESSAGE_MAP(PPB_Flash_UDPSocket_Proxy, msg) - IPC_MESSAGE_HANDLER(PpapiMsg_PPBFlashUDPSocket_BindACK, + IPC_BEGIN_MESSAGE_MAP(PPB_UDPSocket_Private_Proxy, msg) + IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_BindACK, OnMsgBindACK) - IPC_MESSAGE_HANDLER(PpapiMsg_PPBFlashUDPSocket_RecvFromACK, + IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_RecvFromACK, OnMsgRecvFromACK) - IPC_MESSAGE_HANDLER(PpapiMsg_PPBFlashUDPSocket_SendToACK, + IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_SendToACK, OnMsgSendToACK) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; } -void PPB_Flash_UDPSocket_Proxy::OnMsgBindACK( +void PPB_UDPSocket_Private_Proxy::OnMsgBindACK( uint32 /* plugin_dispatcher_id */, uint32 socket_id, bool succeeded) { @@ -338,7 +336,7 @@ void PPB_Flash_UDPSocket_Proxy::OnMsgBindACK( iter->second->OnBindCompleted(succeeded); } -void PPB_Flash_UDPSocket_Proxy::OnMsgRecvFromACK( +void PPB_UDPSocket_Private_Proxy::OnMsgRecvFromACK( uint32 /* plugin_dispatcher_id */, uint32 socket_id, bool succeeded, @@ -354,7 +352,7 @@ void PPB_Flash_UDPSocket_Proxy::OnMsgRecvFromACK( iter->second->OnRecvFromCompleted(succeeded, data, addr); } -void PPB_Flash_UDPSocket_Proxy::OnMsgSendToACK( +void PPB_UDPSocket_Private_Proxy::OnMsgSendToACK( uint32 /* plugin_dispatcher_id */, uint32 socket_id, bool succeeded, diff --git a/ppapi/proxy/ppb_flash_udp_socket_proxy.h b/ppapi/proxy/ppb_udp_socket_private_proxy.h index ab5f84d..337cf6b 100644 --- a/ppapi/proxy/ppb_flash_udp_socket_proxy.h +++ b/ppapi/proxy/ppb_udp_socket_private_proxy.h @@ -2,37 +2,39 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef PPAPI_PROXY_PPB_FLASH_UDP_SOCKET_PROXY_H_ -#define PPAPI_PROXY_PPB_FLASH_UDP_SOCKET_PROXY_H_ +#ifndef PPAPI_PROXY_PPB_UDP_SOCKET_PRIVATE_PROXY_H_ +#define PPAPI_PROXY_PPB_UDP_SOCKET_PRIVATE_PROXY_H_ #include <string> #include "base/basictypes.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" -#include "ppapi/c/private/ppb_flash_udp_socket.h" +#include "ppapi/c/private/ppb_udp_socket_private.h" #include "ppapi/proxy/interface_proxy.h" namespace ppapi { namespace proxy { -// The maximum number of bytes that each PpapiHostMsg_PPBFlashUDPSocket_RecvFrom +// The maximum number of bytes that each PpapiHostMsg_PPBUDPSocket_RecvFrom // message is allowed to request. -extern const int32_t kFlashUDPSocketMaxReadSize; -// The maximum number of bytes that each PpapiHostMsg_PPBFlashUDPSocket_SendTo +extern const int32_t kUDPSocketMaxReadSize; +// The maximum number of bytes that each PpapiHostMsg_PPBUDPSocket_SendTo // message is allowed to carry. -extern const int32_t kFlashUDPSocketMaxWriteSize; +extern const int32_t kUDPSocketMaxWriteSize; -class PPB_Flash_UDPSocket_Proxy : public InterfaceProxy { +class PPB_UDPSocket_Private_Proxy : public InterfaceProxy { public: - PPB_Flash_UDPSocket_Proxy(Dispatcher* dispatcher); - virtual ~PPB_Flash_UDPSocket_Proxy(); + PPB_UDPSocket_Private_Proxy(Dispatcher* dispatcher); + virtual ~PPB_UDPSocket_Private_Proxy(); static PP_Resource CreateProxyResource(PP_Instance instance); // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); + static const ApiID kApiID = API_ID_PPB_UDPSOCKET_PRIVATE; + private: // Browser->plugin message handlers. void OnMsgBindACK(uint32 plugin_dispatcher_id, @@ -48,11 +50,11 @@ class PPB_Flash_UDPSocket_Proxy : public InterfaceProxy { bool succeeded, int32_t bytes_written); - DISALLOW_COPY_AND_ASSIGN(PPB_Flash_UDPSocket_Proxy); + DISALLOW_COPY_AND_ASSIGN(PPB_UDPSocket_Private_Proxy); }; } // namespace proxy } // namespace ppapi -#endif // PPAPI_PROXY_PPB_FLASH_UDP_SOCKET_PROXY_H_ +#endif // PPAPI_PROXY_PPB_UDP_SOCKET_PRIVATE_PROXY_H_ diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc index 2c074df..afdf56d 100644 --- a/ppapi/proxy/resource_creation_proxy.cc +++ b/ppapi/proxy/resource_creation_proxy.cc @@ -19,13 +19,13 @@ #include "ppapi/proxy/ppb_file_system_proxy.h" #include "ppapi/proxy/ppb_flash_menu_proxy.h" #include "ppapi/proxy/ppb_flash_net_connector_proxy.h" -#include "ppapi/proxy/ppb_flash_tcp_socket_proxy.h" -#include "ppapi/proxy/ppb_flash_udp_socket_proxy.h" #include "ppapi/proxy/ppb_font_proxy.h" #include "ppapi/proxy/ppb_graphics_2d_proxy.h" #include "ppapi/proxy/ppb_graphics_3d_proxy.h" #include "ppapi/proxy/ppb_image_data_proxy.h" #include "ppapi/proxy/ppb_surface_3d_proxy.h" +#include "ppapi/proxy/ppb_tcp_socket_private_proxy.h" +#include "ppapi/proxy/ppb_udp_socket_private_proxy.h" #include "ppapi/proxy/ppb_url_loader_proxy.h" #include "ppapi/proxy/ppb_video_capture_proxy.h" #include "ppapi/proxy/ppb_video_decoder_proxy.h" @@ -152,16 +152,6 @@ PP_Resource ResourceCreationProxy::CreateFlashNetConnector( return PPB_Flash_NetConnector_Proxy::CreateProxyResource(instance); } -PP_Resource ResourceCreationProxy::CreateFlashTCPSocket( - PP_Instance instance) { - return PPB_Flash_TCPSocket_Proxy::CreateProxyResource(instance); -} - -PP_Resource ResourceCreationProxy::CreateFlashUDPSocket( - PP_Instance instance) { - return PPB_Flash_UDPSocket_Proxy::CreateProxyResource(instance); -} - PP_Resource ResourceCreationProxy::CreateFontObject( PP_Instance instance, const PP_FontDescription_Dev* description) { @@ -291,6 +281,12 @@ PP_Resource ResourceCreationProxy::CreateSurface3D( attrib_list); } + +PP_Resource ResourceCreationProxy::CreateTCPSocketPrivate( + PP_Instance instance) { + return PPB_TCPSocket_Private_Proxy::CreateProxyResource(instance); +} + PP_Resource ResourceCreationProxy::CreateTransport(PP_Instance instance, const char* name, PP_TransportType type) { @@ -298,6 +294,11 @@ PP_Resource ResourceCreationProxy::CreateTransport(PP_Instance instance, return 0; } +PP_Resource ResourceCreationProxy::CreateUDPSocketPrivate( + PP_Instance instance) { + return PPB_UDPSocket_Private_Proxy::CreateProxyResource(instance); +} + PP_Resource ResourceCreationProxy::CreateURLLoader(PP_Instance instance) { return PPB_URLLoader_Proxy::CreateProxyResource(instance); } diff --git a/ppapi/proxy/resource_creation_proxy.h b/ppapi/proxy/resource_creation_proxy.h index 74812f4..20924d1 100644 --- a/ppapi/proxy/resource_creation_proxy.h +++ b/ppapi/proxy/resource_creation_proxy.h @@ -70,8 +70,6 @@ class ResourceCreationProxy : public InterfaceProxy, virtual PP_Resource CreateFlashMenu(PP_Instance instance, const PP_Flash_Menu* menu_data) OVERRIDE; virtual PP_Resource CreateFlashNetConnector(PP_Instance instance) OVERRIDE; - virtual PP_Resource CreateFlashTCPSocket(PP_Instance instance) OVERRIDE; - virtual PP_Resource CreateFlashUDPSocket(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateFontObject( PP_Instance instance, const PP_FontDescription_Dev* description) OVERRIDE; @@ -109,9 +107,11 @@ class ResourceCreationProxy : public InterfaceProxy, virtual PP_Resource CreateSurface3D(PP_Instance instance, PP_Config3D_Dev config, const int32_t* attrib_list) OVERRIDE; + virtual PP_Resource CreateTCPSocketPrivate(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateTransport(PP_Instance instance, const char* name, PP_TransportType type) OVERRIDE; + virtual PP_Resource CreateUDPSocketPrivate(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateURLLoader(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateURLRequestInfo( PP_Instance instance, diff --git a/ppapi/shared_impl/api_id.h b/ppapi/shared_impl/api_id.h index 54a93d8..d439d3d 100644 --- a/ppapi/shared_impl/api_id.h +++ b/ppapi/shared_impl/api_id.h @@ -28,8 +28,6 @@ enum ApiID { API_ID_PPB_FLASH_FILE_MODULELOCAL, API_ID_PPB_FLASH_MENU, API_ID_PPB_FLASH_NETCONNECTOR, - API_ID_PPB_FLASH_TCPSOCKET, - API_ID_PPB_FLASH_UDPSOCKET, API_ID_PPB_FONT, API_ID_PPB_GRAPHICS_2D, API_ID_PPB_GRAPHICS_3D, @@ -38,8 +36,10 @@ enum ApiID { API_ID_PPB_OPENGLES2, API_ID_PPB_PDF, API_ID_PPB_SURFACE_3D, + API_ID_PPB_TCPSOCKET_PRIVATE, API_ID_PPB_TESTING, API_ID_PPB_TEXT_INPUT, + API_ID_PPB_UDPSOCKET_PRIVATE, API_ID_PPB_URL_LOADER, API_ID_PPB_URL_RESPONSE_INFO, API_ID_PPB_VAR_DEPRECATED, diff --git a/ppapi/shared_impl/resource.h b/ppapi/shared_impl/resource.h index 2d9a850..247287f 100644 --- a/ppapi/shared_impl/resource.h +++ b/ppapi/shared_impl/resource.h @@ -31,8 +31,6 @@ F(PPB_Find_API) \ F(PPB_Flash_Menu_API) \ F(PPB_Flash_NetConnector_API) \ - F(PPB_Flash_TCPSocket_API) \ - F(PPB_Flash_UDPSocket_API) \ F(PPB_Font_API) \ F(PPB_Graphics2D_API) \ F(PPB_Graphics3D_API) \ @@ -42,7 +40,9 @@ F(PPB_PDFFont_API) \ F(PPB_Scrollbar_API) \ F(PPB_Surface3D_API) \ + F(PPB_TCPSocket_Private_API) \ F(PPB_Transport_API) \ + F(PPB_UDPSocket_Private_API) \ F(PPB_URLLoader_API) \ F(PPB_URLRequestInfo_API) \ F(PPB_URLResponseInfo_API) \ diff --git a/ppapi/tests/test_tcp_socket_private.cc b/ppapi/tests/test_tcp_socket_private.cc index d45746c..d7a6a3f 100644 --- a/ppapi/tests/test_tcp_socket_private.cc +++ b/ppapi/tests/test_tcp_socket_private.cc @@ -9,7 +9,7 @@ #include "base/string_split.h" #include "ppapi/c/dev/ppb_url_util_dev.h" #include "ppapi/cpp/dev/url_util_dev.h" -#include "ppapi/cpp/private/flash_tcp_socket.h" +#include "ppapi/cpp/private/tcp_socket_private.h" #include "ppapi/cpp/var.h" #include "ppapi/tests/testing_instance.h" #include "ppapi/tests/test_utils.h" @@ -33,7 +33,7 @@ TestTCPSocketPrivate::TestTCPSocketPrivate(TestingInstance* instance) } bool TestTCPSocketPrivate::Init() { - if (!TCPSocketPrivate::IsAvailable()) + if (!pp::TCPSocketPrivate::IsAvailable()) return false; // This test currently only works out-of-process (since the API is really only @@ -87,7 +87,7 @@ void TestTCPSocketPrivate::RunTests(const std::string& filter) { } std::string TestTCPSocketPrivate::TestBasic() { - TCPSocketPrivate socket(instance_); + pp::TCPSocketPrivate socket(instance_); TestCompletionCallback cb(instance_->pp_instance(), force_async_); int32_t rv = socket.Connect(host_.c_str(), port_, cb); @@ -107,7 +107,7 @@ std::string TestTCPSocketPrivate::TestBasic() { } std::string TestTCPSocketPrivate::TestReadWrite() { - TCPSocketPrivate socket(instance_); + pp::TCPSocketPrivate socket(instance_); TestCompletionCallback cb(instance_->pp_instance(), force_async_); int32_t rv = socket.Connect(host_.c_str(), port_, cb); @@ -133,7 +133,7 @@ std::string TestTCPSocketPrivate::TestConnectAddress() { // First, bring up a connection and grab the address. { - TCPSocketPrivate socket(instance_); + pp::TCPSocketPrivate socket(instance_); TestCompletionCallback cb(instance_->pp_instance(), force_async_); int32_t rv = socket.Connect(host_.c_str(), port_, cb); ASSERT_TRUE(!force_async_ || rv == PP_OK_COMPLETIONPENDING); @@ -146,7 +146,7 @@ std::string TestTCPSocketPrivate::TestConnectAddress() { } // Connect to that address. - TCPSocketPrivate socket(instance_); + pp::TCPSocketPrivate socket(instance_); TestCompletionCallback cb(instance_->pp_instance(), force_async_); int32_t rv = socket.ConnectWithNetAddress(&address, cb); ASSERT_TRUE(!force_async_ || rv == PP_OK_COMPLETIONPENDING); @@ -167,8 +167,9 @@ std::string TestTCPSocketPrivate::TestConnectAddress() { // TODO(viettrungluu): Try testing SSL somehow. -int32_t TestTCPSocketPrivate::ReadFirstLineFromSocket(TCPSocketPrivate* socket, - std::string* s) { +int32_t TestTCPSocketPrivate::ReadFirstLineFromSocket( + pp::TCPSocketPrivate* socket, + std::string* s) { char buffer[10000]; s->clear(); @@ -194,7 +195,7 @@ int32_t TestTCPSocketPrivate::ReadFirstLineFromSocket(TCPSocketPrivate* socket, return PP_ERROR_FAILED; } -int32_t TestTCPSocketPrivate::WriteStringToSocket(TCPSocketPrivate* socket, +int32_t TestTCPSocketPrivate::WriteStringToSocket(pp::TCPSocketPrivate* socket, const std::string& s) { const char* buffer = s.data(); size_t written = 0; diff --git a/ppapi/tests/test_tcp_socket_private.h b/ppapi/tests/test_tcp_socket_private.h index 648377e..4c18a62 100644 --- a/ppapi/tests/test_tcp_socket_private.h +++ b/ppapi/tests/test_tcp_socket_private.h @@ -10,14 +10,9 @@ #include "ppapi/c/pp_stdint.h" #include "ppapi/tests/test_case.h" -// TODO(viettrungluu): A rename is in progress and this reduces the amount of -// code that'll have to be changed. namespace pp { -namespace flash { -class TCPSocket; +class TCPSocketPrivate; } -} -typedef pp::flash::TCPSocket TCPSocketPrivate; class TestTCPSocketPrivate : public TestCase { public: @@ -32,8 +27,9 @@ class TestTCPSocketPrivate : public TestCase { std::string TestReadWrite(); std::string TestConnectAddress(); - int32_t ReadFirstLineFromSocket(TCPSocketPrivate* socket, std::string* s); - int32_t WriteStringToSocket(TCPSocketPrivate* socket, const std::string& s); + int32_t ReadFirstLineFromSocket(pp::TCPSocketPrivate* socket, std::string* s); + int32_t WriteStringToSocket(pp::TCPSocketPrivate* socket, + const std::string& s); std::string host_; uint16_t port_; diff --git a/ppapi/thunk/interfaces_ppb_private.h b/ppapi/thunk/interfaces_ppb_private.h index 6183ee4..17defe9 100644 --- a/ppapi/thunk/interfaces_ppb_private.h +++ b/ppapi/thunk/interfaces_ppb_private.h @@ -8,11 +8,18 @@ #include "ppapi/thunk/interfaces_preamble.h" PROXIED_API(PPB_Broker) +PROXIED_API(PPB_TCPSocket_Private) +PROXIED_API(PPB_UDPSocket_Private) PROXIED_IFACE(PPB_Broker, PPB_BROKER_TRUSTED_INTERFACE_0_2, PPB_BrokerTrusted) PROXIED_IFACE(PPB_Instance, PPB_FLASHFULLSCREEN_INTERFACE, PPB_FlashFullscreen) PROXIED_IFACE(NoAPIName, PPB_NETADDRESS_PRIVATE_INTERFACE, PPB_NetAddress_Private) +PROXIED_IFACE(PPB_TCPSocket_Private, PPB_TCPSOCKET_PRIVATE_INTERFACE, + PPB_TCPSocket_Private) +PROXIED_IFACE(PPB_UDPSocket_Private, PPB_UDPSOCKET_PRIVATE_INTERFACE, + PPB_UDPSocket_Private) + // Map the old fullscreen interface string to the Flash one, which is the same // at the ABI level. TODO(polina): remove this when Flash is updated. PROXIED_IFACE(PPB_Instance, PPB_FULLSCREEN_DEV_INTERFACE_0_4, diff --git a/ppapi/thunk/ppb_flash_tcp_socket_api.h b/ppapi/thunk/ppb_tcp_socket_private_api.h index 7aefcae..0483856 100644 --- a/ppapi/thunk/ppb_flash_tcp_socket_api.h +++ b/ppapi/thunk/ppb_tcp_socket_private_api.h @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef PPAPI_THUNK_PPB_FLASH_TCP_SOCKET_API_H_ -#define PPAPI_THUNK_PPB_FLASH_TCP_SOCKET_API_H_ +#ifndef PPAPI_THUNK_PPB_TCP_SOCKET_PRIVATE_API_H_ +#define PPAPI_THUNK_PPB_TCP_SOCKET_PRIVATE_API_H_ -#include "ppapi/c/private/ppb_flash_tcp_socket.h" +#include "ppapi/c/private/ppb_tcp_socket_private.h" namespace ppapi { namespace thunk { -class PPB_Flash_TCPSocket_API { +class PPB_TCPSocket_Private_API { public: - virtual ~PPB_Flash_TCPSocket_API() {} + virtual ~PPB_TCPSocket_Private_API() {} virtual int32_t Connect(const char* host, uint16_t port, @@ -36,4 +36,4 @@ class PPB_Flash_TCPSocket_API { } // namespace thunk } // namespace ppapi -#endif // PPAPI_THUNK_PPB_FLASH_TCP_SOCKET_API_H_ +#endif // PPAPI_THUNK_PPB_TCP_SOCKET_PRIVATE_API_H_ diff --git a/ppapi/thunk/ppb_flash_tcp_socket_thunk.cc b/ppapi/thunk/ppb_tcp_socket_private_thunk.cc index de21042..245654d 100644 --- a/ppapi/thunk/ppb_flash_tcp_socket_thunk.cc +++ b/ppapi/thunk/ppb_tcp_socket_private_thunk.cc @@ -4,11 +4,11 @@ #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" -#include "ppapi/c/private/ppb_flash_tcp_socket.h" +#include "ppapi/c/private/ppb_tcp_socket_private.h" #include "ppapi/thunk/common.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/thunk.h" -#include "ppapi/thunk/ppb_flash_tcp_socket_api.h" +#include "ppapi/thunk/ppb_tcp_socket_private_api.h" #include "ppapi/thunk/resource_creation_api.h" namespace ppapi { @@ -20,11 +20,11 @@ PP_Resource Create(PP_Instance instance) { EnterFunction<ResourceCreationAPI> enter(instance, true); if (enter.failed()) return 0; - return enter.functions()->CreateFlashTCPSocket(instance); + return enter.functions()->CreateTCPSocketPrivate(instance); } -PP_Bool IsFlashTCPSocket(PP_Resource resource) { - EnterResource<PPB_Flash_TCPSocket_API> enter(resource, false); +PP_Bool IsTCPSocket(PP_Resource resource) { + EnterResource<PPB_TCPSocket_Private_API> enter(resource, false); return PP_FromBool(enter.succeeded()); } @@ -32,7 +32,7 @@ int32_t Connect(PP_Resource tcp_socket, const char* host, uint16_t port, PP_CompletionCallback callback) { - EnterResource<PPB_Flash_TCPSocket_API> enter(tcp_socket, true); + EnterResource<PPB_TCPSocket_Private_API> enter(tcp_socket, true); if (enter.failed()) return MayForceCallback(callback, PP_ERROR_BADRESOURCE); int32_t result = enter.object()->Connect(host, port, callback); @@ -42,7 +42,7 @@ int32_t Connect(PP_Resource tcp_socket, int32_t ConnectWithNetAddress(PP_Resource tcp_socket, const PP_NetAddress_Private* addr, PP_CompletionCallback callback) { - EnterResource<PPB_Flash_TCPSocket_API> enter(tcp_socket, true); + EnterResource<PPB_TCPSocket_Private_API> enter(tcp_socket, true); if (enter.failed()) return MayForceCallback(callback, PP_ERROR_BADRESOURCE); int32_t result = enter.object()->ConnectWithNetAddress(addr, callback); @@ -51,7 +51,7 @@ int32_t ConnectWithNetAddress(PP_Resource tcp_socket, PP_Bool GetLocalAddress(PP_Resource tcp_socket, PP_NetAddress_Private* local_addr) { - EnterResource<PPB_Flash_TCPSocket_API> enter(tcp_socket, true); + EnterResource<PPB_TCPSocket_Private_API> enter(tcp_socket, true); if (enter.failed()) return PP_FALSE; return enter.object()->GetLocalAddress(local_addr); @@ -59,7 +59,7 @@ PP_Bool GetLocalAddress(PP_Resource tcp_socket, PP_Bool GetRemoteAddress(PP_Resource tcp_socket, PP_NetAddress_Private* remote_addr) { - EnterResource<PPB_Flash_TCPSocket_API> enter(tcp_socket, true); + EnterResource<PPB_TCPSocket_Private_API> enter(tcp_socket, true); if (enter.failed()) return PP_FALSE; return enter.object()->GetRemoteAddress(remote_addr); @@ -69,7 +69,7 @@ int32_t SSLHandshake(PP_Resource tcp_socket, const char* server_name, uint16_t server_port, PP_CompletionCallback callback) { - EnterResource<PPB_Flash_TCPSocket_API> enter(tcp_socket, true); + EnterResource<PPB_TCPSocket_Private_API> enter(tcp_socket, true); if (enter.failed()) return MayForceCallback(callback, PP_ERROR_BADRESOURCE); int32_t result = enter.object()->SSLHandshake(server_name, server_port, @@ -81,7 +81,7 @@ int32_t Read(PP_Resource tcp_socket, char* buffer, int32_t bytes_to_read, PP_CompletionCallback callback) { - EnterResource<PPB_Flash_TCPSocket_API> enter(tcp_socket, true); + EnterResource<PPB_TCPSocket_Private_API> enter(tcp_socket, true); if (enter.failed()) return MayForceCallback(callback, PP_ERROR_BADRESOURCE); int32_t result = enter.object()->Read(buffer, bytes_to_read, callback); @@ -92,7 +92,7 @@ int32_t Write(PP_Resource tcp_socket, const char* buffer, int32_t bytes_to_write, PP_CompletionCallback callback) { - EnterResource<PPB_Flash_TCPSocket_API> enter(tcp_socket, true); + EnterResource<PPB_TCPSocket_Private_API> enter(tcp_socket, true); if (enter.failed()) return MayForceCallback(callback, PP_ERROR_BADRESOURCE); int32_t result = enter.object()->Write(buffer, bytes_to_write, callback); @@ -100,14 +100,14 @@ int32_t Write(PP_Resource tcp_socket, } void Disconnect(PP_Resource tcp_socket) { - EnterResource<PPB_Flash_TCPSocket_API> enter(tcp_socket, true); + EnterResource<PPB_TCPSocket_Private_API> enter(tcp_socket, true); if (enter.succeeded()) enter.object()->Disconnect(); } -const PPB_Flash_TCPSocket g_ppb_flash_tcp_socket_thunk = { +const PPB_TCPSocket_Private g_ppb_tcp_socket_thunk = { &Create, - &IsFlashTCPSocket, + &IsTCPSocket, &Connect, &ConnectWithNetAddress, &GetLocalAddress, @@ -120,8 +120,8 @@ const PPB_Flash_TCPSocket g_ppb_flash_tcp_socket_thunk = { } // namespace -const PPB_Flash_TCPSocket* GetPPB_Flash_TCPSocket_Thunk() { - return &g_ppb_flash_tcp_socket_thunk; +const PPB_TCPSocket_Private* GetPPB_TCPSocket_Private_Thunk() { + return &g_ppb_tcp_socket_thunk; } } // namespace thunk diff --git a/ppapi/thunk/ppb_flash_udp_socket_api.h b/ppapi/thunk/ppb_udp_socket_private_api.h index 9a30aef..e79b313 100644 --- a/ppapi/thunk/ppb_flash_udp_socket_api.h +++ b/ppapi/thunk/ppb_udp_socket_private_api.h @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef PPAPI_THUNK_PPB_FLASH_UDP_SOCKET_API_H_ -#define PPAPI_THUNK_PPB_FLASH_UDP_SOCKET_API_H_ +#ifndef PPAPI_THUNK_PPB_UDP_SOCKET_PRIVATE_API_H_ +#define PPAPI_THUNK_PPB_UDP_SOCKET_PRIVATE_API_H_ -#include "ppapi/c/private/ppb_flash_udp_socket.h" +#include "ppapi/c/private/ppb_udp_socket_private.h" namespace ppapi { namespace thunk { -class PPB_Flash_UDPSocket_API { +class PPB_UDPSocket_Private_API { public: - virtual ~PPB_Flash_UDPSocket_API() {} + virtual ~PPB_UDPSocket_Private_API() {} virtual int32_t Bind(const PP_NetAddress_Private* addr, PP_CompletionCallback callback) = 0; @@ -30,5 +30,4 @@ class PPB_Flash_UDPSocket_API { } // namespace thunk } // namespace ppapi -#endif // PPAPI_THUNK_PPB_FLASH_UDP_SOCKET_API_H_ - +#endif // PPAPI_THUNK_PPB_UDP_SOCKET_PRIVATE_API_H_ diff --git a/ppapi/thunk/ppb_flash_udp_socket_thunk.cc b/ppapi/thunk/ppb_udp_socket_private_thunk.cc index 7618008..c2c4b5f 100644 --- a/ppapi/thunk/ppb_flash_udp_socket_thunk.cc +++ b/ppapi/thunk/ppb_udp_socket_private_thunk.cc @@ -4,10 +4,10 @@ #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" -#include "ppapi/c/private/ppb_flash_udp_socket.h" +#include "ppapi/c/private/ppb_udp_socket_private.h" #include "ppapi/thunk/common.h" #include "ppapi/thunk/enter.h" -#include "ppapi/thunk/ppb_flash_udp_socket_api.h" +#include "ppapi/thunk/ppb_udp_socket_private_api.h" #include "ppapi/thunk/resource_creation_api.h" #include "ppapi/thunk/thunk.h" @@ -20,18 +20,18 @@ PP_Resource Create(PP_Instance instance) { EnterFunction<ResourceCreationAPI> enter(instance, true); if (enter.failed()) return 0; - return enter.functions()->CreateFlashUDPSocket(instance); + return enter.functions()->CreateUDPSocketPrivate(instance); } -PP_Bool IsFlashUDPSocket(PP_Resource resource) { - EnterResource<PPB_Flash_UDPSocket_API> enter(resource, false); +PP_Bool IsUDPSocket(PP_Resource resource) { + EnterResource<PPB_UDPSocket_Private_API> enter(resource, false); return PP_FromBool(enter.succeeded()); } int32_t Bind(PP_Resource udp_socket, const PP_NetAddress_Private *addr, PP_CompletionCallback callback) { - EnterResource<PPB_Flash_UDPSocket_API> enter(udp_socket, true); + EnterResource<PPB_UDPSocket_Private_API> enter(udp_socket, true); if (enter.failed()) return MayForceCallback(callback, PP_ERROR_BADRESOURCE); int32_t result = enter.object()->Bind(addr, callback); @@ -42,7 +42,7 @@ int32_t RecvFrom(PP_Resource udp_socket, char* buffer, int32_t num_bytes, PP_CompletionCallback callback) { - EnterResource<PPB_Flash_UDPSocket_API> enter(udp_socket, true); + EnterResource<PPB_UDPSocket_Private_API> enter(udp_socket, true); if (enter.failed()) return MayForceCallback(callback, PP_ERROR_BADRESOURCE); int32_t result = enter.object()->RecvFrom(buffer, @@ -53,7 +53,7 @@ int32_t RecvFrom(PP_Resource udp_socket, PP_Bool GetRecvFromAddress(PP_Resource udp_socket, PP_NetAddress_Private* addr) { - EnterResource<PPB_Flash_UDPSocket_API> enter(udp_socket, true); + EnterResource<PPB_UDPSocket_Private_API> enter(udp_socket, true); if (enter.failed()) return PP_FALSE; return enter.object()->GetRecvFromAddress(addr); @@ -64,7 +64,7 @@ int32_t SendTo(PP_Resource udp_socket, int32_t num_bytes, const PP_NetAddress_Private* addr, PP_CompletionCallback callback) { - EnterResource<PPB_Flash_UDPSocket_API> enter(udp_socket, true); + EnterResource<PPB_UDPSocket_Private_API> enter(udp_socket, true); if (enter.failed()) return MayForceCallback(callback, PP_ERROR_BADRESOURCE); int32_t result = enter.object()->SendTo(buffer, num_bytes, addr, callback); @@ -72,14 +72,14 @@ int32_t SendTo(PP_Resource udp_socket, } void Close(PP_Resource udp_socket) { - EnterResource<PPB_Flash_UDPSocket_API> enter(udp_socket, true); + EnterResource<PPB_UDPSocket_Private_API> enter(udp_socket, true); if (enter.succeeded()) enter.object()->Close(); } -const PPB_Flash_UDPSocket g_ppb_flash_udp_socket_thunk = { +const PPB_UDPSocket_Private g_ppb_udp_socket_thunk = { &Create, - &IsFlashUDPSocket, + &IsUDPSocket, &Bind, &RecvFrom, &GetRecvFromAddress, @@ -89,8 +89,8 @@ const PPB_Flash_UDPSocket g_ppb_flash_udp_socket_thunk = { } // namespace -const PPB_Flash_UDPSocket* GetPPB_Flash_UDPSocket_Thunk() { - return &g_ppb_flash_udp_socket_thunk; +const PPB_UDPSocket_Private* GetPPB_UDPSocket_Private_Thunk() { + return &g_ppb_udp_socket_thunk; } } // namespace thunk diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h index d1566cd..dd37bed 100644 --- a/ppapi/thunk/resource_creation_api.h +++ b/ppapi/thunk/resource_creation_api.h @@ -70,8 +70,6 @@ class ResourceCreationAPI { virtual PP_Resource CreateFlashMenu(PP_Instance instance, const PP_Flash_Menu* menu_data) = 0; virtual PP_Resource CreateFlashNetConnector(PP_Instance instance) = 0; - virtual PP_Resource CreateFlashTCPSocket(PP_Instance instace) = 0; - virtual PP_Resource CreateFlashUDPSocket(PP_Instance instace) = 0; // Note: can't be called CreateFont due to Windows #defines. virtual PP_Resource CreateFontObject( PP_Instance instance, @@ -110,9 +108,11 @@ class ResourceCreationAPI { virtual PP_Resource CreateSurface3D(PP_Instance instance, PP_Config3D_Dev config, const int32_t* attrib_list) = 0; + virtual PP_Resource CreateTCPSocketPrivate(PP_Instance instace) = 0; virtual PP_Resource CreateTransport(PP_Instance instance, const char* name, PP_TransportType type) = 0; + virtual PP_Resource CreateUDPSocketPrivate(PP_Instance instace) = 0; virtual PP_Resource CreateURLLoader(PP_Instance instance) = 0; virtual PP_Resource CreateURLRequestInfo( PP_Instance instance, diff --git a/ppapi/thunk/thunk.h b/ppapi/thunk/thunk.h index c197745..8990b94 100644 --- a/ppapi/thunk/thunk.h +++ b/ppapi/thunk/thunk.h @@ -36,12 +36,12 @@ struct PPB_FileIOTrusted; struct PPB_Flash_Clipboard; struct PPB_Flash_Menu; struct PPB_Flash_NetConnector; -struct PPB_Flash_TCPSocket; -struct PPB_Flash_UDPSocket; struct PPB_Graphics3D; struct PPB_Graphics3DTrusted; struct PPB_ImageDataTrusted; struct PPB_Instance_Private; +struct PPB_TCPSocket_Private; +struct PPB_UDPSocket_Private; struct PPB_URLLoaderTrusted; typedef PPB_Instance PPB_Instance_1_0; @@ -64,12 +64,14 @@ PPAPI_THUNK_EXPORT const PPB_Flash_Clipboard* GetPPB_Flash_Clipboard_Thunk(); PPAPI_THUNK_EXPORT const PPB_Flash_Menu* GetPPB_Flash_Menu_Thunk(); PPAPI_THUNK_EXPORT const PPB_Flash_NetConnector* GetPPB_Flash_NetConnector_Thunk(); -PPAPI_THUNK_EXPORT const PPB_Flash_TCPSocket* GetPPB_Flash_TCPSocket_Thunk(); -PPAPI_THUNK_EXPORT const PPB_Flash_UDPSocket* GetPPB_Flash_UDPSocket_Thunk(); PPAPI_THUNK_EXPORT const PPB_Graphics3DTrusted* GetPPB_Graphics3DTrusted_Thunk(); PPAPI_THUNK_EXPORT const PPB_ImageDataTrusted* GetPPB_ImageDataTrusted_Thunk(); PPAPI_THUNK_EXPORT const PPB_Instance_Private* GetPPB_Instance_Private_Thunk(); +PPAPI_THUNK_EXPORT const PPB_TCPSocket_Private* + GetPPB_TCPSocket_Private_Thunk(); +PPAPI_THUNK_EXPORT const PPB_UDPSocket_Private* + GetPPB_UDPSocket_Private_Thunk(); PPAPI_THUNK_EXPORT const PPB_URLLoaderTrusted* GetPPB_URLLoaderTrusted_Thunk(); } // namespace thunk diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc index 93141cf..2fedc53 100644 --- a/webkit/plugins/ppapi/plugin_module.cc +++ b/webkit/plugins/ppapi/plugin_module.cc @@ -68,11 +68,12 @@ #include "ppapi/c/private/ppb_flash_file.h" #include "ppapi/c/private/ppb_flash_fullscreen.h" #include "ppapi/c/private/ppb_flash_tcp_socket.h" -#include "ppapi/c/private/ppb_flash_udp_socket.h" #include "ppapi/c/private/ppb_gpu_blacklist_private.h" #include "ppapi/c/private/ppb_instance_private.h" #include "ppapi/c/private/ppb_pdf.h" #include "ppapi/c/private/ppb_proxy_private.h" +#include "ppapi/c/private/ppb_tcp_socket_private.h" +#include "ppapi/c/private/ppb_udp_socket_private.h" #include "ppapi/c/private/ppb_uma_private.h" #include "ppapi/c/trusted/ppb_audio_trusted.h" #include "ppapi/c/trusted/ppb_broker_trusted.h" @@ -283,9 +284,7 @@ const void* GetInterface(const char* name) { if (strcmp(name, PPB_FLASH_MENU_INTERFACE) == 0) return ::ppapi::thunk::GetPPB_Flash_Menu_Thunk(); if (strcmp(name, PPB_FLASH_TCPSOCKET_INTERFACE) == 0) - return ::ppapi::thunk::GetPPB_Flash_TCPSocket_Thunk(); - if (strcmp(name, PPB_FLASH_UDPSOCKET_INTERFACE) == 0) - return ::ppapi::thunk::GetPPB_Flash_UDPSocket_Thunk(); + return ::ppapi::thunk::GetPPB_TCPSocket_Private_Thunk(); if (strcmp(name, PPB_FULLSCREEN_DEV_INTERFACE_0_4) == 0) return ::ppapi::thunk::GetPPB_FlashFullscreen_Thunk(); if (strcmp(name, PPB_FULLSCREEN_DEV_INTERFACE) == 0) diff --git a/webkit/plugins/ppapi/resource_creation_impl.cc b/webkit/plugins/ppapi/resource_creation_impl.cc index 2a02112..bf74fc9 100644 --- a/webkit/plugins/ppapi/resource_creation_impl.cc +++ b/webkit/plugins/ppapi/resource_creation_impl.cc @@ -139,18 +139,6 @@ PP_Resource ResourceCreationImpl::CreateFlashNetConnector( return (new PPB_Flash_NetConnector_Impl(instance))->GetReference(); } -PP_Resource ResourceCreationImpl::CreateFlashTCPSocket( - PP_Instance instance) { - // Creating TCP socket resource at the renderer side is not supported. - return 0; -} - -PP_Resource ResourceCreationImpl::CreateFlashUDPSocket( - PP_Instance instance) { - // Creating UDP socket resource at the renderer side is not supported. - return 0; -} - PP_Resource ResourceCreationImpl::CreateFontObject( PP_Instance instance, const PP_FontDescription_Dev* description) { @@ -255,6 +243,12 @@ PP_Resource ResourceCreationImpl::CreateSurface3D( return PPB_Surface3D_Impl::Create(instance, config, attrib_list); } + +PP_Resource ResourceCreationImpl::CreateTCPSocketPrivate(PP_Instance instance) { + // Creating TCP socket resource at the renderer side is not supported. + return 0; +} + PP_Resource ResourceCreationImpl::CreateTransport(PP_Instance instance, const char* name, PP_TransportType type) { @@ -263,6 +257,11 @@ PP_Resource ResourceCreationImpl::CreateTransport(PP_Instance instance, #endif } +PP_Resource ResourceCreationImpl::CreateUDPSocketPrivate(PP_Instance instance) { + // Creating UDP socket resource at the renderer side is not supported. + return 0; +} + PP_Resource ResourceCreationImpl::CreateURLLoader(PP_Instance instance) { return (new PPB_URLLoader_Impl(instance, false))->GetReference(); } diff --git a/webkit/plugins/ppapi/resource_creation_impl.h b/webkit/plugins/ppapi/resource_creation_impl.h index 2f9deff..a769a8e 100644 --- a/webkit/plugins/ppapi/resource_creation_impl.h +++ b/webkit/plugins/ppapi/resource_creation_impl.h @@ -57,8 +57,6 @@ class ResourceCreationImpl : public ::ppapi::FunctionGroupBase, virtual PP_Resource CreateFlashMenu(PP_Instance instance, const PP_Flash_Menu* menu_data) OVERRIDE; virtual PP_Resource CreateFlashNetConnector(PP_Instance instance) OVERRIDE; - virtual PP_Resource CreateFlashTCPSocket(PP_Instance instance) OVERRIDE; - virtual PP_Resource CreateFlashUDPSocket(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateFontObject( PP_Instance instance, const PP_FontDescription_Dev* description) OVERRIDE; @@ -96,9 +94,11 @@ class ResourceCreationImpl : public ::ppapi::FunctionGroupBase, virtual PP_Resource CreateSurface3D(PP_Instance instance, PP_Config3D_Dev config, const int32_t* attrib_list) OVERRIDE; + virtual PP_Resource CreateTCPSocketPrivate(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateTransport(PP_Instance instance, const char* name, PP_TransportType type) OVERRIDE; + virtual PP_Resource CreateUDPSocketPrivate(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateURLLoader(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateURLRequestInfo( PP_Instance instance, |