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

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

Issue 8775063: Revert 112693 - committed before review was done - Landing 8688002: PPB_TCPSocket_Private/PPB_UDP... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/pepper_plugin_delegate_impl.h ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
80 #include "webkit/plugins/ppapi/resource_helper.h" 78 #include "webkit/plugins/ppapi/resource_helper.h"
81 #include "webkit/plugins/webplugininfo.h" 79 #include "webkit/plugins/webplugininfo.h"
82 80
83 using WebKit::WebView; 81 using WebKit::WebView;
84 82
85 namespace { 83 namespace {
86 84
87 base::SyncSocket::Handle DuplicateHandle(base::SyncSocket::Handle handle) { 85 base::SyncSocket::Handle DuplicateHandle(base::SyncSocket::Handle handle) {
88 base::SyncSocket::Handle out_handle = base::kInvalidPlatformFileValue; 86 base::SyncSocket::Handle out_handle = base::kInvalidPlatformFileValue;
89 #if defined(OS_WIN) 87 #if defined(OS_WIN)
(...skipping 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1677 base::PlatformFile socket, 1675 base::PlatformFile socket,
1678 const PP_NetAddress_Private& local_addr, 1676 const PP_NetAddress_Private& local_addr,
1679 const PP_NetAddress_Private& remote_addr) { 1677 const PP_NetAddress_Private& remote_addr) {
1680 scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl> connector = 1678 scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl> connector =
1681 *pending_connect_tcps_.Lookup(request_id); 1679 *pending_connect_tcps_.Lookup(request_id);
1682 pending_connect_tcps_.Remove(request_id); 1680 pending_connect_tcps_.Remove(request_id);
1683 1681
1684 connector->CompleteConnectTcp(socket, local_addr, remote_addr); 1682 connector->CompleteConnectTcp(socket, local_addr, remote_addr);
1685 } 1683 }
1686 1684
1687 uint32 PepperPluginDelegateImpl::TCPSocketCreate() {
1688 if (!render_view_->CanUseSocketAPIs())
1689 return 0;
1690
1691 uint32 socket_id = 0;
1692 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_Create(
1693 render_view_->routing_id(), 0, &socket_id));
1694 return socket_id;
1695 }
1696
1697 void PepperPluginDelegateImpl::TCPSocketConnect(
1698 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket,
1699 uint32 socket_id,
1700 const std::string& host,
1701 uint16_t port) {
1702 tcp_sockets_.AddWithID(socket, socket_id);
1703 render_view_->Send(
1704 new PpapiHostMsg_PPBTCPSocket_Connect(socket_id, host, port));
1705 }
1706
1707 void PepperPluginDelegateImpl::TCPSocketConnectWithNetAddress(
1708 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket,
1709 uint32 socket_id,
1710 const PP_NetAddress_Private& addr) {
1711 tcp_sockets_.AddWithID(socket, socket_id);
1712 render_view_->Send(
1713 new PpapiHostMsg_PPBTCPSocket_ConnectWithNetAddress(socket_id, addr));
1714 }
1715
1716 void PepperPluginDelegateImpl::OnTCPSocketConnectACK(
1717 uint32 socket_id,
1718 bool succeeded,
1719 const PP_NetAddress_Private& local_addr,
1720 const PP_NetAddress_Private& remote_addr) {
1721 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket =
1722 tcp_sockets_.Lookup(socket_id);
1723 if (socket)
1724 socket->OnConnectCompleted(succeeded, local_addr, remote_addr);
1725 }
1726
1727 void PepperPluginDelegateImpl::TCPSocketSSLHandshake(
1728 uint32 socket_id,
1729 const std::string& server_name,
1730 uint16_t server_port) {
1731 DCHECK(tcp_sockets_.Lookup(socket_id));
1732 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_SSLHandshake(
1733 socket_id, server_name, server_port));
1734 }
1735
1736 void PepperPluginDelegateImpl::OnTCPSocketSSLHandshakeACK(uint32 socket_id,
1737 bool succeeded) {
1738 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket =
1739 tcp_sockets_.Lookup(socket_id);
1740 if (socket)
1741 socket->OnSSLHandshakeCompleted(succeeded);
1742 }
1743
1744 void PepperPluginDelegateImpl::TCPSocketRead(uint32 socket_id,
1745 int32_t bytes_to_read) {
1746 DCHECK(tcp_sockets_.Lookup(socket_id));
1747 render_view_->Send(
1748 new PpapiHostMsg_PPBTCPSocket_Read(socket_id, bytes_to_read));
1749 }
1750
1751 void PepperPluginDelegateImpl::OnTCPSocketReadACK(uint32 socket_id,
1752 bool succeeded,
1753 const std::string& data) {
1754 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket =
1755 tcp_sockets_.Lookup(socket_id);
1756 if (socket)
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 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket =
1770 tcp_sockets_.Lookup(socket_id);
1771 if (socket)
1772 socket->OnWriteCompleted(succeeded, bytes_written);
1773 }
1774
1775 void PepperPluginDelegateImpl::TCPSocketDisconnect(uint32 socket_id) {
1776 // There are no DCHECK(tcp_sockets_.Lookup(socket_id)) because it
1777 // can be called before
1778 // TCPSocketConnect/TCPSocketConnectWithNetAddress is called.
1779 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_Disconnect(socket_id));
1780 tcp_sockets_.Remove(socket_id);
1781 }
1782
1783 uint32 PepperPluginDelegateImpl::UDPSocketCreate() {
1784 if (!render_view_->CanUseSocketAPIs())
1785 return 0;
1786
1787 uint32 socket_id = 0;
1788 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Create(
1789 render_view_->routing_id(), 0, &socket_id));
1790 return socket_id;
1791 }
1792
1793 void PepperPluginDelegateImpl::UDPSocketBind(
1794 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket,
1795 uint32 socket_id,
1796 const PP_NetAddress_Private& addr) {
1797 udp_sockets_.AddWithID(socket, socket_id);
1798 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Bind(socket_id, addr));
1799 }
1800
1801 void PepperPluginDelegateImpl::OnUDPSocketBindACK(uint32 socket_id,
1802 bool succeeded) {
1803 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket =
1804 udp_sockets_.Lookup(socket_id);
1805 if (socket)
1806 socket->OnBindCompleted(succeeded);
1807 }
1808
1809 void PepperPluginDelegateImpl::UDPSocketRecvFrom(uint32 socket_id,
1810 int32_t num_bytes) {
1811 DCHECK(udp_sockets_.Lookup(socket_id));
1812 render_view_->Send(
1813 new PpapiHostMsg_PPBUDPSocket_RecvFrom(socket_id, num_bytes));
1814 }
1815
1816 void PepperPluginDelegateImpl::OnUDPSocketRecvFromACK(
1817 uint32 socket_id,
1818 bool succeeded,
1819 const std::string& data,
1820 const PP_NetAddress_Private& remote_addr) {
1821 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket =
1822 udp_sockets_.Lookup(socket_id);
1823 if (socket)
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 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket =
1840 udp_sockets_.Lookup(socket_id);
1841 if (socket)
1842 socket->OnSendToCompleted(succeeded, bytes_written);
1843 }
1844
1845 void PepperPluginDelegateImpl::UDPSocketClose(uint32 socket_id) {
1846 // There are no DCHECK(udp_sockets_.Lookup(socket_id)) because it
1847 // can be called before UDPSocketBind is called.
1848 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Close(socket_id));
1849 udp_sockets_.Remove(socket_id);
1850 }
1851
1852 int32_t PepperPluginDelegateImpl::ShowContextMenu( 1685 int32_t PepperPluginDelegateImpl::ShowContextMenu(
1853 webkit::ppapi::PluginInstance* instance, 1686 webkit::ppapi::PluginInstance* instance,
1854 webkit::ppapi::PPB_Flash_Menu_Impl* menu, 1687 webkit::ppapi::PPB_Flash_Menu_Impl* menu,
1855 const gfx::Point& position) { 1688 const gfx::Point& position) {
1856 int32 render_widget_id = render_view_->routing_id(); 1689 int32 render_widget_id = render_view_->routing_id();
1857 if (instance->FlashIsFullscreen(instance->pp_instance())) { 1690 if (instance->FlashIsFullscreen(instance->pp_instance())) {
1858 webkit::ppapi::FullscreenContainer* container = 1691 webkit::ppapi::FullscreenContainer* container =
1859 instance->fullscreen_container(); 1692 instance->fullscreen_container();
1860 DCHECK(container); 1693 DCHECK(container);
1861 render_widget_id = 1694 render_widget_id =
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
2101 if (!context) 1934 if (!context)
2102 return NULL; 1935 return NULL;
2103 if (!context->makeContextCurrent() || context->isContextLost()) 1936 if (!context->makeContextCurrent() || context->isContextLost())
2104 return NULL; 1937 return NULL;
2105 1938
2106 RendererGLContext* parent_context = context->context(); 1939 RendererGLContext* parent_context = context->context();
2107 if (!parent_context) 1940 if (!parent_context)
2108 return NULL; 1941 return NULL;
2109 return parent_context; 1942 return parent_context;
2110 } 1943 }
OLDNEW
« no previous file with comments | « content/renderer/pepper_plugin_delegate_impl.h ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698