diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-08 06:38:45 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-08 06:38:45 +0000 |
commit | 1a78d9f39f364608a1a54b4274322e1ed4c2be9b (patch) | |
tree | 71ca778a5498c3e9e8c95e66013c74c80af13d33 /chrome/renderer | |
parent | 13930f6c2d604b78faadd458ffcad121d434c421 (diff) | |
download | chromium_src-1a78d9f39f364608a1a54b4274322e1ed4c2be9b.zip chromium_src-1a78d9f39f364608a1a54b4274322e1ed4c2be9b.tar.gz chromium_src-1a78d9f39f364608a1a54b4274322e1ed4c2be9b.tar.bz2 |
Make webkit/glue/plugins no longer depend on ppapi/proxy directly. This causes
things that use webkit but otherwise don't need IPC to include the IPC
directory.
This patch moves the set-up of the proxy into the renderer. I also did a lot
of clean-up of the initialization and it seems much nicer now.
BUG=63684
TEST=manual PPAPI proxy testing
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68567 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/DEPS | 1 | ||||
-rw-r--r-- | chrome/renderer/pepper_plugin_delegate_impl.cc | 88 | ||||
-rw-r--r-- | chrome/renderer/pepper_plugin_delegate_impl.h | 3 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 25 |
4 files changed, 88 insertions, 29 deletions
diff --git a/chrome/renderer/DEPS b/chrome/renderer/DEPS index 02bb449..9b488d4 100644 --- a/chrome/renderer/DEPS +++ b/chrome/renderer/DEPS @@ -8,6 +8,7 @@ include_rules = [ "+media/filters", "+media/video", "+ppapi/c", + "+ppapi/proxy", "+sandbox/src", "+skia", "+webkit/extensions", diff --git a/chrome/renderer/pepper_plugin_delegate_impl.cc b/chrome/renderer/pepper_plugin_delegate_impl.cc index c3a85d9..a949ffb8 100644 --- a/chrome/renderer/pepper_plugin_delegate_impl.cc +++ b/chrome/renderer/pepper_plugin_delegate_impl.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <cmath> - #include "chrome/renderer/pepper_plugin_delegate_impl.h" +#include <cmath> + #include "app/l10n_util.h" #include "app/surface/transport_dib.h" #include "base/callback.h" @@ -18,6 +18,7 @@ #include "base/utf_string_conversions.h" #include "chrome/common/child_thread.h" #include "chrome/common/file_system/file_system_dispatcher.h" +#include "chrome/common/pepper_plugin_registry.h" #include "chrome/common/render_messages.h" #include "chrome/common/render_messages_params.h" #include "chrome/renderer/audio_message_filter.h" @@ -32,6 +33,7 @@ #include "grit/locale_settings.h" #include "ipc/ipc_channel_handle.h" #include "ppapi/c/dev/pp_video_dev.h" +#include "ppapi/proxy/host_dispatcher.h" #include "third_party/WebKit/WebKit/chromium/public/WebFileChooserCompletion.h" #include "third_party/WebKit/WebKit/chromium/public/WebFileChooserParams.h" #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" @@ -47,6 +49,10 @@ #include "chrome/renderer/render_thread.h" #endif +#if defined(OS_POSIX) +#include "ipc/ipc_channel_posix.h" +#endif + using WebKit::WebView; namespace { @@ -413,6 +419,60 @@ class PlatformVideoDecoderImpl DISALLOW_COPY_AND_ASSIGN(PlatformVideoDecoderImpl); }; +class DispatcherWrapper : public pepper::PluginDelegate::OutOfProcessProxy { + public: + DispatcherWrapper() {} + virtual ~DispatcherWrapper() {} + + bool Init(base::ProcessHandle plugin_process_handle, + IPC::ChannelHandle channel_handle, + PP_Module pp_module, + pp::proxy::Dispatcher::GetInterfaceFunc local_get_interface); + + // OutOfProcessProxy implementation. + virtual const void* GetProxiedInterface(const char* name) { + return dispatcher_->GetProxiedInterface(name); + } + virtual void AddInstance(PP_Instance instance) { + pp::proxy::HostDispatcher::SetForInstance(instance, dispatcher_.get()); + } + virtual void RemoveInstance(PP_Instance instance) { + pp::proxy::HostDispatcher::RemoveForInstance(instance); + } + + private: + scoped_ptr<pp::proxy::HostDispatcher> dispatcher_; +}; + +bool DispatcherWrapper::Init( + base::ProcessHandle plugin_process_handle, + IPC::ChannelHandle channel_handle, + PP_Module pp_module, + pp::proxy::Dispatcher::GetInterfaceFunc local_get_interface) { + dispatcher_.reset(new pp::proxy::HostDispatcher( + plugin_process_handle, pp_module, local_get_interface)); + +#if defined(OS_POSIX) + // If we received a ChannelHandle, register it now. + if (channel_handle.socket.fd >= 0) + IPC::AddChannelSocket(channel_handle.name, channel_handle.socket.fd); +#endif + + if (!dispatcher_->InitWithChannel( + ChildProcess::current()->io_message_loop(), channel_handle.name, + true, ChildProcess::current()->GetShutDownEvent())) { + dispatcher_.reset(); + return false; + } + + if (!dispatcher_->InitializeModule()) { + // TODO(brettw) does the module get unloaded in this case? + dispatcher_.reset(); + return false; + } + return true; +} + } // namespace PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderView* render_view) @@ -424,19 +484,29 @@ PepperPluginDelegateImpl::~PepperPluginDelegateImpl() { } scoped_refptr<pepper::PluginModule> -PepperPluginDelegateImpl::CreateOutOfProcessPepperPlugin( - const FilePath& path) { +PepperPluginDelegateImpl::CreatePepperPlugin(const FilePath& path) { + // Easy case is in-process plugins. + if (!PepperPluginRegistry::GetInstance()->RunOutOfProcessForPlugin(path)) + return PepperPluginRegistry::GetInstance()->GetModule(path); + + // Out of process: have the browser start the plugin process for us. base::ProcessHandle plugin_process_handle = NULL; IPC::ChannelHandle channel_handle; render_view_->Send(new ViewHostMsg_OpenChannelToPepperPlugin( path, &plugin_process_handle, &channel_handle)); if (channel_handle.name.empty()) return scoped_refptr<pepper::PluginModule>(); // Couldn't be initialized. - return pepper::PluginModule::CreateOutOfProcessModule( - ChildProcess::current()->io_message_loop(), - plugin_process_handle, - channel_handle, - ChildProcess::current()->GetShutDownEvent()); + + // Create a new HostDispatcher for the proxying, and hook it to a new + // PluginModule. + scoped_refptr<pepper::PluginModule> module(new pepper::PluginModule); + scoped_ptr<DispatcherWrapper> dispatcher(new DispatcherWrapper); + if (!dispatcher->Init(plugin_process_handle, channel_handle, + module->pp_module(), + pepper::PluginModule::GetLocalGetInterfaceFunc())) + return scoped_refptr<pepper::PluginModule>(); + module->InitAsProxied(dispatcher.release()); + return module; } void PepperPluginDelegateImpl::ViewInitiatedPaint() { diff --git a/chrome/renderer/pepper_plugin_delegate_impl.h b/chrome/renderer/pepper_plugin_delegate_impl.h index 9402ae2..d59be3b 100644 --- a/chrome/renderer/pepper_plugin_delegate_impl.h +++ b/chrome/renderer/pepper_plugin_delegate_impl.h @@ -44,8 +44,7 @@ class PepperPluginDelegateImpl explicit PepperPluginDelegateImpl(RenderView* render_view); virtual ~PepperPluginDelegateImpl(); - scoped_refptr<pepper::PluginModule> CreateOutOfProcessPepperPlugin( - const FilePath& path); + scoped_refptr<pepper::PluginModule> CreatePepperPlugin(const FilePath& path); // Called by RenderView to tell us about painting events, these two functions // just correspond to the DidInitiatePaint and DidFlushPaint in R.V.. diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index f62a2e9..74f84e1c 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -834,12 +834,12 @@ WebPlugin* RenderView::CreatePluginNoCheck(WebFrame* frame, &info, &setting, &mime_type)); if (!found || !info.enabled) return NULL; + scoped_refptr<pepper::PluginModule> pepper_module( - PepperPluginRegistry::GetInstance()->GetModule(info.path)); + pepper_delegate_.CreatePepperPlugin(info.path)); if (pepper_module) return CreatePepperPlugin(frame, params, info.path, pepper_module.get()); - else - return CreateNPAPIPlugin(frame, params, info.path, mime_type); + return CreateNPAPIPlugin(frame, params, info.path, mime_type); } void RenderView::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) { @@ -2753,21 +2753,10 @@ WebPlugin* RenderView::createPlugin(WebFrame* frame, if (info.path.value() == kDefaultPluginLibraryName || plugin_setting == CONTENT_SETTING_ALLOW || host_setting == CONTENT_SETTING_ALLOW) { - scoped_refptr<pepper::PluginModule> pepper_module; - if (PepperPluginRegistry::GetInstance()->RunOutOfProcessForPlugin( - info.path)) { - pepper_module = - pepper_delegate_.CreateOutOfProcessPepperPlugin(info.path); - } else { - pepper_module = - PepperPluginRegistry::GetInstance()->GetModule(info.path); - } - if (pepper_module) { - return CreatePepperPlugin(frame, - params, - info.path, - pepper_module.get()); - } + scoped_refptr<pepper::PluginModule> pepper_module( + pepper_delegate_.CreatePepperPlugin(info.path)); + if (pepper_module) + return CreatePepperPlugin(frame, params, info.path, pepper_module.get()); return CreateNPAPIPlugin(frame, params, info.path, actual_mime_type); } std::string resource; |