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 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 tcp_sockets_.AddWithID(socket, socket_id); | 631 tcp_sockets_.AddWithID(socket, socket_id); |
633 } | 632 } |
634 | 633 |
635 void PepperHelperImpl::UnregisterTCPSocket(uint32 socket_id) { | 634 void PepperHelperImpl::UnregisterTCPSocket(uint32 socket_id) { |
636 // There is no DCHECK(tcp_sockets_.Lookup(socket_id)) because this method | 635 // There is no DCHECK(tcp_sockets_.Lookup(socket_id)) because this method |
637 // can be called before TCPSocketConnect or TCPSocketConnectWithNetAddress. | 636 // can be called before TCPSocketConnect or TCPSocketConnectWithNetAddress. |
638 if (tcp_sockets_.Lookup(socket_id)) | 637 if (tcp_sockets_.Lookup(socket_id)) |
639 tcp_sockets_.Remove(socket_id); | 638 tcp_sockets_.Remove(socket_id); |
640 } | 639 } |
641 | 640 |
642 void PepperHelperImpl::TCPServerSocketStopListening(uint32 socket_id) { | |
643 tcp_server_sockets_.Remove(socket_id); | |
644 } | |
645 | |
646 void PepperHelperImpl::HandleDocumentLoad( | 641 void PepperHelperImpl::HandleDocumentLoad( |
647 PepperPluginInstanceImpl* instance, | 642 PepperPluginInstanceImpl* instance, |
648 const WebKit::WebURLResponse& response) { | 643 const WebKit::WebURLResponse& response) { |
649 DCHECK(!instance->document_loader()); | 644 DCHECK(!instance->document_loader()); |
650 | 645 |
651 // Create a loader resource host for this load. Note that we have to set | 646 // Create a loader resource host for this load. Note that we have to set |
652 // the document_loader before issuing the in-process | 647 // the document_loader before issuing the in-process |
653 // PPP_Instance.HandleDocumentLoad call below, since this may reentrantly | 648 // PPP_Instance.HandleDocumentLoad call below, since this may reentrantly |
654 // call into the instance and expect it to be valid. | 649 // call into the instance and expect it to be valid. |
655 RendererPpapiHostImpl* host_impl = instance->module()->renderer_ppapi_host(); | 650 RendererPpapiHostImpl* host_impl = instance->module()->renderer_ppapi_host(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 bool handled = true; | 720 bool handled = true; |
726 IPC_BEGIN_MESSAGE_MAP(PepperHelperImpl, message) | 721 IPC_BEGIN_MESSAGE_MAP(PepperHelperImpl, message) |
727 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK, | 722 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK, |
728 OnTCPSocketConnectACK) | 723 OnTCPSocketConnectACK) |
729 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK, | 724 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK, |
730 OnTCPSocketSSLHandshakeACK) | 725 OnTCPSocketSSLHandshakeACK) |
731 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnTCPSocketReadACK) | 726 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnTCPSocketReadACK) |
732 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnTCPSocketWriteACK) | 727 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnTCPSocketWriteACK) |
733 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SetOptionACK, | 728 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SetOptionACK, |
734 OnTCPSocketSetOptionACK) | 729 OnTCPSocketSetOptionACK) |
735 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_ListenACK, | |
736 OnTCPServerSocketListenACK) | |
737 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_AcceptACK, | |
738 OnTCPServerSocketAcceptACK) | |
739 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerChannelCreated, | 730 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerChannelCreated, |
740 OnPpapiBrokerChannelCreated) | 731 OnPpapiBrokerChannelCreated) |
741 IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenPepperFile_ACK, OnAsyncFileOpened) | 732 IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenPepperFile_ACK, OnAsyncFileOpened) |
742 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerPermissionResult, | 733 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerPermissionResult, |
743 OnPpapiBrokerPermissionResult) | 734 OnPpapiBrokerPermissionResult) |
744 IPC_MESSAGE_UNHANDLED(handled = false) | 735 IPC_MESSAGE_UNHANDLED(handled = false) |
745 IPC_END_MESSAGE_MAP() | 736 IPC_END_MESSAGE_MAP() |
746 return handled; | 737 return handled; |
747 } | 738 } |
748 | 739 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 | 785 |
795 void PepperHelperImpl::OnTCPSocketSetOptionACK( | 786 void PepperHelperImpl::OnTCPSocketSetOptionACK( |
796 uint32 plugin_dispatcher_id, | 787 uint32 plugin_dispatcher_id, |
797 uint32 socket_id, | 788 uint32 socket_id, |
798 int32_t result) { | 789 int32_t result) { |
799 PPB_TCPSocket_Private_Impl* socket = tcp_sockets_.Lookup(socket_id); | 790 PPB_TCPSocket_Private_Impl* socket = tcp_sockets_.Lookup(socket_id); |
800 if (socket) | 791 if (socket) |
801 socket->OnSetOptionCompleted(result); | 792 socket->OnSetOptionCompleted(result); |
802 } | 793 } |
803 | 794 |
804 void PepperHelperImpl::OnTCPServerSocketListenACK( | |
805 uint32 plugin_dispatcher_id, | |
806 PP_Resource socket_resource, | |
807 uint32 socket_id, | |
808 const PP_NetAddress_Private& local_addr, | |
809 int32_t status) { | |
810 ppapi::thunk::EnterResource<ppapi::thunk::PPB_TCPServerSocket_Private_API> | |
811 enter(socket_resource, true); | |
812 if (enter.succeeded()) { | |
813 ppapi::PPB_TCPServerSocket_Shared* socket = | |
814 static_cast<ppapi::PPB_TCPServerSocket_Shared*>(enter.object()); | |
815 if (status == PP_OK) | |
816 tcp_server_sockets_.AddWithID(socket, socket_id); | |
817 socket->OnListenCompleted(socket_id, local_addr, status); | |
818 } else if (socket_id != 0 && status == PP_OK) { | |
819 // StopListening was called before completion of Listen. | |
820 Send(new PpapiHostMsg_PPBTCPServerSocket_Destroy(socket_id)); | |
821 } | |
822 } | |
823 | |
824 void PepperHelperImpl::OnTCPServerSocketAcceptACK( | |
825 uint32 plugin_dispatcher_id, | |
826 uint32 server_socket_id, | |
827 uint32 accepted_socket_id, | |
828 const PP_NetAddress_Private& local_addr, | |
829 const PP_NetAddress_Private& remote_addr) { | |
830 ppapi::PPB_TCPServerSocket_Shared* socket = | |
831 tcp_server_sockets_.Lookup(server_socket_id); | |
832 if (socket) { | |
833 bool succeeded = (accepted_socket_id != 0); | |
834 socket->OnAcceptCompleted(succeeded, | |
835 accepted_socket_id, | |
836 local_addr, | |
837 remote_addr); | |
838 } else if (accepted_socket_id != 0) { | |
839 Send(new PpapiHostMsg_PPBTCPSocket_Disconnect(accepted_socket_id)); | |
840 } | |
841 } | |
842 | |
843 void PepperHelperImpl::DidDataFromWebURLResponse( | 795 void PepperHelperImpl::DidDataFromWebURLResponse( |
844 PP_Instance pp_instance, | 796 PP_Instance pp_instance, |
845 const WebKit::WebURLResponse& response, | 797 const WebKit::WebURLResponse& response, |
846 int pending_host_id, | 798 int pending_host_id, |
847 const ppapi::URLResponseInfoData& data) { | 799 const ppapi::URLResponseInfoData& data) { |
848 PepperPluginInstanceImpl* instance = | 800 PepperPluginInstanceImpl* instance = |
849 ResourceHelper::PPInstanceToPluginInstance(pp_instance); | 801 ResourceHelper::PPInstanceToPluginInstance(pp_instance); |
850 if (!instance) | 802 if (!instance) |
851 return; | 803 return; |
852 | 804 |
(...skipping 19 matching lines...) Expand all Loading... |
872 // Running out-of-process. Initiate an IPC call to notify the plugin | 824 // Running out-of-process. Initiate an IPC call to notify the plugin |
873 // process. | 825 // process. |
874 ppapi::proxy::HostDispatcher* dispatcher = | 826 ppapi::proxy::HostDispatcher* dispatcher = |
875 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance); | 827 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance); |
876 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( | 828 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( |
877 ppapi::API_ID_PPP_INSTANCE, pp_instance, pending_host_id, data)); | 829 ppapi::API_ID_PPP_INSTANCE, pp_instance, pending_host_id, data)); |
878 } | 830 } |
879 } | 831 } |
880 | 832 |
881 } // namespace content | 833 } // namespace content |
OLD | NEW |