Chromium Code Reviews| Index: content/renderer/pepper/pepper_helper_impl.cc |
| =================================================================== |
| --- content/renderer/pepper/pepper_helper_impl.cc (revision 214423) |
| +++ content/renderer/pepper/pepper_helper_impl.cc (working copy) |
| @@ -13,7 +13,6 @@ |
| #include "base/callback.h" |
| #include "base/command_line.h" |
| #include "base/files/file_path.h" |
| -#include "base/files/file_util_proxy.h" |
| #include "base/logging.h" |
| #include "base/platform_file.h" |
| #include "base/strings/string_split.h" |
| @@ -38,6 +37,7 @@ |
| #include "content/renderer/p2p/socket_dispatcher.h" |
| #include "content/renderer/pepper/content_renderer_pepper_host_factory.h" |
| #include "content/renderer/pepper/host_dispatcher_wrapper.h" |
| +#include "content/renderer/pepper/host_globals.h" |
| #include "content/renderer/pepper/pepper_broker.h" |
| #include "content/renderer/pepper/pepper_browser_connection.h" |
| #include "content/renderer/pepper/pepper_file_system_host.h" |
| @@ -53,7 +53,6 @@ |
| #include "content/renderer/pepper/ppb_tcp_server_socket_private_impl.h" |
| #include "content/renderer/pepper/ppb_tcp_socket_private_impl.h" |
| #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
| -#include "content/renderer/pepper/resource_helper.h" |
| #include "content/renderer/pepper/url_response_info_util.h" |
| #include "content/renderer/render_thread_impl.h" |
| #include "content/renderer/render_view_impl.h" |
| @@ -114,9 +113,9 @@ |
| PepperHelperImpl::PepperHelperImpl(RenderViewImpl* render_view) |
| : RenderViewObserver(render_view), |
| render_view_(render_view), |
| - pepper_browser_connection_(this), |
| focused_plugin_(NULL), |
| last_mouse_event_target_(NULL) { |
| + new PepperBrowserConnection(render_view); |
|
scottmg
2013/08/01 02:45:02
why allocated and leaked now instead of contained?
jam
2013/08/01 06:53:35
this is a RenderViewObserver which deletes itself
|
| } |
| PepperHelperImpl::~PepperHelperImpl() { |
| @@ -507,7 +506,8 @@ |
| PPB_Broker_Impl* client) { |
| DCHECK(client); |
| - PluginModule* plugin_module = ResourceHelper::GetPluginModule(client); |
| + PluginModule* plugin_module = |
| + HostGlobals::Get()->GetInstance(client->pp_instance())->module(); |
| if (!plugin_module) |
| return NULL; |
| @@ -541,7 +541,8 @@ |
| if (!client.get()) |
| return; |
| - PluginModule* plugin_module = ResourceHelper::GetPluginModule(client.get()); |
| + PluginModule* plugin_module = |
| + HostGlobals::Get()->GetInstance(client->pp_instance())->module(); |
| if (!plugin_module) |
| return; |
| @@ -549,37 +550,6 @@ |
| broker->OnBrokerPermissionResult(client.get(), result); |
| } |
| -bool PepperHelperImpl::AsyncOpenFile(const base::FilePath& path, |
| - int flags, |
| - const AsyncOpenFileCallback& callback) { |
| - int message_id = pending_async_open_files_.Add( |
| - new AsyncOpenFileCallback(callback)); |
| - return Send(new ViewHostMsg_AsyncOpenFile( |
| - routing_id(), path, flags, message_id)); |
| -} |
| - |
| -void PepperHelperImpl::OnAsyncFileOpened( |
| - base::PlatformFileError error_code, |
| - IPC::PlatformFileForTransit file_for_transit, |
| - int message_id) { |
| - AsyncOpenFileCallback* callback = |
| - pending_async_open_files_.Lookup(message_id); |
| - DCHECK(callback); |
| - pending_async_open_files_.Remove(message_id); |
| - |
| - base::PlatformFile file = |
| - IPC::PlatformFileForTransitToPlatformFile(file_for_transit); |
| - callback->Run(error_code, base::PassPlatformFile(&file)); |
| - // Make sure we won't leak file handle if the requester has died. |
| - if (file != base::kInvalidPlatformFileValue) { |
| - base::FileUtilProxy::Close( |
| - RenderThreadImpl::current()->GetFileThreadMessageLoopProxy().get(), |
| - file, |
| - base::FileUtilProxy::StatusCallback()); |
| - } |
| - delete callback; |
| -} |
| - |
| void PepperHelperImpl::OnSetFocus(bool has_focus) { |
| for (std::set<PepperPluginInstanceImpl*>::iterator i = |
| active_instances_.begin(); |
| @@ -609,23 +579,6 @@ |
| last_mouse_event_target_ = NULL; |
| } |
| -void PepperHelperImpl::RegisterTCPSocket( |
| - PPB_TCPSocket_Private_Impl* socket, |
| - uint32 socket_id) { |
| - tcp_sockets_.AddWithID(socket, socket_id); |
| -} |
| - |
| -void PepperHelperImpl::UnregisterTCPSocket(uint32 socket_id) { |
| - // There is no DCHECK(tcp_sockets_.Lookup(socket_id)) because this method |
| - // can be called before TCPSocketConnect or TCPSocketConnectWithNetAddress. |
| - if (tcp_sockets_.Lookup(socket_id)) |
| - tcp_sockets_.Remove(socket_id); |
| -} |
| - |
| -void PepperHelperImpl::TCPServerSocketStopListening(uint32 socket_id) { |
| - tcp_server_sockets_.Remove(socket_id); |
| -} |
| - |
| void PepperHelperImpl::HandleDocumentLoad( |
| PepperPluginInstanceImpl* instance, |
| const WebKit::WebURLResponse& response) { |
| @@ -724,26 +677,10 @@ |
| } |
| bool PepperHelperImpl::OnMessageReceived(const IPC::Message& message) { |
| - if (pepper_browser_connection_.OnMessageReceived(message)) |
| - return true; |
| - |
| bool handled = true; |
| IPC_BEGIN_MESSAGE_MAP(PepperHelperImpl, message) |
| - IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK, |
| - OnTCPSocketConnectACK) |
| - IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK, |
| - OnTCPSocketSSLHandshakeACK) |
| - IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnTCPSocketReadACK) |
| - IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnTCPSocketWriteACK) |
| - IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SetOptionACK, |
| - OnTCPSocketSetOptionACK) |
| - IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_ListenACK, |
| - OnTCPServerSocketListenACK) |
| - IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_AcceptACK, |
| - OnTCPServerSocketAcceptACK) |
| IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerChannelCreated, |
| OnPpapiBrokerChannelCreated) |
| - IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenFile_ACK, OnAsyncFileOpened) |
| IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerPermissionResult, |
| OnPpapiBrokerPermissionResult) |
| IPC_MESSAGE_UNHANDLED(handled = false) |
| @@ -757,92 +694,4 @@ |
| // it's non-pointer member in RenderViewImpl. |
| } |
| -void PepperHelperImpl::OnTCPSocketConnectACK( |
| - uint32 plugin_dispatcher_id, |
| - uint32 socket_id, |
| - int32_t result, |
| - const PP_NetAddress_Private& local_addr, |
| - const PP_NetAddress_Private& remote_addr) { |
| - PPB_TCPSocket_Private_Impl* socket = tcp_sockets_.Lookup(socket_id); |
| - if (socket) |
| - socket->OnConnectCompleted(result, local_addr, remote_addr); |
| - if (result != PP_OK) |
| - tcp_sockets_.Remove(socket_id); |
| -} |
| - |
| -void PepperHelperImpl::OnTCPSocketSSLHandshakeACK( |
| - uint32 plugin_dispatcher_id, |
| - uint32 socket_id, |
| - bool succeeded, |
| - const ppapi::PPB_X509Certificate_Fields& certificate_fields) { |
| - PPB_TCPSocket_Private_Impl* socket = tcp_sockets_.Lookup(socket_id); |
| - if (socket) |
| - socket->OnSSLHandshakeCompleted(succeeded, certificate_fields); |
| -} |
| - |
| -void PepperHelperImpl::OnTCPSocketReadACK(uint32 plugin_dispatcher_id, |
| - uint32 socket_id, |
| - int32_t result, |
| - const std::string& data) { |
| - PPB_TCPSocket_Private_Impl* socket = tcp_sockets_.Lookup(socket_id); |
| - if (socket) |
| - socket->OnReadCompleted(result, data); |
| -} |
| - |
| -void PepperHelperImpl::OnTCPSocketWriteACK(uint32 plugin_dispatcher_id, |
| - uint32 socket_id, |
| - int32_t result) { |
| - PPB_TCPSocket_Private_Impl* socket = tcp_sockets_.Lookup(socket_id); |
| - if (socket) |
| - socket->OnWriteCompleted(result); |
| -} |
| - |
| -void PepperHelperImpl::OnTCPSocketSetOptionACK( |
| - uint32 plugin_dispatcher_id, |
| - uint32 socket_id, |
| - int32_t result) { |
| - PPB_TCPSocket_Private_Impl* socket = tcp_sockets_.Lookup(socket_id); |
| - if (socket) |
| - socket->OnSetOptionCompleted(result); |
| -} |
| - |
| -void PepperHelperImpl::OnTCPServerSocketListenACK( |
| - uint32 plugin_dispatcher_id, |
| - PP_Resource socket_resource, |
| - uint32 socket_id, |
| - const PP_NetAddress_Private& local_addr, |
| - int32_t status) { |
| - ppapi::thunk::EnterResource<ppapi::thunk::PPB_TCPServerSocket_Private_API> |
| - enter(socket_resource, true); |
| - if (enter.succeeded()) { |
| - ppapi::PPB_TCPServerSocket_Shared* socket = |
| - static_cast<ppapi::PPB_TCPServerSocket_Shared*>(enter.object()); |
| - if (status == PP_OK) |
| - tcp_server_sockets_.AddWithID(socket, socket_id); |
| - socket->OnListenCompleted(socket_id, local_addr, status); |
| - } else if (socket_id != 0 && status == PP_OK) { |
| - // StopListening was called before completion of Listen. |
| - Send(new PpapiHostMsg_PPBTCPServerSocket_Destroy(socket_id)); |
| - } |
| -} |
| - |
| -void PepperHelperImpl::OnTCPServerSocketAcceptACK( |
| - uint32 plugin_dispatcher_id, |
| - uint32 server_socket_id, |
| - uint32 accepted_socket_id, |
| - const PP_NetAddress_Private& local_addr, |
| - const PP_NetAddress_Private& remote_addr) { |
| - ppapi::PPB_TCPServerSocket_Shared* socket = |
| - tcp_server_sockets_.Lookup(server_socket_id); |
| - if (socket) { |
| - bool succeeded = (accepted_socket_id != 0); |
| - socket->OnAcceptCompleted(succeeded, |
| - accepted_socket_id, |
| - local_addr, |
| - remote_addr); |
| - } else if (accepted_socket_id != 0) { |
| - Send(new PpapiHostMsg_PPBTCPSocket_Disconnect(accepted_socket_id)); |
| - } |
| -} |
| - |
| } // namespace content |