Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(429)

Side by Side Diff: content/renderer/pepper_plugin_delegate_impl.cc

Issue 8688002: PPB_TCPSocket_Private/PPB_UDPSocket_Private are exposed to Browser (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 uint32 socket_id = 0;
1686 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_Create(
1687 render_view_->routing_id(), 0, &socket_id));
1688 return socket_id;
1689 }
1690
1691 void PepperPluginDelegateImpl::TCPSocketConnect(
1692 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket,
1693 uint32 socket_id,
1694 const std::string& host,
1695 uint16_t port) {
1696 tcp_sockets_.AddWithID(
1697 new scoped_refptr<webkit::ppapi::PPB_TCPSocket_Private_Impl>(socket),
1698 socket_id);
1699 render_view_->Send(
1700 new PpapiHostMsg_PPBTCPSocket_Connect(socket_id, host, port));
1701 }
1702
1703 void PepperPluginDelegateImpl::TCPSocketConnectWithNetAddress(
1704 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket,
1705 uint32 socket_id,
1706 const PP_NetAddress_Private& addr) {
1707 tcp_sockets_.AddWithID(
1708 new scoped_refptr<webkit::ppapi::PPB_TCPSocket_Private_Impl>(socket),
1709 socket_id);
1710 render_view_->Send(
1711 new PpapiHostMsg_PPBTCPSocket_ConnectWithNetAddress(socket_id, addr));
1712 }
1713
1714 void PepperPluginDelegateImpl::OnTCPSocketConnectACK(
1715 uint32 socket_id,
1716 bool succeeded,
1717 const PP_NetAddress_Private& local_addr,
1718 const PP_NetAddress_Private& remote_addr) {
1719 DCHECK(tcp_sockets_.Lookup(socket_id));
1720 scoped_refptr<webkit::ppapi::PPB_TCPSocket_Private_Impl> socket =
1721 *tcp_sockets_.Lookup(socket_id);
1722 if (socket.get())
1723 socket->OnConnectCompleted(succeeded, local_addr, remote_addr);
1724 }
1725
1726 void PepperPluginDelegateImpl::TCPSocketSSLHandshake(uint32 socket_id,
1727 const std::string& server_name,
1728 uint16_t server_port) {
1729 DCHECK(tcp_sockets_.Lookup(socket_id));
1730 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_SSLHandshake(
1731 socket_id, server_name, server_port));
1732 }
1733
1734 void PepperPluginDelegateImpl::OnTCPSocketSSLHandshakeACK(uint32 socket_id,
1735 bool succeeded) {
1736 DCHECK(tcp_sockets_.Lookup(socket_id));
1737 scoped_refptr<webkit::ppapi::PPB_TCPSocket_Private_Impl> socket =
1738 *tcp_sockets_.Lookup(socket_id);
1739 if (socket.get())
1740 socket->OnSSLHandshakeCompleted(succeeded);
1741 }
1742
1743 void PepperPluginDelegateImpl::TCPSocketRead(uint32 socket_id,
1744 int32_t bytes_to_read) {
1745 DCHECK(tcp_sockets_.Lookup(socket_id));
1746 render_view_->Send(
1747 new PpapiHostMsg_PPBTCPSocket_Read(socket_id, bytes_to_read));
1748 }
1749
1750 void PepperPluginDelegateImpl::OnTCPSocketReadACK(uint32 socket_id,
1751 bool succeeded,
1752 const std::string& data) {
1753 DCHECK(tcp_sockets_.Lookup(socket_id));
1754 scoped_refptr<webkit::ppapi::PPB_TCPSocket_Private_Impl> socket =
1755 *tcp_sockets_.Lookup(socket_id);
1756 if (socket.get())
1757 socket->OnReadCompleted(succeeded, data);
1758 }
1759
1760 void PepperPluginDelegateImpl::TCPSocketWrite(uint32 socket_id,
1761 const std::string& buffer) {
1762 DCHECK(tcp_sockets_.Lookup(socket_id));
1763 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_Write(socket_id, buffer));
1764 }
1765
1766 void PepperPluginDelegateImpl::OnTCPSocketWriteACK(uint32 socket_id,
1767 bool succeeded,
1768 int32_t bytes_written) {
1769 DCHECK(tcp_sockets_.Lookup(socket_id));
1770 scoped_refptr<webkit::ppapi::PPB_TCPSocket_Private_Impl> socket =
1771 *tcp_sockets_.Lookup(socket_id);
1772 if (socket.get())
1773 socket->OnWriteCompleted(succeeded, bytes_written);
1774 }
1775
1776 void PepperPluginDelegateImpl::TCPSocketDisconnect(uint32 socket_id) {
1777 DCHECK(tcp_sockets_.Lookup(socket_id));
1778 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_Disconnect(socket_id));
1779 tcp_sockets_.Remove(socket_id);
1780 }
1781
1782 uint32 PepperPluginDelegateImpl::UDPSocketCreate() {
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(
1794 new scoped_refptr<webkit::ppapi::PPB_UDPSocket_Private_Impl>(socket),
1795 socket_id);
1796 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Bind(socket_id, addr));
1797 }
1798
1799 void PepperPluginDelegateImpl::OnUDPSocketBindACK(uint32 socket_id,
1800 bool succeeded) {
1801 DCHECK(udp_sockets_.Lookup(socket_id));
1802 scoped_refptr<webkit::ppapi::PPB_UDPSocket_Private_Impl> socket =
1803 *udp_sockets_.Lookup(socket_id);
1804 if (socket.get())
1805 socket->OnBindCompleted(succeeded);
1806 }
1807
1808 void PepperPluginDelegateImpl::UDPSocketRecvFrom(uint32 socket_id,
1809 int32_t num_bytes) {
1810 DCHECK(udp_sockets_.Lookup(socket_id));
1811 render_view_->Send(
1812 new PpapiHostMsg_PPBUDPSocket_RecvFrom(socket_id, num_bytes));
1813 }
1814
1815 void PepperPluginDelegateImpl::OnUDPSocketRecvFromACK(
1816 uint32 socket_id,
1817 bool succeeded,
1818 const std::string& data,
1819 const PP_NetAddress_Private& remote_addr) {
1820 DCHECK(udp_sockets_.Lookup(socket_id));
1821 scoped_refptr<webkit::ppapi::PPB_UDPSocket_Private_Impl> socket =
1822 *udp_sockets_.Lookup(socket_id);
1823 if (socket.get())
1824 socket->OnRecvFromCompleted(succeeded, data, remote_addr);
1825 }
1826
1827 void PepperPluginDelegateImpl::UDPSocketSendTo(
1828 uint32 socket_id,
1829 const std::string& buffer,
1830 const PP_NetAddress_Private& net_addr) {
1831 DCHECK(udp_sockets_.Lookup(socket_id));
1832 render_view_->Send(
1833 new PpapiHostMsg_PPBUDPSocket_SendTo(socket_id, buffer, net_addr));
1834 }
1835
1836 void PepperPluginDelegateImpl::OnUDPSocketSendToACK(uint32 socket_id,
1837 bool succeeded,
1838 int32_t bytes_written) {
1839 DCHECK(udp_sockets_.Lookup(socket_id));
1840 scoped_refptr<webkit::ppapi::PPB_UDPSocket_Private_Impl> socket =
1841 *udp_sockets_.Lookup(socket_id);
1842 if (socket.get())
1843 socket->OnSendToCompleted(succeeded, bytes_written);
1844 }
1845
1846 void PepperPluginDelegateImpl::UDPSocketClose(uint32 socket_id) {
1847 DCHECK(udp_sockets_.Lookup(socket_id));
1848 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Close(socket_id));
1849 udp_sockets_.Remove(socket_id);
1850 }
1851
1682 int32_t PepperPluginDelegateImpl::ShowContextMenu( 1852 int32_t PepperPluginDelegateImpl::ShowContextMenu(
1683 webkit::ppapi::PluginInstance* instance, 1853 webkit::ppapi::PluginInstance* instance,
1684 webkit::ppapi::PPB_Flash_Menu_Impl* menu, 1854 webkit::ppapi::PPB_Flash_Menu_Impl* menu,
1685 const gfx::Point& position) { 1855 const gfx::Point& position) {
1686 int32 render_widget_id = render_view_->routing_id(); 1856 int32 render_widget_id = render_view_->routing_id();
1687 if (instance->FlashIsFullscreen(instance->pp_instance())) { 1857 if (instance->FlashIsFullscreen(instance->pp_instance())) {
1688 webkit::ppapi::FullscreenContainer* container = 1858 webkit::ppapi::FullscreenContainer* container =
1689 instance->fullscreen_container(); 1859 instance->fullscreen_container();
1690 DCHECK(container); 1860 DCHECK(container);
1691 render_widget_id = 1861 render_widget_id =
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1931 if (!context) 2101 if (!context)
1932 return NULL; 2102 return NULL;
1933 if (!context->makeContextCurrent() || context->isContextLost()) 2103 if (!context->makeContextCurrent() || context->isContextLost())
1934 return NULL; 2104 return NULL;
1935 2105
1936 RendererGLContext* parent_context = context->context(); 2106 RendererGLContext* parent_context = context->context();
1937 if (!parent_context) 2107 if (!parent_context)
1938 return NULL; 2108 return NULL;
1939 return parent_context; 2109 return parent_context;
1940 } 2110 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698