| 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_plugin_delegate_impl.h" | 5 #include "content/renderer/pepper/pepper_plugin_delegate_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 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 tcp_sockets_.AddWithID(socket, socket_id); | 620 tcp_sockets_.AddWithID(socket, socket_id); |
| 622 } | 621 } |
| 623 | 622 |
| 624 void PepperPluginDelegateImpl::UnregisterTCPSocket(uint32 socket_id) { | 623 void PepperPluginDelegateImpl::UnregisterTCPSocket(uint32 socket_id) { |
| 625 // There is no DCHECK(tcp_sockets_.Lookup(socket_id)) because this method | 624 // There is no DCHECK(tcp_sockets_.Lookup(socket_id)) because this method |
| 626 // can be called before TCPSocketConnect or TCPSocketConnectWithNetAddress. | 625 // can be called before TCPSocketConnect or TCPSocketConnectWithNetAddress. |
| 627 if (tcp_sockets_.Lookup(socket_id)) | 626 if (tcp_sockets_.Lookup(socket_id)) |
| 628 tcp_sockets_.Remove(socket_id); | 627 tcp_sockets_.Remove(socket_id); |
| 629 } | 628 } |
| 630 | 629 |
| 631 void PepperPluginDelegateImpl::TCPServerSocketStopListening(uint32 socket_id) { | |
| 632 tcp_server_sockets_.Remove(socket_id); | |
| 633 } | |
| 634 | |
| 635 void PepperPluginDelegateImpl::HandleDocumentLoad( | 630 void PepperPluginDelegateImpl::HandleDocumentLoad( |
| 636 PepperPluginInstanceImpl* instance, | 631 PepperPluginInstanceImpl* instance, |
| 637 const WebKit::WebURLResponse& response) { | 632 const WebKit::WebURLResponse& response) { |
| 638 DCHECK(!instance->document_loader()); | 633 DCHECK(!instance->document_loader()); |
| 639 | 634 |
| 640 PP_Instance pp_instance = instance->pp_instance(); | 635 PP_Instance pp_instance = instance->pp_instance(); |
| 641 RendererPpapiHostImpl* host_impl = instance->module()->renderer_ppapi_host(); | 636 RendererPpapiHostImpl* host_impl = instance->module()->renderer_ppapi_host(); |
| 642 | 637 |
| 643 // Create a loader resource host for this load. Note that we have to set | 638 // Create a loader resource host for this load. Note that we have to set |
| 644 // the document_loader before issuing the in-process | 639 // the document_loader before issuing the in-process |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 bool handled = true; | 732 bool handled = true; |
| 738 IPC_BEGIN_MESSAGE_MAP(PepperPluginDelegateImpl, message) | 733 IPC_BEGIN_MESSAGE_MAP(PepperPluginDelegateImpl, message) |
| 739 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK, | 734 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK, |
| 740 OnTCPSocketConnectACK) | 735 OnTCPSocketConnectACK) |
| 741 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK, | 736 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK, |
| 742 OnTCPSocketSSLHandshakeACK) | 737 OnTCPSocketSSLHandshakeACK) |
| 743 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnTCPSocketReadACK) | 738 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnTCPSocketReadACK) |
| 744 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnTCPSocketWriteACK) | 739 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnTCPSocketWriteACK) |
| 745 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SetOptionACK, | 740 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SetOptionACK, |
| 746 OnTCPSocketSetOptionACK) | 741 OnTCPSocketSetOptionACK) |
| 747 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_ListenACK, | |
| 748 OnTCPServerSocketListenACK) | |
| 749 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_AcceptACK, | |
| 750 OnTCPServerSocketAcceptACK) | |
| 751 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerChannelCreated, | 742 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerChannelCreated, |
| 752 OnPpapiBrokerChannelCreated) | 743 OnPpapiBrokerChannelCreated) |
| 753 IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenFile_ACK, OnAsyncFileOpened) | 744 IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenFile_ACK, OnAsyncFileOpened) |
| 754 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerPermissionResult, | 745 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerPermissionResult, |
| 755 OnPpapiBrokerPermissionResult) | 746 OnPpapiBrokerPermissionResult) |
| 756 IPC_MESSAGE_UNHANDLED(handled = false) | 747 IPC_MESSAGE_UNHANDLED(handled = false) |
| 757 IPC_END_MESSAGE_MAP() | 748 IPC_END_MESSAGE_MAP() |
| 758 return handled; | 749 return handled; |
| 759 } | 750 } |
| 760 | 751 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 | 797 |
| 807 void PepperPluginDelegateImpl::OnTCPSocketSetOptionACK( | 798 void PepperPluginDelegateImpl::OnTCPSocketSetOptionACK( |
| 808 uint32 plugin_dispatcher_id, | 799 uint32 plugin_dispatcher_id, |
| 809 uint32 socket_id, | 800 uint32 socket_id, |
| 810 int32_t result) { | 801 int32_t result) { |
| 811 PPB_TCPSocket_Private_Impl* socket = tcp_sockets_.Lookup(socket_id); | 802 PPB_TCPSocket_Private_Impl* socket = tcp_sockets_.Lookup(socket_id); |
| 812 if (socket) | 803 if (socket) |
| 813 socket->OnSetOptionCompleted(result); | 804 socket->OnSetOptionCompleted(result); |
| 814 } | 805 } |
| 815 | 806 |
| 816 void PepperPluginDelegateImpl::OnTCPServerSocketListenACK( | |
| 817 uint32 plugin_dispatcher_id, | |
| 818 PP_Resource socket_resource, | |
| 819 uint32 socket_id, | |
| 820 const PP_NetAddress_Private& local_addr, | |
| 821 int32_t status) { | |
| 822 ppapi::thunk::EnterResource<ppapi::thunk::PPB_TCPServerSocket_Private_API> | |
| 823 enter(socket_resource, true); | |
| 824 if (enter.succeeded()) { | |
| 825 ppapi::PPB_TCPServerSocket_Shared* socket = | |
| 826 static_cast<ppapi::PPB_TCPServerSocket_Shared*>(enter.object()); | |
| 827 if (status == PP_OK) | |
| 828 tcp_server_sockets_.AddWithID(socket, socket_id); | |
| 829 socket->OnListenCompleted(socket_id, local_addr, status); | |
| 830 } else if (socket_id != 0 && status == PP_OK) { | |
| 831 // StopListening was called before completion of Listen. | |
| 832 Send(new PpapiHostMsg_PPBTCPServerSocket_Destroy(socket_id)); | |
| 833 } | |
| 834 } | |
| 835 | |
| 836 void PepperPluginDelegateImpl::OnTCPServerSocketAcceptACK( | |
| 837 uint32 plugin_dispatcher_id, | |
| 838 uint32 server_socket_id, | |
| 839 uint32 accepted_socket_id, | |
| 840 const PP_NetAddress_Private& local_addr, | |
| 841 const PP_NetAddress_Private& remote_addr) { | |
| 842 ppapi::PPB_TCPServerSocket_Shared* socket = | |
| 843 tcp_server_sockets_.Lookup(server_socket_id); | |
| 844 if (socket) { | |
| 845 bool succeeded = (accepted_socket_id != 0); | |
| 846 socket->OnAcceptCompleted(succeeded, | |
| 847 accepted_socket_id, | |
| 848 local_addr, | |
| 849 remote_addr); | |
| 850 } else if (accepted_socket_id != 0) { | |
| 851 Send(new PpapiHostMsg_PPBTCPSocket_Disconnect(accepted_socket_id)); | |
| 852 } | |
| 853 } | |
| 854 | |
| 855 } // namespace content | 807 } // namespace content |
| OLD | NEW |