Index: chrome/renderer/pepper/ppb_nacl_private_impl.cc |
=================================================================== |
--- chrome/renderer/pepper/ppb_nacl_private_impl.cc (revision 162270) |
+++ chrome/renderer/pepper/ppb_nacl_private_impl.cc (working copy) |
@@ -9,7 +9,6 @@ |
#include "base/command_line.h" |
#include "base/lazy_instance.h" |
#include "base/logging.h" |
-#include "base/message_loop.h" |
#include "base/rand_util.h" |
#include "chrome/common/chrome_switches.h" |
#include "chrome/common/render_messages.h" |
@@ -17,34 +16,18 @@ |
#include "content/public/common/content_client.h" |
#include "content/public/common/content_switches.h" |
#include "content/public/common/sandbox_init.h" |
+#include "content/public/renderer/renderer_ppapi_host.h" |
#include "content/public/renderer/render_thread.h" |
-#include "content/public/renderer/render_view.h" |
-#include "content/public/renderer/renderer_restrict_dispatch_group.h" |
#include "ipc/ipc_sync_message_filter.h" |
#include "ppapi/c/pp_bool.h" |
#include "ppapi/c/private/pp_file_handle.h" |
#include "ppapi/c/private/ppb_nacl_private.h" |
#include "ppapi/native_client/src/trusted/plugin/nacl_entry_points.h" |
-#include "ppapi/proxy/host_dispatcher.h" |
-#include "ppapi/proxy/proxy_channel.h" |
#include "ppapi/shared_impl/ppapi_preferences.h" |
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
#include "webkit/plugins/ppapi/host_globals.h" |
#include "webkit/plugins/ppapi/plugin_module.h" |
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
-using content::RenderThread; |
-using content::RenderView; |
-using webkit::ppapi::HostGlobals; |
-using webkit::ppapi::PluginInstance; |
-using webkit::ppapi::PluginDelegate; |
-using webkit::ppapi::PluginModule; |
-using WebKit::WebView; |
- |
namespace { |
// This allows us to send requests from background threads. |
@@ -95,110 +78,6 @@ |
return PP_TRUE; |
} |
-class ProxyChannelDelegate |
- : public ppapi::proxy::ProxyChannel::Delegate { |
- public: |
- ProxyChannelDelegate(); |
- virtual ~ProxyChannelDelegate(); |
- |
- // ProxyChannel::Delegate implementation. |
- virtual base::MessageLoopProxy* GetIPCMessageLoop() OVERRIDE; |
- virtual base::WaitableEvent* GetShutdownEvent() OVERRIDE; |
- virtual IPC::PlatformFileForTransit ShareHandleWithRemote( |
- base::PlatformFile handle, |
- const IPC::SyncChannel& channel, |
- bool should_close_source) OVERRIDE; |
- private: |
- // TODO(bbudge) Modify the content public API so we can get |
- // the renderer process's shutdown event. |
- base::WaitableEvent shutdown_event_; |
-}; |
- |
-ProxyChannelDelegate::ProxyChannelDelegate() |
- : shutdown_event_(true, false) { |
-} |
- |
-ProxyChannelDelegate::~ProxyChannelDelegate() { |
-} |
- |
-base::MessageLoopProxy* ProxyChannelDelegate::GetIPCMessageLoop() { |
- return RenderThread::Get()->GetIOMessageLoopProxy().get(); |
-} |
- |
-base::WaitableEvent* ProxyChannelDelegate::GetShutdownEvent() { |
- return &shutdown_event_; |
-} |
- |
-IPC::PlatformFileForTransit ProxyChannelDelegate::ShareHandleWithRemote( |
- base::PlatformFile handle, |
- const IPC::SyncChannel& channel, |
- bool should_close_source) { |
- return content::BrokerGetFileHandleForProcess(handle, channel.peer_pid(), |
- should_close_source); |
-} |
- |
-// Stubbed out SyncMessageStatusReceiver, required by HostDispatcher. |
-// TODO(bbudge) Use a content::PepperHungPluginFilter instead. |
-class SyncMessageStatusReceiver |
- : public ppapi::proxy::HostDispatcher::SyncMessageStatusReceiver { |
- public: |
- SyncMessageStatusReceiver() {} |
- |
- // SyncMessageStatusReceiver implementation. |
- virtual void BeginBlockOnSyncMessage() OVERRIDE {} |
- virtual void EndBlockOnSyncMessage() OVERRIDE {} |
- |
- private: |
- virtual ~SyncMessageStatusReceiver() {} |
-}; |
- |
-class OutOfProcessProxy : public PluginDelegate::OutOfProcessProxy { |
- public: |
- OutOfProcessProxy() {} |
- virtual ~OutOfProcessProxy() {} |
- |
- bool Init(const IPC::ChannelHandle& channel_handle, |
- PP_Module pp_module, |
- PP_GetInterface_Func local_get_interface, |
- const ppapi::Preferences& preferences, |
- SyncMessageStatusReceiver* status_receiver, |
- const ppapi::PpapiPermissions& permissions) { |
- dispatcher_delegate_.reset(new ProxyChannelDelegate); |
- dispatcher_.reset(new ppapi::proxy::HostDispatcher( |
- pp_module, local_get_interface, status_receiver, permissions)); |
- |
- if (!dispatcher_->InitHostWithChannel(dispatcher_delegate_.get(), |
- channel_handle, |
- true, // Client. |
- preferences)) { |
- dispatcher_.reset(); |
- dispatcher_delegate_.reset(); |
- return false; |
- } |
- |
- // Make sure that incoming plugin->renderer "unblock" messages can ONLY |
- // unblock other pepper messages. |
- dispatcher_->channel()->SetRestrictDispatchChannelGroup( |
- content::kRendererRestrictDispatchGroup_Pepper); |
- return true; |
- } |
- |
- // OutOfProcessProxy implementation. |
- virtual const void* GetProxiedInterface(const char* name) OVERRIDE { |
- return dispatcher_->GetProxiedInterface(name); |
- } |
- virtual void AddInstance(PP_Instance instance) OVERRIDE { |
- ppapi::proxy::HostDispatcher::SetForInstance(instance, dispatcher_.get()); |
- } |
- virtual void RemoveInstance(PP_Instance instance) OVERRIDE { |
- ppapi::proxy::HostDispatcher::RemoveForInstance(instance); |
- } |
- |
- private: |
- scoped_ptr<ppapi::proxy::HostDispatcher> dispatcher_; |
- scoped_ptr<ppapi::proxy::ProxyChannel::Delegate> dispatcher_delegate_; |
-}; |
- |
PP_Bool StartPpapiProxy(PP_Instance instance) { |
if (CommandLine::ForCurrentProcess()->HasSwitch( |
switches::kEnableNaClIPCProxy)) { |
@@ -209,45 +88,38 @@ |
IPC::ChannelHandle channel_handle = it->second; |
map.erase(it); |
- PluginInstance* plugin_instance = |
+ webkit::ppapi::PluginInstance* plugin_instance = |
content::GetHostGlobals()->GetInstance(instance); |
if (!plugin_instance) |
return PP_FALSE; |
- WebView* web_view = |
- plugin_instance->container()->element().document().frame()->view(); |
- RenderView* render_view = content::RenderView::FromWebView(web_view); |
+ // Create a new module for each instance of the NaCl plugin that is using |
+ // the IPC based out-of-process proxy. We can't use the existing module, |
+ // because it is configured for the in-process NaCl plugin, and we must |
+ // keep it that way to allow the page to create other instances. |
+ webkit::ppapi::PluginModule* plugin_module = plugin_instance->module(); |
+ scoped_refptr<webkit::ppapi::PluginModule> nacl_plugin_module( |
+ plugin_module->CreateModuleForNaClInstance()); |
- PluginModule* plugin_module = plugin_instance->module(); |
- |
- scoped_refptr<SyncMessageStatusReceiver> |
- status_receiver(new SyncMessageStatusReceiver()); |
- scoped_ptr<OutOfProcessProxy> out_of_process_proxy(new OutOfProcessProxy); |
- // Create a new module for each instance of the NaCl plugin that is using |
- // the IPC based out-of-process proxy. We can't use the existing module, |
- // because it is configured for the in-process NaCl plugin, and we must |
- // keep it that way to allow the page to create other instances. |
- scoped_refptr<PluginModule> nacl_plugin_module( |
- plugin_module->CreateModuleForNaClInstance()); |
- |
// TODO(brettw) bug 153036 set NaCl permissions to allow dev interface |
// usage when necessary. |
ppapi::PpapiPermissions permissions; |
- |
- if (out_of_process_proxy->Init( |
+ // TODO(bbudge) fill in place-holder params below with the nexe URL and |
+ // NaCl process id. |
+ content::RendererPpapiHost* renderer_ppapi_host = |
+ content::RendererPpapiHost::CreateExternalPluginModule( |
+ nacl_plugin_module, |
+ plugin_instance, |
+ FilePath(FILE_PATH_LITERAL("NaCl")), |
+ permissions, |
channel_handle, |
- nacl_plugin_module->pp_module(), |
- PluginModule::GetLocalGetInterfaceFunc(), |
- ppapi::Preferences(render_view->GetWebkitPreferences()), |
- status_receiver.get(), |
- permissions)) { |
- nacl_plugin_module->InitAsProxiedNaCl( |
- out_of_process_proxy.PassAs<PluginDelegate::OutOfProcessProxy>(), |
- instance); |
+ 0); // plugin_child_id |
+ if (renderer_ppapi_host) { |
+ // Allow the module to reset the instance to the new proxy. |
+ nacl_plugin_module->InitAsProxiedNaCl(plugin_instance); |
return PP_TRUE; |
} |
} |
- |
return PP_FALSE; |
} |