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

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

Issue 19005006: Switched proxy for TCPServerSocketPrivate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed content_unittests. Created 7 years, 5 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 #include "third_party/WebKit/public/web/WebInputEvent.h" 91 #include "third_party/WebKit/public/web/WebInputEvent.h"
92 #include "third_party/WebKit/public/web/WebPluginContainer.h" 92 #include "third_party/WebKit/public/web/WebPluginContainer.h"
93 #include "third_party/WebKit/public/web/WebScreenInfo.h" 93 #include "third_party/WebKit/public/web/WebScreenInfo.h"
94 #include "third_party/WebKit/public/web/WebView.h" 94 #include "third_party/WebKit/public/web/WebView.h"
95 #include "ui/gfx/size.h" 95 #include "ui/gfx/size.h"
96 #include "url/gurl.h" 96 #include "url/gurl.h"
97 #include "webkit/plugins/npapi/webplugin.h" 97 #include "webkit/plugins/npapi/webplugin.h"
98 #include "webkit/plugins/ppapi/plugin_module.h" 98 #include "webkit/plugins/ppapi/plugin_module.h"
99 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 99 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
100 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" 100 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h"
101 #include "webkit/plugins/ppapi/ppb_tcp_server_socket_private_impl.h"
102 #include "webkit/plugins/ppapi/ppb_tcp_socket_private_impl.h" 101 #include "webkit/plugins/ppapi/ppb_tcp_socket_private_impl.h"
103 #include "webkit/plugins/ppapi/resource_helper.h" 102 #include "webkit/plugins/ppapi/resource_helper.h"
104 #include "webkit/plugins/webplugininfo.h" 103 #include "webkit/plugins/webplugininfo.h"
105 104
106 using WebKit::WebView; 105 using WebKit::WebView;
107 using WebKit::WebFrame; 106 using WebKit::WebFrame;
108 107
109 namespace content { 108 namespace content {
110 109
111 namespace { 110 namespace {
(...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 render_view_->Send( 1216 render_view_->Send(
1218 new PpapiHostMsg_PPBTCPSocket_SetOption(socket_id, name, value)); 1217 new PpapiHostMsg_PPBTCPSocket_SetOption(socket_id, name, value));
1219 } 1218 }
1220 1219
1221 void PepperPluginDelegateImpl::RegisterTCPSocket( 1220 void PepperPluginDelegateImpl::RegisterTCPSocket(
1222 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket, 1221 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket,
1223 uint32 socket_id) { 1222 uint32 socket_id) {
1224 tcp_sockets_.AddWithID(socket, socket_id); 1223 tcp_sockets_.AddWithID(socket, socket_id);
1225 } 1224 }
1226 1225
1227 void PepperPluginDelegateImpl::TCPServerSocketListen(
1228 PP_Resource socket_resource,
1229 const PP_NetAddress_Private& addr,
1230 int32_t backlog) {
1231 render_view_->Send(
1232 new PpapiHostMsg_PPBTCPServerSocket_Listen(
1233 render_view_->routing_id(), 0, socket_resource, addr, backlog));
1234 }
1235
1236 void PepperPluginDelegateImpl::TCPServerSocketAccept(uint32 server_socket_id) {
1237 DCHECK(tcp_server_sockets_.Lookup(server_socket_id));
1238 render_view_->Send(new PpapiHostMsg_PPBTCPServerSocket_Accept(
1239 render_view_->routing_id(), server_socket_id));
1240 }
1241
1242 void PepperPluginDelegateImpl::TCPServerSocketStopListening(
1243 PP_Resource socket_resource,
1244 uint32 socket_id) {
1245 if (socket_id != 0) {
1246 render_view_->Send(new PpapiHostMsg_PPBTCPServerSocket_Destroy(socket_id));
1247 tcp_server_sockets_.Remove(socket_id);
1248 }
1249 }
1250
1251 bool PepperPluginDelegateImpl::AddNetworkListObserver( 1226 bool PepperPluginDelegateImpl::AddNetworkListObserver(
1252 webkit_glue::NetworkListObserver* observer) { 1227 webkit_glue::NetworkListObserver* observer) {
1253 #if defined(ENABLE_WEBRTC) 1228 #if defined(ENABLE_WEBRTC)
1254 P2PSocketDispatcher* socket_dispatcher = 1229 P2PSocketDispatcher* socket_dispatcher =
1255 RenderThreadImpl::current()->p2p_socket_dispatcher(); 1230 RenderThreadImpl::current()->p2p_socket_dispatcher();
1256 if (!socket_dispatcher) { 1231 if (!socket_dispatcher) {
1257 return false; 1232 return false;
1258 } 1233 }
1259 socket_dispatcher->AddNetworkListObserver(observer); 1234 socket_dispatcher->AddNetworkListObserver(observer);
1260 return true; 1235 return true;
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1488 bool handled = true; 1463 bool handled = true;
1489 IPC_BEGIN_MESSAGE_MAP(PepperPluginDelegateImpl, message) 1464 IPC_BEGIN_MESSAGE_MAP(PepperPluginDelegateImpl, message)
1490 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK, 1465 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK,
1491 OnTCPSocketConnectACK) 1466 OnTCPSocketConnectACK)
1492 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK, 1467 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK,
1493 OnTCPSocketSSLHandshakeACK) 1468 OnTCPSocketSSLHandshakeACK)
1494 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnTCPSocketReadACK) 1469 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnTCPSocketReadACK)
1495 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnTCPSocketWriteACK) 1470 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnTCPSocketWriteACK)
1496 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SetOptionACK, 1471 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SetOptionACK,
1497 OnTCPSocketSetOptionACK) 1472 OnTCPSocketSetOptionACK)
1498 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_ListenACK,
1499 OnTCPServerSocketListenACK)
1500 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_AcceptACK,
1501 OnTCPServerSocketAcceptACK)
1502 IPC_MESSAGE_UNHANDLED(handled = false) 1473 IPC_MESSAGE_UNHANDLED(handled = false)
1503 IPC_END_MESSAGE_MAP() 1474 IPC_END_MESSAGE_MAP()
1504 return handled; 1475 return handled;
1505 } 1476 }
1506 1477
1507 void PepperPluginDelegateImpl::OnDestruct() { 1478 void PepperPluginDelegateImpl::OnDestruct() {
1508 // Nothing to do here. Default implementation in RenderViewObserver does 1479 // Nothing to do here. Default implementation in RenderViewObserver does
1509 // 'delete this' but it's not suitable for PepperPluginDelegateImpl because 1480 // 'delete this' but it's not suitable for PepperPluginDelegateImpl because
1510 // it's non-pointer member in RenderViewImpl. 1481 // it's non-pointer member in RenderViewImpl.
1511 } 1482 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 void PepperPluginDelegateImpl::OnTCPSocketSetOptionACK( 1528 void PepperPluginDelegateImpl::OnTCPSocketSetOptionACK(
1558 uint32 plugin_dispatcher_id, 1529 uint32 plugin_dispatcher_id,
1559 uint32 socket_id, 1530 uint32 socket_id,
1560 int32_t result) { 1531 int32_t result) {
1561 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket = 1532 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket =
1562 tcp_sockets_.Lookup(socket_id); 1533 tcp_sockets_.Lookup(socket_id);
1563 if (socket) 1534 if (socket)
1564 socket->OnSetOptionCompleted(result); 1535 socket->OnSetOptionCompleted(result);
1565 } 1536 }
1566 1537
1567 void PepperPluginDelegateImpl::OnTCPServerSocketListenACK(
1568 uint32 plugin_dispatcher_id,
1569 PP_Resource socket_resource,
1570 uint32 socket_id,
1571 const PP_NetAddress_Private& local_addr,
1572 int32_t status) {
1573 ppapi::thunk::EnterResource<ppapi::thunk::PPB_TCPServerSocket_Private_API>
1574 enter(socket_resource, true);
1575 if (enter.succeeded()) {
1576 ppapi::PPB_TCPServerSocket_Shared* socket =
1577 static_cast<ppapi::PPB_TCPServerSocket_Shared*>(enter.object());
1578 if (status == PP_OK)
1579 tcp_server_sockets_.AddWithID(socket, socket_id);
1580 socket->OnListenCompleted(socket_id, local_addr, status);
1581 } else if (socket_id != 0 && status == PP_OK) {
1582 // StopListening was called before completion of Listen.
1583 render_view_->Send(new PpapiHostMsg_PPBTCPServerSocket_Destroy(socket_id));
1584 }
1585 }
1586
1587 void PepperPluginDelegateImpl::OnTCPServerSocketAcceptACK(
1588 uint32 plugin_dispatcher_id,
1589 uint32 server_socket_id,
1590 uint32 accepted_socket_id,
1591 const PP_NetAddress_Private& local_addr,
1592 const PP_NetAddress_Private& remote_addr) {
1593 ppapi::PPB_TCPServerSocket_Shared* socket =
1594 tcp_server_sockets_.Lookup(server_socket_id);
1595 if (socket) {
1596 bool succeeded = (accepted_socket_id != 0);
1597 socket->OnAcceptCompleted(succeeded,
1598 accepted_socket_id,
1599 local_addr,
1600 remote_addr);
1601 } else if (accepted_socket_id != 0) {
1602 render_view_->Send(
1603 new PpapiHostMsg_PPBTCPSocket_Disconnect(accepted_socket_id));
1604 }
1605 }
1606
1607 int PepperPluginDelegateImpl::GetRoutingID() const { 1538 int PepperPluginDelegateImpl::GetRoutingID() const {
1608 return render_view_->routing_id(); 1539 return render_view_->routing_id();
1609 } 1540 }
1610 1541
1611 int PepperPluginDelegateImpl::OpenDevice(PP_DeviceType_Dev type, 1542 int PepperPluginDelegateImpl::OpenDevice(PP_DeviceType_Dev type,
1612 const std::string& device_id, 1543 const std::string& device_id,
1613 const GURL& document_url, 1544 const GURL& document_url,
1614 const OpenDeviceCallback& callback) { 1545 const OpenDeviceCallback& callback) {
1615 int request_id = 1546 int request_id =
1616 device_enumeration_event_handler_->RegisterOpenDeviceCallback(callback); 1547 device_enumeration_event_handler_->RegisterOpenDeviceCallback(callback);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1702 should_close_source); 1633 should_close_source);
1703 } 1634 }
1704 1635
1705 bool PepperPluginDelegateImpl::IsRunningInProcess(PP_Instance instance) const { 1636 bool PepperPluginDelegateImpl::IsRunningInProcess(PP_Instance instance) const {
1706 RendererPpapiHostImpl* host = 1637 RendererPpapiHostImpl* host =
1707 RendererPpapiHostImpl::GetForPPInstance(instance); 1638 RendererPpapiHostImpl::GetForPPInstance(instance);
1708 return host && host->IsRunningInProcess(); 1639 return host && host->IsRunningInProcess();
1709 } 1640 }
1710 1641
1711 } // namespace content 1642 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698