| 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_in_process_resource_creation.h" | 5 #include "content/renderer/pepper/pepper_in_process_resource_creation.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "content/renderer/pepper/content_renderer_pepper_host_factory.h" | 10 #include "content/renderer/pepper/content_renderer_pepper_host_factory.h" |
| 11 #include "ipc/ipc_message.h" | 11 #include "ipc/ipc_message.h" |
| 12 #include "ipc/ipc_message_macros.h" | 12 #include "ipc/ipc_message_macros.h" |
| 13 #include "ppapi/host/ppapi_host.h" | 13 #include "ppapi/host/ppapi_host.h" |
| 14 #include "ppapi/proxy/ppapi_messages.h" | 14 #include "ppapi/proxy/ppapi_messages.h" |
| 15 #include "ppapi/shared_impl/ppapi_globals.h" | 15 #include "ppapi/shared_impl/ppapi_globals.h" |
| 16 #include "ppapi/shared_impl/ppapi_permissions.h" |
| 16 #include "ppapi/shared_impl/resource_tracker.h" | 17 #include "ppapi/shared_impl/resource_tracker.h" |
| 17 | 18 |
| 18 // Note that the code in the creation functions in this file should generally | 19 // Note that the code in the creation functions in this file should generally |
| 19 // be the same as that in ppapi/proxy/resource_creation_proxy.cc. See | 20 // be the same as that in ppapi/proxy/resource_creation_proxy.cc. See |
| 20 // pepper_in_process_resource_creation.h for what this file is for. | 21 // pepper_in_process_resource_creation.h for what this file is for. |
| 21 | 22 |
| 22 namespace content { | 23 namespace content { |
| 23 | 24 |
| 24 class PepperInProcessResourceCreation::PluginToHostRouter | 25 class PepperInProcessResourceCreation::PluginToHostRouter |
| 25 : public IPC::Sender { | 26 : public IPC::Sender { |
| 26 public: | 27 public: |
| 27 PluginToHostRouter(RenderViewImpl* render_view, | 28 PluginToHostRouter(RenderViewImpl* render_view, |
| 28 IPC::Sender* host_to_plugin_sender); | 29 IPC::Sender* host_to_plugin_sender, |
| 30 const ppapi::PpapiPermissions& perms); |
| 29 virtual ~PluginToHostRouter() {} | 31 virtual ~PluginToHostRouter() {} |
| 30 | 32 |
| 31 // Sender implementation. | 33 // Sender implementation. |
| 32 virtual bool Send(IPC::Message* msg) OVERRIDE; | 34 virtual bool Send(IPC::Message* msg) OVERRIDE; |
| 33 | 35 |
| 34 private: | 36 private: |
| 35 void DoSend(IPC::Message* msg); | 37 void DoSend(IPC::Message* msg); |
| 36 | 38 |
| 37 base::WeakPtrFactory<PluginToHostRouter> weak_factory_; | 39 base::WeakPtrFactory<PluginToHostRouter> weak_factory_; |
| 38 | 40 |
| 39 ContentRendererPepperHostFactory factory_; | 41 ContentRendererPepperHostFactory factory_; |
| 40 ppapi::host::PpapiHost host_; | 42 ppapi::host::PpapiHost host_; |
| 41 | 43 |
| 42 DISALLOW_COPY_AND_ASSIGN(PluginToHostRouter); | 44 DISALLOW_COPY_AND_ASSIGN(PluginToHostRouter); |
| 43 }; | 45 }; |
| 44 | 46 |
| 45 PepperInProcessResourceCreation::PluginToHostRouter::PluginToHostRouter( | 47 PepperInProcessResourceCreation::PluginToHostRouter::PluginToHostRouter( |
| 46 RenderViewImpl* render_view, | 48 RenderViewImpl* render_view, |
| 47 IPC::Sender* host_to_plugin_sender) | 49 IPC::Sender* host_to_plugin_sender, |
| 50 const ppapi::PpapiPermissions& perms) |
| 48 : weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 51 : weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 49 factory_(render_view), | 52 factory_(render_view), |
| 50 host_(host_to_plugin_sender, &factory_) { | 53 host_(host_to_plugin_sender, &factory_, perms) { |
| 51 } | 54 } |
| 52 | 55 |
| 53 bool PepperInProcessResourceCreation::PluginToHostRouter::Send( | 56 bool PepperInProcessResourceCreation::PluginToHostRouter::Send( |
| 54 IPC::Message* msg) { | 57 IPC::Message* msg) { |
| 55 // Don't directly call into the message handler to avoid reentrancy. The IPC | 58 // Don't directly call into the message handler to avoid reentrancy. The IPC |
| 56 // systen assumes everything is executed from the message loop, so emulate | 59 // systen assumes everything is executed from the message loop, so emulate |
| 57 // the same thing for in-process. | 60 // the same thing for in-process. |
| 58 MessageLoop::current()->PostTask(FROM_HERE, | 61 MessageLoop::current()->PostTask(FROM_HERE, |
| 59 base::Bind(&PluginToHostRouter::DoSend, weak_factory_.GetWeakPtr(), | 62 base::Bind(&PluginToHostRouter::DoSend, weak_factory_.GetWeakPtr(), |
| 60 base::Owned(msg))); | 63 base::Owned(msg))); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 return; | 126 return; |
| 124 } | 127 } |
| 125 resource->OnReplyReceived(reply_params.sequence(), reply_params.result(), | 128 resource->OnReplyReceived(reply_params.sequence(), reply_params.result(), |
| 126 nested_msg); | 129 nested_msg); |
| 127 } | 130 } |
| 128 | 131 |
| 129 // PepperInProcessResourceCreation -------------------------------------------- | 132 // PepperInProcessResourceCreation -------------------------------------------- |
| 130 | 133 |
| 131 PepperInProcessResourceCreation::PepperInProcessResourceCreation( | 134 PepperInProcessResourceCreation::PepperInProcessResourceCreation( |
| 132 RenderViewImpl* render_view, | 135 RenderViewImpl* render_view, |
| 133 webkit::ppapi::PluginInstance* instance) | 136 webkit::ppapi::PluginInstance* instance, |
| 137 const ppapi::PpapiPermissions& perms) |
| 134 : ResourceCreationImpl(instance), | 138 : ResourceCreationImpl(instance), |
| 135 host_to_plugin_router_(new HostToPluginRouter), | 139 host_to_plugin_router_(new HostToPluginRouter), |
| 136 plugin_to_host_router_( | 140 plugin_to_host_router_( |
| 137 new PluginToHostRouter(render_view, host_to_plugin_router_.get())) { | 141 new PluginToHostRouter(render_view, host_to_plugin_router_.get(), |
| 142 perms)) { |
| 138 } | 143 } |
| 139 | 144 |
| 140 PepperInProcessResourceCreation::~PepperInProcessResourceCreation() { | 145 PepperInProcessResourceCreation::~PepperInProcessResourceCreation() { |
| 141 } | 146 } |
| 142 | 147 |
| 143 } // namespace content | 148 } // namespace content |
| OLD | NEW |