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

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: Added data size check. 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 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 if (tcp_sockets_.Lookup(socket_id)) 1177 if (tcp_sockets_.Lookup(socket_id))
1179 tcp_sockets_.Remove(socket_id); 1178 tcp_sockets_.Remove(socket_id);
1180 } 1179 }
1181 1180
1182 void PepperPluginDelegateImpl::RegisterTCPSocket( 1181 void PepperPluginDelegateImpl::RegisterTCPSocket(
1183 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket, 1182 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket,
1184 uint32 socket_id) { 1183 uint32 socket_id) {
1185 tcp_sockets_.AddWithID(socket, socket_id); 1184 tcp_sockets_.AddWithID(socket, socket_id);
1186 } 1185 }
1187 1186
1188 uint32 PepperPluginDelegateImpl::UDPSocketCreate() {
1189 uint32 socket_id = 0;
1190 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Create(
1191 render_view_->routing_id(), 0, &socket_id));
1192 return socket_id;
1193 }
1194
1195 void PepperPluginDelegateImpl::UDPSocketSetBoolSocketFeature(
1196 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket,
1197 uint32 socket_id,
1198 int32_t name,
1199 bool value) {
1200 render_view_->Send(
1201 new PpapiHostMsg_PPBUDPSocket_SetBoolSocketFeature(
1202 render_view_->routing_id(), socket_id, name, value));
1203 }
1204
1205 void PepperPluginDelegateImpl::UDPSocketBind(
1206 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket,
1207 uint32 socket_id,
1208 const PP_NetAddress_Private& addr) {
1209 if (!udp_sockets_.Lookup(socket_id))
1210 udp_sockets_.AddWithID(socket, socket_id);
1211 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Bind(
1212 render_view_->routing_id(), socket_id, addr));
1213 }
1214
1215 void PepperPluginDelegateImpl::UDPSocketRecvFrom(uint32 socket_id,
1216 int32_t num_bytes) {
1217 DCHECK(udp_sockets_.Lookup(socket_id));
1218 render_view_->Send(
1219 new PpapiHostMsg_PPBUDPSocket_RecvFrom(socket_id, num_bytes));
1220 }
1221
1222 void PepperPluginDelegateImpl::UDPSocketSendTo(
1223 uint32 socket_id,
1224 const std::string& buffer,
1225 const PP_NetAddress_Private& net_addr) {
1226 DCHECK(udp_sockets_.Lookup(socket_id));
1227 render_view_->Send(
1228 new PpapiHostMsg_PPBUDPSocket_SendTo(render_view_->routing_id(),
1229 socket_id, buffer, net_addr));
1230 }
1231
1232 void PepperPluginDelegateImpl::UDPSocketClose(uint32 socket_id) {
1233 // There are no DCHECK(udp_sockets_.Lookup(socket_id)) because it
1234 // can be called before UDPSocketBind is called.
1235 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Close(socket_id));
1236 if (udp_sockets_.Lookup(socket_id))
1237 udp_sockets_.Remove(socket_id);
1238 }
1239
1240 void PepperPluginDelegateImpl::TCPServerSocketListen( 1187 void PepperPluginDelegateImpl::TCPServerSocketListen(
1241 PP_Resource socket_resource, 1188 PP_Resource socket_resource,
1242 const PP_NetAddress_Private& addr, 1189 const PP_NetAddress_Private& addr,
1243 int32_t backlog) { 1190 int32_t backlog) {
1244 render_view_->Send( 1191 render_view_->Send(
1245 new PpapiHostMsg_PPBTCPServerSocket_Listen( 1192 new PpapiHostMsg_PPBTCPServerSocket_Listen(
1246 render_view_->routing_id(), 0, socket_resource, addr, backlog)); 1193 render_view_->routing_id(), 0, socket_resource, addr, backlog));
1247 } 1194 }
1248 1195
1249 void PepperPluginDelegateImpl::TCPServerSocketAccept(uint32 server_socket_id) { 1196 void PepperPluginDelegateImpl::TCPServerSocketAccept(uint32 server_socket_id) {
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1474 1421
1475 bool PepperPluginDelegateImpl::OnMessageReceived(const IPC::Message& message) { 1422 bool PepperPluginDelegateImpl::OnMessageReceived(const IPC::Message& message) {
1476 bool handled = true; 1423 bool handled = true;
1477 IPC_BEGIN_MESSAGE_MAP(PepperPluginDelegateImpl, message) 1424 IPC_BEGIN_MESSAGE_MAP(PepperPluginDelegateImpl, message)
1478 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK, 1425 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK,
1479 OnTCPSocketConnectACK) 1426 OnTCPSocketConnectACK)
1480 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK, 1427 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK,
1481 OnTCPSocketSSLHandshakeACK) 1428 OnTCPSocketSSLHandshakeACK)
1482 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnTCPSocketReadACK) 1429 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnTCPSocketReadACK)
1483 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnTCPSocketWriteACK) 1430 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnTCPSocketWriteACK)
1484 IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_BindACK, OnUDPSocketBindACK)
1485 IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_RecvFromACK,
1486 OnUDPSocketRecvFromACK)
1487 IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_SendToACK, OnUDPSocketSendToACK)
1488 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_ListenACK, 1431 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_ListenACK,
1489 OnTCPServerSocketListenACK) 1432 OnTCPServerSocketListenACK)
1490 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_AcceptACK, 1433 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_AcceptACK,
1491 OnTCPServerSocketAcceptACK) 1434 OnTCPServerSocketAcceptACK)
1492 IPC_MESSAGE_HANDLER(PpapiMsg_PPBHostResolver_ResolveACK, 1435 IPC_MESSAGE_HANDLER(PpapiMsg_PPBHostResolver_ResolveACK,
1493 OnHostResolverResolveACK) 1436 OnHostResolverResolveACK)
1494 IPC_MESSAGE_UNHANDLED(handled = false) 1437 IPC_MESSAGE_UNHANDLED(handled = false)
1495 IPC_END_MESSAGE_MAP() 1438 IPC_END_MESSAGE_MAP()
1496 return handled; 1439 return handled;
1497 } 1440 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1540 void PepperPluginDelegateImpl::OnTCPSocketWriteACK(uint32 plugin_dispatcher_id, 1483 void PepperPluginDelegateImpl::OnTCPSocketWriteACK(uint32 plugin_dispatcher_id,
1541 uint32 socket_id, 1484 uint32 socket_id,
1542 bool succeeded, 1485 bool succeeded,
1543 int32_t bytes_written) { 1486 int32_t bytes_written) {
1544 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket = 1487 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket =
1545 tcp_sockets_.Lookup(socket_id); 1488 tcp_sockets_.Lookup(socket_id);
1546 if (socket) 1489 if (socket)
1547 socket->OnWriteCompleted(succeeded, bytes_written); 1490 socket->OnWriteCompleted(succeeded, bytes_written);
1548 } 1491 }
1549 1492
1550 void PepperPluginDelegateImpl::OnUDPSocketBindACK(
1551 uint32 plugin_dispatcher_id,
1552 uint32 socket_id,
1553 bool succeeded,
1554 const PP_NetAddress_Private& addr) {
1555 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket =
1556 udp_sockets_.Lookup(socket_id);
1557 if (socket)
1558 socket->OnBindCompleted(succeeded, addr);
1559 if (!succeeded)
1560 udp_sockets_.Remove(socket_id);
1561 }
1562
1563 void PepperPluginDelegateImpl::OnUDPSocketRecvFromACK(
1564 uint32 plugin_dispatcher_id,
1565 uint32 socket_id,
1566 bool succeeded,
1567 const std::string& data,
1568 const PP_NetAddress_Private& remote_addr) {
1569 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket =
1570 udp_sockets_.Lookup(socket_id);
1571 if (socket)
1572 socket->OnRecvFromCompleted(succeeded, data, remote_addr);
1573 }
1574
1575 void PepperPluginDelegateImpl::OnUDPSocketSendToACK(uint32 plugin_dispatcher_id,
1576 uint32 socket_id,
1577 bool succeeded,
1578 int32_t bytes_written) {
1579 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket =
1580 udp_sockets_.Lookup(socket_id);
1581 if (socket)
1582 socket->OnSendToCompleted(succeeded, bytes_written);
1583 }
1584
1585 void PepperPluginDelegateImpl::OnTCPServerSocketListenACK( 1493 void PepperPluginDelegateImpl::OnTCPServerSocketListenACK(
1586 uint32 plugin_dispatcher_id, 1494 uint32 plugin_dispatcher_id,
1587 PP_Resource socket_resource, 1495 PP_Resource socket_resource,
1588 uint32 socket_id, 1496 uint32 socket_id,
1589 int32_t status) { 1497 int32_t status) {
1590 ppapi::thunk::EnterResource<ppapi::thunk::PPB_TCPServerSocket_Private_API> 1498 ppapi::thunk::EnterResource<ppapi::thunk::PPB_TCPServerSocket_Private_API>
1591 enter(socket_resource, true); 1499 enter(socket_resource, true);
1592 if (enter.succeeded()) { 1500 if (enter.succeeded()) {
1593 ppapi::PPB_TCPServerSocket_Shared* socket = 1501 ppapi::PPB_TCPServerSocket_Shared* socket =
1594 static_cast<ppapi::PPB_TCPServerSocket_Shared*>(enter.object()); 1502 static_cast<ppapi::PPB_TCPServerSocket_Shared*>(enter.object());
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1729 RenderWidgetFullscreenPepper* container = 1637 RenderWidgetFullscreenPepper* container =
1730 static_cast<RenderWidgetFullscreenPepper*>( 1638 static_cast<RenderWidgetFullscreenPepper*>(
1731 instance->fullscreen_container()); 1639 instance->fullscreen_container());
1732 return container->mouse_lock_dispatcher(); 1640 return container->mouse_lock_dispatcher();
1733 } else { 1641 } else {
1734 return render_view_->mouse_lock_dispatcher(); 1642 return render_view_->mouse_lock_dispatcher();
1735 } 1643 }
1736 } 1644 }
1737 1645
1738 } // namespace content 1646 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698