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

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: Fixed codereview issues. 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
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 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, const std::string& server_name, uint16_t server_port) {
yzshen1 2011/11/29 20:19:33 Nit: For definition / declaration, either put the
ygorshenin 2011/11/30 11:50:54 Done.
1726 DCHECK(tcp_sockets_.Lookup(socket_id));
1727 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_SSLHandshake(
1728 socket_id, server_name, server_port));
1729 }
1730
1731 void PepperPluginDelegateImpl::OnTCPSocketSSLHandshakeACK(uint32 socket_id,
1732 bool succeeded) {
1733 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket =
1734 tcp_sockets_.Lookup(socket_id);
1735 if (socket)
1736 socket->OnSSLHandshakeCompleted(succeeded);
1737 }
1738
1739 void PepperPluginDelegateImpl::TCPSocketRead(uint32 socket_id,
1740 int32_t bytes_to_read) {
1741 DCHECK(tcp_sockets_.Lookup(socket_id));
1742 render_view_->Send(
1743 new PpapiHostMsg_PPBTCPSocket_Read(socket_id, bytes_to_read));
1744 }
1745
1746 void PepperPluginDelegateImpl::OnTCPSocketReadACK(uint32 socket_id,
1747 bool succeeded,
1748 const std::string& data) {
1749 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket =
1750 tcp_sockets_.Lookup(socket_id);
1751 if (socket)
1752 socket->OnReadCompleted(succeeded, data);
1753 }
1754
1755 void PepperPluginDelegateImpl::TCPSocketWrite(uint32 socket_id,
1756 const std::string& buffer) {
1757 DCHECK(tcp_sockets_.Lookup(socket_id));
1758 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_Write(socket_id, buffer));
1759 }
1760
1761 void PepperPluginDelegateImpl::OnTCPSocketWriteACK(uint32 socket_id,
1762 bool succeeded,
1763 int32_t bytes_written) {
1764 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket =
1765 tcp_sockets_.Lookup(socket_id);
1766 if (socket)
1767 socket->OnWriteCompleted(succeeded, bytes_written);
1768 }
1769
1770 void PepperPluginDelegateImpl::TCPSocketDisconnect(uint32 socket_id) {
1771 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_Disconnect(socket_id));
1772 tcp_sockets_.Remove(socket_id);
1773 }
1774
1775 uint32 PepperPluginDelegateImpl::UDPSocketCreate() {
1776 if (!render_view_->CanUseSocketAPIs())
1777 return 0;
1778
1779 uint32 socket_id = 0;
1780 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Create(
1781 render_view_->routing_id(), 0, &socket_id));
1782 return socket_id;
1783 }
1784
1785 void PepperPluginDelegateImpl::UDPSocketBind(
1786 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket,
1787 uint32 socket_id,
1788 const PP_NetAddress_Private& addr) {
1789 udp_sockets_.AddWithID(socket, socket_id);
1790 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Bind(socket_id, addr));
1791 }
1792
1793 void PepperPluginDelegateImpl::OnUDPSocketBindACK(uint32 socket_id,
1794 bool succeeded) {
1795 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket =
1796 udp_sockets_.Lookup(socket_id);
1797 if (socket)
1798 socket->OnBindCompleted(succeeded);
1799 }
1800
1801 void PepperPluginDelegateImpl::UDPSocketRecvFrom(uint32 socket_id,
1802 int32_t num_bytes) {
1803 DCHECK(udp_sockets_.Lookup(socket_id));
1804 render_view_->Send(
1805 new PpapiHostMsg_PPBUDPSocket_RecvFrom(socket_id, num_bytes));
1806 }
1807
1808 void PepperPluginDelegateImpl::OnUDPSocketRecvFromACK(
1809 uint32 socket_id,
1810 bool succeeded,
1811 const std::string& data,
1812 const PP_NetAddress_Private& remote_addr) {
1813 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket =
1814 udp_sockets_.Lookup(socket_id);
1815 if (socket)
1816 socket->OnRecvFromCompleted(succeeded, data, remote_addr);
1817 }
1818
1819 void PepperPluginDelegateImpl::UDPSocketSendTo(
1820 uint32 socket_id,
1821 const std::string& buffer,
1822 const PP_NetAddress_Private& net_addr) {
1823 DCHECK(udp_sockets_.Lookup(socket_id));
1824 render_view_->Send(
1825 new PpapiHostMsg_PPBUDPSocket_SendTo(socket_id, buffer, net_addr));
1826 }
1827
1828 void PepperPluginDelegateImpl::OnUDPSocketSendToACK(uint32 socket_id,
1829 bool succeeded,
1830 int32_t bytes_written) {
1831 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket =
1832 udp_sockets_.Lookup(socket_id);
1833 if (socket)
1834 socket->OnSendToCompleted(succeeded, bytes_written);
1835 }
1836
1837 void PepperPluginDelegateImpl::UDPSocketClose(uint32 socket_id) {
1838 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Close(socket_id));
1839 udp_sockets_.Remove(socket_id);
1840 }
1841
1682 int32_t PepperPluginDelegateImpl::ShowContextMenu( 1842 int32_t PepperPluginDelegateImpl::ShowContextMenu(
1683 webkit::ppapi::PluginInstance* instance, 1843 webkit::ppapi::PluginInstance* instance,
1684 webkit::ppapi::PPB_Flash_Menu_Impl* menu, 1844 webkit::ppapi::PPB_Flash_Menu_Impl* menu,
1685 const gfx::Point& position) { 1845 const gfx::Point& position) {
1686 int32 render_widget_id = render_view_->routing_id(); 1846 int32 render_widget_id = render_view_->routing_id();
1687 if (instance->FlashIsFullscreen(instance->pp_instance())) { 1847 if (instance->FlashIsFullscreen(instance->pp_instance())) {
1688 webkit::ppapi::FullscreenContainer* container = 1848 webkit::ppapi::FullscreenContainer* container =
1689 instance->fullscreen_container(); 1849 instance->fullscreen_container();
1690 DCHECK(container); 1850 DCHECK(container);
1691 render_widget_id = 1851 render_widget_id =
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1931 if (!context) 2091 if (!context)
1932 return NULL; 2092 return NULL;
1933 if (!context->makeContextCurrent() || context->isContextLost()) 2093 if (!context->makeContextCurrent() || context->isContextLost())
1934 return NULL; 2094 return NULL;
1935 2095
1936 RendererGLContext* parent_context = context->context(); 2096 RendererGLContext* parent_context = context->context();
1937 if (!parent_context) 2097 if (!parent_context)
1938 return NULL; 2098 return NULL;
1939 return parent_context; 2099 return parent_context;
1940 } 2100 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698