| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/pepper/pepper_helper_impl.h" | 5 #include "content/renderer/pepper/pepper_helper_impl.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <cstddef> | 8 #include <cstddef> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <queue> | 10 #include <queue> |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "content/renderer/pepper/pepper_file_system_host.h" | 43 #include "content/renderer/pepper/pepper_file_system_host.h" |
| 44 #include "content/renderer/pepper/pepper_graphics_2d_host.h" | 44 #include "content/renderer/pepper/pepper_graphics_2d_host.h" |
| 45 #include "content/renderer/pepper/pepper_hung_plugin_filter.h" | 45 #include "content/renderer/pepper/pepper_hung_plugin_filter.h" |
| 46 #include "content/renderer/pepper/pepper_in_process_resource_creation.h" | 46 #include "content/renderer/pepper/pepper_in_process_resource_creation.h" |
| 47 #include "content/renderer/pepper/pepper_in_process_router.h" | 47 #include "content/renderer/pepper/pepper_in_process_router.h" |
| 48 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 48 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 49 #include "content/renderer/pepper/pepper_plugin_registry.h" | 49 #include "content/renderer/pepper/pepper_plugin_registry.h" |
| 50 #include "content/renderer/pepper/pepper_url_loader_host.h" | 50 #include "content/renderer/pepper/pepper_url_loader_host.h" |
| 51 #include "content/renderer/pepper/pepper_webplugin_impl.h" | 51 #include "content/renderer/pepper/pepper_webplugin_impl.h" |
| 52 #include "content/renderer/pepper/plugin_module.h" | 52 #include "content/renderer/pepper/plugin_module.h" |
| 53 #include "content/renderer/pepper/ppb_tcp_server_socket_private_impl.h" | |
| 54 #include "content/renderer/pepper/ppb_tcp_socket_private_impl.h" | 53 #include "content/renderer/pepper/ppb_tcp_socket_private_impl.h" |
| 55 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 54 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
| 56 #include "content/renderer/pepper/resource_helper.h" | 55 #include "content/renderer/pepper/resource_helper.h" |
| 57 #include "content/renderer/pepper/url_response_info_util.h" | 56 #include "content/renderer/pepper/url_response_info_util.h" |
| 58 #include "content/renderer/render_thread_impl.h" | 57 #include "content/renderer/render_thread_impl.h" |
| 59 #include "content/renderer/render_view_impl.h" | 58 #include "content/renderer/render_view_impl.h" |
| 60 #include "content/renderer/render_widget_fullscreen_pepper.h" | 59 #include "content/renderer/render_widget_fullscreen_pepper.h" |
| 61 #include "content/renderer/webplugin_delegate_proxy.h" | 60 #include "content/renderer/webplugin_delegate_proxy.h" |
| 62 #include "ipc/ipc_channel_handle.h" | 61 #include "ipc/ipc_channel_handle.h" |
| 63 #include "ipc/ipc_platform_file.h" | 62 #include "ipc/ipc_platform_file.h" |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 tcp_sockets_.AddWithID(socket, socket_id); | 615 tcp_sockets_.AddWithID(socket, socket_id); |
| 617 } | 616 } |
| 618 | 617 |
| 619 void PepperHelperImpl::UnregisterTCPSocket(uint32 socket_id) { | 618 void PepperHelperImpl::UnregisterTCPSocket(uint32 socket_id) { |
| 620 // There is no DCHECK(tcp_sockets_.Lookup(socket_id)) because this method | 619 // There is no DCHECK(tcp_sockets_.Lookup(socket_id)) because this method |
| 621 // can be called before TCPSocketConnect or TCPSocketConnectWithNetAddress. | 620 // can be called before TCPSocketConnect or TCPSocketConnectWithNetAddress. |
| 622 if (tcp_sockets_.Lookup(socket_id)) | 621 if (tcp_sockets_.Lookup(socket_id)) |
| 623 tcp_sockets_.Remove(socket_id); | 622 tcp_sockets_.Remove(socket_id); |
| 624 } | 623 } |
| 625 | 624 |
| 626 void PepperHelperImpl::TCPServerSocketStopListening(uint32 socket_id) { | |
| 627 tcp_server_sockets_.Remove(socket_id); | |
| 628 } | |
| 629 | |
| 630 void PepperHelperImpl::HandleDocumentLoad( | 625 void PepperHelperImpl::HandleDocumentLoad( |
| 631 PepperPluginInstanceImpl* instance, | 626 PepperPluginInstanceImpl* instance, |
| 632 const WebKit::WebURLResponse& response) { | 627 const WebKit::WebURLResponse& response) { |
| 633 DCHECK(!instance->document_loader()); | 628 DCHECK(!instance->document_loader()); |
| 634 | 629 |
| 635 // Create a loader resource host for this load. Note that we have to set | 630 // Create a loader resource host for this load. Note that we have to set |
| 636 // the document_loader before issuing the in-process | 631 // the document_loader before issuing the in-process |
| 637 // PPP_Instance.HandleDocumentLoad call below, since this may reentrantly | 632 // PPP_Instance.HandleDocumentLoad call below, since this may reentrantly |
| 638 // call into the instance and expect it to be valid. | 633 // call into the instance and expect it to be valid. |
| 639 RendererPpapiHostImpl* host_impl = instance->module()->renderer_ppapi_host(); | 634 RendererPpapiHostImpl* host_impl = instance->module()->renderer_ppapi_host(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 bool handled = true; | 704 bool handled = true; |
| 710 IPC_BEGIN_MESSAGE_MAP(PepperHelperImpl, message) | 705 IPC_BEGIN_MESSAGE_MAP(PepperHelperImpl, message) |
| 711 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK, | 706 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK, |
| 712 OnTCPSocketConnectACK) | 707 OnTCPSocketConnectACK) |
| 713 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK, | 708 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK, |
| 714 OnTCPSocketSSLHandshakeACK) | 709 OnTCPSocketSSLHandshakeACK) |
| 715 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnTCPSocketReadACK) | 710 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnTCPSocketReadACK) |
| 716 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnTCPSocketWriteACK) | 711 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnTCPSocketWriteACK) |
| 717 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SetOptionACK, | 712 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SetOptionACK, |
| 718 OnTCPSocketSetOptionACK) | 713 OnTCPSocketSetOptionACK) |
| 719 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_ListenACK, | |
| 720 OnTCPServerSocketListenACK) | |
| 721 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_AcceptACK, | |
| 722 OnTCPServerSocketAcceptACK) | |
| 723 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerChannelCreated, | 714 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerChannelCreated, |
| 724 OnPpapiBrokerChannelCreated) | 715 OnPpapiBrokerChannelCreated) |
| 725 IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenPepperFile_ACK, OnAsyncFileOpened) | 716 IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenPepperFile_ACK, OnAsyncFileOpened) |
| 726 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerPermissionResult, | 717 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerPermissionResult, |
| 727 OnPpapiBrokerPermissionResult) | 718 OnPpapiBrokerPermissionResult) |
| 728 IPC_MESSAGE_UNHANDLED(handled = false) | 719 IPC_MESSAGE_UNHANDLED(handled = false) |
| 729 IPC_END_MESSAGE_MAP() | 720 IPC_END_MESSAGE_MAP() |
| 730 return handled; | 721 return handled; |
| 731 } | 722 } |
| 732 | 723 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 | 769 |
| 779 void PepperHelperImpl::OnTCPSocketSetOptionACK( | 770 void PepperHelperImpl::OnTCPSocketSetOptionACK( |
| 780 uint32 plugin_dispatcher_id, | 771 uint32 plugin_dispatcher_id, |
| 781 uint32 socket_id, | 772 uint32 socket_id, |
| 782 int32_t result) { | 773 int32_t result) { |
| 783 PPB_TCPSocket_Private_Impl* socket = tcp_sockets_.Lookup(socket_id); | 774 PPB_TCPSocket_Private_Impl* socket = tcp_sockets_.Lookup(socket_id); |
| 784 if (socket) | 775 if (socket) |
| 785 socket->OnSetOptionCompleted(result); | 776 socket->OnSetOptionCompleted(result); |
| 786 } | 777 } |
| 787 | 778 |
| 788 void PepperHelperImpl::OnTCPServerSocketListenACK( | |
| 789 uint32 plugin_dispatcher_id, | |
| 790 PP_Resource socket_resource, | |
| 791 uint32 socket_id, | |
| 792 const PP_NetAddress_Private& local_addr, | |
| 793 int32_t status) { | |
| 794 ppapi::thunk::EnterResource<ppapi::thunk::PPB_TCPServerSocket_Private_API> | |
| 795 enter(socket_resource, true); | |
| 796 if (enter.succeeded()) { | |
| 797 ppapi::PPB_TCPServerSocket_Shared* socket = | |
| 798 static_cast<ppapi::PPB_TCPServerSocket_Shared*>(enter.object()); | |
| 799 if (status == PP_OK) | |
| 800 tcp_server_sockets_.AddWithID(socket, socket_id); | |
| 801 socket->OnListenCompleted(socket_id, local_addr, status); | |
| 802 } else if (socket_id != 0 && status == PP_OK) { | |
| 803 // StopListening was called before completion of Listen. | |
| 804 Send(new PpapiHostMsg_PPBTCPServerSocket_Destroy(socket_id)); | |
| 805 } | |
| 806 } | |
| 807 | |
| 808 void PepperHelperImpl::OnTCPServerSocketAcceptACK( | |
| 809 uint32 plugin_dispatcher_id, | |
| 810 uint32 server_socket_id, | |
| 811 uint32 accepted_socket_id, | |
| 812 const PP_NetAddress_Private& local_addr, | |
| 813 const PP_NetAddress_Private& remote_addr) { | |
| 814 ppapi::PPB_TCPServerSocket_Shared* socket = | |
| 815 tcp_server_sockets_.Lookup(server_socket_id); | |
| 816 if (socket) { | |
| 817 bool succeeded = (accepted_socket_id != 0); | |
| 818 socket->OnAcceptCompleted(succeeded, | |
| 819 accepted_socket_id, | |
| 820 local_addr, | |
| 821 remote_addr); | |
| 822 } else if (accepted_socket_id != 0) { | |
| 823 Send(new PpapiHostMsg_PPBTCPSocket_Disconnect(accepted_socket_id)); | |
| 824 } | |
| 825 } | |
| 826 | |
| 827 void PepperHelperImpl::DidDataFromWebURLResponse( | 779 void PepperHelperImpl::DidDataFromWebURLResponse( |
| 828 PP_Instance pp_instance, | 780 PP_Instance pp_instance, |
| 829 const WebKit::WebURLResponse& response, | 781 const WebKit::WebURLResponse& response, |
| 830 int pending_host_id, | 782 int pending_host_id, |
| 831 const ppapi::URLResponseInfoData& data) { | 783 const ppapi::URLResponseInfoData& data) { |
| 832 PepperPluginInstanceImpl* instance = | 784 PepperPluginInstanceImpl* instance = |
| 833 ResourceHelper::PPInstanceToPluginInstance(pp_instance); | 785 ResourceHelper::PPInstanceToPluginInstance(pp_instance); |
| 834 if (!instance) | 786 if (!instance) |
| 835 return; | 787 return; |
| 836 | 788 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 856 // Running out-of-process. Initiate an IPC call to notify the plugin | 808 // Running out-of-process. Initiate an IPC call to notify the plugin |
| 857 // process. | 809 // process. |
| 858 ppapi::proxy::HostDispatcher* dispatcher = | 810 ppapi::proxy::HostDispatcher* dispatcher = |
| 859 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance); | 811 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance); |
| 860 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( | 812 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( |
| 861 ppapi::API_ID_PPP_INSTANCE, pp_instance, pending_host_id, data)); | 813 ppapi::API_ID_PPP_INSTANCE, pp_instance, pending_host_id, data)); |
| 862 } | 814 } |
| 863 } | 815 } |
| 864 | 816 |
| 865 } // namespace content | 817 } // namespace content |
| OLD | NEW |