OLD | NEW |
---|---|
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_helper_impl.h" | 5 #include "content/renderer/pepper/pepper_helper_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> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
16 #include "base/files/file_util_proxy.h" | |
17 #include "base/logging.h" | 16 #include "base/logging.h" |
18 #include "base/platform_file.h" | 17 #include "base/platform_file.h" |
19 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
20 #include "base/sync_socket.h" | 19 #include "base/sync_socket.h" |
21 #include "base/time/time.h" | 20 #include "base/time/time.h" |
22 #include "content/child/child_process.h" | 21 #include "content/child/child_process.h" |
23 #include "content/child/npapi/webplugin.h" | 22 #include "content/child/npapi/webplugin.h" |
24 #include "content/common/child_process_messages.h" | 23 #include "content/common/child_process_messages.h" |
25 #include "content/common/gpu/client/context_provider_command_buffer.h" | 24 #include "content/common/gpu/client/context_provider_command_buffer.h" |
26 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 25 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
27 #include "content/common/pepper_messages.h" | 26 #include "content/common/pepper_messages.h" |
28 #include "content/common/view_messages.h" | 27 #include "content/common/view_messages.h" |
29 #include "content/public/common/content_switches.h" | 28 #include "content/public/common/content_switches.h" |
30 #include "content/public/common/context_menu_params.h" | 29 #include "content/public/common/context_menu_params.h" |
31 #include "content/public/common/media_stream_request.h" | 30 #include "content/public/common/media_stream_request.h" |
32 #include "content/public/common/page_zoom.h" | 31 #include "content/public/common/page_zoom.h" |
33 #include "content/public/common/referrer.h" | 32 #include "content/public/common/referrer.h" |
34 #include "content/public/common/webplugininfo.h" | 33 #include "content/public/common/webplugininfo.h" |
35 #include "content/public/renderer/content_renderer_client.h" | 34 #include "content/public/renderer/content_renderer_client.h" |
36 #include "content/renderer/gamepad_shared_memory_reader.h" | 35 #include "content/renderer/gamepad_shared_memory_reader.h" |
37 #include "content/renderer/media/media_stream_dispatcher.h" | 36 #include "content/renderer/media/media_stream_dispatcher.h" |
38 #include "content/renderer/p2p/socket_dispatcher.h" | 37 #include "content/renderer/p2p/socket_dispatcher.h" |
39 #include "content/renderer/pepper/content_renderer_pepper_host_factory.h" | 38 #include "content/renderer/pepper/content_renderer_pepper_host_factory.h" |
40 #include "content/renderer/pepper/host_dispatcher_wrapper.h" | 39 #include "content/renderer/pepper/host_dispatcher_wrapper.h" |
40 #include "content/renderer/pepper/host_globals.h" | |
41 #include "content/renderer/pepper/pepper_broker.h" | 41 #include "content/renderer/pepper/pepper_broker.h" |
42 #include "content/renderer/pepper/pepper_browser_connection.h" | 42 #include "content/renderer/pepper/pepper_browser_connection.h" |
43 #include "content/renderer/pepper/pepper_file_system_host.h" | 43 #include "content/renderer/pepper/pepper_file_system_host.h" |
44 #include "content/renderer/pepper/pepper_graphics_2d_host.h" | 44 #include "content/renderer/pepper/pepper_graphics_2d_host.h" |
45 #include "content/renderer/pepper/pepper_hung_plugin_filter.h" | 45 #include "content/renderer/pepper/pepper_hung_plugin_filter.h" |
46 #include "content/renderer/pepper/pepper_in_process_resource_creation.h" | 46 #include "content/renderer/pepper/pepper_in_process_resource_creation.h" |
47 #include "content/renderer/pepper/pepper_in_process_router.h" | 47 #include "content/renderer/pepper/pepper_in_process_router.h" |
48 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 48 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
49 #include "content/renderer/pepper/pepper_plugin_registry.h" | 49 #include "content/renderer/pepper/pepper_plugin_registry.h" |
50 #include "content/renderer/pepper/pepper_url_loader_host.h" | 50 #include "content/renderer/pepper/pepper_url_loader_host.h" |
51 #include "content/renderer/pepper/pepper_webplugin_impl.h" | 51 #include "content/renderer/pepper/pepper_webplugin_impl.h" |
52 #include "content/renderer/pepper/plugin_module.h" | 52 #include "content/renderer/pepper/plugin_module.h" |
53 #include "content/renderer/pepper/ppb_tcp_server_socket_private_impl.h" | 53 #include "content/renderer/pepper/ppb_tcp_server_socket_private_impl.h" |
54 #include "content/renderer/pepper/ppb_tcp_socket_private_impl.h" | 54 #include "content/renderer/pepper/ppb_tcp_socket_private_impl.h" |
55 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 55 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
56 #include "content/renderer/pepper/resource_helper.h" | |
57 #include "content/renderer/pepper/url_response_info_util.h" | 56 #include "content/renderer/pepper/url_response_info_util.h" |
58 #include "content/renderer/render_thread_impl.h" | 57 #include "content/renderer/render_thread_impl.h" |
59 #include "content/renderer/render_view_impl.h" | 58 #include "content/renderer/render_view_impl.h" |
60 #include "content/renderer/render_widget_fullscreen_pepper.h" | 59 #include "content/renderer/render_widget_fullscreen_pepper.h" |
61 #include "content/renderer/webplugin_delegate_proxy.h" | 60 #include "content/renderer/webplugin_delegate_proxy.h" |
62 #include "ipc/ipc_channel_handle.h" | 61 #include "ipc/ipc_channel_handle.h" |
63 #include "ipc/ipc_platform_file.h" | 62 #include "ipc/ipc_platform_file.h" |
64 #include "media/video/capture/video_capture_proxy.h" | 63 #include "media/video/capture/video_capture_proxy.h" |
65 #include "ppapi/c/dev/pp_video_dev.h" | 64 #include "ppapi/c/dev/pp_video_dev.h" |
66 #include "ppapi/c/pp_errors.h" | 65 #include "ppapi/c/pp_errors.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 RendererPpapiHostImpl::CreateOnModuleForInProcess( | 106 RendererPpapiHostImpl::CreateOnModuleForInProcess( |
108 module, perms); | 107 module, perms); |
109 render_view->PpapiPluginCreated(host_impl); | 108 render_view->PpapiPluginCreated(host_impl); |
110 } | 109 } |
111 | 110 |
112 } // namespace | 111 } // namespace |
113 | 112 |
114 PepperHelperImpl::PepperHelperImpl(RenderViewImpl* render_view) | 113 PepperHelperImpl::PepperHelperImpl(RenderViewImpl* render_view) |
115 : RenderViewObserver(render_view), | 114 : RenderViewObserver(render_view), |
116 render_view_(render_view), | 115 render_view_(render_view), |
117 pepper_browser_connection_(this), | |
118 focused_plugin_(NULL), | 116 focused_plugin_(NULL), |
119 last_mouse_event_target_(NULL) { | 117 last_mouse_event_target_(NULL) { |
118 new PepperBrowserConnection(render_view); | |
scottmg
2013/08/01 02:45:02
why allocated and leaked now instead of contained?
jam
2013/08/01 06:53:35
this is a RenderViewObserver which deletes itself
| |
120 } | 119 } |
121 | 120 |
122 PepperHelperImpl::~PepperHelperImpl() { | 121 PepperHelperImpl::~PepperHelperImpl() { |
123 } | 122 } |
124 | 123 |
125 WebKit::WebPlugin* PepperHelperImpl::CreatePepperWebPlugin( | 124 WebKit::WebPlugin* PepperHelperImpl::CreatePepperWebPlugin( |
126 const WebPluginInfo& webplugin_info, | 125 const WebPluginInfo& webplugin_info, |
127 const WebKit::WebPluginParams& params) { | 126 const WebKit::WebPluginParams& params) { |
128 bool pepper_plugin_was_registered = false; | 127 bool pepper_plugin_was_registered = false; |
129 scoped_refptr<PluginModule> pepper_module( | 128 scoped_refptr<PluginModule> pepper_module( |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
500 last_mouse_event_target_ = NULL; | 499 last_mouse_event_target_ = NULL; |
501 if (focused_plugin_ == instance) | 500 if (focused_plugin_ == instance) |
502 PluginFocusChanged(instance, false); | 501 PluginFocusChanged(instance, false); |
503 } | 502 } |
504 | 503 |
505 // If a broker has not already been created for this plugin, creates one. | 504 // If a broker has not already been created for this plugin, creates one. |
506 PepperBroker* PepperHelperImpl::ConnectToBroker( | 505 PepperBroker* PepperHelperImpl::ConnectToBroker( |
507 PPB_Broker_Impl* client) { | 506 PPB_Broker_Impl* client) { |
508 DCHECK(client); | 507 DCHECK(client); |
509 | 508 |
510 PluginModule* plugin_module = ResourceHelper::GetPluginModule(client); | 509 PluginModule* plugin_module = |
510 HostGlobals::Get()->GetInstance(client->pp_instance())->module(); | |
511 if (!plugin_module) | 511 if (!plugin_module) |
512 return NULL; | 512 return NULL; |
513 | 513 |
514 scoped_refptr<PepperBroker> broker = | 514 scoped_refptr<PepperBroker> broker = |
515 static_cast<PepperBroker*>(plugin_module->GetBroker()); | 515 static_cast<PepperBroker*>(plugin_module->GetBroker()); |
516 if (!broker.get()) | 516 if (!broker.get()) |
517 broker = CreateBroker(plugin_module); | 517 broker = CreateBroker(plugin_module); |
518 | 518 |
519 int request_id = pending_permission_requests_.Add( | 519 int request_id = pending_permission_requests_.Add( |
520 new base::WeakPtr<PPB_Broker_Impl>(client->AsWeakPtr())); | 520 new base::WeakPtr<PPB_Broker_Impl>(client->AsWeakPtr())); |
(...skipping 13 matching lines...) Expand all Loading... | |
534 void PepperHelperImpl::OnPpapiBrokerPermissionResult(int request_id, | 534 void PepperHelperImpl::OnPpapiBrokerPermissionResult(int request_id, |
535 bool result) { | 535 bool result) { |
536 scoped_ptr<base::WeakPtr<PPB_Broker_Impl> > client_ptr( | 536 scoped_ptr<base::WeakPtr<PPB_Broker_Impl> > client_ptr( |
537 pending_permission_requests_.Lookup(request_id)); | 537 pending_permission_requests_.Lookup(request_id)); |
538 DCHECK(client_ptr.get()); | 538 DCHECK(client_ptr.get()); |
539 pending_permission_requests_.Remove(request_id); | 539 pending_permission_requests_.Remove(request_id); |
540 base::WeakPtr<PPB_Broker_Impl> client = *client_ptr; | 540 base::WeakPtr<PPB_Broker_Impl> client = *client_ptr; |
541 if (!client.get()) | 541 if (!client.get()) |
542 return; | 542 return; |
543 | 543 |
544 PluginModule* plugin_module = ResourceHelper::GetPluginModule(client.get()); | 544 PluginModule* plugin_module = |
545 HostGlobals::Get()->GetInstance(client->pp_instance())->module(); | |
545 if (!plugin_module) | 546 if (!plugin_module) |
546 return; | 547 return; |
547 | 548 |
548 PepperBroker* broker = static_cast<PepperBroker*>(plugin_module->GetBroker()); | 549 PepperBroker* broker = static_cast<PepperBroker*>(plugin_module->GetBroker()); |
549 broker->OnBrokerPermissionResult(client.get(), result); | 550 broker->OnBrokerPermissionResult(client.get(), result); |
550 } | 551 } |
551 | 552 |
552 bool PepperHelperImpl::AsyncOpenFile(const base::FilePath& path, | |
553 int flags, | |
554 const AsyncOpenFileCallback& callback) { | |
555 int message_id = pending_async_open_files_.Add( | |
556 new AsyncOpenFileCallback(callback)); | |
557 return Send(new ViewHostMsg_AsyncOpenFile( | |
558 routing_id(), path, flags, message_id)); | |
559 } | |
560 | |
561 void PepperHelperImpl::OnAsyncFileOpened( | |
562 base::PlatformFileError error_code, | |
563 IPC::PlatformFileForTransit file_for_transit, | |
564 int message_id) { | |
565 AsyncOpenFileCallback* callback = | |
566 pending_async_open_files_.Lookup(message_id); | |
567 DCHECK(callback); | |
568 pending_async_open_files_.Remove(message_id); | |
569 | |
570 base::PlatformFile file = | |
571 IPC::PlatformFileForTransitToPlatformFile(file_for_transit); | |
572 callback->Run(error_code, base::PassPlatformFile(&file)); | |
573 // Make sure we won't leak file handle if the requester has died. | |
574 if (file != base::kInvalidPlatformFileValue) { | |
575 base::FileUtilProxy::Close( | |
576 RenderThreadImpl::current()->GetFileThreadMessageLoopProxy().get(), | |
577 file, | |
578 base::FileUtilProxy::StatusCallback()); | |
579 } | |
580 delete callback; | |
581 } | |
582 | |
583 void PepperHelperImpl::OnSetFocus(bool has_focus) { | 553 void PepperHelperImpl::OnSetFocus(bool has_focus) { |
584 for (std::set<PepperPluginInstanceImpl*>::iterator i = | 554 for (std::set<PepperPluginInstanceImpl*>::iterator i = |
585 active_instances_.begin(); | 555 active_instances_.begin(); |
586 i != active_instances_.end(); ++i) | 556 i != active_instances_.end(); ++i) |
587 (*i)->SetContentAreaFocus(has_focus); | 557 (*i)->SetContentAreaFocus(has_focus); |
588 } | 558 } |
589 | 559 |
590 void PepperHelperImpl::PageVisibilityChanged(bool is_visible) { | 560 void PepperHelperImpl::PageVisibilityChanged(bool is_visible) { |
591 for (std::set<PepperPluginInstanceImpl*>::iterator i = | 561 for (std::set<PepperPluginInstanceImpl*>::iterator i = |
592 active_instances_.begin(); | 562 active_instances_.begin(); |
593 i != active_instances_.end(); ++i) | 563 i != active_instances_.end(); ++i) |
594 (*i)->PageVisibilityChanged(is_visible); | 564 (*i)->PageVisibilityChanged(is_visible); |
595 } | 565 } |
596 | 566 |
597 bool PepperHelperImpl::IsPluginFocused() const { | 567 bool PepperHelperImpl::IsPluginFocused() const { |
598 return focused_plugin_ != NULL; | 568 return focused_plugin_ != NULL; |
599 } | 569 } |
600 | 570 |
601 void PepperHelperImpl::WillHandleMouseEvent() { | 571 void PepperHelperImpl::WillHandleMouseEvent() { |
602 // This method is called for every mouse event that the render view receives. | 572 // This method is called for every mouse event that the render view receives. |
603 // And then the mouse event is forwarded to WebKit, which dispatches it to the | 573 // And then the mouse event is forwarded to WebKit, which dispatches it to the |
604 // event target. Potentially a Pepper plugin will receive the event. | 574 // event target. Potentially a Pepper plugin will receive the event. |
605 // In order to tell whether a plugin gets the last mouse event and which it | 575 // In order to tell whether a plugin gets the last mouse event and which it |
606 // is, we set |last_mouse_event_target_| to NULL here. If a plugin gets the | 576 // is, we set |last_mouse_event_target_| to NULL here. If a plugin gets the |
607 // event, it will notify us via DidReceiveMouseEvent() and set itself as | 577 // event, it will notify us via DidReceiveMouseEvent() and set itself as |
608 // |last_mouse_event_target_|. | 578 // |last_mouse_event_target_|. |
609 last_mouse_event_target_ = NULL; | 579 last_mouse_event_target_ = NULL; |
610 } | 580 } |
611 | 581 |
612 void PepperHelperImpl::RegisterTCPSocket( | |
613 PPB_TCPSocket_Private_Impl* socket, | |
614 uint32 socket_id) { | |
615 tcp_sockets_.AddWithID(socket, socket_id); | |
616 } | |
617 | |
618 void PepperHelperImpl::UnregisterTCPSocket(uint32 socket_id) { | |
619 // There is no DCHECK(tcp_sockets_.Lookup(socket_id)) because this method | |
620 // can be called before TCPSocketConnect or TCPSocketConnectWithNetAddress. | |
621 if (tcp_sockets_.Lookup(socket_id)) | |
622 tcp_sockets_.Remove(socket_id); | |
623 } | |
624 | |
625 void PepperHelperImpl::TCPServerSocketStopListening(uint32 socket_id) { | |
626 tcp_server_sockets_.Remove(socket_id); | |
627 } | |
628 | |
629 void PepperHelperImpl::HandleDocumentLoad( | 582 void PepperHelperImpl::HandleDocumentLoad( |
630 PepperPluginInstanceImpl* instance, | 583 PepperPluginInstanceImpl* instance, |
631 const WebKit::WebURLResponse& response) { | 584 const WebKit::WebURLResponse& response) { |
632 DCHECK(!instance->document_loader()); | 585 DCHECK(!instance->document_loader()); |
633 | 586 |
634 PP_Instance pp_instance = instance->pp_instance(); | 587 PP_Instance pp_instance = instance->pp_instance(); |
635 RendererPpapiHostImpl* host_impl = instance->module()->renderer_ppapi_host(); | 588 RendererPpapiHostImpl* host_impl = instance->module()->renderer_ppapi_host(); |
636 | 589 |
637 // Create a loader resource host for this load. Note that we have to set | 590 // Create a loader resource host for this load. Note that we have to set |
638 // the document_loader before issuing the in-process | 591 // the document_loader before issuing the in-process |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
717 last_mouse_event_target_ = instance; | 670 last_mouse_event_target_ = instance; |
718 } | 671 } |
719 | 672 |
720 void PepperHelperImpl::SampleGamepads(WebKit::WebGamepads* data) { | 673 void PepperHelperImpl::SampleGamepads(WebKit::WebGamepads* data) { |
721 if (!gamepad_shared_memory_reader_) | 674 if (!gamepad_shared_memory_reader_) |
722 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader); | 675 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader); |
723 gamepad_shared_memory_reader_->SampleGamepads(*data); | 676 gamepad_shared_memory_reader_->SampleGamepads(*data); |
724 } | 677 } |
725 | 678 |
726 bool PepperHelperImpl::OnMessageReceived(const IPC::Message& message) { | 679 bool PepperHelperImpl::OnMessageReceived(const IPC::Message& message) { |
727 if (pepper_browser_connection_.OnMessageReceived(message)) | |
728 return true; | |
729 | |
730 bool handled = true; | 680 bool handled = true; |
731 IPC_BEGIN_MESSAGE_MAP(PepperHelperImpl, message) | 681 IPC_BEGIN_MESSAGE_MAP(PepperHelperImpl, message) |
732 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK, | |
733 OnTCPSocketConnectACK) | |
734 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK, | |
735 OnTCPSocketSSLHandshakeACK) | |
736 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnTCPSocketReadACK) | |
737 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnTCPSocketWriteACK) | |
738 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SetOptionACK, | |
739 OnTCPSocketSetOptionACK) | |
740 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_ListenACK, | |
741 OnTCPServerSocketListenACK) | |
742 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_AcceptACK, | |
743 OnTCPServerSocketAcceptACK) | |
744 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerChannelCreated, | 682 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerChannelCreated, |
745 OnPpapiBrokerChannelCreated) | 683 OnPpapiBrokerChannelCreated) |
746 IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenFile_ACK, OnAsyncFileOpened) | |
747 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerPermissionResult, | 684 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerPermissionResult, |
748 OnPpapiBrokerPermissionResult) | 685 OnPpapiBrokerPermissionResult) |
749 IPC_MESSAGE_UNHANDLED(handled = false) | 686 IPC_MESSAGE_UNHANDLED(handled = false) |
750 IPC_END_MESSAGE_MAP() | 687 IPC_END_MESSAGE_MAP() |
751 return handled; | 688 return handled; |
752 } | 689 } |
753 | 690 |
754 void PepperHelperImpl::OnDestruct() { | 691 void PepperHelperImpl::OnDestruct() { |
755 // Nothing to do here. Default implementation in RenderViewObserver does | 692 // Nothing to do here. Default implementation in RenderViewObserver does |
756 // 'delete this' but it's not suitable for PepperHelperImpl because | 693 // 'delete this' but it's not suitable for PepperHelperImpl because |
757 // it's non-pointer member in RenderViewImpl. | 694 // it's non-pointer member in RenderViewImpl. |
758 } | 695 } |
759 | 696 |
760 void PepperHelperImpl::OnTCPSocketConnectACK( | |
761 uint32 plugin_dispatcher_id, | |
762 uint32 socket_id, | |
763 int32_t result, | |
764 const PP_NetAddress_Private& local_addr, | |
765 const PP_NetAddress_Private& remote_addr) { | |
766 PPB_TCPSocket_Private_Impl* socket = tcp_sockets_.Lookup(socket_id); | |
767 if (socket) | |
768 socket->OnConnectCompleted(result, local_addr, remote_addr); | |
769 if (result != PP_OK) | |
770 tcp_sockets_.Remove(socket_id); | |
771 } | |
772 | |
773 void PepperHelperImpl::OnTCPSocketSSLHandshakeACK( | |
774 uint32 plugin_dispatcher_id, | |
775 uint32 socket_id, | |
776 bool succeeded, | |
777 const ppapi::PPB_X509Certificate_Fields& certificate_fields) { | |
778 PPB_TCPSocket_Private_Impl* socket = tcp_sockets_.Lookup(socket_id); | |
779 if (socket) | |
780 socket->OnSSLHandshakeCompleted(succeeded, certificate_fields); | |
781 } | |
782 | |
783 void PepperHelperImpl::OnTCPSocketReadACK(uint32 plugin_dispatcher_id, | |
784 uint32 socket_id, | |
785 int32_t result, | |
786 const std::string& data) { | |
787 PPB_TCPSocket_Private_Impl* socket = tcp_sockets_.Lookup(socket_id); | |
788 if (socket) | |
789 socket->OnReadCompleted(result, data); | |
790 } | |
791 | |
792 void PepperHelperImpl::OnTCPSocketWriteACK(uint32 plugin_dispatcher_id, | |
793 uint32 socket_id, | |
794 int32_t result) { | |
795 PPB_TCPSocket_Private_Impl* socket = tcp_sockets_.Lookup(socket_id); | |
796 if (socket) | |
797 socket->OnWriteCompleted(result); | |
798 } | |
799 | |
800 void PepperHelperImpl::OnTCPSocketSetOptionACK( | |
801 uint32 plugin_dispatcher_id, | |
802 uint32 socket_id, | |
803 int32_t result) { | |
804 PPB_TCPSocket_Private_Impl* socket = tcp_sockets_.Lookup(socket_id); | |
805 if (socket) | |
806 socket->OnSetOptionCompleted(result); | |
807 } | |
808 | |
809 void PepperHelperImpl::OnTCPServerSocketListenACK( | |
810 uint32 plugin_dispatcher_id, | |
811 PP_Resource socket_resource, | |
812 uint32 socket_id, | |
813 const PP_NetAddress_Private& local_addr, | |
814 int32_t status) { | |
815 ppapi::thunk::EnterResource<ppapi::thunk::PPB_TCPServerSocket_Private_API> | |
816 enter(socket_resource, true); | |
817 if (enter.succeeded()) { | |
818 ppapi::PPB_TCPServerSocket_Shared* socket = | |
819 static_cast<ppapi::PPB_TCPServerSocket_Shared*>(enter.object()); | |
820 if (status == PP_OK) | |
821 tcp_server_sockets_.AddWithID(socket, socket_id); | |
822 socket->OnListenCompleted(socket_id, local_addr, status); | |
823 } else if (socket_id != 0 && status == PP_OK) { | |
824 // StopListening was called before completion of Listen. | |
825 Send(new PpapiHostMsg_PPBTCPServerSocket_Destroy(socket_id)); | |
826 } | |
827 } | |
828 | |
829 void PepperHelperImpl::OnTCPServerSocketAcceptACK( | |
830 uint32 plugin_dispatcher_id, | |
831 uint32 server_socket_id, | |
832 uint32 accepted_socket_id, | |
833 const PP_NetAddress_Private& local_addr, | |
834 const PP_NetAddress_Private& remote_addr) { | |
835 ppapi::PPB_TCPServerSocket_Shared* socket = | |
836 tcp_server_sockets_.Lookup(server_socket_id); | |
837 if (socket) { | |
838 bool succeeded = (accepted_socket_id != 0); | |
839 socket->OnAcceptCompleted(succeeded, | |
840 accepted_socket_id, | |
841 local_addr, | |
842 remote_addr); | |
843 } else if (accepted_socket_id != 0) { | |
844 Send(new PpapiHostMsg_PPBTCPSocket_Disconnect(accepted_socket_id)); | |
845 } | |
846 } | |
847 | |
848 } // namespace content | 697 } // namespace content |
OLD | NEW |