OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_plugin_delegate_impl.h" | 5 #include "content/renderer/pepper_plugin_delegate_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <queue> | 8 #include <queue> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 #include "webkit/fileapi/file_system_callback_dispatcher.h" | 68 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
69 #include "webkit/glue/context_menu.h" | 69 #include "webkit/glue/context_menu.h" |
70 #include "webkit/plugins/npapi/webplugin.h" | 70 #include "webkit/plugins/npapi/webplugin.h" |
71 #include "webkit/plugins/ppapi/file_path.h" | 71 #include "webkit/plugins/ppapi/file_path.h" |
72 #include "webkit/plugins/ppapi/ppb_file_io_impl.h" | 72 #include "webkit/plugins/ppapi/ppb_file_io_impl.h" |
73 #include "webkit/plugins/ppapi/plugin_module.h" | 73 #include "webkit/plugins/ppapi/plugin_module.h" |
74 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 74 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
75 #include "webkit/plugins/ppapi/ppb_broker_impl.h" | 75 #include "webkit/plugins/ppapi/ppb_broker_impl.h" |
76 #include "webkit/plugins/ppapi/ppb_flash_impl.h" | 76 #include "webkit/plugins/ppapi/ppb_flash_impl.h" |
77 #include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h" | 77 #include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h" |
78 #include "webkit/plugins/ppapi/ppb_tcp_socket_private_impl.h" | |
79 #include "webkit/plugins/ppapi/ppb_udp_socket_private_impl.h" | |
78 #include "webkit/plugins/ppapi/resource_helper.h" | 80 #include "webkit/plugins/ppapi/resource_helper.h" |
79 #include "webkit/plugins/webplugininfo.h" | 81 #include "webkit/plugins/webplugininfo.h" |
80 | 82 |
81 using WebKit::WebView; | 83 using WebKit::WebView; |
82 | 84 |
83 namespace { | 85 namespace { |
84 | 86 |
85 base::SyncSocket::Handle DuplicateHandle(base::SyncSocket::Handle handle) { | 87 base::SyncSocket::Handle DuplicateHandle(base::SyncSocket::Handle handle) { |
86 base::SyncSocket::Handle out_handle = base::kInvalidPlatformFileValue; | 88 base::SyncSocket::Handle out_handle = base::kInvalidPlatformFileValue; |
87 #if defined(OS_WIN) | 89 #if defined(OS_WIN) |
(...skipping 1584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1672 base::PlatformFile socket, | 1674 base::PlatformFile socket, |
1673 const PP_NetAddress_Private& local_addr, | 1675 const PP_NetAddress_Private& local_addr, |
1674 const PP_NetAddress_Private& remote_addr) { | 1676 const PP_NetAddress_Private& remote_addr) { |
1675 scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl> connector = | 1677 scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl> connector = |
1676 *pending_connect_tcps_.Lookup(request_id); | 1678 *pending_connect_tcps_.Lookup(request_id); |
1677 pending_connect_tcps_.Remove(request_id); | 1679 pending_connect_tcps_.Remove(request_id); |
1678 | 1680 |
1679 connector->CompleteConnectTcp(socket, local_addr, remote_addr); | 1681 connector->CompleteConnectTcp(socket, local_addr, remote_addr); |
1680 } | 1682 } |
1681 | 1683 |
1684 uint32 PepperPluginDelegateImpl::TCPSocketCreate() { | |
1685 if (!render_view_->CanUseSocketAPIs()) | |
1686 return 0; | |
1687 | |
1688 uint32 socket_id = 0; | |
1689 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_Create( | |
1690 render_view_->routing_id(), 0, &socket_id)); | |
1691 return socket_id; | |
1692 } | |
1693 | |
1694 void PepperPluginDelegateImpl::TCPSocketConnect( | |
1695 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket, | |
1696 uint32 socket_id, | |
1697 const std::string& host, | |
1698 uint16_t port) { | |
1699 tcp_sockets_.AddWithID(socket, socket_id); | |
1700 render_view_->Send( | |
1701 new PpapiHostMsg_PPBTCPSocket_Connect(socket_id, host, port)); | |
1702 } | |
1703 | |
1704 void PepperPluginDelegateImpl::TCPSocketConnectWithNetAddress( | |
1705 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket, | |
1706 uint32 socket_id, | |
1707 const PP_NetAddress_Private& addr) { | |
1708 tcp_sockets_.AddWithID(socket, socket_id); | |
1709 render_view_->Send( | |
1710 new PpapiHostMsg_PPBTCPSocket_ConnectWithNetAddress(socket_id, addr)); | |
1711 } | |
1712 | |
1713 void PepperPluginDelegateImpl::OnTCPSocketConnectACK( | |
1714 uint32 socket_id, | |
1715 bool succeeded, | |
1716 const PP_NetAddress_Private& local_addr, | |
1717 const PP_NetAddress_Private& remote_addr) { | |
1718 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket = | |
1719 tcp_sockets_.Lookup(socket_id); | |
1720 if (socket) | |
1721 socket->OnConnectCompleted(succeeded, local_addr, remote_addr); | |
1722 } | |
1723 | |
1724 void PepperPluginDelegateImpl::TCPSocketSSLHandshake( | |
1725 uint32 socket_id, | |
1726 const std::string& server_name, | |
1727 uint16_t server_port) { | |
1728 DCHECK(tcp_sockets_.Lookup(socket_id)); | |
1729 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_SSLHandshake( | |
1730 socket_id, server_name, server_port)); | |
1731 } | |
1732 | |
1733 void PepperPluginDelegateImpl::OnTCPSocketSSLHandshakeACK(uint32 socket_id, | |
1734 bool succeeded) { | |
1735 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket = | |
1736 tcp_sockets_.Lookup(socket_id); | |
1737 if (socket) | |
1738 socket->OnSSLHandshakeCompleted(succeeded); | |
1739 } | |
1740 | |
1741 void PepperPluginDelegateImpl::TCPSocketRead(uint32 socket_id, | |
1742 int32_t bytes_to_read) { | |
1743 DCHECK(tcp_sockets_.Lookup(socket_id)); | |
1744 render_view_->Send( | |
1745 new PpapiHostMsg_PPBTCPSocket_Read(socket_id, bytes_to_read)); | |
1746 } | |
1747 | |
1748 void PepperPluginDelegateImpl::OnTCPSocketReadACK(uint32 socket_id, | |
1749 bool succeeded, | |
1750 const std::string& data) { | |
1751 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket = | |
1752 tcp_sockets_.Lookup(socket_id); | |
1753 if (socket) | |
1754 socket->OnReadCompleted(succeeded, data); | |
1755 } | |
1756 | |
1757 void PepperPluginDelegateImpl::TCPSocketWrite(uint32 socket_id, | |
1758 const std::string& buffer) { | |
1759 DCHECK(tcp_sockets_.Lookup(socket_id)); | |
1760 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_Write(socket_id, buffer)); | |
1761 } | |
1762 | |
1763 void PepperPluginDelegateImpl::OnTCPSocketWriteACK(uint32 socket_id, | |
1764 bool succeeded, | |
1765 int32_t bytes_written) { | |
1766 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket = | |
1767 tcp_sockets_.Lookup(socket_id); | |
1768 if (socket) | |
1769 socket->OnWriteCompleted(succeeded, bytes_written); | |
1770 } | |
1771 | |
1772 void PepperPluginDelegateImpl::TCPSocketDisconnect(uint32 socket_id) { | |
1773 // There are no DCHECK(tcp_sockets_.Lookup(socket_id)) because | |
1774 // TCPSocketDisconnect may be called more than once. | |
yzshen1
2011/11/30 21:11:04
because it can be called before TCPSocketConnect/T
ygorshenin
2011/12/01 10:58:31
Done.
| |
1775 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_Disconnect(socket_id)); | |
1776 tcp_sockets_.Remove(socket_id); | |
1777 } | |
1778 | |
1779 uint32 PepperPluginDelegateImpl::UDPSocketCreate() { | |
1780 if (!render_view_->CanUseSocketAPIs()) | |
1781 return 0; | |
1782 | |
1783 uint32 socket_id = 0; | |
1784 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Create( | |
1785 render_view_->routing_id(), 0, &socket_id)); | |
1786 return socket_id; | |
1787 } | |
1788 | |
1789 void PepperPluginDelegateImpl::UDPSocketBind( | |
1790 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket, | |
1791 uint32 socket_id, | |
1792 const PP_NetAddress_Private& addr) { | |
1793 udp_sockets_.AddWithID(socket, socket_id); | |
1794 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Bind(socket_id, addr)); | |
1795 } | |
1796 | |
1797 void PepperPluginDelegateImpl::OnUDPSocketBindACK(uint32 socket_id, | |
1798 bool succeeded) { | |
1799 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket = | |
1800 udp_sockets_.Lookup(socket_id); | |
1801 if (socket) | |
1802 socket->OnBindCompleted(succeeded); | |
1803 } | |
1804 | |
1805 void PepperPluginDelegateImpl::UDPSocketRecvFrom(uint32 socket_id, | |
1806 int32_t num_bytes) { | |
1807 DCHECK(udp_sockets_.Lookup(socket_id)); | |
1808 render_view_->Send( | |
1809 new PpapiHostMsg_PPBUDPSocket_RecvFrom(socket_id, num_bytes)); | |
1810 } | |
1811 | |
1812 void PepperPluginDelegateImpl::OnUDPSocketRecvFromACK( | |
1813 uint32 socket_id, | |
1814 bool succeeded, | |
1815 const std::string& data, | |
1816 const PP_NetAddress_Private& remote_addr) { | |
1817 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket = | |
1818 udp_sockets_.Lookup(socket_id); | |
1819 if (socket) | |
1820 socket->OnRecvFromCompleted(succeeded, data, remote_addr); | |
1821 } | |
1822 | |
1823 void PepperPluginDelegateImpl::UDPSocketSendTo( | |
1824 uint32 socket_id, | |
1825 const std::string& buffer, | |
1826 const PP_NetAddress_Private& net_addr) { | |
1827 DCHECK(udp_sockets_.Lookup(socket_id)); | |
1828 render_view_->Send( | |
1829 new PpapiHostMsg_PPBUDPSocket_SendTo(socket_id, buffer, net_addr)); | |
1830 } | |
1831 | |
1832 void PepperPluginDelegateImpl::OnUDPSocketSendToACK(uint32 socket_id, | |
1833 bool succeeded, | |
1834 int32_t bytes_written) { | |
1835 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket = | |
1836 udp_sockets_.Lookup(socket_id); | |
1837 if (socket) | |
1838 socket->OnSendToCompleted(succeeded, bytes_written); | |
1839 } | |
1840 | |
1841 void PepperPluginDelegateImpl::UDPSocketClose(uint32 socket_id) { | |
1842 // There are no DCHECK(udp_sockets_.Lookup(socket_id)) because of | |
1843 // UDPSocketClose may be called more than once. | |
1844 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Close(socket_id)); | |
1845 udp_sockets_.Remove(socket_id); | |
1846 } | |
1847 | |
1682 int32_t PepperPluginDelegateImpl::ShowContextMenu( | 1848 int32_t PepperPluginDelegateImpl::ShowContextMenu( |
1683 webkit::ppapi::PluginInstance* instance, | 1849 webkit::ppapi::PluginInstance* instance, |
1684 webkit::ppapi::PPB_Flash_Menu_Impl* menu, | 1850 webkit::ppapi::PPB_Flash_Menu_Impl* menu, |
1685 const gfx::Point& position) { | 1851 const gfx::Point& position) { |
1686 int32 render_widget_id = render_view_->routing_id(); | 1852 int32 render_widget_id = render_view_->routing_id(); |
1687 if (instance->FlashIsFullscreen(instance->pp_instance())) { | 1853 if (instance->FlashIsFullscreen(instance->pp_instance())) { |
1688 webkit::ppapi::FullscreenContainer* container = | 1854 webkit::ppapi::FullscreenContainer* container = |
1689 instance->fullscreen_container(); | 1855 instance->fullscreen_container(); |
1690 DCHECK(container); | 1856 DCHECK(container); |
1691 render_widget_id = | 1857 render_widget_id = |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1931 if (!context) | 2097 if (!context) |
1932 return NULL; | 2098 return NULL; |
1933 if (!context->makeContextCurrent() || context->isContextLost()) | 2099 if (!context->makeContextCurrent() || context->isContextLost()) |
1934 return NULL; | 2100 return NULL; |
1935 | 2101 |
1936 RendererGLContext* parent_context = context->context(); | 2102 RendererGLContext* parent_context = context->context(); |
1937 if (!parent_context) | 2103 if (!parent_context) |
1938 return NULL; | 2104 return NULL; |
1939 return parent_context; | 2105 return parent_context; |
1940 } | 2106 } |
OLD | NEW |