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

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

Issue 11441012: PPB_UDPSocket_Private is switched to the new Pepper proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix. Created 7 years, 11 months 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
OLDNEW
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 81 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
82 #include "ui/gfx/size.h" 82 #include "ui/gfx/size.h"
83 #include "webkit/fileapi/file_system_callback_dispatcher.h" 83 #include "webkit/fileapi/file_system_callback_dispatcher.h"
84 #include "webkit/plugins/npapi/webplugin.h" 84 #include "webkit/plugins/npapi/webplugin.h"
85 #include "webkit/plugins/ppapi/plugin_module.h" 85 #include "webkit/plugins/ppapi/plugin_module.h"
86 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 86 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
87 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" 87 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h"
88 #include "webkit/plugins/ppapi/ppb_file_io_impl.h" 88 #include "webkit/plugins/ppapi/ppb_file_io_impl.h"
89 #include "webkit/plugins/ppapi/ppb_tcp_server_socket_private_impl.h" 89 #include "webkit/plugins/ppapi/ppb_tcp_server_socket_private_impl.h"
90 #include "webkit/plugins/ppapi/ppb_tcp_socket_private_impl.h" 90 #include "webkit/plugins/ppapi/ppb_tcp_socket_private_impl.h"
91 #include "webkit/plugins/ppapi/ppb_udp_socket_private_impl.h"
92 #include "webkit/plugins/ppapi/resource_helper.h" 91 #include "webkit/plugins/ppapi/resource_helper.h"
93 #include "webkit/plugins/webplugininfo.h" 92 #include "webkit/plugins/webplugininfo.h"
94 93
95 using WebKit::WebView; 94 using WebKit::WebView;
96 using WebKit::WebFrame; 95 using WebKit::WebFrame;
97 96
98 namespace content { 97 namespace content {
99 98
100 namespace { 99 namespace {
101 100
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 if (tcp_sockets_.Lookup(socket_id)) 1181 if (tcp_sockets_.Lookup(socket_id))
1183 tcp_sockets_.Remove(socket_id); 1182 tcp_sockets_.Remove(socket_id);
1184 } 1183 }
1185 1184
1186 void PepperPluginDelegateImpl::RegisterTCPSocket( 1185 void PepperPluginDelegateImpl::RegisterTCPSocket(
1187 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket, 1186 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket,
1188 uint32 socket_id) { 1187 uint32 socket_id) {
1189 tcp_sockets_.AddWithID(socket, socket_id); 1188 tcp_sockets_.AddWithID(socket, socket_id);
1190 } 1189 }
1191 1190
1192 uint32 PepperPluginDelegateImpl::UDPSocketCreate() {
1193 uint32 socket_id = 0;
1194 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Create(
1195 render_view_->routing_id(), 0, &socket_id));
1196 return socket_id;
1197 }
1198
1199 void PepperPluginDelegateImpl::UDPSocketSetBoolSocketFeature(
1200 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket,
1201 uint32 socket_id,
1202 int32_t name,
1203 bool value) {
1204 render_view_->Send(
1205 new PpapiHostMsg_PPBUDPSocket_SetBoolSocketFeature(
1206 render_view_->routing_id(), socket_id, name, value));
1207 }
1208
1209 void PepperPluginDelegateImpl::UDPSocketBind(
1210 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket,
1211 uint32 socket_id,
1212 const PP_NetAddress_Private& addr) {
1213 if (!udp_sockets_.Lookup(socket_id))
1214 udp_sockets_.AddWithID(socket, socket_id);
1215 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Bind(
1216 render_view_->routing_id(), socket_id, addr));
1217 }
1218
1219 void PepperPluginDelegateImpl::UDPSocketRecvFrom(uint32 socket_id,
1220 int32_t num_bytes) {
1221 DCHECK(udp_sockets_.Lookup(socket_id));
1222 render_view_->Send(
1223 new PpapiHostMsg_PPBUDPSocket_RecvFrom(socket_id, num_bytes));
1224 }
1225
1226 void PepperPluginDelegateImpl::UDPSocketSendTo(
1227 uint32 socket_id,
1228 const std::string& buffer,
1229 const PP_NetAddress_Private& net_addr) {
1230 DCHECK(udp_sockets_.Lookup(socket_id));
1231 render_view_->Send(
1232 new PpapiHostMsg_PPBUDPSocket_SendTo(render_view_->routing_id(),
1233 socket_id, buffer, net_addr));
1234 }
1235
1236 void PepperPluginDelegateImpl::UDPSocketClose(uint32 socket_id) {
1237 // There are no DCHECK(udp_sockets_.Lookup(socket_id)) because it
1238 // can be called before UDPSocketBind is called.
1239 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Close(socket_id));
1240 if (udp_sockets_.Lookup(socket_id))
1241 udp_sockets_.Remove(socket_id);
1242 }
1243
1244 void PepperPluginDelegateImpl::TCPServerSocketListen( 1191 void PepperPluginDelegateImpl::TCPServerSocketListen(
1245 PP_Resource socket_resource, 1192 PP_Resource socket_resource,
1246 const PP_NetAddress_Private& addr, 1193 const PP_NetAddress_Private& addr,
1247 int32_t backlog) { 1194 int32_t backlog) {
1248 render_view_->Send( 1195 render_view_->Send(
1249 new PpapiHostMsg_PPBTCPServerSocket_Listen( 1196 new PpapiHostMsg_PPBTCPServerSocket_Listen(
1250 render_view_->routing_id(), 0, socket_resource, addr, backlog)); 1197 render_view_->routing_id(), 0, socket_resource, addr, backlog));
1251 } 1198 }
1252 1199
1253 void PepperPluginDelegateImpl::TCPServerSocketAccept(uint32 server_socket_id) { 1200 void PepperPluginDelegateImpl::TCPServerSocketAccept(uint32 server_socket_id) {
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 1425
1479 bool PepperPluginDelegateImpl::OnMessageReceived(const IPC::Message& message) { 1426 bool PepperPluginDelegateImpl::OnMessageReceived(const IPC::Message& message) {
1480 bool handled = true; 1427 bool handled = true;
1481 IPC_BEGIN_MESSAGE_MAP(PepperPluginDelegateImpl, message) 1428 IPC_BEGIN_MESSAGE_MAP(PepperPluginDelegateImpl, message)
1482 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK, 1429 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK,
1483 OnTCPSocketConnectACK) 1430 OnTCPSocketConnectACK)
1484 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK, 1431 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK,
1485 OnTCPSocketSSLHandshakeACK) 1432 OnTCPSocketSSLHandshakeACK)
1486 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnTCPSocketReadACK) 1433 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnTCPSocketReadACK)
1487 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnTCPSocketWriteACK) 1434 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnTCPSocketWriteACK)
1488 IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_BindACK, OnUDPSocketBindACK)
1489 IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_RecvFromACK,
1490 OnUDPSocketRecvFromACK)
1491 IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_SendToACK, OnUDPSocketSendToACK)
1492 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_ListenACK, 1435 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_ListenACK,
1493 OnTCPServerSocketListenACK) 1436 OnTCPServerSocketListenACK)
1494 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_AcceptACK, 1437 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_AcceptACK,
1495 OnTCPServerSocketAcceptACK) 1438 OnTCPServerSocketAcceptACK)
1496 IPC_MESSAGE_HANDLER(PpapiMsg_PPBHostResolver_ResolveACK, 1439 IPC_MESSAGE_HANDLER(PpapiMsg_PPBHostResolver_ResolveACK,
1497 OnHostResolverResolveACK) 1440 OnHostResolverResolveACK)
1498 IPC_MESSAGE_UNHANDLED(handled = false) 1441 IPC_MESSAGE_UNHANDLED(handled = false)
1499 IPC_END_MESSAGE_MAP() 1442 IPC_END_MESSAGE_MAP()
1500 return handled; 1443 return handled;
1501 } 1444 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 void PepperPluginDelegateImpl::OnTCPSocketWriteACK(uint32 plugin_dispatcher_id, 1487 void PepperPluginDelegateImpl::OnTCPSocketWriteACK(uint32 plugin_dispatcher_id,
1545 uint32 socket_id, 1488 uint32 socket_id,
1546 bool succeeded, 1489 bool succeeded,
1547 int32_t bytes_written) { 1490 int32_t bytes_written) {
1548 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket = 1491 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket =
1549 tcp_sockets_.Lookup(socket_id); 1492 tcp_sockets_.Lookup(socket_id);
1550 if (socket) 1493 if (socket)
1551 socket->OnWriteCompleted(succeeded, bytes_written); 1494 socket->OnWriteCompleted(succeeded, bytes_written);
1552 } 1495 }
1553 1496
1554 void PepperPluginDelegateImpl::OnUDPSocketBindACK(
1555 uint32 plugin_dispatcher_id,
1556 uint32 socket_id,
1557 bool succeeded,
1558 const PP_NetAddress_Private& addr) {
1559 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket =
1560 udp_sockets_.Lookup(socket_id);
1561 if (socket)
1562 socket->OnBindCompleted(succeeded, addr);
1563 if (!succeeded)
1564 udp_sockets_.Remove(socket_id);
1565 }
1566
1567 void PepperPluginDelegateImpl::OnUDPSocketRecvFromACK(
1568 uint32 plugin_dispatcher_id,
1569 uint32 socket_id,
1570 bool succeeded,
1571 const std::string& data,
1572 const PP_NetAddress_Private& remote_addr) {
1573 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket =
1574 udp_sockets_.Lookup(socket_id);
1575 if (socket)
1576 socket->OnRecvFromCompleted(succeeded, data, remote_addr);
1577 }
1578
1579 void PepperPluginDelegateImpl::OnUDPSocketSendToACK(uint32 plugin_dispatcher_id,
1580 uint32 socket_id,
1581 bool succeeded,
1582 int32_t bytes_written) {
1583 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket =
1584 udp_sockets_.Lookup(socket_id);
1585 if (socket)
1586 socket->OnSendToCompleted(succeeded, bytes_written);
1587 }
1588
1589 void PepperPluginDelegateImpl::OnTCPServerSocketListenACK( 1497 void PepperPluginDelegateImpl::OnTCPServerSocketListenACK(
1590 uint32 plugin_dispatcher_id, 1498 uint32 plugin_dispatcher_id,
1591 PP_Resource socket_resource, 1499 PP_Resource socket_resource,
1592 uint32 socket_id, 1500 uint32 socket_id,
1593 int32_t status) { 1501 int32_t status) {
1594 ppapi::thunk::EnterResource<ppapi::thunk::PPB_TCPServerSocket_Private_API> 1502 ppapi::thunk::EnterResource<ppapi::thunk::PPB_TCPServerSocket_Private_API>
1595 enter(socket_resource, true); 1503 enter(socket_resource, true);
1596 if (enter.succeeded()) { 1504 if (enter.succeeded()) {
1597 ppapi::PPB_TCPServerSocket_Shared* socket = 1505 ppapi::PPB_TCPServerSocket_Shared* socket =
1598 static_cast<ppapi::PPB_TCPServerSocket_Shared*>(enter.object()); 1506 static_cast<ppapi::PPB_TCPServerSocket_Shared*>(enter.object());
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1733 RenderWidgetFullscreenPepper* container = 1641 RenderWidgetFullscreenPepper* container =
1734 static_cast<RenderWidgetFullscreenPepper*>( 1642 static_cast<RenderWidgetFullscreenPepper*>(
1735 instance->fullscreen_container()); 1643 instance->fullscreen_container());
1736 return container->mouse_lock_dispatcher(); 1644 return container->mouse_lock_dispatcher();
1737 } else { 1645 } else {
1738 return render_view_->mouse_lock_dispatcher(); 1646 return render_view_->mouse_lock_dispatcher();
1739 } 1647 }
1740 } 1648 }
1741 1649
1742 } // namespace content 1650 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698