From 41dbab71f2dd13c1cfad3b84d0e7bd5ef78bf6d4 Mon Sep 17 00:00:00 2001 From: "alokp@chromium.org" Date: Thu, 15 Sep 2011 07:36:50 +0000 Subject: [PATCH] Removed the dependency of PepperPluginRegistry on Pepper proxy. We would need to move PepperPluginRegistry to webkit/plugins/ppapi so that it can be used by test_shell. But before we can move it, we need to remove all dependencies on content and pepper/proxy. TEST=Manually ran pepper 3d demos in-process and out-of-process. Review URL: http://codereview.chromium.org/7885009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101259 0039d316-1c4b-4281-b951-d872f2087c98 --- content/common/pepper_plugin_registry.cc | 11 ---- content/common/pepper_plugin_registry.h | 8 +-- content/renderer/pepper_plugin_delegate_impl.cc | 76 +++++++++++++++---------- content/renderer/pepper_plugin_delegate_impl.h | 1 + ppapi/proxy/proxy_channel.h | 2 + 5 files changed, 49 insertions(+), 49 deletions(-) diff --git a/content/common/pepper_plugin_registry.cc b/content/common/pepper_plugin_registry.cc index 9fb138115489..80154f5b4dfc 100644 --- a/content/common/pepper_plugin_registry.cc +++ b/content/common/pepper_plugin_registry.cc @@ -10,7 +10,6 @@ #include "base/string_split.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" -#include "content/common/child_process.h" #include "content/common/content_client.h" #include "content/common/content_switches.h" #include "webkit/plugins/npapi/plugin_list.h" @@ -250,13 +249,3 @@ PepperPluginRegistry::PepperPluginRegistry() { } } -base::MessageLoopProxy* PepperPluginRegistry::GetIPCMessageLoop() { - // This is called only in the renderer so we know we have a child process. - DCHECK(ChildProcess::current()) << "Must be in the renderer."; - return ChildProcess::current()->io_message_loop_proxy(); -} - -base::WaitableEvent* PepperPluginRegistry::GetShutdownEvent() { - DCHECK(ChildProcess::current()) << "Must be in the renderer."; - return ChildProcess::current()->GetShutDownEvent(); -} diff --git a/content/common/pepper_plugin_registry.h b/content/common/pepper_plugin_registry.h index ee2404a4dcac..2ec144c9f867 100644 --- a/content/common/pepper_plugin_registry.h +++ b/content/common/pepper_plugin_registry.h @@ -13,7 +13,6 @@ #include "base/file_path.h" #include "content/common/content_export.h" -#include "ppapi/proxy/proxy_channel.h" #include "webkit/plugins/ppapi/plugin_delegate.h" #include "webkit/plugins/ppapi/plugin_module.h" #include "webkit/plugins/webplugininfo.h" @@ -59,8 +58,7 @@ bool MakePepperPluginInfo(const webkit::WebPluginInfo& webplugin_info, // is a list of all live modules (some of which may be out-of-process and hence // not preloaded). class PepperPluginRegistry - : public webkit::ppapi::PluginDelegate::ModuleLifetime, - public ppapi::proxy::ProxyChannel::Delegate { + : public webkit::ppapi::PluginDelegate::ModuleLifetime { public: ~PepperPluginRegistry(); @@ -105,10 +103,6 @@ class PepperPluginRegistry private: PepperPluginRegistry(); - // ProxyChannel::Delegate implementation. - virtual base::MessageLoopProxy* GetIPCMessageLoop(); - virtual base::WaitableEvent* GetShutdownEvent(); - // All known pepper plugins. std::vector plugin_list_; diff --git a/content/renderer/pepper_plugin_delegate_impl.cc b/content/renderer/pepper_plugin_delegate_impl.cc index e863ea29b1b3..cd0cefb88c01 100644 --- a/content/renderer/pepper_plugin_delegate_impl.cc +++ b/content/renderer/pepper_plugin_delegate_impl.cc @@ -333,17 +333,47 @@ void PlatformAudioImpl::OnLowLatencyCreated( } } -class DispatcherWrapper +class DispatcherDelegate : public ppapi::proxy::ProxyChannel::Delegate { + public: + virtual ~DispatcherDelegate() {} + + // ProxyChannel::Delegate implementation. + virtual base::MessageLoopProxy* GetIPCMessageLoop() { + // This is called only in the renderer so we know we have a child process. + DCHECK(ChildProcess::current()) << "Must be in the renderer."; + return ChildProcess::current()->io_message_loop_proxy(); + } + virtual base::WaitableEvent* GetShutdownEvent() { + DCHECK(ChildProcess::current()) << "Must be in the renderer."; + return ChildProcess::current()->GetShutDownEvent(); + } +}; + +class HostDispatcherWrapper : public webkit::ppapi::PluginDelegate::OutOfProcessProxy { public: - DispatcherWrapper() {} - virtual ~DispatcherWrapper() {} + HostDispatcherWrapper() {} + virtual ~HostDispatcherWrapper() {} - bool Init(RenderView* render_view, - base::ProcessHandle plugin_process_handle, + bool Init(base::ProcessHandle plugin_process_handle, const IPC::ChannelHandle& channel_handle, PP_Module pp_module, - ppapi::proxy::Dispatcher::GetInterfaceFunc local_get_interface); + ppapi::proxy::Dispatcher::GetInterfaceFunc local_get_interface, + const ppapi::Preferences& preferences) { + dispatcher_delegate_.reset(new DispatcherDelegate); + dispatcher_.reset(new ppapi::proxy::HostDispatcher( + plugin_process_handle, pp_module, local_get_interface)); + + if (!dispatcher_->InitHostWithChannel( + dispatcher_delegate_.get(), + channel_handle, true, preferences)) { + dispatcher_.reset(); + dispatcher_delegate_.reset(); + return false; + } + dispatcher_->channel()->SetRestrictDispatchToSameChannel(true); + return true; + } // OutOfProcessProxy implementation. virtual const void* GetProxiedInterface(const char* name) { @@ -358,6 +388,7 @@ class DispatcherWrapper private: scoped_ptr dispatcher_; + scoped_ptr dispatcher_delegate_; }; class QuotaCallbackTranslator : public QuotaDispatcher::Callback { @@ -437,26 +468,6 @@ class PlatformVideoCaptureImpl } // namespace -bool DispatcherWrapper::Init( - RenderView* render_view, - base::ProcessHandle plugin_process_handle, - const IPC::ChannelHandle& channel_handle, - PP_Module pp_module, - ppapi::proxy::Dispatcher::GetInterfaceFunc local_get_interface) { - dispatcher_.reset(new ppapi::proxy::HostDispatcher( - plugin_process_handle, pp_module, local_get_interface)); - - if (!dispatcher_->InitHostWithChannel( - PepperPluginRegistry::GetInstance(), - channel_handle, true, - ppapi::Preferences(render_view->webkit_preferences()))) { - dispatcher_.reset(); - return false; - } - dispatcher_->channel()->SetRestrictDispatchToSameChannel(true); - return true; -} - BrokerDispatcherWrapper::BrokerDispatcherWrapper() { } @@ -466,13 +477,15 @@ BrokerDispatcherWrapper::~BrokerDispatcherWrapper() { bool BrokerDispatcherWrapper::Init( base::ProcessHandle plugin_process_handle, const IPC::ChannelHandle& channel_handle) { + dispatcher_delegate_.reset(new DispatcherDelegate); dispatcher_.reset( new ppapi::proxy::BrokerHostDispatcher(plugin_process_handle)); - if (!dispatcher_->InitBrokerWithChannel(PepperPluginRegistry::GetInstance(), + if (!dispatcher_->InitBrokerWithChannel(dispatcher_delegate_.get(), channel_handle, true)) { dispatcher_.reset(); + dispatcher_delegate_.reset(); return false; } dispatcher_->channel()->SetRestrictDispatchToSameChannel(true); @@ -698,12 +711,13 @@ PepperPluginDelegateImpl::CreatePepperPluginModule( module = new webkit::ppapi::PluginModule(info->name, path, PepperPluginRegistry::GetInstance()); PepperPluginRegistry::GetInstance()->AddLiveModule(path, module); - scoped_ptr dispatcher(new DispatcherWrapper); + scoped_ptr dispatcher(new HostDispatcherWrapper); if (!dispatcher->Init( - render_view_, - plugin_process_handle, channel_handle, + plugin_process_handle, + channel_handle, module->pp_module(), - webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc())) + webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(), + GetPreferences())) return scoped_refptr(); module->InitAsProxied(dispatcher.release()); return module; diff --git a/content/renderer/pepper_plugin_delegate_impl.h b/content/renderer/pepper_plugin_delegate_impl.h index ca2b3fd1a972..cf8d2c371bfe 100644 --- a/content/renderer/pepper_plugin_delegate_impl.h +++ b/content/renderer/pepper_plugin_delegate_impl.h @@ -68,6 +68,7 @@ class BrokerDispatcherWrapper { private: scoped_ptr dispatcher_; + scoped_ptr dispatcher_delegate_; }; // This object is NOT thread-safe. diff --git a/ppapi/proxy/proxy_channel.h b/ppapi/proxy/proxy_channel.h index 744d087cb53e..3dfc2977d630 100644 --- a/ppapi/proxy/proxy_channel.h +++ b/ppapi/proxy/proxy_channel.h @@ -34,6 +34,8 @@ class PPAPI_PROXY_EXPORT ProxyChannel class Delegate { public: + virtual ~Delegate() {} + // Returns the dedicated message loop for processing IPC requests. virtual base::MessageLoopProxy* GetIPCMessageLoop() = 0; -- 2.11.4.GIT