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 /ppapi | |
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
Diffstat (limited to 'ppapi')
-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 |
11 files changed, 82 insertions, 18 deletions
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() {} |