diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-13 22:46:42 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-13 22:46:42 +0000 |
commit | 5ed5a3eebe9cab0c54cc23ab3d059af37a4f3a92 (patch) | |
tree | 4e802bfe6319118b99483ada9888bbaebd17516e | |
parent | d99bcf2707cd81d8653485cab5d32f4811a58112 (diff) | |
download | chromium_src-5ed5a3eebe9cab0c54cc23ab3d059af37a4f3a92.zip chromium_src-5ed5a3eebe9cab0c54cc23ab3d059af37a4f3a92.tar.gz chromium_src-5ed5a3eebe9cab0c54cc23ab3d059af37a4f3a92.tar.bz2 |
Add a way to implement GetInterface in the broker.
This also adds some cleanup in the Pepper API to provide typedefs for the three PPP_* functions. I removed some ad-hoc typedefes we had floating around and replaced them with these more "official" ones.
BUG=
TEST=
Review URL: https://chromiumcodereview.appspot.com/10069035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132285 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/ppapi_plugin/plugin_process_dispatcher.cc | 2 | ||||
-rw-r--r-- | content/ppapi_plugin/plugin_process_dispatcher.h | 2 | ||||
-rw-r--r-- | content/ppapi_plugin/ppapi_thread.cc | 12 | ||||
-rw-r--r-- | content/ppapi_plugin/ppapi_thread.h | 2 | ||||
-rw-r--r-- | content/renderer/pepper/pepper_plugin_delegate_impl.cc | 2 | ||||
-rw-r--r-- | ppapi/api/ppp.idl | 16 | ||||
-rw-r--r-- | ppapi/c/ppp.h | 32 | ||||
-rw-r--r-- | ppapi/cpp/module_embedder.h | 15 | ||||
-rw-r--r-- | ppapi/cpp/ppp_entrypoints.cc | 13 | ||||
-rw-r--r-- | ppapi/proxy/dispatcher.cc | 2 | ||||
-rw-r--r-- | ppapi/proxy/dispatcher.h | 12 | ||||
-rw-r--r-- | ppapi/proxy/host_dispatcher.cc | 2 | ||||
-rw-r--r-- | ppapi/proxy/host_dispatcher.h | 2 | ||||
-rw-r--r-- | ppapi/proxy/plugin_dispatcher.cc | 2 | ||||
-rw-r--r-- | ppapi/proxy/plugin_dispatcher.h | 2 | ||||
-rw-r--r-- | ppapi/proxy/proxy_channel.h | 2 |
16 files changed, 92 insertions, 28 deletions
diff --git a/content/ppapi_plugin/plugin_process_dispatcher.cc b/content/ppapi_plugin/plugin_process_dispatcher.cc index 5d33e12..22c42c7 100644 --- a/content/ppapi_plugin/plugin_process_dispatcher.cc +++ b/content/ppapi_plugin/plugin_process_dispatcher.cc @@ -17,7 +17,7 @@ const int kPluginReleaseTimeSeconds = 30; PluginProcessDispatcher::PluginProcessDispatcher( base::ProcessHandle remote_process_handle, - GetInterfaceFunc get_interface) + PP_GetInterface_Func get_interface) : ppapi::proxy::PluginDispatcher(remote_process_handle, get_interface) { ChildProcess::current()->AddRefProcess(); } diff --git a/content/ppapi_plugin/plugin_process_dispatcher.h b/content/ppapi_plugin/plugin_process_dispatcher.h index ffcdc48..12455d8 100644 --- a/content/ppapi_plugin/plugin_process_dispatcher.h +++ b/content/ppapi_plugin/plugin_process_dispatcher.h @@ -14,7 +14,7 @@ class PluginProcessDispatcher : public ppapi::proxy::PluginDispatcher { public: PluginProcessDispatcher(base::ProcessHandle remote_process_handle, - GetInterfaceFunc get_interface); + PP_GetInterface_Func get_interface); virtual ~PluginProcessDispatcher(); private: diff --git a/content/ppapi_plugin/ppapi_thread.cc b/content/ppapi_plugin/ppapi_thread.cc index 30c99b1..dec254f 100644 --- a/content/ppapi_plugin/ppapi_thread.cc +++ b/content/ppapi_plugin/ppapi_thread.cc @@ -63,11 +63,11 @@ PpapiThread::~PpapiThread() { return; // The ShutdownModule/ShutdownBroker function is optional. - ppapi::proxy::ProxyChannel::ShutdownModuleFunc shutdown_function = + PP_ShutdownModule_Func shutdown_function = is_broker_ ? - reinterpret_cast<ppapi::proxy::ProxyChannel::ShutdownModuleFunc>( + reinterpret_cast<PP_ShutdownModule_Func>( library_.GetFunctionPointer("PPP_ShutdownBroker")) : - reinterpret_cast<ppapi::proxy::ProxyChannel::ShutdownModuleFunc>( + reinterpret_cast<PP_ShutdownModule_Func>( library_.GetFunctionPointer("PPP_ShutdownModule")); if (shutdown_function) shutdown_function(); @@ -210,7 +210,7 @@ void PpapiThread::OnMsgLoadPlugin(const FilePath& path) { } else { // Get the GetInterface function (required). get_plugin_interface_ = - reinterpret_cast<ppapi::proxy::Dispatcher::GetInterfaceFunc>( + reinterpret_cast<PP_GetInterface_Func>( library.GetFunctionPointer("PPP_GetInterface")); if (!get_plugin_interface_) { LOG(WARNING) << "No PPP_GetInterface in plugin library"; @@ -227,8 +227,8 @@ void PpapiThread::OnMsgLoadPlugin(const FilePath& path) { #endif // Get the InitializeModule function (required). - ppapi::proxy::Dispatcher::InitModuleFunc init_module = - reinterpret_cast<ppapi::proxy::Dispatcher::InitModuleFunc>( + PP_InitializeModule_Func init_module = + reinterpret_cast<PP_InitializeModule_Func>( library.GetFunctionPointer("PPP_InitializeModule")); if (!init_module) { LOG(WARNING) << "No PPP_InitializeModule in plugin library"; diff --git a/content/ppapi_plugin/ppapi_thread.h b/content/ppapi_plugin/ppapi_thread.h index e7e046c..dfd23ab 100644 --- a/content/ppapi_plugin/ppapi_thread.h +++ b/content/ppapi_plugin/ppapi_thread.h @@ -86,7 +86,7 @@ class PpapiThread : public ChildThread, // Global state tracking for the proxy. ppapi::proxy::PluginGlobals plugin_globals_; - ppapi::proxy::Dispatcher::GetInterfaceFunc get_plugin_interface_; + PP_GetInterface_Func get_plugin_interface_; // Callback to call when a new instance connects to the broker. // Used only when is_broker_. diff --git a/content/renderer/pepper/pepper_plugin_delegate_impl.cc b/content/renderer/pepper/pepper_plugin_delegate_impl.cc index 30c4806..debbd55 100644 --- a/content/renderer/pepper/pepper_plugin_delegate_impl.cc +++ b/content/renderer/pepper/pepper_plugin_delegate_impl.cc @@ -105,7 +105,7 @@ class HostDispatcherWrapper bool Init(base::ProcessHandle plugin_process_handle, const IPC::ChannelHandle& channel_handle, PP_Module pp_module, - ppapi::proxy::Dispatcher::GetInterfaceFunc local_get_interface, + PP_GetInterface_Func local_get_interface, const ppapi::Preferences& preferences, PepperHungPluginFilter* filter) { if (channel_handle.name.empty()) diff --git a/ppapi/api/ppp.idl b/ppapi/api/ppp.idl index b26e63f..8eb978a 100644 --- a/ppapi/api/ppp.idl +++ b/ppapi/api/ppp.idl @@ -121,3 +121,19 @@ PP_EXPORT const void* PPP_GetInterface(const char* interface_name); #endinl +/** + * Defines the type of the <code>PPP_InitializeModule</code> function. + */ +typedef int32_t PP_InitializeModule_Func( + [in] PP_Module module, + [in] PPB_GetInterface get_browser_interface); + +/** + * Defines the type of the <code>PPP_ShutdownModule</code> function. + */ +typedef void PP_ShutdownModule_Func(); + +/** + * Defines the type of the <code>PPP_ShutdownModule</code> function. + */ +typedef interface_t PP_GetInterface_Func([in] str_t interface_name); diff --git a/ppapi/c/ppp.h b/ppapi/c/ppp.h index cb36b10..8cd3248 100644 --- a/ppapi/c/ppp.h +++ b/ppapi/c/ppp.h @@ -1,14 +1,17 @@ -/* Copyright (c) 2011 The Chromium Authors. All rights reserved. +/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -/* From ppp.idl modified Mon Aug 8 06:47:44 2011. */ +/* From ppp.idl modified Fri Apr 13 10:57:17 2012. */ #ifndef PPAPI_C_PPP_H_ #define PPAPI_C_PPP_H_ #include "ppapi/c/pp_macros.h" +#include "ppapi/c/pp_module.h" +#include "ppapi/c/pp_stdint.h" +#include "ppapi/c/ppb.h" /** * @file @@ -127,5 +130,30 @@ PP_EXPORT const void* PPP_GetInterface(const char* interface_name); } /* extern "C" */ #endif + +/** + * @addtogroup Typedefs + * @{ + */ +/** + * Defines the type of the <code>PPP_InitializeModule</code> function. + */ +typedef int32_t (*PP_InitializeModule_Func)( + PP_Module module, + PPB_GetInterface get_browser_interface); + +/** + * Defines the type of the <code>PPP_ShutdownModule</code> function. + */ +typedef void (*PP_ShutdownModule_Func)(); + +/** + * Defines the type of the <code>PPP_ShutdownModule</code> function. + */ +typedef const void* (*PP_GetInterface_Func)(const char* interface_name); +/** + * @} + */ + #endif /* PPAPI_C_PPP_H_ */ diff --git a/ppapi/cpp/module_embedder.h b/ppapi/cpp/module_embedder.h index b7b7d43..a1d00a8 100644 --- a/ppapi/cpp/module_embedder.h +++ b/ppapi/cpp/module_embedder.h @@ -5,6 +5,8 @@ #ifndef PPAPI_CPP_MODULE_EMBEDDER_H_ #define PPAPI_CPP_MODULE_EMBEDDER_H_ +#include "ppapi/c/ppp.h" + /// @file /// This file defines the APIs for creating a Module object. namespace pp { @@ -20,6 +22,19 @@ class Module; /// failure. Upon failure, the module will be unloaded. pp::Module* CreateModule(); +/// Sets the get interface function in the broker process. +/// +/// This function is only relevant when you're using the PPB_Broker interface +/// in a trusted native plugin. In this case, you may need to implement +/// PPP_GetInterface when the plugin is loaded in the unsandboxed process. +/// Normally the C++ wrappers implement PPP_GetInterface for you but this +/// doesn't work in the context of the broker process. +// +/// So if you need to implement PPP_* interfaces in the broker process, call +/// this function in your PPP_InitializeBroker implementation which will set +/// up the given function as implementing PPP_GetInterface. +void SetBrokerGetInterfaceFunc(PP_GetInterface_Func broker_get_interface); + } // namespace pp #endif // PPAPI_CPP_MODULE_EMBEDDER_H_ diff --git a/ppapi/cpp/ppp_entrypoints.cc b/ppapi/cpp/ppp_entrypoints.cc index c3e7568..19a2ac9 100644 --- a/ppapi/cpp/ppp_entrypoints.cc +++ b/ppapi/cpp/ppp_entrypoints.cc @@ -14,6 +14,7 @@ #include "ppapi/cpp/module_embedder.h" static pp::Module* g_module_singleton = NULL; +static PP_GetInterface_Func g_broker_get_interface = NULL; namespace pp { @@ -22,6 +23,10 @@ pp::Module* Module::Get() { return g_module_singleton; } +void SetBrokerGetIntefaceFunc(PP_GetInterface_Func broker_get_interface) { + g_broker_get_interface = broker_get_interface; +} + } // namespace pp // Global PPP functions -------------------------------------------------------- @@ -46,7 +51,9 @@ PP_EXPORT void PPP_ShutdownModule() { } PP_EXPORT const void* PPP_GetInterface(const char* interface_name) { - if (!g_module_singleton) - return NULL; - return g_module_singleton->GetPluginInterface(interface_name); + if (g_module_singleton) + return g_module_singleton->GetPluginInterface(interface_name); + if (g_broker_get_interface) + return g_broker_get_interface(interface_name); + return NULL; } diff --git a/ppapi/proxy/dispatcher.cc b/ppapi/proxy/dispatcher.cc index 39b1a06..a646643 100644 --- a/ppapi/proxy/dispatcher.cc +++ b/ppapi/proxy/dispatcher.cc @@ -18,7 +18,7 @@ namespace ppapi { namespace proxy { Dispatcher::Dispatcher(base::ProcessHandle remote_process_handle, - GetInterfaceFunc local_get_interface) + PP_GetInterface_Func local_get_interface) : ProxyChannel(remote_process_handle), disallow_trusted_interfaces_(false), // TODO(brettw) make this settable. local_get_interface_(local_get_interface) { diff --git a/ppapi/proxy/dispatcher.h b/ppapi/proxy/dispatcher.h index df0f484..f5cc468 100644 --- a/ppapi/proxy/dispatcher.h +++ b/ppapi/proxy/dispatcher.h @@ -15,6 +15,7 @@ #include "ipc/ipc_channel_proxy.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_module.h" +#include "ppapi/c/ppp.h" #include "ppapi/proxy/proxy_channel.h" #include "ppapi/proxy/interface_list.h" #include "ppapi/proxy/interface_proxy.h" @@ -43,9 +44,6 @@ class VarSerializationRules; // | class PPAPI_PROXY_EXPORT Dispatcher : public ProxyChannel { public: - typedef const void* (*GetInterfaceFunc)(const char*); - typedef int32_t (*InitModuleFunc)(PP_Module, GetInterfaceFunc); - virtual ~Dispatcher(); // Returns true if the dispatcher is on the plugin side, or false if it's the @@ -78,11 +76,13 @@ class PPAPI_PROXY_EXPORT Dispatcher : public ProxyChannel { // IPC::Channel::Listener implementation. virtual bool OnMessageReceived(const IPC::Message& msg); - GetInterfaceFunc local_get_interface() const { return local_get_interface_; } + PP_GetInterface_Func local_get_interface() const { + return local_get_interface_; + } protected: Dispatcher(base::ProcessHandle remote_process_handle, - GetInterfaceFunc local_get_interface); + PP_GetInterface_Func local_get_interface); // Setter for the derived classes to set the appropriate var serialization. // Takes one reference of the given pointer, which must be on the heap. @@ -105,7 +105,7 @@ class PPAPI_PROXY_EXPORT Dispatcher : public ProxyChannel { bool disallow_trusted_interfaces_; - GetInterfaceFunc local_get_interface_; + PP_GetInterface_Func local_get_interface_; scoped_refptr<VarSerializationRules> serialization_rules_; diff --git a/ppapi/proxy/host_dispatcher.cc b/ppapi/proxy/host_dispatcher.cc index 9256fe9..8a610e0 100644 --- a/ppapi/proxy/host_dispatcher.cc +++ b/ppapi/proxy/host_dispatcher.cc @@ -63,7 +63,7 @@ class BoolRestorer { HostDispatcher::HostDispatcher(base::ProcessHandle remote_process_handle, PP_Module module, - GetInterfaceFunc local_get_interface, + PP_GetInterface_Func local_get_interface, SyncMessageStatusReceiver* sync_status) : Dispatcher(remote_process_handle, local_get_interface), sync_status_(sync_status), diff --git a/ppapi/proxy/host_dispatcher.h b/ppapi/proxy/host_dispatcher.h index 2d44979..be9c426 100644 --- a/ppapi/proxy/host_dispatcher.h +++ b/ppapi/proxy/host_dispatcher.h @@ -50,7 +50,7 @@ class PPAPI_PROXY_EXPORT HostDispatcher : public Dispatcher { // You must call InitHostWithChannel after the constructor. HostDispatcher(base::ProcessHandle host_process_handle, PP_Module module, - GetInterfaceFunc local_get_interface, + PP_GetInterface_Func local_get_interface, SyncMessageStatusReceiver* sync_status); ~HostDispatcher(); diff --git a/ppapi/proxy/plugin_dispatcher.cc b/ppapi/proxy/plugin_dispatcher.cc index 4380dea..94cd3df 100644 --- a/ppapi/proxy/plugin_dispatcher.cc +++ b/ppapi/proxy/plugin_dispatcher.cc @@ -59,7 +59,7 @@ InstanceData::~InstanceData() { } PluginDispatcher::PluginDispatcher(base::ProcessHandle remote_process_handle, - GetInterfaceFunc get_interface) + PP_GetInterface_Func get_interface) : Dispatcher(remote_process_handle, get_interface), plugin_delegate_(NULL), received_preferences_(false), diff --git a/ppapi/proxy/plugin_dispatcher.h b/ppapi/proxy/plugin_dispatcher.h index 6e9b348..88d3763 100644 --- a/ppapi/proxy/plugin_dispatcher.h +++ b/ppapi/proxy/plugin_dispatcher.h @@ -67,7 +67,7 @@ class PPAPI_PROXY_EXPORT PluginDispatcher // // You must call InitPluginWithChannel after the constructor. PluginDispatcher(base::ProcessHandle remote_process_handle, - GetInterfaceFunc get_interface); + PP_GetInterface_Func get_interface); virtual ~PluginDispatcher(); // The plugin side maintains a mapping from PP_Instance to Dispatcher so diff --git a/ppapi/proxy/proxy_channel.h b/ppapi/proxy/proxy_channel.h index 0a1fb03..f32d470 100644 --- a/ppapi/proxy/proxy_channel.h +++ b/ppapi/proxy/proxy_channel.h @@ -28,8 +28,6 @@ class PPAPI_PROXY_EXPORT ProxyChannel : public IPC::Channel::Listener, public IPC::Message::Sender { public: - typedef void (*ShutdownModuleFunc)(); - class PPAPI_PROXY_EXPORT Delegate { public: virtual ~Delegate() {} |