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

Side by Side 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, 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/renderer/pepper/pepper_in_process_resource_creation.h"
6
7 #include "content/renderer/pepper/content_renderer_pepper_host_factory.h"
8 #include "ipc/ipc_message.h"
9 #include "ipc/ipc_message_macros.h"
10 #include "ppapi/host/ppapi_host.h"
11 #include "ppapi/proxy/ppapi_messages.h"
12 #include "ppapi/shared_impl/ppapi_globals.h"
13 #include "ppapi/shared_impl/resource_tracker.h"
14
15 // 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
16 // the same as that in pepper/proxy/resource_creation_proxy.cc. See
dmichael (off chromium) 2012/07/02 19:34:57 pepper->ppapi?
17 // pepper_in_process_resource_creation.h for what this file is for.
18
19 namespace content {
20
21 class PepperInProcessResourceCreation::PluginToHostRouter
22 : public IPC::Sender {
23 public:
24 PluginToHostRouter(RenderViewImpl* render_view,
25 IPC::Sender* host_to_plugin_sender);
26 virtual ~PluginToHostRouter() {}
27
28 // Sender implementation.
29 virtual bool Send(IPC::Message* msg) OVERRIDE;
30
31 private:
32 ContentRendererPepperHostFactory factory_;
33 ppapi::host::PpapiHost host_;
34 };
35
36 PepperInProcessResourceCreation::PluginToHostRouter::PluginToHostRouter(
37 RenderViewImpl* render_view,
38 IPC::Sender* host_to_plugin_sender)
39 : factory_(render_view),
40 host_(host_to_plugin_sender, &factory_) {
41 }
42
43 bool PepperInProcessResourceCreation::PluginToHostRouter::Send(
44 IPC::Message* msg) {
45 scoped_ptr<IPC::Message> msg_deletor(msg);
46 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
47 }
48
49 // HostToPluginRouter ---------------------------------------------------------
50
51 class PepperInProcessResourceCreation::HostToPluginRouter
52 : public IPC::Sender {
53 public:
54 HostToPluginRouter() {}
55 virtual ~HostToPluginRouter() {}
56
57 // Sender implementation.
58 virtual bool Send(IPC::Message* msg) OVERRIDE;
59
60 private:
61 void OnMsgResourceReply(
62 const ppapi::proxy::ResourceMessageReplyParams& reply_params,
63 const IPC::Message& nested_msg);
64 };
65
66 bool PepperInProcessResourceCreation::HostToPluginRouter::Send(
67 IPC::Message* msg) {
68 scoped_ptr<IPC::Message> msg_deletor(msg);
69 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
70 IPC_MESSAGE_HANDLER(PpapiPluginMsg_ResourceReply, OnMsgResourceReply)
71 IPC_MESSAGE_UNHANDLED(return false);
72 IPC_END_MESSAGE_MAP()
73 return true;
74 }
75
76 void PepperInProcessResourceCreation::HostToPluginRouter::OnMsgResourceReply(
77 const ppapi::proxy::ResourceMessageReplyParams& reply_params,
78 const IPC::Message& nested_msg) {
79 ppapi::Resource* resource =
80 ppapi::PpapiGlobals::Get()->GetResourceTracker()->GetResource(
81 reply_params.pp_resource());
82 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
83 NOTREACHED();
84 return;
85 }
86 resource->OnReplyReceived(reply_params.sequence(), reply_params.result(),
87 nested_msg);
88 }
89
90 // PepperInProcessResourceCreation --------------------------------------------
91
92 PepperInProcessResourceCreation::PepperInProcessResourceCreation(
93 RenderViewImpl* render_view,
94 webkit::ppapi::PluginInstance* instance)
95 : ResourceCreationImpl(instance),
96 host_to_plugin_router_(new HostToPluginRouter),
97 plugin_to_host_router_(
98 new PluginToHostRouter(render_view, host_to_plugin_router_.get())) {
99 }
100
101 PepperInProcessResourceCreation::~PepperInProcessResourceCreation() {
102 }
103
104 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698