Index: content/renderer/pepper/pepper_in_process_resource_creation.cc |
diff --git a/content/renderer/pepper/pepper_in_process_resource_creation.cc b/content/renderer/pepper/pepper_in_process_resource_creation.cc |
index 19eac81d3879683f1793c03e9ea17948bcf3ced5..64880db91a740f4a1db3608746c6245db22ff5c5 100644 |
--- a/content/renderer/pepper/pepper_in_process_resource_creation.cc |
+++ b/content/renderer/pepper/pepper_in_process_resource_creation.cc |
@@ -7,8 +7,9 @@ |
#include "base/bind.h" |
#include "base/memory/weak_ptr.h" |
#include "base/message_loop.h" |
-#include "content/renderer/pepper/content_renderer_pepper_host_factory.h" |
#include "content/renderer/render_view_impl.h" |
+#include "content/renderer/pepper/pepper_in_process_router.h" |
+#include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
#include "ipc/ipc_message.h" |
#include "ipc/ipc_message_macros.h" |
#include "ppapi/host/ppapi_host.h" |
@@ -25,131 +26,13 @@ |
namespace content { |
-class PepperInProcessResourceCreation::PluginToHostRouter |
- : public IPC::Sender { |
- public: |
- PluginToHostRouter(RenderViewImpl* render_view, |
- PepperInstanceStateAccessor* state, |
- IPC::Sender* host_to_plugin_sender, |
- const ppapi::PpapiPermissions& perms); |
- virtual ~PluginToHostRouter() {} |
- |
- ppapi::host::PpapiHost& host() { return host_; } |
- |
- // Sender implementation. |
- virtual bool Send(IPC::Message* msg) OVERRIDE; |
- |
- private: |
- void DoSend(IPC::Message* msg); |
- |
- base::WeakPtrFactory<PluginToHostRouter> weak_factory_; |
- |
- ContentRendererPepperHostFactory factory_; |
- ppapi::host::PpapiHost host_; |
- |
- DISALLOW_COPY_AND_ASSIGN(PluginToHostRouter); |
-}; |
- |
-PepperInProcessResourceCreation::PluginToHostRouter::PluginToHostRouter( |
- RenderViewImpl* render_view, |
- PepperInstanceStateAccessor* state, |
- IPC::Sender* host_to_plugin_sender, |
- const ppapi::PpapiPermissions& perms) |
- : weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
- factory_(render_view, perms, state), |
- host_(host_to_plugin_sender, &factory_, perms) { |
-} |
- |
-bool PepperInProcessResourceCreation::PluginToHostRouter::Send( |
- IPC::Message* msg) { |
- // Don't directly call into the message handler to avoid reentrancy. The IPC |
- // systen assumes everything is executed from the message loop, so emulate |
- // the same thing for in-process. |
- MessageLoop::current()->PostTask(FROM_HERE, |
- base::Bind(&PluginToHostRouter::DoSend, weak_factory_.GetWeakPtr(), |
- base::Owned(msg))); |
- return true; |
-} |
- |
-void PepperInProcessResourceCreation::PluginToHostRouter::DoSend( |
- IPC::Message* msg) { |
- host_.OnMessageReceived(*msg); |
-} |
- |
-// HostToPluginRouter --------------------------------------------------------- |
- |
-class PepperInProcessResourceCreation::HostToPluginRouter |
- : public IPC::Sender { |
- public: |
- HostToPluginRouter(); |
- virtual ~HostToPluginRouter() {} |
- |
- // Sender implementation. |
- virtual bool Send(IPC::Message* msg) OVERRIDE; |
- |
- private: |
- void DispatchMsg(IPC::Message* msg); |
- |
- void OnMsgResourceReply( |
- const ppapi::proxy::ResourceMessageReplyParams& reply_params, |
- const IPC::Message& nested_msg); |
- |
- base::WeakPtrFactory<HostToPluginRouter> weak_factory_; |
- |
- DISALLOW_COPY_AND_ASSIGN(HostToPluginRouter); |
-}; |
- |
-PepperInProcessResourceCreation::HostToPluginRouter::HostToPluginRouter() |
- : weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
-} |
- |
-bool PepperInProcessResourceCreation::HostToPluginRouter::Send( |
- IPC::Message* msg) { |
- // As in the PluginToHostRouter, dispatch from the message loop. |
- MessageLoop::current()->PostTask(FROM_HERE, |
- base::Bind(&HostToPluginRouter::DispatchMsg, |
- weak_factory_.GetWeakPtr(), |
- base::Owned(msg))); |
- return true; |
-} |
- |
-void PepperInProcessResourceCreation::HostToPluginRouter::DispatchMsg( |
- IPC::Message* msg) { |
- // Emulate the proxy by dispatching the relevant message here. |
- IPC_BEGIN_MESSAGE_MAP(HostToPluginRouter, *msg) |
- IPC_MESSAGE_HANDLER(PpapiPluginMsg_ResourceReply, OnMsgResourceReply) |
- IPC_END_MESSAGE_MAP() |
-} |
- |
-void PepperInProcessResourceCreation::HostToPluginRouter::OnMsgResourceReply( |
- const ppapi::proxy::ResourceMessageReplyParams& reply_params, |
- const IPC::Message& nested_msg) { |
- ppapi::Resource* resource = |
- ppapi::PpapiGlobals::Get()->GetResourceTracker()->GetResource( |
- reply_params.pp_resource()); |
- if (!resource) { |
- // The resource could have been destroyed while the async processing was |
- // pending. Just drop the message. |
- return; |
- } |
- resource->OnReplyReceived(reply_params.sequence(), reply_params.result(), |
- nested_msg); |
-} |
- |
// PepperInProcessResourceCreation -------------------------------------------- |
PepperInProcessResourceCreation::PepperInProcessResourceCreation( |
- RenderViewImpl* render_view, |
- webkit::ppapi::PluginInstance* instance, |
- const ppapi::PpapiPermissions& perms) |
+ RendererPpapiHostImpl* host_impl, |
+ webkit::ppapi::PluginInstance* instance) |
: ResourceCreationImpl(instance), |
- instance_state_(instance->module()), |
- host_to_plugin_router_(new HostToPluginRouter), |
- plugin_to_host_router_( |
- new PluginToHostRouter(render_view, &instance_state_, |
- host_to_plugin_router_.get(), |
- perms)) { |
- render_view->PpapiPluginCreated(&plugin_to_host_router_->host()); |
+ host_impl_(host_impl) { |
} |
PepperInProcessResourceCreation::~PepperInProcessResourceCreation() { |
@@ -160,7 +43,7 @@ PP_Resource PepperInProcessResourceCreation::CreateFileChooser( |
PP_FileChooserMode_Dev mode, |
const char* accept_types) { |
return (new ppapi::proxy::FileChooserResource( |
- plugin_to_host_router_.get(), |
+ host_impl_->in_process_router()->GetPluginConnection(), |
instance, mode, accept_types))->GetReference(); |
} |