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

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: PPB_UDPSocket_Shared is merged to UDPSocketPrivateResource. PepperUDPSocketPrivateShared is merged … Created 7 years, 12 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_flash_impl.h" 89 #include "webkit/plugins/ppapi/ppb_flash_impl.h"
90 #include "webkit/plugins/ppapi/ppb_tcp_server_socket_private_impl.h" 90 #include "webkit/plugins/ppapi/ppb_tcp_server_socket_private_impl.h"
91 #include "webkit/plugins/ppapi/ppb_tcp_socket_private_impl.h" 91 #include "webkit/plugins/ppapi/ppb_tcp_socket_private_impl.h"
92 #include "webkit/plugins/ppapi/ppb_udp_socket_private_impl.h"
93 #include "webkit/plugins/ppapi/resource_helper.h" 92 #include "webkit/plugins/ppapi/resource_helper.h"
94 #include "webkit/plugins/webplugininfo.h" 93 #include "webkit/plugins/webplugininfo.h"
95 94
96 using WebKit::WebView; 95 using WebKit::WebView;
97 using WebKit::WebFrame; 96 using WebKit::WebFrame;
98 97
99 namespace content { 98 namespace content {
100 99
101 namespace { 100 namespace {
102 101
(...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 if (tcp_sockets_.Lookup(socket_id)) 1166 if (tcp_sockets_.Lookup(socket_id))
1168 tcp_sockets_.Remove(socket_id); 1167 tcp_sockets_.Remove(socket_id);
1169 } 1168 }
1170 1169
1171 void PepperPluginDelegateImpl::RegisterTCPSocket( 1170 void PepperPluginDelegateImpl::RegisterTCPSocket(
1172 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket, 1171 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket,
1173 uint32 socket_id) { 1172 uint32 socket_id) {
1174 tcp_sockets_.AddWithID(socket, socket_id); 1173 tcp_sockets_.AddWithID(socket, socket_id);
1175 } 1174 }
1176 1175
1177 uint32 PepperPluginDelegateImpl::UDPSocketCreate() {
1178 uint32 socket_id = 0;
1179 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Create(
1180 render_view_->routing_id(), 0, &socket_id));
1181 return socket_id;
1182 }
1183
1184 void PepperPluginDelegateImpl::UDPSocketSetBoolSocketFeature(
1185 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket,
1186 uint32 socket_id,
1187 int32_t name,
1188 bool value) {
1189 render_view_->Send(
1190 new PpapiHostMsg_PPBUDPSocket_SetBoolSocketFeature(
1191 render_view_->routing_id(), socket_id, name, value));
1192 }
1193
1194 void PepperPluginDelegateImpl::UDPSocketBind(
1195 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket,
1196 uint32 socket_id,
1197 const PP_NetAddress_Private& addr) {
1198 if (!udp_sockets_.Lookup(socket_id))
1199 udp_sockets_.AddWithID(socket, socket_id);
1200 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Bind(
1201 render_view_->routing_id(), socket_id, addr));
1202 }
1203
1204 void PepperPluginDelegateImpl::UDPSocketRecvFrom(uint32 socket_id,
1205 int32_t num_bytes) {
1206 DCHECK(udp_sockets_.Lookup(socket_id));
1207 render_view_->Send(
1208 new PpapiHostMsg_PPBUDPSocket_RecvFrom(socket_id, num_bytes));
1209 }
1210
1211 void PepperPluginDelegateImpl::UDPSocketSendTo(
1212 uint32 socket_id,
1213 const std::string& buffer,
1214 const PP_NetAddress_Private& net_addr) {
1215 DCHECK(udp_sockets_.Lookup(socket_id));
1216 render_view_->Send(
1217 new PpapiHostMsg_PPBUDPSocket_SendTo(render_view_->routing_id(),
1218 socket_id, buffer, net_addr));
1219 }
1220
1221 void PepperPluginDelegateImpl::UDPSocketClose(uint32 socket_id) {
1222 // There are no DCHECK(udp_sockets_.Lookup(socket_id)) because it
1223 // can be called before UDPSocketBind is called.
1224 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Close(socket_id));
1225 if (udp_sockets_.Lookup(socket_id))
1226 udp_sockets_.Remove(socket_id);
1227 }
1228
1229 void PepperPluginDelegateImpl::TCPServerSocketListen( 1176 void PepperPluginDelegateImpl::TCPServerSocketListen(
1230 PP_Resource socket_resource, 1177 PP_Resource socket_resource,
1231 const PP_NetAddress_Private& addr, 1178 const PP_NetAddress_Private& addr,
1232 int32_t backlog) { 1179 int32_t backlog) {
1233 render_view_->Send( 1180 render_view_->Send(
1234 new PpapiHostMsg_PPBTCPServerSocket_Listen( 1181 new PpapiHostMsg_PPBTCPServerSocket_Listen(
1235 render_view_->routing_id(), 0, socket_resource, addr, backlog)); 1182 render_view_->routing_id(), 0, socket_resource, addr, backlog));
1236 } 1183 }
1237 1184
1238 void PepperPluginDelegateImpl::TCPServerSocketAccept(uint32 server_socket_id) { 1185 void PepperPluginDelegateImpl::TCPServerSocketAccept(uint32 server_socket_id) {
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 1410
1464 bool PepperPluginDelegateImpl::OnMessageReceived(const IPC::Message& message) { 1411 bool PepperPluginDelegateImpl::OnMessageReceived(const IPC::Message& message) {
1465 bool handled = true; 1412 bool handled = true;
1466 IPC_BEGIN_MESSAGE_MAP(PepperPluginDelegateImpl, message) 1413 IPC_BEGIN_MESSAGE_MAP(PepperPluginDelegateImpl, message)
1467 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK, 1414 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK,
1468 OnTCPSocketConnectACK) 1415 OnTCPSocketConnectACK)
1469 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK, 1416 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK,
1470 OnTCPSocketSSLHandshakeACK) 1417 OnTCPSocketSSLHandshakeACK)
1471 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnTCPSocketReadACK) 1418 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnTCPSocketReadACK)
1472 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnTCPSocketWriteACK) 1419 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnTCPSocketWriteACK)
1473 IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_BindACK, OnUDPSocketBindACK)
1474 IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_RecvFromACK,
1475 OnUDPSocketRecvFromACK)
1476 IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_SendToACK, OnUDPSocketSendToACK)
1477 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_ListenACK, 1420 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_ListenACK,
1478 OnTCPServerSocketListenACK) 1421 OnTCPServerSocketListenACK)
1479 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_AcceptACK, 1422 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_AcceptACK,
1480 OnTCPServerSocketAcceptACK) 1423 OnTCPServerSocketAcceptACK)
1481 IPC_MESSAGE_HANDLER(PpapiMsg_PPBHostResolver_ResolveACK, 1424 IPC_MESSAGE_HANDLER(PpapiMsg_PPBHostResolver_ResolveACK,
1482 OnHostResolverResolveACK) 1425 OnHostResolverResolveACK)
1483 IPC_MESSAGE_UNHANDLED(handled = false) 1426 IPC_MESSAGE_UNHANDLED(handled = false)
1484 IPC_END_MESSAGE_MAP() 1427 IPC_END_MESSAGE_MAP()
1485 return handled; 1428 return handled;
1486 } 1429 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 void PepperPluginDelegateImpl::OnTCPSocketWriteACK(uint32 plugin_dispatcher_id, 1472 void PepperPluginDelegateImpl::OnTCPSocketWriteACK(uint32 plugin_dispatcher_id,
1530 uint32 socket_id, 1473 uint32 socket_id,
1531 bool succeeded, 1474 bool succeeded,
1532 int32_t bytes_written) { 1475 int32_t bytes_written) {
1533 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket = 1476 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket =
1534 tcp_sockets_.Lookup(socket_id); 1477 tcp_sockets_.Lookup(socket_id);
1535 if (socket) 1478 if (socket)
1536 socket->OnWriteCompleted(succeeded, bytes_written); 1479 socket->OnWriteCompleted(succeeded, bytes_written);
1537 } 1480 }
1538 1481
1539 void PepperPluginDelegateImpl::OnUDPSocketBindACK(
1540 uint32 plugin_dispatcher_id,
1541 uint32 socket_id,
1542 bool succeeded,
1543 const PP_NetAddress_Private& addr) {
1544 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket =
1545 udp_sockets_.Lookup(socket_id);
1546 if (socket)
1547 socket->OnBindCompleted(succeeded, addr);
1548 if (!succeeded)
1549 udp_sockets_.Remove(socket_id);
1550 }
1551
1552 void PepperPluginDelegateImpl::OnUDPSocketRecvFromACK(
1553 uint32 plugin_dispatcher_id,
1554 uint32 socket_id,
1555 bool succeeded,
1556 const std::string& data,
1557 const PP_NetAddress_Private& remote_addr) {
1558 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket =
1559 udp_sockets_.Lookup(socket_id);
1560 if (socket)
1561 socket->OnRecvFromCompleted(succeeded, data, remote_addr);
1562 }
1563
1564 void PepperPluginDelegateImpl::OnUDPSocketSendToACK(uint32 plugin_dispatcher_id,
1565 uint32 socket_id,
1566 bool succeeded,
1567 int32_t bytes_written) {
1568 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket =
1569 udp_sockets_.Lookup(socket_id);
1570 if (socket)
1571 socket->OnSendToCompleted(succeeded, bytes_written);
1572 }
1573
1574 void PepperPluginDelegateImpl::OnTCPServerSocketListenACK( 1482 void PepperPluginDelegateImpl::OnTCPServerSocketListenACK(
1575 uint32 plugin_dispatcher_id, 1483 uint32 plugin_dispatcher_id,
1576 PP_Resource socket_resource, 1484 PP_Resource socket_resource,
1577 uint32 socket_id, 1485 uint32 socket_id,
1578 int32_t status) { 1486 int32_t status) {
1579 ppapi::thunk::EnterResource<ppapi::thunk::PPB_TCPServerSocket_Private_API> 1487 ppapi::thunk::EnterResource<ppapi::thunk::PPB_TCPServerSocket_Private_API>
1580 enter(socket_resource, true); 1488 enter(socket_resource, true);
1581 if (enter.succeeded()) { 1489 if (enter.succeeded()) {
1582 ppapi::PPB_TCPServerSocket_Shared* socket = 1490 ppapi::PPB_TCPServerSocket_Shared* socket =
1583 static_cast<ppapi::PPB_TCPServerSocket_Shared*>(enter.object()); 1491 static_cast<ppapi::PPB_TCPServerSocket_Shared*>(enter.object());
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1718 RenderWidgetFullscreenPepper* container = 1626 RenderWidgetFullscreenPepper* container =
1719 static_cast<RenderWidgetFullscreenPepper*>( 1627 static_cast<RenderWidgetFullscreenPepper*>(
1720 instance->fullscreen_container()); 1628 instance->fullscreen_container());
1721 return container->mouse_lock_dispatcher(); 1629 return container->mouse_lock_dispatcher();
1722 } else { 1630 } else {
1723 return render_view_->mouse_lock_dispatcher(); 1631 return render_view_->mouse_lock_dispatcher();
1724 } 1632 }
1725 } 1633 }
1726 1634
1727 } // namespace content 1635 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698