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

Unified Diff: content/renderer/pepper/pepper_in_process_resource_creation.cc

Issue 10815073: Refactoring of new IPC-only pepper implementation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
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 2af7707c6656d2bca7d541acebe13cf4c29f9cda..f3bf25e505a42147bc546f0ee325120fa7a2e3d8 100644
--- a/content/renderer/pepper/pepper_in_process_resource_creation.cc
+++ b/content/renderer/pepper/pepper_in_process_resource_creation.cc
@@ -8,7 +8,8 @@
#include "base/memory/weak_ptr.h"
#include "base/message_loop.h"
#include "content/renderer/render_view_impl.h"
-#include "content/renderer/pepper/content_renderer_pepper_host_factory.h"
+#include "content/renderer/pepper/renderer_ppapi_host_impl.h"
+#include "content/renderer/pepper/pepper_in_process_router.h"
#include "ipc/ipc_message.h"
#include "ipc/ipc_message_macros.h"
#include "ppapi/host/ppapi_host.h"
@@ -25,151 +26,13 @@
namespace content {
-// PluginResources take a plugin->browser channel in their constructor. When
-// in process, we don't have a per-plugin-module object in the browser. We
-// currently just don't support these resource objects in-process.
-//
-// But to keep things linking, we provide this dummy browser channel. It will
-// just assert if anything attempts to actually send a message.
-class PepperInProcessResourceCreation::DummyBrowserChannel
- : public IPC::Sender {
- public:
- DummyBrowserChannel() {}
- ~DummyBrowserChannel() {}
-
- // Sender implementation.
- virtual bool Send(IPC::Message* msg) OVERRIDE {
- NOTREACHED();
- delete msg;
- return false;
- }
-};
-
-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, 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()),
- dummy_browser_channel_(new DummyBrowserChannel),
- 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() {
@@ -180,13 +43,8 @@ PP_Resource PepperInProcessResourceCreation::CreateFileChooser(
PP_FileChooserMode_Dev mode,
const char* accept_types) {
return (new ppapi::proxy::FileChooserResource(
- GetConnection(),
+ host_impl_->in_process_router()->GetPluginConnection(),
instance, mode, accept_types))->GetReference();
}
-ppapi::proxy::Connection PepperInProcessResourceCreation::GetConnection() {
- return ppapi::proxy::Connection(dummy_browser_channel_.get(),
- plugin_to_host_router_.get());
-}
-
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698