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

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

Issue 10578043: Hook up content/renderer to the PPAPI host. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
new file mode 100644
index 0000000000000000000000000000000000000000..0f41ebed4755e892389e2a57e115cd014cceffe3
--- /dev/null
+++ b/content/renderer/pepper/pepper_in_process_resource_creation.cc
@@ -0,0 +1,104 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/renderer/pepper/pepper_in_process_resource_creation.h"
+
+#include "content/renderer/pepper/content_renderer_pepper_host_factory.h"
+#include "ipc/ipc_message.h"
+#include "ipc/ipc_message_macros.h"
+#include "ppapi/host/ppapi_host.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/shared_impl/ppapi_globals.h"
+#include "ppapi/shared_impl/resource_tracker.h"
+
+// Note that the code in the creation functions in this file should generall be
dmichael (off chromium) 2012/07/02 19:34:57 generall->generally
+// the same as that in pepper/proxy/resource_creation_proxy.cc. See
dmichael (off chromium) 2012/07/02 19:34:57 pepper->ppapi?
+// pepper_in_process_resource_creation.h for what this file is for.
+
+namespace content {
+
+class PepperInProcessResourceCreation::PluginToHostRouter
+ : public IPC::Sender {
+ public:
+ PluginToHostRouter(RenderViewImpl* render_view,
+ IPC::Sender* host_to_plugin_sender);
+ virtual ~PluginToHostRouter() {}
+
+ // Sender implementation.
+ virtual bool Send(IPC::Message* msg) OVERRIDE;
+
+ private:
+ ContentRendererPepperHostFactory factory_;
+ ppapi::host::PpapiHost host_;
+};
+
+PepperInProcessResourceCreation::PluginToHostRouter::PluginToHostRouter(
+ RenderViewImpl* render_view,
+ IPC::Sender* host_to_plugin_sender)
+ : factory_(render_view),
+ host_(host_to_plugin_sender, &factory_) {
+}
+
+bool PepperInProcessResourceCreation::PluginToHostRouter::Send(
+ IPC::Message* msg) {
+ scoped_ptr<IPC::Message> msg_deletor(msg);
+ return host_.OnMessageReceived(*msg);
dmichael (off chromium) 2012/07/02 19:34:57 Are there any cases where the proxy code assumes a
brettw 2012/07/03 16:52:54 You're right, I should probably do this asynchrono
dmichael (off chromium) 2012/07/03 17:08:52 But now I think it won't work with synchronous mes
brettw 2012/07/03 17:22:53 There are no synchronous resource messages (everyt
dmichael (off chromium) 2012/07/03 17:30:16 I'm not sure how it's going to support stuff like
+}
+
+// HostToPluginRouter ---------------------------------------------------------
+
+class PepperInProcessResourceCreation::HostToPluginRouter
+ : public IPC::Sender {
+ public:
+ HostToPluginRouter() {}
+ virtual ~HostToPluginRouter() {}
+
+ // Sender implementation.
+ virtual bool Send(IPC::Message* msg) OVERRIDE;
+
+ private:
+ void OnMsgResourceReply(
+ const ppapi::proxy::ResourceMessageReplyParams& reply_params,
+ const IPC::Message& nested_msg);
+};
+
+bool PepperInProcessResourceCreation::HostToPluginRouter::Send(
+ IPC::Message* msg) {
+ scoped_ptr<IPC::Message> msg_deletor(msg);
+ IPC_BEGIN_MESSAGE_MAP(HostToPluginRouter, *msg)
dmichael (off chromium) 2012/07/02 19:34:57 Having this MESSAGE_MAP stuff in a Send is weird e
brettw 2012/07/03 16:52:54 The while point of shared_impl is to be shared bet
dmichael (off chromium) 2012/07/03 17:08:52 Yeah, it's pretty short now. I was afraid of wheth
+ IPC_MESSAGE_HANDLER(PpapiPluginMsg_ResourceReply, OnMsgResourceReply)
+ IPC_MESSAGE_UNHANDLED(return false);
+ IPC_END_MESSAGE_MAP()
+ return true;
+}
+
+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) {
dmichael (off chromium) 2012/07/02 19:34:57 Are we sure this can't happen? I guess right now,
brettw 2012/07/03 16:52:54 Good point, I removed the assert & added a comment
+ NOTREACHED();
+ return;
+ }
+ resource->OnReplyReceived(reply_params.sequence(), reply_params.result(),
+ nested_msg);
+}
+
+// PepperInProcessResourceCreation --------------------------------------------
+
+PepperInProcessResourceCreation::PepperInProcessResourceCreation(
+ RenderViewImpl* render_view,
+ webkit::ppapi::PluginInstance* instance)
+ : ResourceCreationImpl(instance),
+ host_to_plugin_router_(new HostToPluginRouter),
+ plugin_to_host_router_(
+ new PluginToHostRouter(render_view, host_to_plugin_router_.get())) {
+}
+
+PepperInProcessResourceCreation::~PepperInProcessResourceCreation() {
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698