diff options
Diffstat (limited to 'ppapi')
139 files changed, 1541 insertions, 2236 deletions
diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi index 02a2420..f8f236f 100644 --- a/ppapi/ppapi_proxy.gypi +++ b/ppapi/ppapi_proxy.gypi @@ -33,10 +33,13 @@ 'proxy/broker_dispatcher.h', 'proxy/dispatcher.cc', 'proxy/dispatcher.h', + 'proxy/enter_proxy.h', 'proxy/host_dispatcher.cc', 'proxy/host_dispatcher.h', 'proxy/host_var_serialization_rules.cc', 'proxy/host_var_serialization_rules.h', + 'proxy/interface_list.cc', + 'proxy/interface_list.h', 'proxy/interface_proxy.cc', 'proxy/interface_proxy.h', 'proxy/plugin_dispatcher.cc', @@ -53,8 +56,6 @@ 'proxy/ppapi_messages.h', 'proxy/ppapi_param_traits.cc', 'proxy/ppapi_param_traits.h', - 'proxy/ppb_audio_config_proxy.cc', - 'proxy/ppb_audio_config_proxy.h', 'proxy/ppb_audio_proxy.cc', 'proxy/ppb_audio_proxy.h', 'proxy/ppb_broker_proxy.cc', @@ -63,8 +64,6 @@ 'proxy/ppb_buffer_proxy.h', 'proxy/ppb_char_set_proxy.cc', 'proxy/ppb_char_set_proxy.h', - 'proxy/ppb_console_proxy.cc', - 'proxy/ppb_console_proxy.h', 'proxy/ppb_context_3d_proxy.cc', 'proxy/ppb_context_3d_proxy.h', 'proxy/ppb_core_proxy.cc', @@ -99,14 +98,10 @@ 'proxy/ppb_graphics_3d_proxy.h', 'proxy/ppb_image_data_proxy.cc', 'proxy/ppb_image_data_proxy.h', - 'proxy/ppb_input_event_proxy.cc', - 'proxy/ppb_input_event_proxy.h', 'proxy/ppb_instance_proxy.cc', 'proxy/ppb_instance_proxy.h', 'proxy/ppb_memory_proxy.cc', 'proxy/ppb_memory_proxy.h', - 'proxy/ppb_opengles2_proxy.cc', - 'proxy/ppb_opengles2_proxy.h', 'proxy/ppb_pdf_proxy.cc', 'proxy/ppb_pdf_proxy.h', 'proxy/ppb_surface_3d_proxy.cc', @@ -115,8 +110,6 @@ 'proxy/ppb_testing_proxy.h', 'proxy/ppb_url_loader_proxy.cc', 'proxy/ppb_url_loader_proxy.h', - 'proxy/ppb_url_request_info_proxy.cc', - 'proxy/ppb_url_request_info_proxy.h', 'proxy/ppb_url_response_info_proxy.cc', 'proxy/ppb_url_response_info_proxy.h', 'proxy/ppb_url_util_proxy.cc', diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi index 714a512..b029721 100644 --- a/ppapi/ppapi_shared.gypi +++ b/ppapi/ppapi_shared.gypi @@ -85,6 +85,7 @@ 'thunk/common.h', 'thunk/common.cc', + 'thunk/enter.cc', 'thunk/enter.h', 'thunk/ppb_audio_api.h', 'thunk/ppb_audio_config_api.h', @@ -99,6 +100,7 @@ 'thunk/ppb_buffer_trusted_thunk.cc', 'thunk/ppb_char_set_api.h', 'thunk/ppb_char_set_thunk.cc', + 'thunk/ppb_console_thunk.cc', 'thunk/ppb_context_3d_api.h', 'thunk/ppb_context_3d_thunk.cc', 'thunk/ppb_context_3d_trusted_thunk.cc', diff --git a/ppapi/proxy/dispatcher.cc b/ppapi/proxy/dispatcher.cc index d77c905..8381c6a 100644 --- a/ppapi/proxy/dispatcher.cc +++ b/ppapi/proxy/dispatcher.cc @@ -11,209 +11,12 @@ #include "base/compiler_specific.h" #include "base/logging.h" #include "base/memory/singleton.h" -#include "ppapi/c/dev/ppb_buffer_dev.h" -#include "ppapi/c/dev/ppb_char_set_dev.h" -#include "ppapi/c/dev/ppb_context_3d_dev.h" -#include "ppapi/c/dev/ppb_crypto_dev.h" -#include "ppapi/c/dev/ppb_cursor_control_dev.h" -#include "ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h" -#include "ppapi/c/dev/ppb_font_dev.h" -#include "ppapi/c/dev/ppb_surface_3d_dev.h" -#include "ppapi/c/dev/ppb_testing_dev.h" -#include "ppapi/c/dev/ppb_url_util_dev.h" -#include "ppapi/c/dev/ppb_var_deprecated.h" -#include "ppapi/c/pp_errors.h" -#include "ppapi/c/ppb_audio.h" -#include "ppapi/c/ppb_audio_config.h" -#include "ppapi/c/ppb_core.h" -#include "ppapi/c/ppb_graphics_2d.h" -#include "ppapi/c/ppb_image_data.h" -#include "ppapi/c/ppb_instance.h" -#include "ppapi/c/ppb_opengles.h" -#include "ppapi/c/ppb_url_loader.h" -#include "ppapi/c/ppb_url_request_info.h" -#include "ppapi/c/ppb_url_response_info.h" -#include "ppapi/c/ppb_var.h" -#include "ppapi/c/ppp_instance.h" -#include "ppapi/c/private/ppb_flash.h" -#include "ppapi/c/private/ppb_flash_clipboard.h" -#include "ppapi/c/private/ppb_flash_file.h" -#include "ppapi/c/private/ppb_flash_menu.h" -#include "ppapi/c/private/ppb_flash_net_connector.h" -#include "ppapi/c/private/ppb_flash_tcp_socket.h" -#include "ppapi/c/private/ppb_pdf.h" -#include "ppapi/c/trusted/ppb_url_loader_trusted.h" #include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/proxy/ppb_audio_config_proxy.h" -#include "ppapi/proxy/ppb_audio_proxy.h" -#include "ppapi/proxy/ppb_broker_proxy.h" -#include "ppapi/proxy/ppb_buffer_proxy.h" -#include "ppapi/proxy/ppb_char_set_proxy.h" -#include "ppapi/proxy/ppb_console_proxy.h" -#include "ppapi/proxy/ppb_context_3d_proxy.h" -#include "ppapi/proxy/ppb_core_proxy.h" -#include "ppapi/proxy/ppb_crypto_proxy.h" -#include "ppapi/proxy/ppb_cursor_control_proxy.h" -#include "ppapi/proxy/ppb_file_chooser_proxy.h" -#include "ppapi/proxy/ppb_file_ref_proxy.h" -#include "ppapi/proxy/ppb_file_system_proxy.h" -#include "ppapi/proxy/ppb_flash_clipboard_proxy.h" -#include "ppapi/proxy/ppb_flash_file_proxy.h" -#include "ppapi/proxy/ppb_flash_proxy.h" -#include "ppapi/proxy/ppb_flash_menu_proxy.h" -#include "ppapi/proxy/ppb_flash_net_connector_proxy.h" -#include "ppapi/proxy/ppb_flash_tcp_socket_proxy.h" -#include "ppapi/proxy/ppb_font_proxy.h" -#include "ppapi/proxy/ppb_graphics_2d_proxy.h" -#include "ppapi/proxy/ppb_graphics_3d_proxy.h" -#include "ppapi/proxy/ppb_image_data_proxy.h" -#include "ppapi/proxy/ppb_input_event_proxy.h" -#include "ppapi/proxy/ppb_instance_proxy.h" -#include "ppapi/proxy/ppb_memory_proxy.h" -#include "ppapi/proxy/ppb_opengles2_proxy.h" -#include "ppapi/proxy/ppb_pdf_proxy.h" -#include "ppapi/proxy/ppb_surface_3d_proxy.h" -#include "ppapi/proxy/ppb_testing_proxy.h" -#include "ppapi/proxy/ppb_url_loader_proxy.h" -#include "ppapi/proxy/ppb_url_request_info_proxy.h" -#include "ppapi/proxy/ppb_url_response_info_proxy.h" -#include "ppapi/proxy/ppb_url_util_proxy.h" -#include "ppapi/proxy/ppb_var_deprecated_proxy.h" -#include "ppapi/proxy/ppb_var_proxy.h" -#include "ppapi/proxy/ppb_video_capture_proxy.h" -#include "ppapi/proxy/ppb_video_decoder_proxy.h" -#include "ppapi/proxy/ppp_class_proxy.h" -#include "ppapi/proxy/ppp_graphics_3d_proxy.h" -#include "ppapi/proxy/ppp_input_event_proxy.h" -#include "ppapi/proxy/ppp_instance_private_proxy.h" -#include "ppapi/proxy/ppp_instance_proxy.h" -#include "ppapi/proxy/ppp_messaging_proxy.h" -#include "ppapi/proxy/ppp_mouse_lock_proxy.h" -#include "ppapi/proxy/ppp_video_decoder_proxy.h" #include "ppapi/proxy/var_serialization_rules.h" namespace ppapi { namespace proxy { -namespace { - -struct InterfaceList { - InterfaceList(); - - static InterfaceList* GetInstance(); - - void AddPPP(const InterfaceProxy::Info* info); - void AddPPB(const InterfaceProxy::Info* info); - - typedef std::map<std::string, const InterfaceProxy::Info*> NameToInfo; - NameToInfo name_to_plugin_info_; - NameToInfo name_to_browser_info_; - - // Note that there can be multiple interface names mapping to the same ID. - // In this case, the ID will map to one of them. This is temporary while - // we're converting to the thunk system, when that is complete, we need to - // have a better way of handling multiple interface implemented by one - // proxy object. - const InterfaceProxy::Info* id_to_browser_info_[INTERFACE_ID_COUNT]; -}; - -InterfaceList::InterfaceList() { - memset(id_to_browser_info_, 0, sizeof(id_to_browser_info_)); - - // PPB (browser) interfaces. - AddPPB(PPB_AudioConfig_Proxy::GetInfo()); - AddPPB(PPB_Audio_Proxy::GetInfo()); - AddPPB(PPB_Broker_Proxy::GetInfo()); - AddPPB(PPB_Buffer_Proxy::GetInfo()); - AddPPB(PPB_CharSet_Proxy::GetInfo()); - AddPPB(PPB_Console_Proxy::GetInfo()); - AddPPB(PPB_Context3D_Proxy::GetInfo()); - AddPPB(PPB_Context3D_Proxy::GetTextureMappingInfo()); - AddPPB(PPB_Core_Proxy::GetInfo()); - AddPPB(PPB_Crypto_Proxy::GetInfo()); - AddPPB(PPB_CursorControl_Proxy::GetInfo()); - AddPPB(PPB_FileChooser_Proxy::GetInfo()); - AddPPB(PPB_FileChooser_Proxy::GetInfo0_4()); - AddPPB(PPB_FileRef_Proxy::GetInfo()); - AddPPB(PPB_FileSystem_Proxy::GetInfo()); - AddPPB(PPB_Flash_Clipboard_Proxy::GetInfo()); - AddPPB(PPB_Flash_File_FileRef_Proxy::GetInfo()); - AddPPB(PPB_Flash_File_ModuleLocal_Proxy::GetInfo()); - AddPPB(PPB_Flash_Menu_Proxy::GetInfo()); - AddPPB(PPB_Flash_Proxy::GetInfo()); - AddPPB(PPB_Flash_TCPSocket_Proxy::GetInfo()); - AddPPB(PPB_Font_Proxy::GetInfo()); - AddPPB(PPB_Graphics2D_Proxy::GetInfo()); - AddPPB(PPB_Graphics3D_Proxy::GetInfo()); - AddPPB(PPB_ImageData_Proxy::GetInfo()); - AddPPB(PPB_InputEvent_Proxy::GetInputEventInfo()); - AddPPB(PPB_InputEvent_Proxy::GetKeyboardInputEventInfo()); - AddPPB(PPB_InputEvent_Proxy::GetMouseInputEventInfo1_0()); - AddPPB(PPB_InputEvent_Proxy::GetMouseInputEventInfo1_1()); - AddPPB(PPB_InputEvent_Proxy::GetWheelInputEventInfo()); - AddPPB(PPB_Instance_Proxy::GetInfo0_5()); - AddPPB(PPB_Instance_Proxy::GetInfo1_0()); - AddPPB(PPB_Instance_Proxy::GetInfoFullscreen()); - AddPPB(PPB_Instance_Proxy::GetInfoMessaging()); - AddPPB(PPB_Instance_Proxy::GetInfoMouseLock()); - AddPPB(PPB_Instance_Proxy::GetInfoPrivate()); - AddPPB(PPB_Memory_Proxy::GetInfo()); - AddPPB(PPB_OpenGLES2_Proxy::GetInfo()); - AddPPB(PPB_PDF_Proxy::GetInfo()); - AddPPB(PPB_Surface3D_Proxy::GetInfo()); - AddPPB(PPB_Testing_Proxy::GetInfo()); - AddPPB(PPB_URLLoader_Proxy::GetInfo()); - AddPPB(PPB_URLLoader_Proxy::GetTrustedInfo()); - AddPPB(PPB_URLRequestInfo_Proxy::GetInfo()); - AddPPB(PPB_URLResponseInfo_Proxy::GetInfo()); - AddPPB(PPB_URLUtil_Proxy::GetInfo()); - AddPPB(PPB_Var_Deprecated_Proxy::GetInfo()); - AddPPB(PPB_Var_Proxy::GetInfo()); - AddPPB(PPB_VideoCapture_Proxy::GetInfo()); - AddPPB(PPB_VideoDecoder_Proxy::GetInfo()); - -#ifdef ENABLE_FLAPPER_HACKS - AddPPB(PPB_Flash_NetConnector_Proxy::GetInfo()); -#endif - - // PPP (plugin) interfaces. - AddPPP(PPP_Graphics3D_Proxy::GetInfo()); - AddPPP(PPP_InputEvent_Proxy::GetInfo()); - AddPPP(PPP_Instance_Private_Proxy::GetInfo()); - AddPPP(PPP_Instance_Proxy::GetInfo1_0()); - AddPPP(PPP_Messaging_Proxy::GetInfo()); - AddPPP(PPP_MouseLock_Proxy::GetInfo()); - AddPPP(PPP_VideoCapture_Proxy::GetInfo()); - AddPPP(PPP_VideoDecoder_Proxy::GetInfo()); -} - -void InterfaceList::AddPPP(const InterfaceProxy::Info* info) { - DCHECK(name_to_plugin_info_.find(info->name) == - name_to_plugin_info_.end()); - DCHECK(info->id >= INTERFACE_ID_NONE && info->id < INTERFACE_ID_COUNT); - - name_to_plugin_info_[info->name] = info; -} - -void InterfaceList::AddPPB(const InterfaceProxy::Info* info) { - DCHECK(name_to_browser_info_.find(info->name) == - name_to_browser_info_.end()); - DCHECK(info->id >= INTERFACE_ID_NONE && info->id < INTERFACE_ID_COUNT); - DCHECK(info->id == INTERFACE_ID_NONE || - id_to_browser_info_[info->id] == NULL); - - name_to_browser_info_[std::string(info->name)] = info; - if (info->id != INTERFACE_ID_NONE) - id_to_browser_info_[info->id] = info; -} - -// static -InterfaceList* InterfaceList::GetInstance() { - return Singleton<InterfaceList>::get(); -} - -} // namespace - Dispatcher::Dispatcher(base::ProcessHandle remote_process_handle, GetInterfaceFunc local_get_interface) : ProxyChannel(remote_process_handle), @@ -225,6 +28,32 @@ Dispatcher::Dispatcher(base::ProcessHandle remote_process_handle, Dispatcher::~Dispatcher() { } +InterfaceProxy* Dispatcher::GetInterfaceProxy(InterfaceID id) { + InterfaceProxy* proxy = proxies_[id].get(); + if (!proxy) { + // Handle the first time for a given API by creating the proxy for it. + InterfaceProxy::Factory factory = + InterfaceList::GetInstance()->GetFactoryForID(id); + if (!factory) { + NOTREACHED(); + return NULL; + } + proxy = factory(this); + DCHECK(proxy); + proxies_[id].reset(proxy); + } + return proxy; +} + +base::MessageLoopProxy* Dispatcher::GetIPCMessageLoop() { + return delegate()->GetIPCMessageLoop(); +} + +void Dispatcher::AddIOThreadMessageFilter( + IPC::ChannelProxy::MessageFilter* filter) { + channel()->AddFilter(filter); +} + bool Dispatcher::OnMessageReceived(const IPC::Message& msg) { // Control messages. if (msg.routing_id() == MSG_ROUTING_CONTROL) { @@ -236,37 +65,19 @@ bool Dispatcher::OnMessageReceived(const IPC::Message& msg) { IPC_END_MESSAGE_MAP() return handled; } - return false; -} -// static -const InterfaceProxy::Info* Dispatcher::GetPPBInterfaceInfo( - const std::string& name) { - const InterfaceList* list = InterfaceList::GetInstance(); - InterfaceList::NameToInfo::const_iterator found = - list->name_to_browser_info_.find(name); - if (found == list->name_to_browser_info_.end()) - return NULL; - return found->second; -} - -// static -const InterfaceProxy::Info* Dispatcher::GetPPBInterfaceInfo(InterfaceID id) { - if (id <= 0 || id >= INTERFACE_ID_COUNT) - return NULL; - const InterfaceList* list = InterfaceList::GetInstance(); - return list->id_to_browser_info_[id]; -} + if (msg.routing_id() <= 0 || msg.routing_id() >= INTERFACE_ID_COUNT) { + OnInvalidMessageReceived(); + return true; + } -// static -const InterfaceProxy::Info* Dispatcher::GetPPPInterfaceInfo( - const std::string& name) { - const InterfaceList* list = InterfaceList::GetInstance(); - InterfaceList::NameToInfo::const_iterator found = - list->name_to_plugin_info_.find(name); - if (found == list->name_to_plugin_info_.end()) - return NULL; - return found->second; + InterfaceProxy* proxy = GetInterfaceProxy( + static_cast<InterfaceID>(msg.routing_id())); + if (!proxy) { + NOTREACHED(); + return true; + } + return proxy->OnMessageReceived(msg); } void Dispatcher::SetSerializationRules( @@ -274,17 +85,7 @@ void Dispatcher::SetSerializationRules( serialization_rules_.reset(var_serialization_rules); } -const void* Dispatcher::GetLocalInterface(const char* interface_name) { - return local_get_interface_(interface_name); -} - -base::MessageLoopProxy* Dispatcher::GetIPCMessageLoop() { - return delegate()->GetIPCMessageLoop(); -} - -void Dispatcher::AddIOThreadMessageFilter( - IPC::ChannelProxy::MessageFilter* filter) { - channel()->AddFilter(filter); +void Dispatcher::OnInvalidMessageReceived() { } } // namespace proxy diff --git a/ppapi/proxy/dispatcher.h b/ppapi/proxy/dispatcher.h index bf3e36f..a48cff7 100644 --- a/ppapi/proxy/dispatcher.h +++ b/ppapi/proxy/dispatcher.h @@ -17,6 +17,7 @@ #include "ppapi/proxy/callback_tracker.h" #include "ppapi/proxy/proxy_channel.h" #include "ppapi/proxy/interface_id.h" +#include "ppapi/proxy/interface_list.h" #include "ppapi/proxy/interface_proxy.h" #include "ppapi/proxy/plugin_var_tracker.h" @@ -57,8 +58,10 @@ class PPAPI_PROXY_EXPORT Dispatcher : public ProxyChannel { return serialization_rules_.get(); } - // Wrapper for calling the local GetInterface function. - const void* GetLocalInterface(const char* interface_name); + // Returns a non-owning pointer to the interface proxy for the given ID, or + // NULL if the ID isn't found. This will create the proxy if it hasn't been + // created so far. + InterfaceProxy* GetInterfaceProxy(InterfaceID id); // Returns the pointer to the IO thread for processing IPC messages. // TODO(brettw) remove this. It's a hack to support the Flash @@ -84,14 +87,7 @@ class PPAPI_PROXY_EXPORT Dispatcher : public ProxyChannel { return callback_tracker_; } - // Retrieves the information associated with the given interface, identified - // either by name or ID. Each function searches either PPP or PPB interfaces. - static const InterfaceProxy::Info* GetPPBInterfaceInfo( - const std::string& name); - static const InterfaceProxy::Info* GetPPBInterfaceInfo( - InterfaceID id); - static const InterfaceProxy::Info* GetPPPInterfaceInfo( - const std::string& name); + GetInterfaceFunc local_get_interface() const { return local_get_interface_; } protected: Dispatcher(base::ProcessHandle remote_process_handle, @@ -101,11 +97,21 @@ class PPAPI_PROXY_EXPORT Dispatcher : public ProxyChannel { // Takes ownership of the given pointer, which must be on the heap. void SetSerializationRules(VarSerializationRules* var_serialization_rules); + // Called when an invalid message is received from the remote site. The + // default implementation does nothing, derived classes can override. + virtual void OnInvalidMessageReceived(); + bool disallow_trusted_interfaces() const { return disallow_trusted_interfaces_; } private: + friend class HostDispatcherTest; + friend class PluginDispatcherTest; + + // Lists all lazily-created interface proxies. + scoped_ptr<InterfaceProxy> proxies_[INTERFACE_ID_COUNT]; + bool disallow_trusted_interfaces_; GetInterfaceFunc local_get_interface_; diff --git a/ppapi/proxy/enter_proxy.h b/ppapi/proxy/enter_proxy.h index 6852780..d7bf7c2 100644 --- a/ppapi/proxy/enter_proxy.h +++ b/ppapi/proxy/enter_proxy.h @@ -13,6 +13,11 @@ #include "ppapi/thunk/enter.h" namespace ppapi { + +namespace thunk { +class ResourceCreationAPI; +} + namespace proxy { // Wrapper around EnterResourceNoLock that takes a host resource. This is used @@ -115,6 +120,21 @@ class EnterHostFromHostResourceForceCallback RunCallback(PP_ERROR_BADRESOURCE); } + // For callbacks that take two extra parameters as a closure. + template<class CallbackFactory, typename Method, typename A, typename B> + EnterHostFromHostResourceForceCallback( + const HostResource& host_resource, + CallbackFactory& factory, + Method method, + const A& a, + const B& b) + : EnterHostFromHostResource<ResourceT>(host_resource), + needs_running_(true), + callback_(factory.NewOptionalCallback(method, a, b)) { + if (this->failed()) + RunCallback(PP_ERROR_BADRESOURCE); + } + ~EnterHostFromHostResourceForceCallback() { if (needs_running_) { NOTREACHED() << "Should always call SetResult except in the " diff --git a/ppapi/proxy/host_dispatcher.cc b/ppapi/proxy/host_dispatcher.cc index c5bf08f..a9f14f4 100644 --- a/ppapi/proxy/host_dispatcher.cc +++ b/ppapi/proxy/host_dispatcher.cc @@ -11,6 +11,7 @@ #include "ppapi/c/private/ppb_proxy_private.h" #include "ppapi/c/ppb_var.h" #include "ppapi/proxy/host_var_serialization_rules.h" +#include "ppapi/proxy/interface_list.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/resource_creation_proxy.h" @@ -75,7 +76,7 @@ HostDispatcher::HostDispatcher(base::ProcessHandle remote_process_handle, SetSerializationRules(new HostVarSerializationRules(var_interface, module)); ppb_proxy_ = reinterpret_cast<const PPB_Proxy_Private*>( - GetLocalInterface(PPB_PROXY_PRIVATE_INTERFACE)); + local_get_interface(PPB_PROXY_PRIVATE_INTERFACE)); DCHECK(ppb_proxy_) << "The proxy interface should always be supported."; ppb_proxy_->SetReserveInstanceIDCallback(pp_module_, &ReserveInstanceID); @@ -156,39 +157,7 @@ bool HostDispatcher::OnMessageReceived(const IPC::Message& msg) { BoolRestorer restorer(&allow_plugin_reentrancy_); allow_plugin_reentrancy_ = false; - // Handle common control messages. - if (Dispatcher::OnMessageReceived(msg)) - return true; - - if (msg.routing_id() <= 0 || msg.routing_id() >= INTERFACE_ID_COUNT) { - NOTREACHED(); - // TODO(brettw): kill the plugin if it starts sending invalid messages? - return true; - } - - // New-style function proxies. - // TODO(brettw) this is hacked in for the routing for the types we've - // implemented in this style so far. When everything is implemented in this - // style, this function should be cleaned up. - if (msg.routing_id() == INTERFACE_ID_RESOURCE_CREATION) { - ResourceCreationProxy proxy(this); - return proxy.OnMessageReceived(msg); - } - - InterfaceProxy* proxy = target_proxies_[msg.routing_id()].get(); - if (!proxy) { - // Autocreate any proxy objects to handle requests from the plugin. Since - // we always support all known PPB_* interfaces (modulo the trusted bit), - // there's very little checking necessary. - const InterfaceProxy::Info* info = GetPPBInterfaceInfo( - static_cast<InterfaceID>(msg.routing_id())); - if (!info || - (info->is_trusted && disallow_trusted_interfaces())) - return true; - proxy = CreatePPBInterfaceProxy(info); - } - - return proxy->OnMessageReceived(msg); + return Dispatcher::OnMessageReceived(msg); } void HostDispatcher::OnChannelError() { @@ -198,67 +167,35 @@ void HostDispatcher::OnChannelError() { ppb_proxy_->PluginCrashed(pp_module()); } -const void* HostDispatcher::GetProxiedInterface( - const std::string& proxied_interface) { - // First see if we even have a proxy for this interface. - const InterfaceProxy::Info* info = GetPPPInterfaceInfo(proxied_interface); - if (!info) - return NULL; +const void* HostDispatcher::GetProxiedInterface(const std::string& iface_name) { + const void* proxied_interface = + InterfaceList::GetInstance()->GetInterfaceForPPP(iface_name); + if (!proxied_interface) + return NULL; // Don't have a proxy for this interface, don't query further. - PluginIFSupportedMap::iterator iter(plugin_if_supported_.find( - proxied_interface)); - if (iter == plugin_if_supported_.end()) { + PluginSupportedMap::iterator iter(plugin_supported_.find(iface_name)); + if (iter == plugin_supported_.end()) { // Need to query. Cache the result so we only do this once. bool supported = false; bool previous_reentrancy_value = allow_plugin_reentrancy_; allow_plugin_reentrancy_ = true; - Send(new PpapiMsg_SupportsInterface(proxied_interface, &supported)); + Send(new PpapiMsg_SupportsInterface(iface_name, &supported)); allow_plugin_reentrancy_ = previous_reentrancy_value; - std::pair<PluginIFSupportedMap::iterator, bool> iter_success_pair; - iter_success_pair = plugin_if_supported_.insert( - PluginIFSupportedMap::value_type(proxied_interface, supported)); + std::pair<PluginSupportedMap::iterator, bool> iter_success_pair; + iter_success_pair = plugin_supported_.insert( + PluginSupportedMap::value_type(iface_name, supported)); iter = iter_success_pair.first; } if (iter->second) - return info->interface_ptr; + return proxied_interface; return NULL; } -InterfaceProxy* HostDispatcher::GetOrCreatePPBInterfaceProxy( - InterfaceID id) { - InterfaceProxy* proxy = target_proxies_[id].get(); - if (!proxy) { - const InterfaceProxy::Info* info = GetPPBInterfaceInfo(id); - if (!info) - return NULL; - - // Sanity check. This function won't normally be called for trusted - // interfaces, but in case somebody does this, we don't want to then give - // the plugin the ability to call that trusted interface (since the - // checking occurs at proxy-creation time). - if (info->is_trusted && disallow_trusted_interfaces()) - return NULL; - - proxy = CreatePPBInterfaceProxy(info); - } - return proxy; -} - -InterfaceProxy* HostDispatcher::CreatePPBInterfaceProxy( - const InterfaceProxy::Info* info) { - const void* local_interface = GetLocalInterface(info->name); - if (!local_interface) { - // This should always succeed since the browser should support the stuff - // the proxy does. If this happens, something is out of sync. - NOTREACHED(); - return NULL; - } - - InterfaceProxy* proxy = info->create_proxy(this, local_interface); - target_proxies_[info->id].reset(proxy); - return proxy; +void HostDispatcher::OnInvalidMessageReceived() { + // TODO(brettw) bug 95345 kill the plugin when an invalid message is + // received. } // ScopedModuleReference ------------------------------------------------------- diff --git a/ppapi/proxy/host_dispatcher.h b/ppapi/proxy/host_dispatcher.h index 623aa26..10fca5c 100644 --- a/ppapi/proxy/host_dispatcher.h +++ b/ppapi/proxy/host_dispatcher.h @@ -32,7 +32,6 @@ struct Preferences; namespace proxy { -class InterfaceProxy; class VarSerialization; class PPAPI_PROXY_EXPORT HostDispatcher : public Dispatcher { @@ -80,18 +79,11 @@ class PPAPI_PROXY_EXPORT HostDispatcher : public Dispatcher { // if the plugin supports the given interface (with caching) and returns the // pointer to the proxied interface if it is supported. Returns NULL if the // given interface isn't supported by the plugin or the proxy. - const void* GetProxiedInterface(const std::string& proxied_interface); - - // Returns the proxy object associated with the given interface ID, creating - // it if necessary. This is used in cases where a proxy needs to access code - // in the proxy for another interface. It's assumed that the interface always - // exists, so this is only used for browser proxies. - // - // Will return NULL if an interface isn't supported. - InterfaceProxy* GetOrCreatePPBInterfaceProxy(InterfaceID id); + const void* GetProxiedInterface(const std::string& iface_name); // See the value below. Call this when processing a scripting message from - // the plugin that can be reentered. + // the plugin that can be reentered. This is set to false at the beginning + // of processing of each message from the plugin. void set_allow_plugin_reentrancy() { allow_plugin_reentrancy_ = true; } @@ -99,28 +91,17 @@ class PPAPI_PROXY_EXPORT HostDispatcher : public Dispatcher { // Returns the proxy interface for talking to the implementation. const PPB_Proxy_Private* ppb_proxy() const { return ppb_proxy_; } - private: - friend class HostDispatcherTest; - - // Makes an instance of the given PPB interface proxy, storing it in the - // target_proxies_ array. An proxy for this interface must not exist yet. - InterfaceProxy* CreatePPBInterfaceProxy(const InterfaceProxy::Info* info); + protected: + // Overridden from Dispatcher. + virtual void OnInvalidMessageReceived(); + private: PP_Module pp_module_; - typedef std::map<std::string, bool> PluginIFSupportedMap; // Maps interface name to whether that interface is supported. If an interface // name is not in the map, that implies that we haven't queried for it yet. - std::map<std::string, bool> plugin_if_supported_; - - // All target proxies currently created. These are ones that receive - // messages. They are created on demand when we receive messages. - scoped_ptr<InterfaceProxy> target_proxies_[INTERFACE_ID_COUNT]; - - // Function proxies created for "new-style" FunctionGroups. - // TODO(brettw) this is in progress. It should be merged with the target - // proxies so there is one list to consult. - scoped_ptr<FunctionGroupBase> function_proxies_[INTERFACE_ID_COUNT]; + typedef base::hash_map<std::string, bool> PluginSupportedMap; + PluginSupportedMap plugin_supported_; // Guaranteed non-NULL. const PPB_Proxy_Private* ppb_proxy_; diff --git a/ppapi/proxy/host_dispatcher_unittest.cc b/ppapi/proxy/host_dispatcher_unittest.cc index 25dfa5c..5ce8ba3 100644 --- a/ppapi/proxy/host_dispatcher_unittest.cc +++ b/ppapi/proxy/host_dispatcher_unittest.cc @@ -17,7 +17,7 @@ class HostDispatcherTest : public HostProxyTest { HostDispatcherTest() {} bool HasTargetProxy(InterfaceID id) { - return !!host_dispatcher()->target_proxies_[id].get(); + return !!host_dispatcher()->proxies_[id].get(); } }; diff --git a/ppapi/proxy/interface_id.h b/ppapi/proxy/interface_id.h index 277f964..3b43943 100644 --- a/ppapi/proxy/interface_id.h +++ b/ppapi/proxy/interface_id.h @@ -18,7 +18,6 @@ enum InterfaceID { INTERFACE_ID_PPB_BROKER, INTERFACE_ID_PPB_BUFFER, INTERFACE_ID_PPB_CHAR_SET, - INTERFACE_ID_PPB_CONSOLE, INTERFACE_ID_PPB_CONTEXT_3D, INTERFACE_ID_PPB_CORE, INTERFACE_ID_PPB_CRYPTO, @@ -37,19 +36,15 @@ enum InterfaceID { INTERFACE_ID_PPB_FONT, INTERFACE_ID_PPB_GRAPHICS_2D, INTERFACE_ID_PPB_GRAPHICS_3D, - INTERFACE_ID_PPB_IMAGE_DATA, INTERFACE_ID_PPB_INSTANCE, INTERFACE_ID_PPB_INSTANCE_PRIVATE, - INTERFACE_ID_PPB_MEMORY, INTERFACE_ID_PPB_OPENGLES2, INTERFACE_ID_PPB_PDF, INTERFACE_ID_PPB_SURFACE_3D, INTERFACE_ID_PPB_TESTING, INTERFACE_ID_PPB_URL_LOADER, - INTERFACE_ID_PPB_URL_REQUEST_INFO, INTERFACE_ID_PPB_URL_RESPONSE_INFO, INTERFACE_ID_PPB_URL_UTIL, - INTERFACE_ID_PPB_VAR, INTERFACE_ID_PPB_VAR_DEPRECATED, INTERFACE_ID_PPB_VIDEO_CAPTURE_DEV, INTERFACE_ID_PPB_VIDEO_DECODER_DEV, diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc new file mode 100644 index 0000000..0b386aa --- /dev/null +++ b/ppapi/proxy/interface_list.cc @@ -0,0 +1,296 @@ +// Copyright (c) 2011 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. + +#include "ppapi/proxy/interface_list.h" + +#include "base/memory/singleton.h" +#include "ppapi/c/dev/ppb_buffer_dev.h" +#include "ppapi/c/dev/ppb_char_set_dev.h" +#include "ppapi/c/dev/ppb_console_dev.h" +#include "ppapi/c/dev/ppb_context_3d_dev.h" +#include "ppapi/c/dev/ppb_crypto_dev.h" +#include "ppapi/c/dev/ppb_cursor_control_dev.h" +#include "ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h" +#include "ppapi/c/dev/ppb_font_dev.h" +#include "ppapi/c/dev/ppb_memory_dev.h" +#include "ppapi/c/dev/ppb_mouse_lock_dev.h" +#include "ppapi/c/dev/ppb_surface_3d_dev.h" +#include "ppapi/c/dev/ppb_testing_dev.h" +#include "ppapi/c/dev/ppb_url_util_dev.h" +#include "ppapi/c/dev/ppb_var_deprecated.h" +#include "ppapi/c/dev/ppb_video_capture_dev.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/ppb_audio.h" +#include "ppapi/c/ppb_audio_config.h" +#include "ppapi/c/ppb_core.h" +#include "ppapi/c/ppb_file_ref.h" +#include "ppapi/c/ppb_file_system.h" +#include "ppapi/c/ppb_graphics_2d.h" +#include "ppapi/c/ppb_image_data.h" +#include "ppapi/c/ppb_input_event.h" +#include "ppapi/c/ppb_instance.h" +#include "ppapi/c/ppb_messaging.h" +#include "ppapi/c/ppb_opengles.h" +#include "ppapi/c/ppb_url_loader.h" +#include "ppapi/c/ppb_url_request_info.h" +#include "ppapi/c/ppb_url_response_info.h" +#include "ppapi/c/ppb_var.h" +#include "ppapi/c/ppp_instance.h" +#include "ppapi/c/private/ppb_flash.h" +#include "ppapi/c/private/ppb_flash_clipboard.h" +#include "ppapi/c/private/ppb_flash_file.h" +#include "ppapi/c/private/ppb_flash_menu.h" +#include "ppapi/c/private/ppb_flash_net_connector.h" +#include "ppapi/c/private/ppb_flash_tcp_socket.h" +#include "ppapi/c/private/ppb_pdf.h" +#include "ppapi/c/trusted/ppb_broker_trusted.h" +#include "ppapi/c/trusted/ppb_url_loader_trusted.h" +#include "ppapi/proxy/interface_proxy.h" +#include "ppapi/proxy/ppb_audio_proxy.h" +#include "ppapi/proxy/ppb_broker_proxy.h" +#include "ppapi/proxy/ppb_buffer_proxy.h" +#include "ppapi/proxy/ppb_char_set_proxy.h" +#include "ppapi/proxy/ppb_context_3d_proxy.h" +#include "ppapi/proxy/ppb_core_proxy.h" +#include "ppapi/proxy/ppb_crypto_proxy.h" +#include "ppapi/proxy/ppb_cursor_control_proxy.h" +#include "ppapi/proxy/ppb_file_chooser_proxy.h" +#include "ppapi/proxy/ppb_file_ref_proxy.h" +#include "ppapi/proxy/ppb_file_system_proxy.h" +#include "ppapi/proxy/ppb_flash_clipboard_proxy.h" +#include "ppapi/proxy/ppb_flash_file_proxy.h" +#include "ppapi/proxy/ppb_flash_proxy.h" +#include "ppapi/proxy/ppb_flash_menu_proxy.h" +#include "ppapi/proxy/ppb_flash_net_connector_proxy.h" +#include "ppapi/proxy/ppb_flash_tcp_socket_proxy.h" +#include "ppapi/proxy/ppb_font_proxy.h" +#include "ppapi/proxy/ppb_graphics_2d_proxy.h" +#include "ppapi/proxy/ppb_graphics_3d_proxy.h" +#include "ppapi/proxy/ppb_image_data_proxy.h" +#include "ppapi/proxy/ppb_instance_proxy.h" +#include "ppapi/proxy/ppb_memory_proxy.h" +#include "ppapi/proxy/ppp_mouse_lock_proxy.h" +#include "ppapi/proxy/ppb_pdf_proxy.h" +#include "ppapi/proxy/ppb_surface_3d_proxy.h" +#include "ppapi/proxy/ppb_testing_proxy.h" +#include "ppapi/proxy/ppb_url_loader_proxy.h" +#include "ppapi/proxy/ppb_url_response_info_proxy.h" +#include "ppapi/proxy/ppb_url_util_proxy.h" +#include "ppapi/proxy/ppb_var_deprecated_proxy.h" +#include "ppapi/proxy/ppb_var_proxy.h" +#include "ppapi/proxy/ppb_video_capture_proxy.h" +#include "ppapi/proxy/ppb_video_decoder_proxy.h" +#include "ppapi/proxy/ppp_class_proxy.h" +#include "ppapi/proxy/ppp_graphics_3d_proxy.h" +#include "ppapi/proxy/ppp_input_event_proxy.h" +#include "ppapi/proxy/ppp_instance_private_proxy.h" +#include "ppapi/proxy/ppp_instance_proxy.h" +#include "ppapi/proxy/ppp_messaging_proxy.h" +#include "ppapi/proxy/ppp_video_decoder_proxy.h" +#include "ppapi/proxy/resource_creation_proxy.h" +#include "ppapi/shared_impl/opengles2_impl.h" +#include "ppapi/thunk/thunk.h" + +// Helper to get the proxy name PPB_Foo_Proxy given the API name PPB_Foo. +#define PROXY_CLASS_NAME(api_name) api_name##_Proxy + +// Helper to get the interface ID PPB_Foo_Proxy::kInterfaceID given the API +// name PPB_Foo. +#define PROXY_INTERFACE_ID(api_name) PROXY_CLASS_NAME(api_name)::kInterfaceID + +// Helper to get the name of the factory function CreatePPB_Foo_Proxy given +// the API name PPB_Foo. +#define PROXY_FACTORY_NAME(api_name) Create##api_name##_Proxy + +// Helper to get the name of the thunk GetPPB_Foo_1_0_Thunk given the interface +// struct name PPB_Foo_1_0. +#define INTERFACE_THUNK_NAME(iface_struct) thunk::Get##iface_struct##_Thunk + +namespace ppapi { +namespace proxy { + +namespace { + +// The interface list has interfaces with no ID listed as "NoAPIName" which +// means there's no corresponding _Proxy object. Our macros expand this to +// NoAPIName_Proxy, and then they look for kInterfaceID inside it. +// +// This dummy class provides the correct definition for that interface ID, +// which is "NONE". +class NoAPIName_Proxy { + public: + static const InterfaceID kInterfaceID = INTERFACE_ID_NONE; +}; + +// Define factory functions for each interface type. These are of the form: +// InterfaceProxy* CreatePPB_URLLoader_Proxy(... +#define PROXIED_API(api_name) \ + InterfaceProxy* PROXY_FACTORY_NAME(api_name)(Dispatcher* dispatcher) { \ + return new PROXY_CLASS_NAME(api_name)(dispatcher); \ + } +#include "ppapi/thunk/interfaces_ppb_public_stable.h" +#include "ppapi/thunk/interfaces_ppb_public_dev.h" +#include "ppapi/thunk/interfaces_ppb_private.h" +#undef PROXIED_API + +} // namespace + +InterfaceList::InterfaceList() { + memset(id_to_factory_, 0, sizeof(id_to_factory_)); + + // Register the API factories for each of the API types. This calls AddProxy + // for each InterfaceProxy type we support. + #define PROXIED_API(api_name) \ + AddProxy(PROXY_INTERFACE_ID(api_name), &PROXY_FACTORY_NAME(api_name)); + + // Register each proxied interface by calling AddPPB for each supported + // interface. + #define PROXIED_IFACE(api_name, iface_str, iface_struct) \ + AddPPB(iface_str, PROXY_INTERFACE_ID(api_name), \ + INTERFACE_THUNK_NAME(iface_struct)()); + + #include "ppapi/thunk/interfaces_ppb_public_stable.h" + #include "ppapi/thunk/interfaces_ppb_public_dev.h" + #include "ppapi/thunk/interfaces_ppb_private.h" + + #undef PROXIED_API + #undef PROXIED_IFACE + + // New-style AddPPB not converted to the macros above. + AddPPB(PPB_CORE_INTERFACE, INTERFACE_ID_PPB_CORE, + PPB_Core_Proxy::GetPPB_Core_Interface()); + AddPPB(PPB_MEMORY_DEV_INTERFACE, INTERFACE_ID_NONE, + GetPPB_Memory_Interface()); + AddPPB(PPB_OPENGLES2_INTERFACE, INTERFACE_ID_NONE, + OpenGLES2Impl::GetInterface()); + AddPPB(PPB_VAR_INTERFACE, INTERFACE_ID_NONE, + GetPPB_Var_Interface()); + + // Manually add some special proxies. These don't have interfaces that they + // support, so aren't covered by the macros above, but have proxies for + // message routing. + AddProxy(INTERFACE_ID_RESOURCE_CREATION, &ResourceCreationProxy::Create); + AddProxy(INTERFACE_ID_PPP_CLASS, &PPP_Class_Proxy::Create); + + // PPB (browser) interfaces. + AddPPB(PPB_Crypto_Proxy::GetInfo()); + AddPPB(PPB_Flash_Clipboard_Proxy::GetInfo()); + AddPPB(PPB_Flash_File_FileRef_Proxy::GetInfo()); + AddPPB(PPB_Flash_File_ModuleLocal_Proxy::GetInfo()); + AddPPB(PPB_Flash_Menu_Proxy::GetInfo()); + AddPPB(PPB_Flash_Proxy::GetInfo()); + AddPPB(PPB_Flash_TCPSocket_Proxy::GetInfo()); + AddPPB(PPB_Instance_Proxy::GetInfoFullscreen()); + AddPPB(PPB_Instance_Proxy::GetInfoPrivate()); + AddPPB(PPB_PDF_Proxy::GetInfo()); + AddPPB(PPB_Testing_Proxy::GetInfo()); + AddPPB(PPB_URLLoader_Proxy::GetTrustedInfo()); + AddPPB(PPB_URLUtil_Proxy::GetInfo()); + AddPPB(PPB_Var_Deprecated_Proxy::GetInfo()); + +#ifdef ENABLE_FLAPPER_HACKS + AddPPB(PPB_Flash_NetConnector_Proxy::GetInfo()); +#endif + + // PPP (plugin) interfaces. + AddPPP(PPP_Graphics3D_Proxy::GetInfo()); + AddPPP(PPP_InputEvent_Proxy::GetInfo()); + AddPPP(PPP_Instance_Private_Proxy::GetInfo()); + AddPPP(PPP_Instance_Proxy::GetInfo1_0()); + AddPPP(PPP_Messaging_Proxy::GetInfo()); + AddPPP(PPP_MouseLock_Proxy::GetInfo()); + AddPPP(PPP_VideoCapture_Proxy::GetInfo()); + AddPPP(PPP_VideoDecoder_Proxy::GetInfo()); +} + +InterfaceList::~InterfaceList() { +} + +// static +InterfaceList* InterfaceList::GetInstance() { + return Singleton<InterfaceList>::get(); +} + +InterfaceID InterfaceList::GetIDForPPBInterface(const std::string& name) const { + NameToInterfaceInfoMap::const_iterator found = + name_to_browser_info_.find(name); + if (found == name_to_browser_info_.end()) + return INTERFACE_ID_NONE; + return found->second.id; +} + +InterfaceID InterfaceList::GetIDForPPPInterface(const std::string& name) const { + NameToInterfaceInfoMap::const_iterator found = + name_to_plugin_info_.find(name); + if (found == name_to_plugin_info_.end()) + return INTERFACE_ID_NONE; + return found->second.id; +} + +InterfaceProxy::Factory InterfaceList::GetFactoryForID(InterfaceID id) const { + int index = static_cast<int>(id); + COMPILE_ASSERT(INTERFACE_ID_NONE == 0, none_must_be_zero); + if (id <= 0 || id >= INTERFACE_ID_COUNT) + return NULL; + return id_to_factory_[index]; +} + +const void* InterfaceList::GetInterfaceForPPB(const std::string& name) const { + NameToInterfaceInfoMap::const_iterator found = + name_to_browser_info_.find(name); + if (found == name_to_browser_info_.end()) + return NULL; + return found->second.iface; +} + +const void* InterfaceList::GetInterfaceForPPP(const std::string& name) const { + NameToInterfaceInfoMap::const_iterator found = + name_to_plugin_info_.find(name); + if (found == name_to_plugin_info_.end()) + return NULL; + return found->second.iface; +} + +void InterfaceList::AddProxy(InterfaceID id, + InterfaceProxy::Factory factory) { + // For interfaces with no corresponding _Proxy objects, the macros will + // generate calls to this function with INTERFACE_ID_NONE. This means we + // should just skip adding a factory for these functions. + if (id == INTERFACE_ID_NONE) + return; + + // The factory should be an exact dupe of the one we already have if it + // has already been registered before. + int index = static_cast<int>(id); + DCHECK(!id_to_factory_[index] || id_to_factory_[index] == factory); + + id_to_factory_[index] = factory; +} + +void InterfaceList::AddPPB(const char* name, + InterfaceID id, + const void* iface) { + DCHECK(name_to_browser_info_.find(name) == name_to_browser_info_.end()); + name_to_browser_info_[name] = InterfaceInfo(id, iface); +} + +void InterfaceList::AddPPP(const char* name, + InterfaceID id, + const void* iface) { + DCHECK(name_to_plugin_info_.find(name) == name_to_plugin_info_.end()); + name_to_plugin_info_[name] = InterfaceInfo(id, iface); +} + +void InterfaceList::AddPPB(const InterfaceProxy::Info* info) { + AddProxy(info->id, info->create_proxy); + AddPPB(info->name, info->id, info->interface_ptr); +} + +void InterfaceList::AddPPP(const InterfaceProxy::Info* info) { + AddProxy(info->id, info->create_proxy); + AddPPP(info->name, info->id, info->interface_ptr); +} + +} // namespace proxy +} // namespace ppapi diff --git a/ppapi/proxy/interface_list.h b/ppapi/proxy/interface_list.h new file mode 100644 index 0000000..0290af9 --- /dev/null +++ b/ppapi/proxy/interface_list.h @@ -0,0 +1,77 @@ +// Copyright (c) 2011 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. + +#ifndef PPAPI_PROXY_INTERFACE_LIST_H_ +#define PPAPI_PROXY_INTERFACE_LIST_H_ + +#include <map> +#include <string> + +#include "base/basictypes.h" +#include "ppapi/proxy/interface_proxy.h" + +namespace ppapi { +namespace proxy { + +class InterfaceList { + public: + InterfaceList(); + ~InterfaceList(); + + static InterfaceList* GetInstance(); + + // Looks up the ID for the given interface name. Returns INTERFACE_ID_NONE if + // the interface string is not found. + InterfaceID GetIDForPPBInterface(const std::string& name) const; + InterfaceID GetIDForPPPInterface(const std::string& name) const; + + // Looks up the factory function for the given ID. Returns NULL if not + // supported. + InterfaceProxy::Factory GetFactoryForID(InterfaceID id) const; + + // Returns the interface pointer for the given browser or plugin interface, + // or NULL if it's not supported. + const void* GetInterfaceForPPB(const std::string& name) const; + const void* GetInterfaceForPPP(const std::string& name) const; + + private: + struct InterfaceInfo { + InterfaceInfo() + : id(INTERFACE_ID_NONE), + iface(NULL) { + } + InterfaceInfo(InterfaceID in_id, const void* in_interface) + : id(in_id), + iface(in_interface) { + } + + InterfaceID id; + const void* iface; + }; + + typedef std::map<std::string, InterfaceInfo> NameToInterfaceInfoMap; + + void AddProxy(InterfaceID id, InterfaceProxy::Factory factory); + + void AddPPB(const char* name, InterfaceID id, const void* iface); + void AddPPP(const char* name, InterfaceID id, const void* iface); + + // Old-style add functions. These should be removed when the rest of the + // proxies are converted over to using the new system. + void AddPPB(const InterfaceProxy::Info* info); + void AddPPP(const InterfaceProxy::Info* info); + + NameToInterfaceInfoMap name_to_browser_info_; + NameToInterfaceInfoMap name_to_plugin_info_; + + InterfaceProxy::Factory id_to_factory_[INTERFACE_ID_COUNT]; + + DISALLOW_COPY_AND_ASSIGN(InterfaceList); +}; + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_INTERFACE_LIST_H_ + diff --git a/ppapi/proxy/interface_proxy.cc b/ppapi/proxy/interface_proxy.cc index a474383..913821a 100644 --- a/ppapi/proxy/interface_proxy.cc +++ b/ppapi/proxy/interface_proxy.cc @@ -10,10 +10,8 @@ namespace ppapi { namespace proxy { -InterfaceProxy::InterfaceProxy(Dispatcher* dispatcher, - const void* target_interface) - : dispatcher_(dispatcher), - target_interface_(target_interface) { +InterfaceProxy::InterfaceProxy(Dispatcher* dispatcher) + : dispatcher_(dispatcher) { } InterfaceProxy::~InterfaceProxy() { diff --git a/ppapi/proxy/interface_proxy.h b/ppapi/proxy/interface_proxy.h index 1fed704..795944b 100644 --- a/ppapi/proxy/interface_proxy.h +++ b/ppapi/proxy/interface_proxy.h @@ -12,6 +12,7 @@ #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_var.h" #include "ppapi/proxy/interface_id.h" +#include "ppapi/shared_impl/function_group_base.h" namespace ppapi { namespace proxy { @@ -19,13 +20,16 @@ namespace proxy { class Dispatcher; class InterfaceProxy : public IPC::Channel::Listener, - public IPC::Message::Sender { + public IPC::Message::Sender, + public FunctionGroupBase { public: // Factory function type for interfaces. Ownership of the returned pointer // is transferred to the caller. - typedef InterfaceProxy* (*Factory)(Dispatcher* dispatcher, - const void* target_interface); + typedef InterfaceProxy* (*Factory)(Dispatcher* dispatcher); + // DEPRECATED: New classes should be registered directly in the interface + // list. This is kept around until we convert all the existing code. + // // Information about the interface. Each interface has a static function to // return its info, which allows either construction on the target side, and // getting the proxied interface on the source side (see dispatcher.h for @@ -43,9 +47,6 @@ class InterfaceProxy : public IPC::Channel::Listener, virtual ~InterfaceProxy(); - // The actual implementation of the given interface in the current process. - const void* target_interface() const { return target_interface_; } - Dispatcher* dispatcher() const { return dispatcher_; } // IPC::Message::Sender implementation. @@ -57,19 +58,13 @@ class InterfaceProxy : public IPC::Channel::Listener, protected: // Creates the given interface associated with the given dispatcher. The // dispatcher manages our lifetime. - // - // The target interface pointer, when non-NULL, indicates that this is a - // target proxy (see dispatcher.h for a definition). In this case, the proxy - // will interpret this pointer to the actual implementation of the interface - // in the local process. - InterfaceProxy(Dispatcher* dispatcher, const void* target_interface); + InterfaceProxy(Dispatcher* dispatcher); uint32 SendCallback(PP_CompletionCallback callback); PP_CompletionCallback ReceiveCallback(uint32 serialized_callback); private: Dispatcher* dispatcher_; - const void* target_interface_; }; } // namespace proxy diff --git a/ppapi/proxy/plugin_dispatcher.cc b/ppapi/proxy/plugin_dispatcher.cc index bb42fcb7..12d2e75 100644 --- a/ppapi/proxy/plugin_dispatcher.cc +++ b/ppapi/proxy/plugin_dispatcher.cc @@ -13,6 +13,7 @@ #include "ipc/ipc_sync_channel.h" #include "base/debug/trace_event.h" #include "ppapi/c/pp_errors.h" +#include "ppapi/proxy/interface_list.h" #include "ppapi/proxy/interface_proxy.h" #include "ppapi/proxy/plugin_message_filter.h" #include "ppapi/proxy/plugin_resource_tracker.h" @@ -53,11 +54,6 @@ PluginDispatcher::PluginDispatcher(base::ProcessHandle remote_process_handle, received_preferences_(false), plugin_dispatcher_id_(0) { SetSerializationRules(new PluginVarSerializationRules); - - // As a plugin, we always support the PPP_Class interface. There's no - // GetInterface call or name for it, so we insert it into our table now. - target_proxies_[INTERFACE_ID_PPP_CLASS].reset(new PPP_Class_Proxy(this)); - TrackerBase::Init(&PluginResourceTracker::GetTrackerBaseInstance); } @@ -83,13 +79,19 @@ PluginDispatcher* PluginDispatcher::GetForResource(const Resource* resource) { } // static -const void* PluginDispatcher::GetInterfaceFromDispatcher( - const char* dispatcher_interface) { - // All interfaces the plugin requests of the browser are "PPB". - const InterfaceProxy::Info* info = GetPPBInterfaceInfo(dispatcher_interface); - if (!info) - return NULL; - return info->interface_ptr; +const void* PluginDispatcher::GetBrowserInterface(const char* interface) { + return InterfaceList::GetInstance()->GetInterfaceForPPB(interface); +} + +const void* PluginDispatcher::GetPluginInterface( + const std::string& interface_name) { + InterfaceMap::iterator found = plugin_interfaces_.find(interface_name); + if (found == plugin_interfaces_.end()) { + const void* ret = local_get_interface()(interface_name.c_str()); + plugin_interfaces_.insert(std::make_pair(interface_name, ret)); + return ret; + } + return found->second; } bool PluginDispatcher::InitPluginWithChannel( @@ -131,56 +133,18 @@ bool PluginDispatcher::OnMessageReceived(const IPC::Message& msg) { TRACE_EVENT2("ppapi proxy", "PluginDispatcher::OnMessageReceived", "Class", IPC_MESSAGE_ID_CLASS(msg.type()), "Line", IPC_MESSAGE_ID_LINE(msg.type())); - // Handle common control messages. - if (Dispatcher::OnMessageReceived(msg)) - return true; - if (msg.routing_id() == MSG_ROUTING_CONTROL) { // Handle some plugin-specific control messages. bool handled = true; IPC_BEGIN_MESSAGE_MAP(PluginDispatcher, msg) IPC_MESSAGE_HANDLER(PpapiMsg_SupportsInterface, OnMsgSupportsInterface) IPC_MESSAGE_HANDLER(PpapiMsg_SetPreferences, OnMsgSetPreferences) + IPC_MESSAGE_UNHANDLED(handled = false); IPC_END_MESSAGE_MAP() - return handled; - } - - if (msg.routing_id() <= 0 || msg.routing_id() >= INTERFACE_ID_COUNT) { - // Host is sending us garbage. Since it's supposed to be trusted, this - // isn't supposed to happen. Crash here in all builds in case the renderer - // is compromised. - CHECK(false); - return true; - } - - // There are two cases: - // - // * The first case is that the host is calling a PPP interface. It will - // always do a check for the interface before sending messages, and this - // will create the necessary interface proxy at that time. So when we - // actually receive a message, we know such a proxy will exist. - // - // * The second case is that the host is sending a response to the plugin - // side of a PPB interface (some, like the URL loader, have complex - // response messages). Since the host is trusted and not supposed to be - // doing silly things, we can just create a PPB proxy project on demand the - // first time it's needed. - - InterfaceProxy* proxy = target_proxies_[msg.routing_id()].get(); - if (!proxy) { - // Handle the first time the host calls a PPB reply interface by - // autocreating it. - const InterfaceProxy::Info* info = GetPPBInterfaceInfo( - static_cast<InterfaceID>(msg.routing_id())); - if (!info) { - NOTREACHED(); + if (handled) return true; - } - proxy = info->create_proxy(this, NULL); - target_proxies_[info->id].reset(proxy); } - - return proxy->OnMessageReceived(msg); + return Dispatcher::OnMessageReceived(msg); } void PluginDispatcher::OnChannelError() { @@ -238,23 +202,7 @@ WebKitForwarding* PluginDispatcher::GetWebKitForwarding() { } FunctionGroupBase* PluginDispatcher::GetFunctionAPI(InterfaceID id) { - scoped_ptr<FunctionGroupBase >& proxy = function_proxies_[id]; - - if (proxy.get()) - return proxy.get(); - - if (id == INTERFACE_ID_PPB_CHAR_SET) - proxy.reset(new PPB_CharSet_Proxy(this, NULL)); - else if(id == INTERFACE_ID_PPB_CURSORCONTROL) - proxy.reset(new PPB_CursorControl_Proxy(this, NULL)); - else if (id == INTERFACE_ID_PPB_FONT) - proxy.reset(new PPB_Font_Proxy(this, NULL)); - else if (id == INTERFACE_ID_PPB_INSTANCE) - proxy.reset(new PPB_Instance_Proxy(this, NULL)); - else if (id == INTERFACE_ID_RESOURCE_CREATION) - proxy.reset(new ResourceCreationProxy(this)); - - return proxy.get(); + return GetInterfaceProxy(id); } void PluginDispatcher::ForceFreeAllInstances() { @@ -278,26 +226,7 @@ void PluginDispatcher::ForceFreeAllInstances() { void PluginDispatcher::OnMsgSupportsInterface( const std::string& interface_name, bool* result) { - *result = false; - - // Setup a proxy for receiving the messages from this interface. - const InterfaceProxy::Info* info = GetPPPInterfaceInfo(interface_name); - if (!info) - return; // Interface not supported by proxy. - - // Check for a cached result. - if (target_proxies_[info->id].get()) { - *result = true; - return; - } - - // Query the plugin & cache the result. - const void* interface_functions = GetLocalInterface(interface_name.c_str()); - if (!interface_functions) - return; - target_proxies_[info->id].reset( - info->create_proxy(this, interface_functions)); - *result = true; + *result = !!GetPluginInterface(interface_name); } void PluginDispatcher::OnMsgSetPreferences(const Preferences& prefs) { diff --git a/ppapi/proxy/plugin_dispatcher.h b/ppapi/proxy/plugin_dispatcher.h index 2238646..9604fe9 100644 --- a/ppapi/proxy/plugin_dispatcher.h +++ b/ppapi/proxy/plugin_dispatcher.h @@ -88,8 +88,11 @@ class PPAPI_PROXY_EXPORT PluginDispatcher : public Dispatcher { // object as a convenience. Returns NULL on failure. static PluginDispatcher* GetForResource(const Resource* resource); - static const void* GetInterfaceFromDispatcher( - const char* dispatcher_interface); + // Implements the GetInterface function for the plugin to call to retrieve + // a browser interface. + static const void* GetBrowserInterface(const char* interface); + + const void* GetPluginInterface(const std::string& interface_name); // You must call this function before anything else. Returns true on success. // The delegate pointer must outlive this class, ownership is not @@ -149,14 +152,12 @@ class PPAPI_PROXY_EXPORT PluginDispatcher : public Dispatcher { PluginDelegate* plugin_delegate_; - // All target proxies currently created. These are ones that receive - // messages. - scoped_ptr<InterfaceProxy> target_proxies_[INTERFACE_ID_COUNT]; - - // Function proxies created for "new-style" FunctionGroups. - // TODO(brettw) this is in progress. It should be merged with the target - // proxies so there is one list to consult. - scoped_ptr<FunctionGroupBase> function_proxies_[INTERFACE_ID_COUNT]; + // Contains all the plugin interfaces we've queried. The mapped value will + // be the pointer to the interface pointer supplied by the plugin if it's + // supported, or NULL if it's not supported. This allows us to cache failures + // and not req-query if a plugin doesn't support the interface. + typedef base::hash_map<std::string, const void*> InterfaceMap; + InterfaceMap plugin_interfaces_; typedef base::hash_map<PP_Instance, InstanceData> InstanceDataMap; InstanceDataMap instance_map_; diff --git a/ppapi/proxy/plugin_dispatcher_unittest.cc b/ppapi/proxy/plugin_dispatcher_unittest.cc index 56f563b..8a32026 100644 --- a/ppapi/proxy/plugin_dispatcher_unittest.cc +++ b/ppapi/proxy/plugin_dispatcher_unittest.cc @@ -53,7 +53,7 @@ class PluginDispatcherTest : public PluginProxyTest { PluginDispatcherTest() {} bool HasTargetProxy(InterfaceID id) { - return !!plugin_dispatcher()->target_proxies_[id].get(); + return !!plugin_dispatcher()->proxies_[id].get(); } }; @@ -64,11 +64,6 @@ TEST_F(PluginDispatcherTest, SupportsInterface) { // Sending a request for a random interface should fail. EXPECT_FALSE(SupportsInterface("Random interface")); - // Sending a request for a PPB interface should fail even though we've - // registered it as existing in the GetInterface function (the plugin proxy - // should only respond to PPP interfaces when asked if it supports them). - EXPECT_FALSE(SupportsInterface(PPB_AUDIO_INTERFACE)); - // Sending a request for a supported PPP interface should succeed. EXPECT_TRUE(SupportsInterface(PPP_INSTANCE_INTERFACE)); } diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index 4611a4f..ac7992d 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -468,17 +468,6 @@ IPC_SYNC_MESSAGE_ROUTED2_2(PpapiHostMsg_PPBBuffer_Create, ppapi::HostResource /* result_resource */, base::SharedMemoryHandle /* result_shm_handle */) -// PPB_Console. -IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBConsole_Log, - PP_Instance /* instance */, - int /* log_level */, - ppapi::proxy::SerializedVar /* value */) -IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBConsole_LogWithSource, - PP_Instance /* instance */, - int /* log_level */, - ppapi::proxy::SerializedVar /* soruce */, - ppapi::proxy::SerializedVar /* value */) - // PPB_Context3D. IPC_SYNC_MESSAGE_ROUTED3_1(PpapiHostMsg_PPBContext3D_Create, PP_Instance /* instance */, @@ -824,6 +813,15 @@ IPC_SYNC_MESSAGE_ROUTED2_2(PpapiHostMsg_PPBInstance_ExecuteScript, ppapi::proxy::SerializedVar /* script */, ppapi::proxy::SerializedVar /* out_exception */, ppapi::proxy::SerializedVar /* result */) +IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBInstance_Log, + PP_Instance /* instance */, + int /* log_level */, + ppapi::proxy::SerializedVar /* value */) +IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBInstance_LogWithSource, + PP_Instance /* instance */, + int /* log_level */, + ppapi::proxy::SerializedVar /* source */, + ppapi::proxy::SerializedVar /* value */) IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBInstance_SetFullscreen, PP_Instance /* instance */, PP_Bool /* fullscreen */, diff --git a/ppapi/proxy/ppb_audio_config_proxy.cc b/ppapi/proxy/ppb_audio_config_proxy.cc deleted file mode 100644 index d578fd5..0000000 --- a/ppapi/proxy/ppb_audio_config_proxy.cc +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2011 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. - -#include "ppapi/proxy/ppb_audio_config_proxy.h" - -#include "ppapi/c/ppb_audio_config.h" -#include "ppapi/proxy/plugin_dispatcher.h" -#include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/shared_impl/audio_config_impl.h" -#include "ppapi/thunk/thunk.h" - -namespace ppapi { -namespace proxy { - -namespace { - -InterfaceProxy* CreateAudioConfigProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_AudioConfig_Proxy(dispatcher, target_interface); -} - -} // namespace - -PPB_AudioConfig_Proxy::PPB_AudioConfig_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { -} - -PPB_AudioConfig_Proxy::~PPB_AudioConfig_Proxy() { -} - -// static -const InterfaceProxy::Info* PPB_AudioConfig_Proxy::GetInfo() { - static const Info info = { - thunk::GetPPB_AudioConfig_Thunk(), - PPB_AUDIO_CONFIG_INTERFACE, - INTERFACE_ID_PPB_AUDIO_CONFIG, - false, - &CreateAudioConfigProxy, - }; - return &info; -} - -bool PPB_AudioConfig_Proxy::OnMessageReceived(const IPC::Message& msg) { - // There are no IPC messages for this interface. - NOTREACHED(); - return false; -} - -} // namespace proxy -} // namespace ppapi diff --git a/ppapi/proxy/ppb_audio_config_proxy.h b/ppapi/proxy/ppb_audio_config_proxy.h deleted file mode 100644 index d70d2db..0000000 --- a/ppapi/proxy/ppb_audio_config_proxy.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2011 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. - -#ifndef PPAPI_PROXY_PPB_AUDIO_CONFIG_PROXY_H_ -#define PPAPI_PROXY_PPB_AUDIO_CONFIG_PROXY_H_ - -#include "base/basictypes.h" -#include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_resource.h" -#include "ppapi/c/ppb_audio_config.h" -#include "ppapi/proxy/interface_proxy.h" - -struct PPB_AudioConfig; - -namespace ppapi { -namespace proxy { - -class PPB_AudioConfig_Proxy : public InterfaceProxy { - public: - PPB_AudioConfig_Proxy(Dispatcher* dispatcher, const void* target_interface); - virtual ~PPB_AudioConfig_Proxy(); - - static const Info* GetInfo(); - - // InterfaceProxy implementation. - virtual bool OnMessageReceived(const IPC::Message& msg); - - private: - DISALLOW_COPY_AND_ASSIGN(PPB_AudioConfig_Proxy); -}; - -} // namespace proxy -} // namespace ppapi - -#endif // PPAPI_PROXY_PPB_AUDIO_CONFIG_PROXY_H_ diff --git a/ppapi/proxy/ppb_audio_proxy.cc b/ppapi/proxy/ppb_audio_proxy.cc index 139df10..453d7b0 100644 --- a/ppapi/proxy/ppb_audio_proxy.cc +++ b/ppapi/proxy/ppb_audio_proxy.cc @@ -116,11 +116,6 @@ int32_t Audio::GetSharedMemory(int* shm_handle, uint32_t* shm_size) { namespace { -InterfaceProxy* CreateAudioProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Audio_Proxy(dispatcher, target_interface); -} - base::PlatformFile IntToPlatformFile(int32_t handle) { // TODO(piman/brettw): Change trusted interface to return a PP_FileHandle, // those casts are ugly. @@ -135,9 +130,8 @@ base::PlatformFile IntToPlatformFile(int32_t handle) { } // namespace -PPB_Audio_Proxy::PPB_Audio_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface), +PPB_Audio_Proxy::PPB_Audio_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { } @@ -145,18 +139,6 @@ PPB_Audio_Proxy::~PPB_Audio_Proxy() { } // static -const InterfaceProxy::Info* PPB_Audio_Proxy::GetInfo() { - static const Info info = { - thunk::GetPPB_Audio_Thunk(), - PPB_AUDIO_INTERFACE, - INTERFACE_ID_PPB_AUDIO, - false, - &CreateAudioProxy, - }; - return &info; -} - -// static PP_Resource PPB_Audio_Proxy::CreateProxyResource( PP_Instance instance_id, PP_Resource config_id, @@ -242,16 +224,19 @@ void PPB_Audio_Proxy::OnMsgCreate(PP_Instance instance_id, // Clean up the temporary audio config resource we made. const PPB_Core* core = static_cast<const PPB_Core*>( - dispatcher()->GetLocalInterface(PPB_CORE_INTERFACE)); + dispatcher()->local_get_interface()(PPB_CORE_INTERFACE)); core->ReleaseResource(audio_config_res); } void PPB_Audio_Proxy::OnMsgStartOrStop(const HostResource& audio_id, bool play) { + EnterHostFromHostResource<PPB_Audio_API> enter(audio_id); + if (enter.failed()) + return; if (play) - ppb_audio_target()->StartPlayback(audio_id.host_resource()); + enter.object()->StartPlayback(); else - ppb_audio_target()->StopPlayback(audio_id.host_resource()); + enter.object()->StopPlayback(); } // Processed in the plugin (message from host). @@ -307,7 +292,7 @@ int32_t PPB_Audio_Proxy::GetAudioConnectedHandles( base::SharedMemoryHandle* foreign_shared_memory_handle, uint32_t* shared_memory_length) { // Get the audio interface which will give us the handles. - EnterResourceNoLock<PPB_Audio_API> enter(resource.host_resource(), false); + EnterHostFromHostResource<PPB_Audio_API> enter(resource); if (enter.failed()) return PP_ERROR_NOINTERFACE; diff --git a/ppapi/proxy/ppb_audio_proxy.h b/ppapi/proxy/ppb_audio_proxy.h index 7948b9c..b548e72 100644 --- a/ppapi/proxy/ppb_audio_proxy.h +++ b/ppapi/proxy/ppb_audio_proxy.h @@ -30,11 +30,9 @@ namespace proxy { class PPB_Audio_Proxy : public InterfaceProxy { public: - PPB_Audio_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPB_Audio_Proxy(Dispatcher* dispatcher); virtual ~PPB_Audio_Proxy(); - static const Info* GetInfo(); - // Creates an Audio object in the plugin process. static PP_Resource CreateProxyResource(PP_Instance instance_id, PP_Resource config_id, @@ -42,13 +40,11 @@ class PPB_Audio_Proxy : public InterfaceProxy { void* user_data); - const PPB_Audio* ppb_audio_target() const { - return static_cast<const PPB_Audio*>(target_interface()); - } - // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); + static const InterfaceID kInterfaceID = INTERFACE_ID_PPB_AUDIO; + private: // Plugin->renderer message handlers. void OnMsgCreate(PP_Instance instance_id, diff --git a/ppapi/proxy/ppb_broker_proxy.cc b/ppapi/proxy/ppb_broker_proxy.cc index 68ba8c0..ff06759 100644 --- a/ppapi/proxy/ppb_broker_proxy.cc +++ b/ppapi/proxy/ppb_broker_proxy.cc @@ -11,6 +11,7 @@ #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/thunk/ppb_broker_api.h" #include "ppapi/thunk/enter.h" +#include "ppapi/thunk/resource_creation_api.h" #include "ppapi/thunk/thunk.h" using ppapi::thunk::PPB_Broker_API; @@ -40,11 +41,6 @@ int32_t PlatformFileToInt(base::PlatformFile handle) { #endif } -InterfaceProxy* CreateBrokerProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Broker_Proxy(dispatcher, target_interface); -} - } // namespace class Broker : public PPB_Broker_API, public Resource { @@ -147,9 +143,8 @@ void Broker::ConnectComplete(IPC::PlatformFileForTransit socket_handle, PP_RunAndClearCompletionCallback(¤t_connect_callback_, result); } -PPB_Broker_Proxy::PPB_Broker_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) , +PPB_Broker_Proxy::PPB_Broker_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)){ } @@ -157,18 +152,6 @@ PPB_Broker_Proxy::~PPB_Broker_Proxy() { } // static -const InterfaceProxy::Info* PPB_Broker_Proxy::GetInfo() { - static const Info info = { - ppapi::thunk::GetPPB_Broker_Thunk(), - PPB_BROKER_TRUSTED_INTERFACE, - INTERFACE_ID_PPB_BROKER, - true, - &CreateBrokerProxy, - }; - return &info; -} - -// static PP_Resource PPB_Broker_Proxy::CreateProxyResource(PP_Instance instance) { PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); if (!dispatcher) @@ -196,9 +179,12 @@ bool PPB_Broker_Proxy::OnMessageReceived(const IPC::Message& msg) { void PPB_Broker_Proxy::OnMsgCreate(PP_Instance instance, HostResource* result_resource) { - result_resource->SetHostResource( - instance, - ppb_broker_target()->CreateTrusted(instance)); + thunk::EnterResourceCreation enter(instance); + if (enter.succeeded()) { + result_resource->SetHostResource( + instance, + enter.functions()->CreateBroker(instance)); + } } void PPB_Broker_Proxy::OnMsgConnect(const HostResource& broker) { @@ -240,8 +226,9 @@ void PPB_Broker_Proxy::ConnectCompleteInHost(int32_t result, IPC::InvalidPlatformFileForTransit(); if (result == PP_OK) { int32_t socket_handle = PlatformFileToInt(base::kInvalidPlatformFileValue); - result = ppb_broker_target()->GetHandle(broker.host_resource(), - &socket_handle); + EnterHostFromHostResource<PPB_Broker_API> enter(broker); + if (enter.succeeded()) + result = enter.object()->GetHandle(&socket_handle); DCHECK(result == PP_OK || socket_handle == PlatformFileToInt(base::kInvalidPlatformFileValue)); diff --git a/ppapi/proxy/ppb_broker_proxy.h b/ppapi/proxy/ppb_broker_proxy.h index e8c34e2..54ff9de 100644 --- a/ppapi/proxy/ppb_broker_proxy.h +++ b/ppapi/proxy/ppb_broker_proxy.h @@ -22,20 +22,16 @@ namespace proxy { class PPB_Broker_Proxy : public InterfaceProxy { public: - PPB_Broker_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPB_Broker_Proxy(Dispatcher* dispatcher); virtual ~PPB_Broker_Proxy(); - static const Info* GetInfo(); - static PP_Resource CreateProxyResource(PP_Instance instance); - const PPB_BrokerTrusted* ppb_broker_target() const { - return static_cast<const PPB_BrokerTrusted*>(target_interface()); - } - // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); + static const InterfaceID kInterfaceID = INTERFACE_ID_PPB_BROKER; + private: // Message handlers. void OnMsgCreate(PP_Instance instance, ppapi::HostResource* result_resource); diff --git a/ppapi/proxy/ppb_buffer_proxy.cc b/ppapi/proxy/ppb_buffer_proxy.cc index d9092fe..957108a 100644 --- a/ppapi/proxy/ppb_buffer_proxy.cc +++ b/ppapi/proxy/ppb_buffer_proxy.cc @@ -17,20 +17,12 @@ #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_buffer_trusted_api.h" +#include "ppapi/thunk/resource_creation_api.h" #include "ppapi/thunk/thunk.h" namespace ppapi { namespace proxy { -namespace { - -InterfaceProxy* CreateBufferProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Buffer_Proxy(dispatcher, target_interface); -} - -} // namespace - Buffer::Buffer(const HostResource& resource, const base::SharedMemoryHandle& shm_handle, uint32_t size) @@ -69,27 +61,14 @@ void Buffer::Unmap() { shm_.Unmap(); } -PPB_Buffer_Proxy::PPB_Buffer_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { +PPB_Buffer_Proxy::PPB_Buffer_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher) { } PPB_Buffer_Proxy::~PPB_Buffer_Proxy() { } // static -const InterfaceProxy::Info* PPB_Buffer_Proxy::GetInfo() { - static const Info info = { - thunk::GetPPB_Buffer_Thunk(), - PPB_BUFFER_DEV_INTERFACE, - INTERFACE_ID_PPB_BUFFER, - false, - &CreateBufferProxy, - }; - return &info; -} - -// static PP_Resource PPB_Buffer_Proxy::CreateProxyResource(PP_Instance instance, uint32_t size) { PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); @@ -135,10 +114,15 @@ void PPB_Buffer_Proxy::OnMsgCreate( HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); if (!dispatcher) return; - PP_Resource local_buffer_resource = - ppb_buffer_target()->Create(instance, size); + + thunk::EnterResourceCreation enter(instance); + if (enter.failed()) + return; + PP_Resource local_buffer_resource = enter.functions()->CreateBuffer(instance, + size); if (local_buffer_resource == 0) return; + thunk::EnterResourceNoLock<thunk::PPB_BufferTrusted_API> trusted_buffer( local_buffer_resource, false); if (trusted_buffer.failed()) diff --git a/ppapi/proxy/ppb_buffer_proxy.h b/ppapi/proxy/ppb_buffer_proxy.h index 2c0b875..4105dcc 100644 --- a/ppapi/proxy/ppb_buffer_proxy.h +++ b/ppapi/proxy/ppb_buffer_proxy.h @@ -46,24 +46,20 @@ class Buffer : public thunk::PPB_Buffer_API, public Resource { class PPB_Buffer_Proxy : public InterfaceProxy { public: - PPB_Buffer_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPB_Buffer_Proxy(Dispatcher* dispatcher); virtual ~PPB_Buffer_Proxy(); - static const Info* GetInfo(); - static PP_Resource CreateProxyResource(PP_Instance instance, uint32_t size); static PP_Resource AddProxyResource(const HostResource& resource, base::SharedMemoryHandle shm_handle, uint32_t size); - const PPB_Buffer_Dev* ppb_buffer_target() const { - return static_cast<const PPB_Buffer_Dev*>(target_interface()); - } - // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); + static const InterfaceID kInterfaceID = INTERFACE_ID_PPB_BUFFER; + private: // Message handlers. void OnMsgCreate(PP_Instance instance, diff --git a/ppapi/proxy/ppb_char_set_proxy.cc b/ppapi/proxy/ppb_char_set_proxy.cc index f23626f..52610f3 100644 --- a/ppapi/proxy/ppb_char_set_proxy.cc +++ b/ppapi/proxy/ppb_char_set_proxy.cc @@ -9,6 +9,7 @@ #include "ppapi/c/dev/ppb_memory_dev.h" #include "ppapi/proxy/plugin_dispatcher.h" #include "ppapi/proxy/ppapi_messages.h" +#include "ppapi/proxy/ppb_memory_proxy.h" #include "ppapi/proxy/serialized_var.h" #include "ppapi/shared_impl/char_set_impl.h" #include "ppapi/thunk/enter.h" @@ -17,40 +18,13 @@ namespace ppapi { namespace proxy { -namespace { - -const PPB_Memory_Dev* GetMemoryDevInterface() { - return static_cast<const PPB_Memory_Dev*>( - PluginDispatcher::GetInterfaceFromDispatcher(PPB_MEMORY_DEV_INTERFACE)); -} - -InterfaceProxy* CreateCharSetProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_CharSet_Proxy(dispatcher, target_interface); -} - -} // namespace - -PPB_CharSet_Proxy::PPB_CharSet_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { +PPB_CharSet_Proxy::PPB_CharSet_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher) { } PPB_CharSet_Proxy::~PPB_CharSet_Proxy() { } -// static -const InterfaceProxy::Info* PPB_CharSet_Proxy::GetInfo() { - static const Info info = { - ppapi::thunk::GetPPB_CharSet_Thunk(), - PPB_CHAR_SET_DEV_INTERFACE, - INTERFACE_ID_PPB_CHAR_SET, - false, - &CreateCharSetProxy, - }; - return &info; -} - ppapi::thunk::PPB_CharSet_FunctionAPI* PPB_CharSet_Proxy::AsPPB_CharSet_FunctionAPI() { return this; @@ -63,8 +37,8 @@ char* PPB_CharSet_Proxy::UTF16ToCharSet( PP_CharSet_ConversionError on_error, uint32_t* output_length) { return ppapi::CharSetImpl::UTF16ToCharSet( - GetMemoryDevInterface(), utf16, utf16_len, output_char_set, on_error, - output_length); + GetPPB_Memory_Interface(), utf16, utf16_len, + output_char_set, on_error, output_length); } uint16_t* PPB_CharSet_Proxy::CharSetToUTF16( @@ -74,8 +48,8 @@ uint16_t* PPB_CharSet_Proxy::CharSetToUTF16( PP_CharSet_ConversionError on_error, uint32_t* output_length) { return ppapi::CharSetImpl::CharSetToUTF16( - GetMemoryDevInterface(), input, input_len, input_char_set, on_error, - output_length); + GetPPB_Memory_Interface(), input, input_len, + input_char_set, on_error, output_length); } PP_Var PPB_CharSet_Proxy::GetDefaultCharSet(PP_Instance instance) { diff --git a/ppapi/proxy/ppb_char_set_proxy.h b/ppapi/proxy/ppb_char_set_proxy.h index af5cdc0..39ddc7b 100644 --- a/ppapi/proxy/ppb_char_set_proxy.h +++ b/ppapi/proxy/ppb_char_set_proxy.h @@ -19,15 +19,12 @@ namespace proxy { class SerializedVarReturnValue; -class PPB_CharSet_Proxy : public ppapi::FunctionGroupBase, - public ppapi::thunk::PPB_CharSet_FunctionAPI, - public InterfaceProxy { +class PPB_CharSet_Proxy : public InterfaceProxy, + public ppapi::thunk::PPB_CharSet_FunctionAPI { public: - PPB_CharSet_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPB_CharSet_Proxy(Dispatcher* dispatcher); virtual ~PPB_CharSet_Proxy(); - static const Info* GetInfo(); - // FunctionGroupBase overrides. virtual ppapi::thunk::PPB_CharSet_FunctionAPI* AsPPB_CharSet_FunctionAPI() OVERRIDE; @@ -48,6 +45,8 @@ class PPB_CharSet_Proxy : public ppapi::FunctionGroupBase, // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; + static const InterfaceID kInterfaceID = INTERFACE_ID_PPB_CHAR_SET; + private: void OnMsgGetDefaultCharSet(PP_Instance instance, SerializedVarReturnValue result); diff --git a/ppapi/proxy/ppb_console_proxy.cc b/ppapi/proxy/ppb_console_proxy.cc deleted file mode 100644 index 3745a77..0000000 --- a/ppapi/proxy/ppb_console_proxy.cc +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) 2011 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. - -#include "ppapi/proxy/ppb_console_proxy.h" - -#include "ppapi/c/dev/ppb_console_dev.h" -#include "ppapi/proxy/plugin_dispatcher.h" -#include "ppapi/proxy/ppapi_messages.h" - -namespace ppapi { -namespace proxy { - -namespace { - -void Log(PP_Instance instance, PP_LogLevel_Dev level, PP_Var value) { - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); - if (!dispatcher) - return; - dispatcher->Send(new PpapiHostMsg_PPBConsole_Log( - INTERFACE_ID_PPB_CONSOLE, instance, static_cast<int>(level), - SerializedVarSendInput(dispatcher, value))); -} - -void LogWithSource(PP_Instance instance, - PP_LogLevel_Dev level, - const PP_Var source, - const PP_Var value) { - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); - if (!dispatcher) - return; - dispatcher->Send(new PpapiHostMsg_PPBConsole_LogWithSource( - INTERFACE_ID_PPB_CONSOLE, instance, static_cast<int>(level), - SerializedVarSendInput(dispatcher, source), - SerializedVarSendInput(dispatcher, value))); -} - -const PPB_Console_Dev console_interface = { - &Log, - &LogWithSource -}; - -InterfaceProxy* CreateConsoleProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Console_Proxy(dispatcher, target_interface); -} - -} // namespace - -PPB_Console_Proxy::PPB_Console_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { -} - -PPB_Console_Proxy::~PPB_Console_Proxy() { -} - -// static -const InterfaceProxy::Info* PPB_Console_Proxy::GetInfo() { - static const Info info = { - &console_interface, - PPB_CONSOLE_DEV_INTERFACE, - INTERFACE_ID_PPB_CONSOLE, - false, - &CreateConsoleProxy, - }; - return &info; -} - -bool PPB_Console_Proxy::OnMessageReceived(const IPC::Message& msg) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(PPB_Console_Proxy, msg) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBConsole_Log, - OnMsgLog) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBConsole_LogWithSource, - OnMsgLogWithSource) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -void PPB_Console_Proxy::OnMsgLog(PP_Instance instance, - int log_level, - SerializedVarReceiveInput value) { - ppb_console_target()->Log(instance, - static_cast<PP_LogLevel_Dev>(log_level), - value.Get(dispatcher())); -} - -void PPB_Console_Proxy::OnMsgLogWithSource(PP_Instance instance, - int log_level, - SerializedVarReceiveInput source, - SerializedVarReceiveInput value) { - ppb_console_target()->LogWithSource( - instance, - static_cast<PP_LogLevel_Dev>(log_level), - source.Get(dispatcher()), - value.Get(dispatcher())); -} - -} // namespace proxy -} // namespace ppapi - diff --git a/ppapi/proxy/ppb_console_proxy.h b/ppapi/proxy/ppb_console_proxy.h deleted file mode 100644 index 33c1d2b..0000000 --- a/ppapi/proxy/ppb_console_proxy.h +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 2011 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. - -#ifndef PPAPI_PROXY_PPB_CONSOLE_PROXY_H_ -#define PPAPI_PROXY_PPB_CONSOLE_PROXY_H_ - -#include "base/basictypes.h" -#include "ppapi/c/pp_instance.h" -#include "ppapi/proxy/interface_proxy.h" -#include "ppapi/proxy/serialized_var.h" - -struct PPB_Console_Dev; - -namespace ppapi { -namespace proxy { - -class PPB_Console_Proxy : public InterfaceProxy { - public: - PPB_Console_Proxy(Dispatcher* dispatcher, const void* target_interface); - virtual ~PPB_Console_Proxy(); - - static const Info* GetInfo(); - - const PPB_Console_Dev* ppb_console_target() const { - return static_cast<const PPB_Console_Dev*>(target_interface()); - } - - // InterfaceProxy implementation. - virtual bool OnMessageReceived(const IPC::Message& msg); - - private: - // Message handlers. - void OnMsgLog(PP_Instance instance, - int log_level, - SerializedVarReceiveInput value); - void OnMsgLogWithSource(PP_Instance instance, - int log_level, - SerializedVarReceiveInput source, - SerializedVarReceiveInput value); - - DISALLOW_COPY_AND_ASSIGN(PPB_Console_Proxy); -}; - -} // namespace proxy -} // namespace ppapi - -#endif // PPAPI_PROXY_PPB_CONSOLE_PROXY_H_ diff --git a/ppapi/proxy/ppb_context_3d_proxy.cc b/ppapi/proxy/ppb_context_3d_proxy.cc index 26ad740..460c922 100644 --- a/ppapi/proxy/ppb_context_3d_proxy.cc +++ b/ppapi/proxy/ppb_context_3d_proxy.cc @@ -68,11 +68,6 @@ gpu::CommandBuffer::State GPUStateFromPPState( const int32 kCommandBufferSize = 1024 * 1024; const int32 kTransferBufferSize = 1024 * 1024; -InterfaceProxy* CreateContext3DProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Context3D_Proxy(dispatcher, target_interface); -} - } // namespace class PepperCommandBuffer : public gpu::CommandBuffer { @@ -521,39 +516,14 @@ gpu::gles2::GLES2Implementation* Context3D::GetGLES2Impl() { // PPB_Context3D_Proxy --------------------------------------------------------- -PPB_Context3D_Proxy::PPB_Context3D_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { +PPB_Context3D_Proxy::PPB_Context3D_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher) { } PPB_Context3D_Proxy::~PPB_Context3D_Proxy() { } // static -const InterfaceProxy::Info* PPB_Context3D_Proxy::GetInfo() { - static const Info info = { - thunk::GetPPB_Context3D_Thunk(), - PPB_CONTEXT_3D_DEV_INTERFACE, - INTERFACE_ID_PPB_CONTEXT_3D, - false, - &CreateContext3DProxy, - }; - return &info; -} - -// static -const InterfaceProxy::Info* PPB_Context3D_Proxy::GetTextureMappingInfo() { - static const Info info = { - thunk::GetPPB_GLESChromiumTextureMapping_Thunk(), - PPB_GLES_CHROMIUM_TEXTURE_MAPPING_DEV_INTERFACE, - INTERFACE_ID_NONE, // CONTEXT_3D is the canonical one. - false, - &CreateContext3DProxy, - }; - return &info; -} - -// static PP_Resource PPB_Context3D_Proxy::Create(PP_Instance instance, PP_Config3D_Dev config, PP_Resource share_context, @@ -621,7 +591,7 @@ void PPB_Context3D_Proxy::OnMsgCreate(PP_Instance instance, HostResource* result) { if (attribs.empty() || attribs.back() != 0) return; // Bad message. - EnterFunctionNoLock<ResourceCreationAPI> enter(instance, true); + thunk::EnterResourceCreation enter(instance); if (enter.succeeded()) { result->SetHostResource( instance, diff --git a/ppapi/proxy/ppb_context_3d_proxy.h b/ppapi/proxy/ppb_context_3d_proxy.h index a24a78d..9670f3a 100644 --- a/ppapi/proxy/ppb_context_3d_proxy.h +++ b/ppapi/proxy/ppb_context_3d_proxy.h @@ -94,12 +94,9 @@ class Context3D : public Resource, public thunk::PPB_Context3D_API { class PPB_Context3D_Proxy : public InterfaceProxy { public: - PPB_Context3D_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPB_Context3D_Proxy(Dispatcher* dispatcher); virtual ~PPB_Context3D_Proxy(); - static const Info* GetInfo(); - static const Info* GetTextureMappingInfo(); - static PP_Resource Create(PP_Instance instance, PP_Config3D_Dev config, PP_Resource share_context, @@ -108,6 +105,8 @@ class PPB_Context3D_Proxy : public InterfaceProxy { // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); + static const InterfaceID kInterfaceID = INTERFACE_ID_PPB_CONTEXT_3D; + private: void OnMsgCreate(PP_Instance instance, PP_Config3D_Dev config, diff --git a/ppapi/proxy/ppb_core_proxy.cc b/ppapi/proxy/ppb_core_proxy.cc index 83eea37..d3d17c0 100644 --- a/ppapi/proxy/ppb_core_proxy.cc +++ b/ppapi/proxy/ppb_core_proxy.cc @@ -75,31 +75,23 @@ const PPB_Core core_interface = { &IsMainThread }; -InterfaceProxy* CreateCoreProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Core_Proxy(dispatcher, target_interface); -} - } // namespace -PPB_Core_Proxy::PPB_Core_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { +PPB_Core_Proxy::PPB_Core_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), + ppb_core_impl_(NULL) { + if (!dispatcher->IsPlugin()) { + ppb_core_impl_ = static_cast<const PPB_Core*>( + dispatcher->local_get_interface()(PPB_CORE_INTERFACE)); + } } PPB_Core_Proxy::~PPB_Core_Proxy() { } // static -const InterfaceProxy::Info* PPB_Core_Proxy::GetInfo() { - static const Info info = { - &core_interface, - PPB_CORE_INTERFACE, - INTERFACE_ID_PPB_CORE, - false, - &CreateCoreProxy, - }; - return &info; +const PPB_Core* PPB_Core_Proxy::GetPPB_Core_Interface() { + return &core_interface; } bool PPB_Core_Proxy::OnMessageReceived(const IPC::Message& msg) { @@ -116,11 +108,11 @@ bool PPB_Core_Proxy::OnMessageReceived(const IPC::Message& msg) { } void PPB_Core_Proxy::OnMsgAddRefResource(const HostResource& resource) { - ppb_core_target()->AddRefResource(resource.host_resource()); + ppb_core_impl_->AddRefResource(resource.host_resource()); } void PPB_Core_Proxy::OnMsgReleaseResource(const HostResource& resource) { - ppb_core_target()->ReleaseResource(resource.host_resource()); + ppb_core_impl_->ReleaseResource(resource.host_resource()); } } // namespace proxy diff --git a/ppapi/proxy/ppb_core_proxy.h b/ppapi/proxy/ppb_core_proxy.h index 1963e71..950e5e8 100644 --- a/ppapi/proxy/ppb_core_proxy.h +++ b/ppapi/proxy/ppb_core_proxy.h @@ -8,6 +8,7 @@ #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_var.h" +#include "ppapi/c/ppb_core.h" #include "ppapi/proxy/interface_proxy.h" #include "ppapi/shared_impl/host_resource.h" @@ -18,22 +19,25 @@ namespace proxy { class PPB_Core_Proxy : public InterfaceProxy { public: - PPB_Core_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPB_Core_Proxy(Dispatcher* dispatcher); virtual ~PPB_Core_Proxy(); - static const Info* GetInfo(); - - const PPB_Core* ppb_core_target() const { - return reinterpret_cast<const PPB_Core*>(target_interface()); - } + static const PPB_Core* GetPPB_Core_Interface(); // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); + static const InterfaceID kInterfaceID = INTERFACE_ID_PPB_CORE; + private: // Message handlers. void OnMsgAddRefResource(const ppapi::HostResource& resource); void OnMsgReleaseResource(const ppapi::HostResource& resource); + + // When this proxy is in the host side, this value caches the interface + // pointer so we don't have to retrieve it from the dispatcher each time. + // In the plugin, this value is always NULL. + const PPB_Core* ppb_core_impl_; }; } // namespace proxy diff --git a/ppapi/proxy/ppb_crypto_proxy.cc b/ppapi/proxy/ppb_crypto_proxy.cc index c534864..e80e17a 100644 --- a/ppapi/proxy/ppb_crypto_proxy.cc +++ b/ppapi/proxy/ppb_crypto_proxy.cc @@ -17,16 +17,14 @@ const PPB_Crypto_Dev crypto_interface = { &ppapi::CryptoImpl::GetRandomBytes }; -InterfaceProxy* CreateCryptoProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Crypto_Proxy(dispatcher, target_interface); +InterfaceProxy* CreateCryptoProxy(Dispatcher* dispatcher) { + return new PPB_Crypto_Proxy(dispatcher); } } // namespace -PPB_Crypto_Proxy::PPB_Crypto_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { +PPB_Crypto_Proxy::PPB_Crypto_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher) { NOTREACHED(); // See comment in the header file. } diff --git a/ppapi/proxy/ppb_crypto_proxy.h b/ppapi/proxy/ppb_crypto_proxy.h index 3ad77c9..8e343a8 100644 --- a/ppapi/proxy/ppb_crypto_proxy.h +++ b/ppapi/proxy/ppb_crypto_proxy.h @@ -16,7 +16,7 @@ class PPB_Crypto_Proxy : public InterfaceProxy { // function that's implemented entirely within the plugin. However, we need // to support this so the machinery for automatically handling interfaces // works. As a result, this constructor will assert if it's actually used. - PPB_Crypto_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPB_Crypto_Proxy(Dispatcher* dispatcher); virtual ~PPB_Crypto_Proxy(); static const Info* GetInfo(); diff --git a/ppapi/proxy/ppb_cursor_control_proxy.cc b/ppapi/proxy/ppb_cursor_control_proxy.cc index 5366ea0..a0b0ee8 100644 --- a/ppapi/proxy/ppb_cursor_control_proxy.cc +++ b/ppapi/proxy/ppb_cursor_control_proxy.cc @@ -18,35 +18,13 @@ using ppapi::thunk::PPB_CursorControl_FunctionAPI; namespace ppapi { namespace proxy { -namespace { - -InterfaceProxy* CreateCursorControlProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_CursorControl_Proxy(dispatcher, target_interface); -} - -} // namespace - -PPB_CursorControl_Proxy::PPB_CursorControl_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { +PPB_CursorControl_Proxy::PPB_CursorControl_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher) { } PPB_CursorControl_Proxy::~PPB_CursorControl_Proxy() { } -// static -const InterfaceProxy::Info* PPB_CursorControl_Proxy::GetInfo() { - static const Info info = { - thunk::GetPPB_CursorControl_Thunk(), - PPB_CURSOR_CONTROL_DEV_INTERFACE, - INTERFACE_ID_PPB_CURSORCONTROL, - false, - &CreateCursorControlProxy, - }; - return &info; -} - ppapi::thunk::PPB_CursorControl_FunctionAPI* PPB_CursorControl_Proxy::AsPPB_CursorControl_FunctionAPI() { return this; diff --git a/ppapi/proxy/ppb_cursor_control_proxy.h b/ppapi/proxy/ppb_cursor_control_proxy.h index 027dbfe..6c42c9b 100644 --- a/ppapi/proxy/ppb_cursor_control_proxy.h +++ b/ppapi/proxy/ppb_cursor_control_proxy.h @@ -21,15 +21,12 @@ namespace ppapi { namespace proxy { class PPB_CursorControl_Proxy - : public ppapi::FunctionGroupBase, - public ppapi::thunk::PPB_CursorControl_FunctionAPI, - public InterfaceProxy { + : public InterfaceProxy, + public ppapi::thunk::PPB_CursorControl_FunctionAPI { public: - PPB_CursorControl_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPB_CursorControl_Proxy(Dispatcher* dispatcher); virtual ~PPB_CursorControl_Proxy(); - static const Info* GetInfo(); - // FunctionGroupBase overrides. ppapi::thunk::PPB_CursorControl_FunctionAPI* AsPPB_CursorControl_FunctionAPI() OVERRIDE; @@ -47,6 +44,8 @@ class PPB_CursorControl_Proxy // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; + static const InterfaceID kInterfaceID = INTERFACE_ID_PPB_CURSORCONTROL; + private: // Message handlers. void OnMsgSetCursor(PP_Instance instance, diff --git a/ppapi/proxy/ppb_file_chooser_proxy.cc b/ppapi/proxy/ppb_file_chooser_proxy.cc index f13ea86..73f7a6a 100644 --- a/ppapi/proxy/ppb_file_chooser_proxy.cc +++ b/ppapi/proxy/ppb_file_chooser_proxy.cc @@ -16,6 +16,7 @@ #include "ppapi/proxy/ppb_file_ref_proxy.h" #include "ppapi/proxy/serialized_var.h" #include "ppapi/shared_impl/var.h" +#include "ppapi/thunk/resource_creation_api.h" #include "ppapi/thunk/thunk.h" using ppapi::thunk::PPB_FileChooser_API; @@ -118,77 +119,14 @@ void FileChooser::ChooseComplete( // DANGER: May delete |this|! } -namespace { - -PP_Resource Create0_4(PP_Instance instance, - const PP_FileChooserOptions_0_4_Dev* options) { - PP_Var accept_var = PP_MakeUndefined(); - if (options->accept_mime_types) - accept_var = StringVar::StringToPPVar(0, options->accept_mime_types); - PP_Resource result = thunk::GetPPB_FileChooser_Thunk()->Create( - instance, options->mode, accept_var); - if (accept_var.type == PP_VARTYPE_STRING) - PluginResourceTracker::GetInstance()->var_tracker().ReleaseVar(accept_var); - return result; -} - -PP_Bool IsFileChooser0_4(PP_Resource resource) { - return thunk::GetPPB_FileChooser_Thunk()->IsFileChooser(resource); -} - -int32_t Show0_4(PP_Resource chooser, PP_CompletionCallback callback) { - return thunk::GetPPB_FileChooser_Thunk()->Show(chooser, callback); -} - -PP_Resource GetNextChosenFile0_4(PP_Resource chooser) { - return thunk::GetPPB_FileChooser_Thunk()->GetNextChosenFile(chooser); -} - -PPB_FileChooser_0_4_Dev file_chooser_0_4_interface = { - &Create0_4, - &IsFileChooser0_4, - &Show0_4, - &GetNextChosenFile0_4 -}; - -InterfaceProxy* CreateFileChooserProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_FileChooser_Proxy(dispatcher, target_interface); -} - -} // namespace - -PPB_FileChooser_Proxy::PPB_FileChooser_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface), +PPB_FileChooser_Proxy::PPB_FileChooser_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { } PPB_FileChooser_Proxy::~PPB_FileChooser_Proxy() { } -const InterfaceProxy::Info* PPB_FileChooser_Proxy::GetInfo() { - static const Info info = { - thunk::GetPPB_FileChooser_Thunk(), - PPB_FILECHOOSER_DEV_INTERFACE, - INTERFACE_ID_PPB_FILE_CHOOSER, - false, - &CreateFileChooserProxy, - }; - return &info; -} - -const InterfaceProxy::Info* PPB_FileChooser_Proxy::GetInfo0_4() { - static const Info info = { - &file_chooser_0_4_interface, - PPB_FILECHOOSER_DEV_INTERFACE_0_4, - INTERFACE_ID_NONE, - false, - &CreateFileChooserProxy, - }; - return &info; -} - // static PP_Resource PPB_FileChooser_Proxy::CreateProxyResource( PP_Instance instance, @@ -229,9 +167,12 @@ void PPB_FileChooser_Proxy::OnMsgCreate( int mode, SerializedVarReceiveInput accept_mime_types, HostResource* result) { - result->SetHostResource(instance, ppb_file_chooser_target()->Create( - instance, static_cast<PP_FileChooserMode_Dev>(mode), - accept_mime_types.Get(dispatcher()))); + thunk::EnterResourceCreation enter(instance); + if (enter.succeeded()) { + result->SetHostResource(instance, enter.functions()->CreateFileChooser( + instance, static_cast<PP_FileChooserMode_Dev>(mode), + accept_mime_types.Get(dispatcher()))); + } } void PPB_FileChooser_Proxy::OnMsgShow(const HostResource& chooser) { @@ -255,19 +196,16 @@ void PPB_FileChooser_Proxy::OnMsgChooseComplete( void PPB_FileChooser_Proxy::OnShowCallback(int32_t result, const HostResource& chooser) { + EnterHostFromHostResource<PPB_FileChooser_API> enter(chooser); + std::vector<PPB_FileRef_CreateInfo> files; - if (result == PP_OK) { - // Jump through some hoops to get the FileRef proxy. Since we know we're - // in the host at this point, we can ask the host dispatcher for it. - DCHECK(!dispatcher()->IsPlugin()); - HostDispatcher* host_disp = static_cast<HostDispatcher*>(dispatcher()); + if (enter.succeeded() && result == PP_OK) { PPB_FileRef_Proxy* file_ref_proxy = static_cast<PPB_FileRef_Proxy*>( - host_disp->GetOrCreatePPBInterfaceProxy(INTERFACE_ID_PPB_FILE_REF)); + dispatcher()->GetInterfaceProxy(INTERFACE_ID_PPB_FILE_REF)); // Convert the returned files to the serialized info. while (PP_Resource cur_file_resource = - ppb_file_chooser_target()->GetNextChosenFile( - chooser.host_resource())) { + enter.object()->GetNextChosenFile()) { PPB_FileRef_CreateInfo cur_create_info; file_ref_proxy->SerializeFileRef(cur_file_resource, &cur_create_info); files.push_back(cur_create_info); diff --git a/ppapi/proxy/ppb_file_chooser_proxy.h b/ppapi/proxy/ppb_file_chooser_proxy.h index 4f3bc84..f1dcd95 100644 --- a/ppapi/proxy/ppb_file_chooser_proxy.h +++ b/ppapi/proxy/ppb_file_chooser_proxy.h @@ -28,24 +28,19 @@ class SerializedVarReceiveInput; class PPB_FileChooser_Proxy : public InterfaceProxy { public: - PPB_FileChooser_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPB_FileChooser_Proxy(Dispatcher* dispatcher); virtual ~PPB_FileChooser_Proxy(); - static const Info* GetInfo(); - static const Info* GetInfo0_4(); - static PP_Resource CreateProxyResource( PP_Instance instance, PP_FileChooserMode_Dev mode, const PP_Var& accept_mime_types); - const PPB_FileChooser_Dev* ppb_file_chooser_target() const { - return static_cast<const PPB_FileChooser_Dev*>(target_interface()); - } - // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); + static const InterfaceID kInterfaceID = INTERFACE_ID_PPB_FILE_CHOOSER; + private: // Plugin -> host message handlers. void OnMsgCreate(PP_Instance instance, diff --git a/ppapi/proxy/ppb_file_ref_proxy.cc b/ppapi/proxy/ppb_file_ref_proxy.cc index 0cf26bd..49a1131 100644 --- a/ppapi/proxy/ppb_file_ref_proxy.cc +++ b/ppapi/proxy/ppb_file_ref_proxy.cc @@ -24,15 +24,6 @@ using ppapi::thunk::ResourceCreationAPI; namespace ppapi { namespace proxy { -namespace { - -InterfaceProxy* CreateFileRefProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_FileRef_Proxy(dispatcher, target_interface); -} - -} // namespace - class FileRef : public FileRefImpl { public: explicit FileRef(const PPB_FileRef_CreateInfo& info); @@ -111,25 +102,13 @@ int32_t FileRef::Rename(PP_Resource new_file_ref, return PP_OK_COMPLETIONPENDING; } -PPB_FileRef_Proxy::PPB_FileRef_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { +PPB_FileRef_Proxy::PPB_FileRef_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher) { } PPB_FileRef_Proxy::~PPB_FileRef_Proxy() { } -const InterfaceProxy::Info* PPB_FileRef_Proxy::GetInfo() { - static const Info info = { - thunk::GetPPB_FileRef_Thunk(), - PPB_FILEREF_INTERFACE, - INTERFACE_ID_PPB_FILE_REF, - false, - &CreateFileRefProxy, - }; - return &info; -} - // static PP_Resource PPB_FileRef_Proxy::CreateProxyResource(PP_Resource file_system, const char* path) { @@ -179,7 +158,7 @@ PP_Resource PPB_FileRef_Proxy::DeserializeFileRef( void PPB_FileRef_Proxy::OnMsgCreate(const HostResource& file_system, const std::string& path, PPB_FileRef_CreateInfo* result) { - EnterFunctionNoLock<ResourceCreationAPI> enter(file_system.instance(), true); + thunk::EnterResourceCreation enter(file_system.instance()); if (enter.failed()) return; PP_Resource resource = enter.functions()->CreateFileRef( diff --git a/ppapi/proxy/ppb_file_ref_proxy.h b/ppapi/proxy/ppb_file_ref_proxy.h index 1241343..6133c1a 100644 --- a/ppapi/proxy/ppb_file_ref_proxy.h +++ b/ppapi/proxy/ppb_file_ref_proxy.h @@ -24,11 +24,9 @@ namespace proxy { class PPB_FileRef_Proxy : public InterfaceProxy { public: - PPB_FileRef_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPB_FileRef_Proxy(Dispatcher* dispatcher); virtual ~PPB_FileRef_Proxy(); - static const Info* GetInfo(); - static PP_Resource CreateProxyResource(PP_Resource file_system, const char* path); @@ -57,6 +55,8 @@ class PPB_FileRef_Proxy : public InterfaceProxy { static PP_Resource DeserializeFileRef( const PPB_FileRef_CreateInfo& serialized); + static const InterfaceID kInterfaceID = INTERFACE_ID_PPB_FILE_REF; + private: // Message handlers. void OnMsgCreate(const ppapi::HostResource& file_system, diff --git a/ppapi/proxy/ppb_file_system_proxy.cc b/ppapi/proxy/ppb_file_system_proxy.cc index 899c51f..8fc7b55 100644 --- a/ppapi/proxy/ppb_file_system_proxy.cc +++ b/ppapi/proxy/ppb_file_system_proxy.cc @@ -27,9 +27,8 @@ namespace proxy { namespace { -InterfaceProxy* CreateFileSystemProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_FileSystem_Proxy(dispatcher, target_interface); +InterfaceProxy* CreateFileSystemProxy(Dispatcher* dispatcher) { + return new PPB_FileSystem_Proxy(dispatcher); } } // namespace @@ -110,9 +109,8 @@ void FileSystem::OpenComplete(int32_t result) { PP_RunAndClearCompletionCallback(¤t_open_callback_, result); } -PPB_FileSystem_Proxy::PPB_FileSystem_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface), +PPB_FileSystem_Proxy::PPB_FileSystem_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { } @@ -160,7 +158,7 @@ bool PPB_FileSystem_Proxy::OnMessageReceived(const IPC::Message& msg) { void PPB_FileSystem_Proxy::OnMsgCreate(PP_Instance instance, int type, HostResource* result) { - EnterFunctionNoLock<ResourceCreationAPI> enter(instance, true); + thunk::EnterResourceCreation enter(instance); if (enter.failed()) return; PP_Resource resource = enter.functions()->CreateFileSystem( diff --git a/ppapi/proxy/ppb_file_system_proxy.h b/ppapi/proxy/ppb_file_system_proxy.h index b83fb992..5573cce 100644 --- a/ppapi/proxy/ppb_file_system_proxy.h +++ b/ppapi/proxy/ppb_file_system_proxy.h @@ -26,7 +26,7 @@ namespace proxy { class PPB_FileSystem_Proxy : public InterfaceProxy { public: - PPB_FileSystem_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPB_FileSystem_Proxy(Dispatcher* dispatcher); virtual ~PPB_FileSystem_Proxy(); static const Info* GetInfo(); @@ -37,6 +37,8 @@ class PPB_FileSystem_Proxy : public InterfaceProxy { // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); + static const InterfaceID kInterfaceID = INTERFACE_ID_PPB_FILE_SYSTEM; + private: // Message handlers. void OnMsgCreate(PP_Instance instance, diff --git a/ppapi/proxy/ppb_flash_clipboard_proxy.cc b/ppapi/proxy/ppb_flash_clipboard_proxy.cc index 38e3e5b..18918fc 100644 --- a/ppapi/proxy/ppb_flash_clipboard_proxy.cc +++ b/ppapi/proxy/ppb_flash_clipboard_proxy.cc @@ -88,16 +88,19 @@ const PPB_Flash_Clipboard flash_clipboard_interface = { &WritePlainText }; -InterfaceProxy* CreateFlashClipboardProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Flash_Clipboard_Proxy(dispatcher, target_interface); +InterfaceProxy* CreateFlashClipboardProxy(Dispatcher* dispatcher) { + return new PPB_Flash_Clipboard_Proxy(dispatcher); } } // namespace -PPB_Flash_Clipboard_Proxy::PPB_Flash_Clipboard_Proxy( - Dispatcher* dispatcher, const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { +PPB_Flash_Clipboard_Proxy::PPB_Flash_Clipboard_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), + ppb_flash_clipboard_impl_(NULL) { + if (!dispatcher->IsPlugin()) { + ppb_flash_clipboard_impl_ = static_cast<const PPB_Flash_Clipboard*>( + dispatcher->local_get_interface()(PPB_FLASH_CLIPBOARD_INTERFACE)); + } } PPB_Flash_Clipboard_Proxy::~PPB_Flash_Clipboard_Proxy() { @@ -134,7 +137,7 @@ void PPB_Flash_Clipboard_Proxy::OnMsgIsFormatAvailable( int clipboard_type, int format, bool* result) { - *result = PP_ToBool(ppb_flash_clipboard_target()->IsFormatAvailable( + *result = PP_ToBool(ppb_flash_clipboard_impl_->IsFormatAvailable( instance_id, static_cast<PP_Flash_Clipboard_Type>(clipboard_type), static_cast<PP_Flash_Clipboard_Format>(format))); @@ -145,7 +148,7 @@ void PPB_Flash_Clipboard_Proxy::OnMsgReadPlainText( int clipboard_type, SerializedVarReturnValue result) { result.Return(dispatcher(), - ppb_flash_clipboard_target()->ReadPlainText( + ppb_flash_clipboard_impl_->ReadPlainText( instance_id, static_cast<PP_Flash_Clipboard_Type>(clipboard_type))); } @@ -154,7 +157,7 @@ void PPB_Flash_Clipboard_Proxy::OnMsgWritePlainText( PP_Instance instance_id, int clipboard_type, SerializedVarReceiveInput text) { - int32_t result = ppb_flash_clipboard_target()->WritePlainText( + int32_t result = ppb_flash_clipboard_impl_->WritePlainText( instance_id, static_cast<PP_Flash_Clipboard_Type>(clipboard_type), text.Get(dispatcher())); diff --git a/ppapi/proxy/ppb_flash_clipboard_proxy.h b/ppapi/proxy/ppb_flash_clipboard_proxy.h index e0a1acf..8d7a7b5 100644 --- a/ppapi/proxy/ppb_flash_clipboard_proxy.h +++ b/ppapi/proxy/ppb_flash_clipboard_proxy.h @@ -18,16 +18,11 @@ class SerializedVarReturnValue; class PPB_Flash_Clipboard_Proxy : public InterfaceProxy { public: - PPB_Flash_Clipboard_Proxy(Dispatcher* dispatcher, - const void* target_interface); + PPB_Flash_Clipboard_Proxy(Dispatcher* dispatcher); virtual ~PPB_Flash_Clipboard_Proxy(); static const Info* GetInfo(); - const PPB_Flash_Clipboard* ppb_flash_clipboard_target() const { - return reinterpret_cast<const PPB_Flash_Clipboard*>(target_interface()); - } - // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); @@ -43,6 +38,11 @@ class PPB_Flash_Clipboard_Proxy : public InterfaceProxy { void OnMsgWritePlainText(PP_Instance instance_id, int clipboard_type, SerializedVarReceiveInput text); + + // When this proxy is in the host side, this value caches the interface + // pointer so we don't have to retrieve it from the dispatcher each time. + // In the plugin, this value is always NULL. + const PPB_Flash_Clipboard* ppb_flash_clipboard_impl_; }; } // namespace proxy diff --git a/ppapi/proxy/ppb_flash_file_proxy.cc b/ppapi/proxy/ppb_flash_file_proxy.cc index 138f990..5f7ef23 100644 --- a/ppapi/proxy/ppb_flash_file_proxy.cc +++ b/ppapi/proxy/ppb_flash_file_proxy.cc @@ -501,17 +501,22 @@ const PPB_Flash_File_ModuleLocal flash_file_modulelocal_interface = { &FreeDirContents, }; -InterfaceProxy* CreateFlashFileModuleLocalProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Flash_File_ModuleLocal_Proxy(dispatcher, target_interface); +InterfaceProxy* CreateFlashFileModuleLocalProxy(Dispatcher* dispatcher) { + return new PPB_Flash_File_ModuleLocal_Proxy(dispatcher); } } // namespace PPB_Flash_File_ModuleLocal_Proxy::PPB_Flash_File_ModuleLocal_Proxy( - Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { + Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), + ppb_flash_file_module_local_impl_(NULL) { + if (!dispatcher->IsPlugin()) { + ppb_flash_file_module_local_impl_ = + static_cast<const PPB_Flash_File_ModuleLocal*>( + dispatcher->local_get_interface()( + PPB_FLASH_FILE_MODULELOCAL_INTERFACE)); + } } PPB_Flash_File_ModuleLocal_Proxy::~PPB_Flash_File_ModuleLocal_Proxy() { @@ -558,8 +563,8 @@ void PPB_Flash_File_ModuleLocal_Proxy::OnMsgOpenFile( IPC::PlatformFileForTransit* file_handle, int32_t* result) { base::PlatformFile file; - *result = ppb_flash_file_module_local_target()-> - OpenFile(instance, path.c_str(), mode, &file); + *result = ppb_flash_file_module_local_impl_->OpenFile( + instance, path.c_str(), mode, &file); *file_handle = PlatformFileToPlatformFileForTransit( dispatcher(), result, file); } @@ -569,8 +574,8 @@ void PPB_Flash_File_ModuleLocal_Proxy::OnMsgRenameFile( const std::string& from_path, const std::string& to_path, int32_t* result) { - *result = ppb_flash_file_module_local_target()-> - RenameFile(instance, from_path.c_str(), to_path.c_str()); + *result = ppb_flash_file_module_local_impl_->RenameFile( + instance, from_path.c_str(), to_path.c_str()); } void PPB_Flash_File_ModuleLocal_Proxy::OnMsgDeleteFileOrDir( @@ -578,23 +583,23 @@ void PPB_Flash_File_ModuleLocal_Proxy::OnMsgDeleteFileOrDir( const std::string& path, PP_Bool recursive, int32_t* result) { - *result = ppb_flash_file_module_local_target()-> - DeleteFileOrDir(instance, path.c_str(), recursive); + *result = ppb_flash_file_module_local_impl_->DeleteFileOrDir( + instance, path.c_str(), recursive); } void PPB_Flash_File_ModuleLocal_Proxy::OnMsgCreateDir(PP_Instance instance, const std::string& path, int32_t* result) { - *result = ppb_flash_file_module_local_target()-> - CreateDir(instance, path.c_str()); + *result = ppb_flash_file_module_local_impl_->CreateDir( + instance, path.c_str()); } void PPB_Flash_File_ModuleLocal_Proxy::OnMsgQueryFile(PP_Instance instance, const std::string& path, PP_FileInfo* info, int32_t* result) { - *result = ppb_flash_file_module_local_target()-> - QueryFile(instance, path.c_str(), info); + *result = ppb_flash_file_module_local_impl_->QueryFile( + instance, path.c_str(), info); } void PPB_Flash_File_ModuleLocal_Proxy::OnMsgGetDirContents( @@ -603,8 +608,8 @@ void PPB_Flash_File_ModuleLocal_Proxy::OnMsgGetDirContents( std::vector<SerializedDirEntry>* entries, int32_t* result) { PP_DirContents_Dev* contents = NULL; - *result = ppb_flash_file_module_local_target()-> - GetDirContents(instance, path.c_str(), &contents); + *result = ppb_flash_file_module_local_impl_->GetDirContents( + instance, path.c_str(), &contents); if (*result != PP_OK) return; @@ -614,7 +619,7 @@ void PPB_Flash_File_ModuleLocal_Proxy::OnMsgGetDirContents( (*entries)[i].name.assign(contents->entries[i].name); (*entries)[i].is_dir = PP_ToBool(contents->entries[i].is_dir); } - ppb_flash_file_module_local_target()->FreeDirContents(instance, contents); + ppb_flash_file_module_local_impl_->FreeDirContents(instance, contents); } // PPB_Flash_File_FileRef ------------------------------------------------------ @@ -665,17 +670,20 @@ const PPB_Flash_File_FileRef flash_file_fileref_interface = { &QueryFileRefFile, }; -InterfaceProxy* CreateFlashFileFileRefProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Flash_File_FileRef_Proxy(dispatcher, target_interface); +InterfaceProxy* CreateFlashFileFileRefProxy(Dispatcher* dispatcher) { + return new PPB_Flash_File_FileRef_Proxy(dispatcher); } } // namespace PPB_Flash_File_FileRef_Proxy::PPB_Flash_File_FileRef_Proxy( - Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { + Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), + ppb_flash_file_fileref_impl_(NULL) { + if (!dispatcher->IsPlugin()) { + ppb_flash_file_fileref_impl_ = static_cast<const PPB_Flash_File_FileRef*>( + dispatcher->local_get_interface()(PPB_FLASH_FILE_FILEREF_INTERFACE)); + } } PPB_Flash_File_FileRef_Proxy::~PPB_Flash_File_FileRef_Proxy() { @@ -713,8 +721,8 @@ void PPB_Flash_File_FileRef_Proxy::OnMsgOpenFile( IPC::PlatformFileForTransit* file_handle, int32_t* result) { base::PlatformFile file; - *result = ppb_flash_file_module_local_target()-> - OpenFile(host_resource.host_resource(), mode, &file); + *result = ppb_flash_file_fileref_impl_->OpenFile( + host_resource.host_resource(), mode, &file); *file_handle = PlatformFileToPlatformFileForTransit( dispatcher(), result, file); } @@ -723,8 +731,8 @@ void PPB_Flash_File_FileRef_Proxy::OnMsgQueryFile( const HostResource& host_resource, PP_FileInfo* info, int32_t* result) { - *result = ppb_flash_file_module_local_target()-> - QueryFile(host_resource.host_resource(), info); + *result = ppb_flash_file_fileref_impl_->QueryFile( + host_resource.host_resource(), info); } } // namespace proxy diff --git a/ppapi/proxy/ppb_flash_file_proxy.h b/ppapi/proxy/ppb_flash_file_proxy.h index ee8d05d..b0ebb63 100644 --- a/ppapi/proxy/ppb_flash_file_proxy.h +++ b/ppapi/proxy/ppb_flash_file_proxy.h @@ -27,16 +27,11 @@ struct SerializedDirEntry; class PPB_Flash_File_ModuleLocal_Proxy : public InterfaceProxy { public: - PPB_Flash_File_ModuleLocal_Proxy(Dispatcher* dispatcher, - const void* target_interface); + PPB_Flash_File_ModuleLocal_Proxy(Dispatcher* dispatcher); virtual ~PPB_Flash_File_ModuleLocal_Proxy(); static const Info* GetInfo(); - const PPB_Flash_File_ModuleLocal* ppb_flash_file_module_local_target() const { - return static_cast<const PPB_Flash_File_ModuleLocal*>(target_interface()); - } - // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); @@ -66,20 +61,22 @@ class PPB_Flash_File_ModuleLocal_Proxy : public InterfaceProxy { const std::string& path, std::vector<SerializedDirEntry>* entries, int32_t* result); + + // When this proxy is in the host side, this value caches the interface + // pointer so we don't have to retrieve it from the dispatcher each time. + // In the plugin, this value is always NULL. + const PPB_Flash_File_ModuleLocal* ppb_flash_file_module_local_impl_; + + DISALLOW_COPY_AND_ASSIGN(PPB_Flash_File_ModuleLocal_Proxy); }; class PPB_Flash_File_FileRef_Proxy : public InterfaceProxy { public: - PPB_Flash_File_FileRef_Proxy(Dispatcher* dispatcher, - const void* target_interface); + PPB_Flash_File_FileRef_Proxy(Dispatcher* dispatcher); virtual ~PPB_Flash_File_FileRef_Proxy(); static const Info* GetInfo(); - const PPB_Flash_File_FileRef* ppb_flash_file_module_local_target() const { - return static_cast<const PPB_Flash_File_FileRef*>(target_interface()); - } - // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); @@ -92,6 +89,13 @@ class PPB_Flash_File_FileRef_Proxy : public InterfaceProxy { void OnMsgQueryFile(const ppapi::HostResource& host_resource, PP_FileInfo* info, int32_t* result); + + // When this proxy is in the host side, this value caches the interface + // pointer so we don't have to retrieve it from the dispatcher each time. + // In the plugin, this value is always NULL. + const PPB_Flash_File_FileRef* ppb_flash_file_fileref_impl_; + + DISALLOW_COPY_AND_ASSIGN(PPB_Flash_File_FileRef_Proxy); }; } // namespace proxy diff --git a/ppapi/proxy/ppb_flash_menu_proxy.cc b/ppapi/proxy/ppb_flash_menu_proxy.cc index 5f6ff05..fad5689 100644 --- a/ppapi/proxy/ppb_flash_menu_proxy.cc +++ b/ppapi/proxy/ppb_flash_menu_proxy.cc @@ -77,16 +77,14 @@ void FlashMenu::ShowACK(int32_t selected_id, int32_t result) { namespace { -InterfaceProxy* CreateFlashMenuProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Flash_Menu_Proxy(dispatcher, target_interface); +InterfaceProxy* CreateFlashMenuProxy(Dispatcher* dispatcher) { + return new PPB_Flash_Menu_Proxy(dispatcher); } } // namespace -PPB_Flash_Menu_Proxy::PPB_Flash_Menu_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface), +PPB_Flash_Menu_Proxy::PPB_Flash_Menu_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { } @@ -144,7 +142,7 @@ bool PPB_Flash_Menu_Proxy::OnMessageReceived(const IPC::Message& msg) { void PPB_Flash_Menu_Proxy::OnMsgCreate(PP_Instance instance, const SerializedFlashMenu& menu_data, HostResource* result) { - EnterFunctionNoLock<ResourceCreationAPI> enter(instance, true); + thunk::EnterResourceCreation enter(instance); if (enter.succeeded()) { result->SetHostResource( instance, diff --git a/ppapi/proxy/ppb_flash_menu_proxy.h b/ppapi/proxy/ppb_flash_menu_proxy.h index 869a7d6..51a4dc6 100644 --- a/ppapi/proxy/ppb_flash_menu_proxy.h +++ b/ppapi/proxy/ppb_flash_menu_proxy.h @@ -22,7 +22,7 @@ class SerializedFlashMenu; class PPB_Flash_Menu_Proxy : public InterfaceProxy { public: - PPB_Flash_Menu_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPB_Flash_Menu_Proxy(Dispatcher* dispatcher); virtual ~PPB_Flash_Menu_Proxy(); static const Info* GetInfo(); diff --git a/ppapi/proxy/ppb_flash_net_connector_proxy.cc b/ppapi/proxy/ppb_flash_net_connector_proxy.cc index 44f856e..323059e 100644 --- a/ppapi/proxy/ppb_flash_net_connector_proxy.cc +++ b/ppapi/proxy/ppb_flash_net_connector_proxy.cc @@ -189,16 +189,15 @@ struct PPB_Flash_NetConnector_Proxy::ConnectCallbackInfo { namespace { -InterfaceProxy* CreateFlashNetConnectorProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Flash_NetConnector_Proxy(dispatcher, target_interface); +InterfaceProxy* CreateFlashNetConnectorProxy(Dispatcher* dispatcher) { + return new PPB_Flash_NetConnector_Proxy(dispatcher); } } // namespace PPB_Flash_NetConnector_Proxy::PPB_Flash_NetConnector_Proxy( - Dispatcher* dispatcher, const void* target_interface) - : InterfaceProxy(dispatcher, target_interface), + Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { } @@ -250,7 +249,7 @@ bool PPB_Flash_NetConnector_Proxy::OnMessageReceived(const IPC::Message& msg) { void PPB_Flash_NetConnector_Proxy::OnMsgCreate(PP_Instance instance, HostResource* result) { - EnterFunctionNoLock<ResourceCreationAPI> enter(instance, true); + thunk::EnterResourceCreation enter(instance); if (enter.succeeded()) { result->SetHostResource( instance, diff --git a/ppapi/proxy/ppb_flash_net_connector_proxy.h b/ppapi/proxy/ppb_flash_net_connector_proxy.h index 191b350..4ac6c5d 100644 --- a/ppapi/proxy/ppb_flash_net_connector_proxy.h +++ b/ppapi/proxy/ppb_flash_net_connector_proxy.h @@ -22,8 +22,7 @@ namespace proxy { class PPB_Flash_NetConnector_Proxy : public InterfaceProxy { public: - PPB_Flash_NetConnector_Proxy(Dispatcher* dispatcher, - const void* target_interface); + PPB_Flash_NetConnector_Proxy(Dispatcher* dispatcher); virtual ~PPB_Flash_NetConnector_Proxy(); static const Info* GetInfo(); diff --git a/ppapi/proxy/ppb_flash_proxy.cc b/ppapi/proxy/ppb_flash_proxy.cc index c551ace..1faae86 100644 --- a/ppapi/proxy/ppb_flash_proxy.cc +++ b/ppapi/proxy/ppb_flash_proxy.cc @@ -20,6 +20,7 @@ #include "ppapi/proxy/serialized_var.h" #include "ppapi/shared_impl/resource.h" #include "ppapi/shared_impl/scoped_pp_resource.h" +#include "ppapi/shared_impl/var.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_url_request_info_api.h" #include "ppapi/thunk/resource_creation_api.h" @@ -152,12 +153,8 @@ double GetLocalTimeZoneOffset(PP_Instance instance, PP_Time t) { } PP_Var GetCommandLineArgs(PP_Module pp_module) { - const PPB_Var_Deprecated* var_deprecated = - static_cast<const PPB_Var_Deprecated*>( - PluginDispatcher::GetInterfaceFromDispatcher( - PPB_VAR_DEPRECATED_INTERFACE)); std::string args = ProxyModule::GetInstance()->GetFlashCommandLineArgs(); - return var_deprecated->VarFromUtf8(pp_module, args.data(), args.length()); + return StringVar::StringToPPVar(pp_module, args); } const PPB_Flash flash_interface = { @@ -171,16 +168,18 @@ const PPB_Flash flash_interface = { &GetCommandLineArgs }; -InterfaceProxy* CreateFlashProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Flash_Proxy(dispatcher, target_interface); +InterfaceProxy* CreateFlashProxy(Dispatcher* dispatcher) { + return new PPB_Flash_Proxy(dispatcher); } } // namespace -PPB_Flash_Proxy::PPB_Flash_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { +PPB_Flash_Proxy::PPB_Flash_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), + ppb_flash_impl_(NULL) { + if (!dispatcher->IsPlugin()) + ppb_flash_impl_ = static_cast<const PPB_Flash*>( + dispatcher->local_get_interface()(PPB_FLASH_INTERFACE)); } PPB_Flash_Proxy::~PPB_Flash_Proxy() { @@ -228,7 +227,7 @@ bool PPB_Flash_Proxy::OnMessageReceived(const IPC::Message& msg) { void PPB_Flash_Proxy::OnMsgSetInstanceAlwaysOnTop( PP_Instance instance, PP_Bool on_top) { - ppb_flash_target()->SetInstanceAlwaysOnTop(instance, on_top); + ppb_flash_impl_->SetInstanceAlwaysOnTop(instance, on_top); } void PPB_Flash_Proxy::OnMsgDrawGlyphs(const PPBFlash_DrawGlyphs_Params& params, @@ -242,7 +241,7 @@ void PPB_Flash_Proxy::OnMsgDrawGlyphs(const PPBFlash_DrawGlyphs_Params& params, params.glyph_indices.empty()) return; - *result = ppb_flash_target()->DrawGlyphs( + *result = ppb_flash_impl_->DrawGlyphs( 0, // Unused instance param. params.image_data.host_resource(), &font_desc, params.color, params.position, params.clip, @@ -255,7 +254,7 @@ void PPB_Flash_Proxy::OnMsgDrawGlyphs(const PPBFlash_DrawGlyphs_Params& params, void PPB_Flash_Proxy::OnMsgGetProxyForURL(PP_Instance instance, const std::string& url, SerializedVarReturnValue result) { - result.Return(dispatcher(), ppb_flash_target()->GetProxyForURL( + result.Return(dispatcher(), ppb_flash_impl_->GetProxyForURL( instance, url.c_str())); } @@ -292,23 +291,23 @@ void PPB_Flash_Proxy::OnMsgNavigate(PP_Instance instance, ScopedPPResource::PassRef(), enter.functions()->CreateURLRequestInfo(instance, data)); - *result = ppb_flash_target()->Navigate(request_resource, - target.c_str(), - from_user_action); + *result = ppb_flash_impl_->Navigate(request_resource, + target.c_str(), + from_user_action); } void PPB_Flash_Proxy::OnMsgRunMessageLoop(PP_Instance instance) { - ppb_flash_target()->RunMessageLoop(instance); + ppb_flash_impl_->RunMessageLoop(instance); } void PPB_Flash_Proxy::OnMsgQuitMessageLoop(PP_Instance instance) { - ppb_flash_target()->QuitMessageLoop(instance); + ppb_flash_impl_->QuitMessageLoop(instance); } void PPB_Flash_Proxy::OnMsgGetLocalTimeZoneOffset(PP_Instance instance, PP_Time t, double* result) { - *result = ppb_flash_target()->GetLocalTimeZoneOffset(instance, t); + *result = ppb_flash_impl_->GetLocalTimeZoneOffset(instance, t); } } // namespace proxy diff --git a/ppapi/proxy/ppb_flash_proxy.h b/ppapi/proxy/ppb_flash_proxy.h index f893ce2..8bb15eb 100644 --- a/ppapi/proxy/ppb_flash_proxy.h +++ b/ppapi/proxy/ppb_flash_proxy.h @@ -29,15 +29,11 @@ class SerializedVarReturnValue; class PPB_Flash_Proxy : public InterfaceProxy { public: - PPB_Flash_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPB_Flash_Proxy(Dispatcher* dispatcher); virtual ~PPB_Flash_Proxy(); static const Info* GetInfo(); - const PPB_Flash* ppb_flash_target() const { - return static_cast<const PPB_Flash*>(target_interface()); - } - // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); @@ -59,6 +55,13 @@ class PPB_Flash_Proxy : public InterfaceProxy { void OnMsgQuitMessageLoop(PP_Instance instance); void OnMsgGetLocalTimeZoneOffset(PP_Instance instance, PP_Time t, double* result); + + // When this proxy is in the host side, this value caches the interface + // pointer so we don't have to retrieve it from the dispatcher each time. + // In the plugin, this value is always NULL. + const PPB_Flash* ppb_flash_impl_; + + DISALLOW_COPY_AND_ASSIGN(PPB_Flash_Proxy); }; } // namespace proxy diff --git a/ppapi/proxy/ppb_flash_tcp_socket_proxy.cc b/ppapi/proxy/ppb_flash_tcp_socket_proxy.cc index 12d40b7..7ff2ce3 100644 --- a/ppapi/proxy/ppb_flash_tcp_socket_proxy.cc +++ b/ppapi/proxy/ppb_flash_tcp_socket_proxy.cc @@ -49,9 +49,8 @@ class AbortCallbackTask : public Task { PP_CompletionCallback callback_; }; -InterfaceProxy* CreateFlashTCPSocketProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Flash_TCPSocket_Proxy(dispatcher, target_interface); +InterfaceProxy* CreateFlashTCPSocketProxy(Dispatcher* dispatcher) { + return new PPB_Flash_TCPSocket_Proxy(dispatcher); } } // namespace @@ -389,10 +388,8 @@ void FlashTCPSocket::PostAbortAndClearIfNecessary( } } -PPB_Flash_TCPSocket_Proxy::PPB_Flash_TCPSocket_Proxy( - Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { +PPB_Flash_TCPSocket_Proxy::PPB_Flash_TCPSocket_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher) { } PPB_Flash_TCPSocket_Proxy::~PPB_Flash_TCPSocket_Proxy() { diff --git a/ppapi/proxy/ppb_flash_tcp_socket_proxy.h b/ppapi/proxy/ppb_flash_tcp_socket_proxy.h index 831a8cc..925a4ae 100644 --- a/ppapi/proxy/ppb_flash_tcp_socket_proxy.h +++ b/ppapi/proxy/ppb_flash_tcp_socket_proxy.h @@ -26,8 +26,7 @@ PPAPI_PROXY_EXPORT extern const int32_t kFlashTCPSocketMaxWriteSize; class PPB_Flash_TCPSocket_Proxy : public InterfaceProxy { public: - PPB_Flash_TCPSocket_Proxy(Dispatcher* dispatcher, - const void* target_interface); + PPB_Flash_TCPSocket_Proxy(Dispatcher* dispatcher); virtual ~PPB_Flash_TCPSocket_Proxy(); static const Info* GetInfo(); diff --git a/ppapi/proxy/ppb_font_proxy.cc b/ppapi/proxy/ppb_font_proxy.cc index 3c42ecd..b6ef2db 100644 --- a/ppapi/proxy/ppb_font_proxy.cc +++ b/ppapi/proxy/ppb_font_proxy.cc @@ -40,33 +40,15 @@ bool PPTextRunToTextRun(const PP_TextRun_Dev* run, return true; } -InterfaceProxy* CreateFontProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Font_Proxy(dispatcher, target_interface); -} - } // namespace -PPB_Font_Proxy::PPB_Font_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { +PPB_Font_Proxy::PPB_Font_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher) { } PPB_Font_Proxy::~PPB_Font_Proxy() { } -// static -const InterfaceProxy::Info* PPB_Font_Proxy::GetInfo() { - static const Info info = { - thunk::GetPPB_Font_Thunk(), - PPB_FONT_DEV_INTERFACE, - INTERFACE_ID_PPB_FONT, - false, - &CreateFontProxy, - }; - return &info; -} - PPB_Font_FunctionAPI* PPB_Font_Proxy::AsPPB_Font_FunctionAPI() { return this; } diff --git a/ppapi/proxy/ppb_font_proxy.h b/ppapi/proxy/ppb_font_proxy.h index c9807e2..d7af485 100644 --- a/ppapi/proxy/ppb_font_proxy.h +++ b/ppapi/proxy/ppb_font_proxy.h @@ -21,15 +21,12 @@ namespace proxy { class SerializedVarReturnValue; -class PPB_Font_Proxy : public ppapi::FunctionGroupBase, - public ppapi::thunk::PPB_Font_FunctionAPI, - public InterfaceProxy { +class PPB_Font_Proxy : public InterfaceProxy, + public ppapi::thunk::PPB_Font_FunctionAPI { public: - PPB_Font_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPB_Font_Proxy(Dispatcher* dispatcher); virtual ~PPB_Font_Proxy(); - static const Info* GetInfo(); - // FunctionGroupBase overrides. virtual ppapi::thunk::PPB_Font_FunctionAPI* AsPPB_Font_FunctionAPI() OVERRIDE; @@ -39,6 +36,8 @@ class PPB_Font_Proxy : public ppapi::FunctionGroupBase, // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; + static const InterfaceID kInterfaceID = INTERFACE_ID_PPB_FONT; + private: DISALLOW_COPY_AND_ASSIGN(PPB_Font_Proxy); }; diff --git a/ppapi/proxy/ppb_graphics_2d_proxy.cc b/ppapi/proxy/ppb_graphics_2d_proxy.cc index a855cfd..232e1fe 100644 --- a/ppapi/proxy/ppb_graphics_2d_proxy.cc +++ b/ppapi/proxy/ppb_graphics_2d_proxy.cc @@ -24,15 +24,6 @@ using ppapi::thunk::PPB_Graphics2D_API; namespace ppapi { namespace proxy { -namespace { - -InterfaceProxy* CreateGraphics2DProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Graphics2D_Proxy(dispatcher, target_interface); -} - -} // namespace - class Graphics2D : public Resource, public thunk::PPB_Graphics2D_API { public: Graphics2D(const HostResource& host_resource, @@ -148,9 +139,8 @@ void Graphics2D::FlushACK(int32_t result_code) { PP_RunAndClearCompletionCallback(¤t_flush_callback_, result_code); } -PPB_Graphics2D_Proxy::PPB_Graphics2D_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface), +PPB_Graphics2D_Proxy::PPB_Graphics2D_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { } @@ -158,18 +148,6 @@ PPB_Graphics2D_Proxy::~PPB_Graphics2D_Proxy() { } // static -const InterfaceProxy::Info* PPB_Graphics2D_Proxy::GetInfo() { - static const Info info = { - thunk::GetPPB_Graphics2D_Thunk(), - PPB_GRAPHICS_2D_INTERFACE, - INTERFACE_ID_PPB_GRAPHICS_2D, - false, - &CreateGraphics2DProxy, - }; - return &info; -} - -// static PP_Resource PPB_Graphics2D_Proxy::CreateProxyResource( PP_Instance instance, const PP_Size& size, diff --git a/ppapi/proxy/ppb_graphics_2d_proxy.h b/ppapi/proxy/ppb_graphics_2d_proxy.h index cd4c55f..59b4b1b 100644 --- a/ppapi/proxy/ppb_graphics_2d_proxy.h +++ b/ppapi/proxy/ppb_graphics_2d_proxy.h @@ -26,22 +26,18 @@ namespace proxy { class PPB_Graphics2D_Proxy : public InterfaceProxy { public: - PPB_Graphics2D_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPB_Graphics2D_Proxy(Dispatcher* dispatcher); virtual ~PPB_Graphics2D_Proxy(); - static const Info* GetInfo(); - static PP_Resource CreateProxyResource(PP_Instance instance, const PP_Size& size, PP_Bool is_always_opaque); - const PPB_Graphics2D* ppb_graphics_2d_target() const { - return static_cast<const PPB_Graphics2D*>(target_interface()); - } - // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); + static const InterfaceID kInterfaceID = INTERFACE_ID_PPB_GRAPHICS_2D; + private: // Plugin->renderer message handlers. void OnMsgPaintImageData(const ppapi::HostResource& graphics_2d, @@ -67,6 +63,8 @@ class PPB_Graphics2D_Proxy : public InterfaceProxy { pp::CompletionCallbackFactory<PPB_Graphics2D_Proxy, ProxyNonThreadSafeRefCount> callback_factory_; + + DISALLOW_COPY_AND_ASSIGN(PPB_Graphics2D_Proxy); }; } // namespace proxy diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.cc b/ppapi/proxy/ppb_graphics_3d_proxy.cc index 31d9ccb..e184ef0 100644 --- a/ppapi/proxy/ppb_graphics_3d_proxy.cc +++ b/ppapi/proxy/ppb_graphics_3d_proxy.cc @@ -316,10 +316,6 @@ gpu::CommandBuffer::State GPUStateFromPPState( return state; } -InterfaceProxy* CreateGraphics3DProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Graphics3D_Proxy(dispatcher, target_interface); -} } // namespace Graphics3D::Graphics3D(const HostResource& resource) @@ -395,9 +391,8 @@ int32 Graphics3D::DoSwapBuffers() { return PP_OK_COMPLETIONPENDING; } -PPB_Graphics3D_Proxy::PPB_Graphics3D_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface), +PPB_Graphics3D_Proxy::PPB_Graphics3D_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { } @@ -405,18 +400,6 @@ PPB_Graphics3D_Proxy::~PPB_Graphics3D_Proxy() { } // static -const InterfaceProxy::Info* PPB_Graphics3D_Proxy::GetInfo() { - static const Info info = { - thunk::GetPPB_Graphics3D_Thunk(), - PPB_GRAPHICS_3D_INTERFACE, - INTERFACE_ID_PPB_GRAPHICS_3D, - false, - &CreateGraphics3DProxy, - }; - return &info; -} - -// static PP_Resource PPB_Graphics3D_Proxy::CreateProxyResource( PP_Instance instance, PP_Resource share_context, @@ -490,7 +473,7 @@ void PPB_Graphics3D_Proxy::OnMsgCreate(PP_Instance instance, if (attribs.empty() || attribs.back() != PP_GRAPHICS3DATTRIB_NONE) return; // Bad message. - EnterFunctionNoLock<ResourceCreationAPI> enter(instance, true); + thunk::EnterResourceCreation enter(instance); if (enter.succeeded()) { result->SetHostResource( instance, diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.h b/ppapi/proxy/ppb_graphics_3d_proxy.h index 4fd97a2..ef2b70b 100644 --- a/ppapi/proxy/ppb_graphics_3d_proxy.h +++ b/ppapi/proxy/ppb_graphics_3d_proxy.h @@ -63,22 +63,18 @@ class Graphics3D : public Resource, public Graphics3DImpl { class PPB_Graphics3D_Proxy : public InterfaceProxy { public: - PPB_Graphics3D_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPB_Graphics3D_Proxy(Dispatcher* dispatcher); virtual ~PPB_Graphics3D_Proxy(); - static const Info* GetInfo(); - static PP_Resource CreateProxyResource(PP_Instance instance, PP_Resource share_context, const int32_t* attrib_list); - const PPB_Graphics3D* ppb_graphics_3d_target() const { - return static_cast<const PPB_Graphics3D*>(target_interface()); - } - // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); + static const InterfaceID kInterfaceID = INTERFACE_ID_PPB_GRAPHICS_3D; + private: void OnMsgCreate(PP_Instance instance, const std::vector<int32_t>& attribs, diff --git a/ppapi/proxy/ppb_image_data_proxy.cc b/ppapi/proxy/ppb_image_data_proxy.cc index 0f96b99..32c24a9 100644 --- a/ppapi/proxy/ppb_image_data_proxy.cc +++ b/ppapi/proxy/ppb_image_data_proxy.cc @@ -25,43 +25,6 @@ namespace ppapi { namespace proxy { -namespace { - -InterfaceProxy* CreateImageDataProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_ImageData_Proxy(dispatcher, target_interface); -} - -} // namespace - -// PPB_ImageData_Proxy --------------------------------------------------------- - -PPB_ImageData_Proxy::PPB_ImageData_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { -} - -PPB_ImageData_Proxy::~PPB_ImageData_Proxy() { -} - -// static -const InterfaceProxy::Info* PPB_ImageData_Proxy::GetInfo() { - static const Info info = { - thunk::GetPPB_ImageData_Thunk(), - PPB_IMAGEDATA_INTERFACE, - INTERFACE_ID_PPB_IMAGE_DATA, - false, - &CreateImageDataProxy, - }; - return &info; -} - -bool PPB_ImageData_Proxy::OnMessageReceived(const IPC::Message& msg) { - return false; -} - -// ImageData ------------------------------------------------------------------- - ImageData::ImageData(const HostResource& resource, const PP_ImageDataDesc& desc, ImageHandle handle) diff --git a/ppapi/proxy/ppb_image_data_proxy.h b/ppapi/proxy/ppb_image_data_proxy.h index 1b96917..6cf4910 100644 --- a/ppapi/proxy/ppb_image_data_proxy.h +++ b/ppapi/proxy/ppb_image_data_proxy.h @@ -32,21 +32,6 @@ class HostResource; namespace proxy { -class PPB_ImageData_Proxy : public InterfaceProxy { - public: - PPB_ImageData_Proxy(Dispatcher* dispatcher, const void* target_interface); - virtual ~PPB_ImageData_Proxy(); - - static const Info* GetInfo(); - - const PPB_ImageData* ppb_image_data_target() const { - return static_cast<const PPB_ImageData*>(target_interface()); - } - - // InterfaceProxy implementation. - virtual bool OnMessageReceived(const IPC::Message& msg); -}; - class ImageData : public ppapi::Resource, public ppapi::thunk::PPB_ImageData_API, public ppapi::ImageDataImpl { diff --git a/ppapi/proxy/ppb_input_event_proxy.cc b/ppapi/proxy/ppb_input_event_proxy.cc deleted file mode 100644 index 655b10d..0000000 --- a/ppapi/proxy/ppb_input_event_proxy.cc +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (c) 2011 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. - -#include "ppapi/proxy/ppb_input_event_proxy.h" - -#include "ppapi/c/ppb_audio_config.h" -#include "ppapi/proxy/plugin_dispatcher.h" -#include "ppapi/proxy/plugin_var_tracker.h" -#include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/shared_impl/input_event_impl.h" -#include "ppapi/shared_impl/resource.h" -#include "ppapi/shared_impl/var.h" -#include "ppapi/thunk/thunk.h" - -using ppapi::thunk::PPB_InputEvent_API; - -namespace ppapi { -namespace proxy { - -namespace { - -InterfaceProxy* CreateInputEventProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_InputEvent_Proxy(dispatcher, target_interface); -} - -} // namespace - -PPB_InputEvent_Proxy::PPB_InputEvent_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { -} - -PPB_InputEvent_Proxy::~PPB_InputEvent_Proxy() { -} - -// static -const InterfaceProxy::Info* PPB_InputEvent_Proxy::GetInputEventInfo() { - static const Info info = { - thunk::GetPPB_InputEvent_Thunk(), - PPB_INPUT_EVENT_INTERFACE, - INTERFACE_ID_NONE, - false, - &CreateInputEventProxy, - }; - return &info; -} - -// static -const InterfaceProxy::Info* PPB_InputEvent_Proxy::GetKeyboardInputEventInfo() { - static const Info info = { - thunk::GetPPB_KeyboardInputEvent_Thunk(), - PPB_KEYBOARD_INPUT_EVENT_INTERFACE, - INTERFACE_ID_NONE, - false, - &CreateInputEventProxy, - }; - return &info; -} - -// static -const InterfaceProxy::Info* PPB_InputEvent_Proxy::GetMouseInputEventInfo1_0() { - static const Info info = { - thunk::GetPPB_MouseInputEvent_1_0_Thunk(), - PPB_MOUSE_INPUT_EVENT_INTERFACE_1_0, - INTERFACE_ID_NONE, - false, - &CreateInputEventProxy, - }; - return &info; -} - -// static -const InterfaceProxy::Info* PPB_InputEvent_Proxy::GetMouseInputEventInfo1_1() { - static const Info info = { - thunk::GetPPB_MouseInputEvent_1_1_Thunk(), - PPB_MOUSE_INPUT_EVENT_INTERFACE_1_1, - INTERFACE_ID_NONE, - false, - &CreateInputEventProxy, - }; - return &info; -} - -// static -const InterfaceProxy::Info* PPB_InputEvent_Proxy::GetWheelInputEventInfo() { - static const Info info = { - thunk::GetPPB_WheelInputEvent_Thunk(), - PPB_WHEEL_INPUT_EVENT_INTERFACE, - INTERFACE_ID_NONE, - false, - &CreateInputEventProxy, - }; - return &info; -} - -bool PPB_InputEvent_Proxy::OnMessageReceived(const IPC::Message& msg) { - // There are no IPC messages for this interface. - NOTREACHED(); - return false; -} - -} // namespace proxy -} // namespace ppapi diff --git a/ppapi/proxy/ppb_input_event_proxy.h b/ppapi/proxy/ppb_input_event_proxy.h deleted file mode 100644 index 5e60acb..0000000 --- a/ppapi/proxy/ppb_input_event_proxy.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2011 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. - -#ifndef PPAPI_PROXY_PPB_INPUT_EVENT_PROXY_H_ -#define PPAPI_PROXY_PPB_INPUT_EVENT_PROXY_H_ - -#include "base/basictypes.h" -#include "ppapi/c/pp_instance.h" -#include "ppapi/proxy/interface_proxy.h" -#include "ppapi/shared_impl/input_event_impl.h" - -namespace ppapi { - -struct InputEventData; - -namespace proxy { - -class PPB_InputEvent_Proxy : public InterfaceProxy { - public: - PPB_InputEvent_Proxy(Dispatcher* dispatcher, const void* target_interface); - virtual ~PPB_InputEvent_Proxy(); - - static const Info* GetInputEventInfo(); - static const Info* GetKeyboardInputEventInfo(); - static const Info* GetMouseInputEventInfo1_0(); - static const Info* GetMouseInputEventInfo1_1(); - static const Info* GetWheelInputEventInfo(); - - // InterfaceProxy implementation. - virtual bool OnMessageReceived(const IPC::Message& msg); - - private: - DISALLOW_COPY_AND_ASSIGN(PPB_InputEvent_Proxy); -}; - -} // namespace proxy -} // namespace ppapi - -#endif // PPAPI_PROXY_PPB_INPUT_EVENT_PROXY_H_ diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc index 10464c6..5dcf713 100644 --- a/ppapi/proxy/ppb_instance_proxy.cc +++ b/ppapi/proxy/ppb_instance_proxy.cc @@ -32,70 +32,22 @@ namespace proxy { namespace { -InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Instance_Proxy(dispatcher, target_interface); +typedef EnterFunctionNoLock<PPB_Instance_FunctionAPI> EnterInstanceNoLock; + +InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher) { + return new PPB_Instance_Proxy(dispatcher); } } // namespace -PPB_Instance_Proxy::PPB_Instance_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { +PPB_Instance_Proxy::PPB_Instance_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher) { } PPB_Instance_Proxy::~PPB_Instance_Proxy() { } // static -const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfo0_5() { - static const Info info = { - ppapi::thunk::GetPPB_Instance_1_0_Thunk(), - PPB_INSTANCE_INTERFACE_0_5, - INTERFACE_ID_NONE, // 1_0 is the canonical one. - false, - &CreateInstanceProxy, - }; - return &info; -} - -// static -const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfo1_0() { - static const Info info = { - ppapi::thunk::GetPPB_Instance_1_0_Thunk(), - PPB_INSTANCE_INTERFACE_1_0, - INTERFACE_ID_PPB_INSTANCE, - false, - &CreateInstanceProxy, - }; - return &info; -} - -// static -const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfoMessaging() { - static const Info info = { - ppapi::thunk::GetPPB_Messaging_Thunk(), - PPB_MESSAGING_INTERFACE, - INTERFACE_ID_NONE, // 1_0 is the canonical one. - false, - &CreateInstanceProxy, - }; - return &info; -} - -// static -const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfoMouseLock() { - static const Info info = { - ppapi::thunk::GetPPB_MouseLock_Thunk(), - PPB_MOUSELOCK_DEV_INTERFACE, - INTERFACE_ID_NONE, // 1_0 is the canonical one. - false, - &CreateInstanceProxy, - }; - return &info; -} - -// static const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfoPrivate() { static const Info info = { ppapi::thunk::GetPPB_Instance_Private_Thunk(), @@ -138,6 +90,10 @@ bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { OnMsgIsFullFrame) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ExecuteScript, OnMsgExecuteScript) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_Log, + OnMsgLog) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_LogWithSource, + OnMsgLogWithSource) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_PostMessage, OnMsgPostMessage) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetFullscreen, @@ -209,6 +165,24 @@ PP_Var PPB_Instance_Proxy::ExecuteScript(PP_Instance instance, return result.Return(dispatcher()); } +void PPB_Instance_Proxy::Log(PP_Instance instance, + int log_level, + PP_Var value) { + dispatcher()->Send(new PpapiHostMsg_PPBInstance_Log( + INTERFACE_ID_PPB_INSTANCE, instance, static_cast<int>(log_level), + SerializedVarSendInput(dispatcher(), value))); +} + +void PPB_Instance_Proxy::LogWithSource(PP_Instance instance, + int log_level, + PP_Var source, + PP_Var value) { + dispatcher()->Send(new PpapiHostMsg_PPBInstance_LogWithSource( + INTERFACE_ID_PPB_INSTANCE, instance, static_cast<int>(log_level), + SerializedVarSendInput(dispatcher(), source), + SerializedVarSendInput(dispatcher(), value))); +} + PP_Bool PPB_Instance_Proxy::IsFullscreen(PP_Instance instance) { InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> GetInstanceData(instance); @@ -305,7 +279,7 @@ void PPB_Instance_Proxy::UnlockMouse(PP_Instance instance) { void PPB_Instance_Proxy::OnMsgGetWindowObject( PP_Instance instance, SerializedVarReturnValue result) { - EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); + EnterInstanceNoLock enter(instance, false); if (enter.succeeded()) result.Return(dispatcher(), enter.functions()->GetWindowObject(instance)); } @@ -313,7 +287,7 @@ void PPB_Instance_Proxy::OnMsgGetWindowObject( void PPB_Instance_Proxy::OnMsgGetOwnerElementObject( PP_Instance instance, SerializedVarReturnValue result) { - EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); + EnterInstanceNoLock enter(instance, false); if (enter.succeeded()) { result.Return(dispatcher(), enter.functions()->GetOwnerElementObject(instance)); @@ -323,7 +297,7 @@ void PPB_Instance_Proxy::OnMsgGetOwnerElementObject( void PPB_Instance_Proxy::OnMsgBindGraphics(PP_Instance instance, const HostResource& device, PP_Bool* result) { - EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); + EnterInstanceNoLock enter(instance, false); if (enter.succeeded()) { *result = enter.functions()->BindGraphics(instance, device.host_resource()); @@ -332,7 +306,7 @@ void PPB_Instance_Proxy::OnMsgBindGraphics(PP_Instance instance, void PPB_Instance_Proxy::OnMsgIsFullFrame(PP_Instance instance, PP_Bool* result) { - EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); + EnterInstanceNoLock enter(instance, false); if (enter.succeeded()) *result = enter.functions()->IsFullFrame(instance); } @@ -342,7 +316,7 @@ void PPB_Instance_Proxy::OnMsgExecuteScript( SerializedVarReceiveInput script, SerializedVarOutParam out_exception, SerializedVarReturnValue result) { - EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); + EnterInstanceNoLock enter(instance, false); if (enter.failed()) return; @@ -357,10 +331,30 @@ void PPB_Instance_Proxy::OnMsgExecuteScript( out_exception.OutParam(dispatcher()))); } +void PPB_Instance_Proxy::OnMsgLog(PP_Instance instance, + int log_level, + SerializedVarReceiveInput value) { + EnterInstanceNoLock enter(instance, false); + if (enter.succeeded()) + enter.functions()->Log(instance, log_level, value.Get(dispatcher())); +} + +void PPB_Instance_Proxy::OnMsgLogWithSource(PP_Instance instance, + int log_level, + SerializedVarReceiveInput source, + SerializedVarReceiveInput value) { + EnterInstanceNoLock enter(instance, false); + if (enter.succeeded()) { + enter.functions()->LogWithSource(instance, log_level, + source.Get(dispatcher()), + value.Get(dispatcher())); + } +} + void PPB_Instance_Proxy::OnMsgSetFullscreen(PP_Instance instance, PP_Bool fullscreen, PP_Bool* result) { - EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); + EnterInstanceNoLock enter(instance, false); if (enter.succeeded()) *result = enter.functions()->SetFullscreen(instance, fullscreen); } @@ -368,7 +362,7 @@ void PPB_Instance_Proxy::OnMsgSetFullscreen(PP_Instance instance, void PPB_Instance_Proxy::OnMsgGetScreenSize(PP_Instance instance, PP_Bool* result, PP_Size* size) { - EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); + EnterInstanceNoLock enter(instance, false); if (enter.succeeded()) *result = enter.functions()->GetScreenSize(instance, size); } @@ -376,7 +370,7 @@ void PPB_Instance_Proxy::OnMsgGetScreenSize(PP_Instance instance, void PPB_Instance_Proxy::OnMsgRequestInputEvents(PP_Instance instance, bool is_filtering, uint32_t event_classes) { - EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); + EnterInstanceNoLock enter(instance, false); if (enter.succeeded()) { if (is_filtering) enter.functions()->RequestFilteringInputEvents(instance, event_classes); @@ -387,14 +381,14 @@ void PPB_Instance_Proxy::OnMsgRequestInputEvents(PP_Instance instance, void PPB_Instance_Proxy::OnMsgClearInputEvents(PP_Instance instance, uint32_t event_classes) { - EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); + EnterInstanceNoLock enter(instance, false); if (enter.succeeded()) enter.functions()->ClearInputEventRequest(instance, event_classes); } void PPB_Instance_Proxy::OnMsgPostMessage(PP_Instance instance, SerializedVarReceiveInput message) { - EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); + EnterInstanceNoLock enter(instance, false); if (enter.succeeded()) enter.functions()->PostMessage(instance, message.Get(dispatcher())); } diff --git a/ppapi/proxy/ppb_instance_proxy.h b/ppapi/proxy/ppb_instance_proxy.h index d0ec32b..4199912 100644 --- a/ppapi/proxy/ppb_instance_proxy.h +++ b/ppapi/proxy/ppb_instance_proxy.h @@ -23,16 +23,11 @@ class SerializedVarReturnValue; class PPB_Instance_Proxy : public InterfaceProxy, public ppapi::InstanceImpl, - public ppapi::FunctionGroupBase, public ppapi::thunk::PPB_Instance_FunctionAPI { public: - PPB_Instance_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPB_Instance_Proxy(Dispatcher* dispatcher); virtual ~PPB_Instance_Proxy(); - static const Info* GetInfo0_5(); - static const Info* GetInfo1_0(); - static const Info* GetInfoMessaging(); - static const Info* GetInfoMouseLock(); static const Info* GetInfoPrivate(); static const Info* GetInfoFullscreen(); @@ -51,6 +46,13 @@ class PPB_Instance_Proxy : public InterfaceProxy, virtual PP_Var ExecuteScript(PP_Instance instance, PP_Var script, PP_Var* exception) OVERRIDE; + virtual void Log(PP_Instance instance, + int log_level, + PP_Var value) OVERRIDE; + virtual void LogWithSource(PP_Instance instance, + int log_level, + PP_Var source, + PP_Var value) OVERRIDE; virtual PP_Bool IsFullscreen(PP_Instance instance) OVERRIDE; virtual PP_Bool SetFullscreen(PP_Instance instance, PP_Bool fullscreen) OVERRIDE; @@ -71,6 +73,8 @@ class PPB_Instance_Proxy : public InterfaceProxy, PP_CompletionCallback callback) OVERRIDE; virtual void UnlockMouse(PP_Instance instance) OVERRIDE; + static const InterfaceID kInterfaceID = INTERFACE_ID_PPB_INSTANCE; + private: // Message handlers. void OnMsgGetWindowObject(PP_Instance instance, @@ -85,6 +89,13 @@ class PPB_Instance_Proxy : public InterfaceProxy, SerializedVarReceiveInput script, SerializedVarOutParam out_exception, SerializedVarReturnValue result); + void OnMsgLog(PP_Instance instance, + int log_level, + SerializedVarReceiveInput value); + void OnMsgLogWithSource(PP_Instance instance, + int log_level, + SerializedVarReceiveInput source, + SerializedVarReceiveInput value); void OnMsgSetFullscreen(PP_Instance instance, PP_Bool fullscreen, PP_Bool* result); diff --git a/ppapi/proxy/ppb_memory_proxy.cc b/ppapi/proxy/ppb_memory_proxy.cc index ec3fc03..88da6b2 100644 --- a/ppapi/proxy/ppb_memory_proxy.cc +++ b/ppapi/proxy/ppb_memory_proxy.cc @@ -27,37 +27,10 @@ const PPB_Memory_Dev memory_dev_interface = { &MemFree }; -InterfaceProxy* CreateMemoryProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Memory_Proxy(dispatcher, target_interface); -} - } // namespace -PPB_Memory_Proxy::PPB_Memory_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { -} - -PPB_Memory_Proxy::~PPB_Memory_Proxy() { -} - -// static -const InterfaceProxy::Info* PPB_Memory_Proxy::GetInfo() { - static const Info info = { - &memory_dev_interface, - PPB_MEMORY_DEV_INTERFACE, - INTERFACE_ID_PPB_MEMORY, - false, - &CreateMemoryProxy, - }; - return &info; -} - -bool PPB_Memory_Proxy::OnMessageReceived(const IPC::Message& msg) { - // All PPB_Memory_Dev calls are handled locally; there is no need to send or - // receive messages here. - return false; +const PPB_Memory_Dev* GetPPB_Memory_Interface() { + return &memory_dev_interface; } } // namespace proxy diff --git a/ppapi/proxy/ppb_memory_proxy.h b/ppapi/proxy/ppb_memory_proxy.h index 6666ede..fd7d5d2 100644 --- a/ppapi/proxy/ppb_memory_proxy.h +++ b/ppapi/proxy/ppb_memory_proxy.h @@ -12,23 +12,7 @@ struct PPB_Memory_Dev; namespace ppapi { namespace proxy { -class PPB_Memory_Proxy : public InterfaceProxy { - public: - PPB_Memory_Proxy(Dispatcher* dispatcher, - const void* target_interface); - virtual ~PPB_Memory_Proxy(); - - static const Info* GetInfo(); - - const PPB_Memory_Dev* ppb_memory_target() const { - return static_cast<const PPB_Memory_Dev*>(target_interface()); - } - - // InterfaceProxy implementation. In this case, no messages are sent or - // received, so this always returns false. - virtual bool OnMessageReceived(const IPC::Message& msg); - -}; +const PPB_Memory_Dev* GetPPB_Memory_Interface(); } // namespace proxy } // namespace ppapi diff --git a/ppapi/proxy/ppb_opengles2_proxy.cc b/ppapi/proxy/ppb_opengles2_proxy.cc deleted file mode 100644 index 9516678..0000000 --- a/ppapi/proxy/ppb_opengles2_proxy.cc +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2011 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. - -#include "ppapi/proxy/ppb_opengles2_proxy.h" - -#include "ppapi/shared_impl/opengles2_impl.h" - -namespace ppapi { -namespace proxy { - -namespace { -InterfaceProxy* CreateOpenGLES2Proxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_OpenGLES2_Proxy(dispatcher, target_interface); -} -} // namespace - -PPB_OpenGLES2_Proxy::PPB_OpenGLES2_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { -} - -PPB_OpenGLES2_Proxy::~PPB_OpenGLES2_Proxy() { -} - -// static -const InterfaceProxy::Info* PPB_OpenGLES2_Proxy::GetInfo() { - static const Info info = { - ppapi::OpenGLES2Impl::GetInterface(), - PPB_OPENGLES2_INTERFACE, - INTERFACE_ID_PPB_OPENGLES2, - false, - &CreateOpenGLES2Proxy, - }; - return &info; -} - -bool PPB_OpenGLES2_Proxy::OnMessageReceived(const IPC::Message& msg) { - return false; -} - -} // namespace proxy -} // namespace ppapi diff --git a/ppapi/proxy/ppb_opengles2_proxy.h b/ppapi/proxy/ppb_opengles2_proxy.h deleted file mode 100644 index c424ae8..0000000 --- a/ppapi/proxy/ppb_opengles2_proxy.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2011 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. - -#ifndef PPAPI_PPB_OPENGLES2_PROXY_H_ -#define PPAPI_PPB_OPENGLES2_PROXY_H_ - -#include "ppapi/proxy/interface_proxy.h" - -struct PPB_OpenGLES2_Dev; - -namespace ppapi { -namespace proxy { - -class PPB_OpenGLES2_Proxy : public InterfaceProxy { - public: - PPB_OpenGLES2_Proxy(Dispatcher* dispatcher, const void* target_interface); - virtual ~PPB_OpenGLES2_Proxy(); - - static const Info* GetInfo(); - - const PPB_OpenGLES2_Dev* ppb_opengles2_target() const { - return reinterpret_cast<const PPB_OpenGLES2_Dev*>(target_interface()); - } - - // InterfaceProxy implementation. - virtual bool OnMessageReceived(const IPC::Message& msg); -}; - -} // namespace proxy -} // namespace ppapi - -#endif // PPAPI_PPB_OPENGLES2_PROXY_H_ diff --git a/ppapi/proxy/ppb_pdf_proxy.cc b/ppapi/proxy/ppb_pdf_proxy.cc index dcf3358..874e487 100644 --- a/ppapi/proxy/ppb_pdf_proxy.cc +++ b/ppapi/proxy/ppb_pdf_proxy.cc @@ -118,16 +118,19 @@ const PPB_PDF pdf_interface = { &GetFontTableForPrivateFontFile, }; -InterfaceProxy* CreatePDFProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_PDF_Proxy(dispatcher, target_interface); +InterfaceProxy* CreatePDFProxy(Dispatcher* dispatcher) { + return new PPB_PDF_Proxy(dispatcher); } } // namespace -PPB_PDF_Proxy::PPB_PDF_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { +PPB_PDF_Proxy::PPB_PDF_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), + ppb_pdf_impl_(NULL) { + if (!dispatcher->IsPlugin()) { + ppb_pdf_impl_ = static_cast<const PPB_PDF*>( + dispatcher->local_get_interface()(PPB_PDF_INTERFACE)); + } } PPB_PDF_Proxy::~PPB_PDF_Proxy() { @@ -166,7 +169,7 @@ void PPB_PDF_Proxy::OnMsgGetFontFileWithFallback( PP_FontDescription_Dev desc; in_desc.SetToPPFontDescription(dispatcher(), &desc, false); result->SetHostResource(instance, - ppb_pdf_target()->GetFontFileWithFallback( + ppb_pdf_impl_->GetFontFileWithFallback( instance, &desc, static_cast<PP_PrivateFontCharset>(charset))); } @@ -177,12 +180,12 @@ void PPB_PDF_Proxy::OnMsgGetFontTableForPrivateFontFile( // TODO(brettw): It would be nice not to copy here. At least on Linux, // we can map the font file into shared memory and read it that way. uint32_t table_length = 0; - if (!ppb_pdf_target()->GetFontTableForPrivateFontFile( + if (!ppb_pdf_impl_->GetFontTableForPrivateFontFile( font_file.host_resource(), table, NULL, &table_length)) return; result->resize(table_length); - ppb_pdf_target()->GetFontTableForPrivateFontFile(font_file.host_resource(), + ppb_pdf_impl_->GetFontTableForPrivateFontFile(font_file.host_resource(), table, const_cast<char*>(result->c_str()), &table_length); } diff --git a/ppapi/proxy/ppb_pdf_proxy.h b/ppapi/proxy/ppb_pdf_proxy.h index 27ab6c4..7ad012d 100644 --- a/ppapi/proxy/ppb_pdf_proxy.h +++ b/ppapi/proxy/ppb_pdf_proxy.h @@ -18,15 +18,11 @@ struct SerializedFontDescription; class PPB_PDF_Proxy : public InterfaceProxy { public: - PPB_PDF_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPB_PDF_Proxy(Dispatcher* dispatcher); virtual ~PPB_PDF_Proxy(); static const Info* GetInfo(); - const PPB_PDF* ppb_pdf_target() const { - return static_cast<const PPB_PDF*>(target_interface()); - } - // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); @@ -39,6 +35,11 @@ class PPB_PDF_Proxy : public InterfaceProxy { void OnMsgGetFontTableForPrivateFontFile(const ppapi::HostResource& font_file, uint32_t table, std::string* result); + + // When this proxy is in the host side, this value caches the interface + // pointer so we don't have to retrieve it from the dispatcher each time. + // In the plugin, this value is always NULL. + const PPB_PDF* ppb_pdf_impl_; }; } // namespace proxy diff --git a/ppapi/proxy/ppb_surface_3d_proxy.cc b/ppapi/proxy/ppb_surface_3d_proxy.cc index 23348fc..70809da 100644 --- a/ppapi/proxy/ppb_surface_3d_proxy.cc +++ b/ppapi/proxy/ppb_surface_3d_proxy.cc @@ -25,9 +25,8 @@ namespace proxy { namespace { -InterfaceProxy* CreateSurface3DProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Surface3D_Proxy(dispatcher, target_interface); +InterfaceProxy* CreateSurface3DProxy(Dispatcher* dispatcher) { + return new PPB_Surface3D_Proxy(dispatcher); } } // namespace @@ -88,9 +87,8 @@ void Surface3D::SwapBuffersACK(int32_t pp_error) { // PPB_Surface3D_Proxy --------------------------------------------------------- -PPB_Surface3D_Proxy::PPB_Surface3D_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface), +PPB_Surface3D_Proxy::PPB_Surface3D_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { } @@ -100,7 +98,7 @@ PPB_Surface3D_Proxy::~PPB_Surface3D_Proxy() { // static const InterfaceProxy::Info* PPB_Surface3D_Proxy::GetInfo() { static const Info info = { - thunk::GetPPB_Surface3D_Thunk(), + thunk::GetPPB_Surface3D_Dev_Thunk(), PPB_SURFACE_3D_DEV_INTERFACE, INTERFACE_ID_PPB_SURFACE_3D, false, @@ -162,7 +160,7 @@ void PPB_Surface3D_Proxy::OnMsgCreate(PP_Instance instance, attribs.back() != PP_GRAPHICS3DATTRIB_NONE) return; // Bad message. - EnterFunctionNoLock<ResourceCreationAPI> enter(instance, true); + thunk::EnterResourceCreation enter(instance); if (enter.succeeded()) { result->SetHostResource( instance, diff --git a/ppapi/proxy/ppb_surface_3d_proxy.h b/ppapi/proxy/ppb_surface_3d_proxy.h index ce7e8b6..be8ce34 100644 --- a/ppapi/proxy/ppb_surface_3d_proxy.h +++ b/ppapi/proxy/ppb_surface_3d_proxy.h @@ -63,7 +63,7 @@ class Surface3D : public ppapi::Resource, class PPB_Surface3D_Proxy : public InterfaceProxy { public: - PPB_Surface3D_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPB_Surface3D_Proxy(Dispatcher* dispatcher); virtual ~PPB_Surface3D_Proxy(); static const Info* GetInfo(); @@ -75,6 +75,8 @@ class PPB_Surface3D_Proxy : public InterfaceProxy { // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); + static const InterfaceID kInterfaceID = INTERFACE_ID_PPB_SURFACE_3D; + private: // Message handlers. void OnMsgCreate(PP_Instance instance, diff --git a/ppapi/proxy/ppb_testing_proxy.cc b/ppapi/proxy/ppb_testing_proxy.cc index 564f68f..836e1cf 100644 --- a/ppapi/proxy/ppb_testing_proxy.cc +++ b/ppapi/proxy/ppb_testing_proxy.cc @@ -75,16 +75,19 @@ const PPB_Testing_Dev testing_interface = { &IsOutOfProcess }; -InterfaceProxy* CreateTestingProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Testing_Proxy(dispatcher, target_interface); +InterfaceProxy* CreateTestingProxy(Dispatcher* dispatcher) { + return new PPB_Testing_Proxy(dispatcher); } } // namespace -PPB_Testing_Proxy::PPB_Testing_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { +PPB_Testing_Proxy::PPB_Testing_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), + ppb_testing_impl_(NULL) { + if (!dispatcher->IsPlugin()) { + ppb_testing_impl_ = static_cast<const PPB_Testing_Dev*>( + dispatcher->local_get_interface()(PPB_TESTING_DEV_INTERFACE)); + } } PPB_Testing_Proxy::~PPB_Testing_Proxy() { @@ -119,21 +122,21 @@ void PPB_Testing_Proxy::OnMsgReadImageData( const HostResource& image, const PP_Point& top_left, PP_Bool* result) { - *result = ppb_testing_target()->ReadImageData( + *result = ppb_testing_impl_->ReadImageData( device_context_2d.host_resource(), image.host_resource(), &top_left); } void PPB_Testing_Proxy::OnMsgRunMessageLoop(PP_Instance instance) { - ppb_testing_target()->RunMessageLoop(instance); + ppb_testing_impl_->RunMessageLoop(instance); } void PPB_Testing_Proxy::OnMsgQuitMessageLoop(PP_Instance instance) { - ppb_testing_target()->QuitMessageLoop(instance); + ppb_testing_impl_->QuitMessageLoop(instance); } void PPB_Testing_Proxy::OnMsgGetLiveObjectsForInstance(PP_Instance instance, uint32_t* result) { - *result = ppb_testing_target()->GetLiveObjectsForInstance(instance); + *result = ppb_testing_impl_->GetLiveObjectsForInstance(instance); } } // namespace proxy diff --git a/ppapi/proxy/ppb_testing_proxy.h b/ppapi/proxy/ppb_testing_proxy.h index c07f6a9..eaf5fb3 100644 --- a/ppapi/proxy/ppb_testing_proxy.h +++ b/ppapi/proxy/ppb_testing_proxy.h @@ -19,15 +19,11 @@ namespace proxy { class PPB_Testing_Proxy : public InterfaceProxy { public: - PPB_Testing_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPB_Testing_Proxy(Dispatcher* dispatcher); virtual ~PPB_Testing_Proxy(); static const Info* GetInfo(); - const PPB_Testing_Dev* ppb_testing_target() const { - return static_cast<const PPB_Testing_Dev*>(target_interface()); - } - // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); @@ -41,6 +37,11 @@ class PPB_Testing_Proxy : public InterfaceProxy { void OnMsgQuitMessageLoop(PP_Instance instance); void OnMsgGetLiveObjectsForInstance(PP_Instance instance, uint32_t* result); + // When this proxy is in the host side, this value caches the interface + // pointer so we don't have to retrieve it from the dispatcher each time. + // In the plugin, this value is always NULL. + const PPB_Testing_Dev* ppb_testing_impl_; + DISALLOW_COPY_AND_ASSIGN(PPB_Testing_Proxy); }; diff --git a/ppapi/proxy/ppb_url_loader_proxy.cc b/ppapi/proxy/ppb_url_loader_proxy.cc index e6ef68e..ce4bc62 100644 --- a/ppapi/proxy/ppb_url_loader_proxy.cc +++ b/ppapi/proxy/ppb_url_loader_proxy.cc @@ -70,9 +70,8 @@ void UpdateResourceLoadStatus(PP_Instance pp_instance, INTERFACE_ID_PPB_URL_LOADER, params)); } -InterfaceProxy* CreateURLLoaderProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_URLLoader_Proxy(dispatcher, target_interface); +InterfaceProxy* CreateURLLoaderProxy(Dispatcher* dispatcher) { + return new PPB_URLLoader_Proxy(dispatcher); } } // namespace @@ -346,9 +345,8 @@ struct PPB_URLLoader_Proxy::ReadCallbackInfo { std::string read_buffer; }; -PPB_URLLoader_Proxy::PPB_URLLoader_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface), +PPB_URLLoader_Proxy::PPB_URLLoader_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), host_urlloader_trusted_interface_(NULL) { } @@ -363,18 +361,6 @@ PP_Resource PPB_URLLoader_Proxy::TrackPluginResource( } // static -const InterfaceProxy::Info* PPB_URLLoader_Proxy::GetInfo() { - static const Info info = { - thunk::GetPPB_URLLoader_Thunk(), - PPB_URLLOADER_INTERFACE, - INTERFACE_ID_PPB_URL_LOADER, - false, - &CreateURLLoaderProxy, - }; - return &info; -} - -// static const InterfaceProxy::Info* PPB_URLLoader_Proxy::GetTrustedInfo() { static const Info info = { thunk::GetPPB_URLLoaderTrusted_Thunk(), @@ -443,7 +429,7 @@ void PPB_URLLoader_Proxy::PrepareURLLoaderForSendingToPlugin( void PPB_URLLoader_Proxy::OnMsgCreate(PP_Instance instance, HostResource* result) { - EnterFunctionNoLock<ResourceCreationAPI> enter(instance, true); + thunk::EnterResourceCreation enter(instance); if (enter.succeeded()) { result->SetHostResource(instance, enter.functions()->CreateURLLoader(instance)); @@ -456,8 +442,7 @@ void PPB_URLLoader_Proxy::OnMsgOpen(const HostResource& loader, uint32_t serialized_callback) { // Have to be careful to always issue the callback, so don't return early. EnterHostFromHostResource<PPB_URLLoader_API> enter(loader); - EnterFunctionNoLock<ResourceCreationAPI> enter_creation( - loader.instance(), true); + thunk::EnterResourceCreation enter_creation(loader.instance()); PP_CompletionCallback callback = ReceiveCallback(serialized_callback); diff --git a/ppapi/proxy/ppb_url_loader_proxy.h b/ppapi/proxy/ppb_url_loader_proxy.h index 17825f1..defae9b 100644 --- a/ppapi/proxy/ppb_url_loader_proxy.h +++ b/ppapi/proxy/ppb_url_loader_proxy.h @@ -29,10 +29,9 @@ struct PPBURLLoader_UpdateProgress_Params; class PPB_URLLoader_Proxy : public InterfaceProxy { public: - PPB_URLLoader_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPB_URLLoader_Proxy(Dispatcher* dispatcher); virtual ~PPB_URLLoader_Proxy(); - static const Info* GetInfo(); static const Info* GetTrustedInfo(); static PP_Resource CreateProxyResource(PP_Instance instance); @@ -44,10 +43,6 @@ class PPB_URLLoader_Proxy : public InterfaceProxy { static PP_Resource TrackPluginResource( const ppapi::HostResource& url_loader_resource); - const PPB_URLLoader* ppb_url_loader_target() const { - return reinterpret_cast<const PPB_URLLoader*>(target_interface()); - } - // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); @@ -57,6 +52,8 @@ class PPB_URLLoader_Proxy : public InterfaceProxy { // time you're sending a new URLLoader that the plugin hasn't seen yet. void PrepareURLLoaderForSendingToPlugin(PP_Resource resource); + static const InterfaceID kInterfaceID = INTERFACE_ID_PPB_URL_LOADER; + private: // Data associated with callbacks for ReadResponseBody. struct ReadCallbackInfo; diff --git a/ppapi/proxy/ppb_url_request_info_proxy.cc b/ppapi/proxy/ppb_url_request_info_proxy.cc deleted file mode 100644 index e5861f0..0000000 --- a/ppapi/proxy/ppb_url_request_info_proxy.cc +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2011 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. - -#include "ppapi/proxy/ppb_url_request_info_proxy.h" - -#include "ppapi/proxy/plugin_dispatcher.h" -#include "ppapi/shared_impl/url_request_info_impl.h" -#include "ppapi/thunk/thunk.h" - -namespace ppapi { -namespace proxy { - -namespace { - -InterfaceProxy* CreateURLRequestInfoProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_URLRequestInfo_Proxy(dispatcher, target_interface); -} - -} // namespace - -PPB_URLRequestInfo_Proxy::PPB_URLRequestInfo_Proxy( - Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { -} - -PPB_URLRequestInfo_Proxy::~PPB_URLRequestInfo_Proxy() { -} - -// static -const InterfaceProxy::Info* PPB_URLRequestInfo_Proxy::GetInfo() { - static const Info info = { - thunk::GetPPB_URLRequestInfo_Thunk(), - PPB_URLREQUESTINFO_INTERFACE, - INTERFACE_ID_PPB_URL_REQUEST_INFO, - false, - &CreateURLRequestInfoProxy, - }; - return &info; -} - -bool PPB_URLRequestInfo_Proxy::OnMessageReceived(const IPC::Message& msg) { - // No messages to handle. - return false; -} - -} // namespace proxy -} // namespace ppapi diff --git a/ppapi/proxy/ppb_url_request_info_proxy.h b/ppapi/proxy/ppb_url_request_info_proxy.h deleted file mode 100644 index 6242bf8..0000000 --- a/ppapi/proxy/ppb_url_request_info_proxy.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2011 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. - -#ifndef PPAPI_PROXY_PPB_URL_REQUEST_INFO_PROXY_H_ -#define PPAPI_PROXY_PPB_URL_REQUEST_INFO_PROXY_H_ - -#include "base/basictypes.h" -#include "ppapi/c/pp_instance.h" -#include "ppapi/proxy/interface_proxy.h" - -namespace ppapi { - -struct PPB_URLRequestInfo_Data; - -namespace proxy { - -class PPB_URLRequestInfo_Proxy : public InterfaceProxy { - public: - PPB_URLRequestInfo_Proxy(Dispatcher* dispatcher, - const void* target_interface); - virtual ~PPB_URLRequestInfo_Proxy(); - - static const Info* GetInfo(); - - // InterfaceProxy implementation. - virtual bool OnMessageReceived(const IPC::Message& msg); - - private: - DISALLOW_COPY_AND_ASSIGN(PPB_URLRequestInfo_Proxy); -}; - -} // namespace proxy -} // namespace ppapi - -#endif // PPAPI_PROXY_PPB_URL_REQUEST_INFO_PROXY_H_ diff --git a/ppapi/proxy/ppb_url_response_info_proxy.cc b/ppapi/proxy/ppb_url_response_info_proxy.cc index 3801e5f..ace317c 100644 --- a/ppapi/proxy/ppb_url_response_info_proxy.cc +++ b/ppapi/proxy/ppb_url_response_info_proxy.cc @@ -20,15 +20,6 @@ using ppapi::thunk::PPB_URLResponseInfo_API; namespace ppapi { namespace proxy { -namespace { - -InterfaceProxy* CreateURLResponseInfoProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_URLResponseInfo_Proxy(dispatcher, target_interface); -} - -} // namespace - // URLResponseInfo ------------------------------------------------------------- class URLResponseInfo : public Resource, public PPB_URLResponseInfo_API { @@ -80,28 +71,14 @@ PP_Resource URLResponseInfo::GetBodyAsFileRef() { // PPB_URLResponseInfo_Proxy --------------------------------------------------- -PPB_URLResponseInfo_Proxy::PPB_URLResponseInfo_Proxy( - Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { +PPB_URLResponseInfo_Proxy::PPB_URLResponseInfo_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher) { } PPB_URLResponseInfo_Proxy::~PPB_URLResponseInfo_Proxy() { } // static -const InterfaceProxy::Info* PPB_URLResponseInfo_Proxy::GetInfo() { - static const Info info = { - ppapi::thunk::GetPPB_URLResponseInfo_Thunk(), - PPB_URLRESPONSEINFO_INTERFACE, - INTERFACE_ID_PPB_URL_RESPONSE_INFO, - false, - &CreateURLResponseInfoProxy, - }; - return &info; -} - -// static PP_Resource PPB_URLResponseInfo_Proxy::CreateResponseForResource( const HostResource& resource) { return (new URLResponseInfo(resource))->GetReference(); @@ -142,10 +119,8 @@ void PPB_URLResponseInfo_Proxy::OnMsgGetBodyAsFileRef( file_ref = enter.object()->GetBodyAsFileRef(); // Use the FileRef proxy to serialize. - DCHECK(!dispatcher()->IsPlugin()); - HostDispatcher* host_disp = static_cast<HostDispatcher*>(dispatcher()); PPB_FileRef_Proxy* file_ref_proxy = static_cast<PPB_FileRef_Proxy*>( - host_disp->GetOrCreatePPBInterfaceProxy(INTERFACE_ID_PPB_FILE_REF)); + dispatcher()->GetInterfaceProxy(INTERFACE_ID_PPB_FILE_REF)); file_ref_proxy->SerializeFileRef(file_ref, result); } diff --git a/ppapi/proxy/ppb_url_response_info_proxy.h b/ppapi/proxy/ppb_url_response_info_proxy.h index a81549d..8f97a53 100644 --- a/ppapi/proxy/ppb_url_response_info_proxy.h +++ b/ppapi/proxy/ppb_url_response_info_proxy.h @@ -24,12 +24,9 @@ class SerializedVarReturnValue; class PPB_URLResponseInfo_Proxy : public InterfaceProxy { public: - PPB_URLResponseInfo_Proxy(Dispatcher* dispatcher, - const void* target_interface); + PPB_URLResponseInfo_Proxy(Dispatcher* dispatcher); virtual ~PPB_URLResponseInfo_Proxy(); - static const Info* GetInfo(); - // URLResponseInfo objects are actually created and returned by the // URLLoader. This function allows the URLLoader to convert a new // HostResource representing a response info to a properly tracked @@ -41,6 +38,8 @@ class PPB_URLResponseInfo_Proxy : public InterfaceProxy { // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); + static const InterfaceID kInterfaceID = INTERFACE_ID_PPB_URL_RESPONSE_INFO; + private: // Message handlers. void OnMsgGetProperty(const ppapi::HostResource& response, diff --git a/ppapi/proxy/ppb_url_util_proxy.cc b/ppapi/proxy/ppb_url_util_proxy.cc index a202038..b3cea08 100644 --- a/ppapi/proxy/ppb_url_util_proxy.cc +++ b/ppapi/proxy/ppb_url_util_proxy.cc @@ -129,16 +129,19 @@ const PPB_URLUtil_Dev url_util_interface = { &GetPluginInstanceURL }; -InterfaceProxy* CreateURLUtilProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_URLUtil_Proxy(dispatcher, target_interface); +InterfaceProxy* CreateURLUtilProxy(Dispatcher* dispatcher) { + return new PPB_URLUtil_Proxy(dispatcher); } } // namespace -PPB_URLUtil_Proxy::PPB_URLUtil_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { +PPB_URLUtil_Proxy::PPB_URLUtil_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), + ppb_url_util_impl_(NULL) { + if (!dispatcher->IsPlugin()) { + ppb_url_util_impl_ = static_cast<const PPB_URLUtil_Dev*>( + dispatcher->local_get_interface()(PPB_URLUTIL_DEV_INTERFACE)); + } } PPB_URLUtil_Proxy::~PPB_URLUtil_Proxy() { @@ -179,34 +182,34 @@ void PPB_URLUtil_Proxy::OnMsgResolveRelativeToDocument( SerializedVarReceiveInput relative, SerializedVarReturnValue result) { result.Return(dispatcher(), - ppb_url_util_target()->ResolveRelativeToDocument( + ppb_url_util_impl_->ResolveRelativeToDocument( instance, relative.Get(dispatcher()), NULL)); } void PPB_URLUtil_Proxy::OnMsgDocumentCanRequest(PP_Instance instance, SerializedVarReceiveInput url, PP_Bool* result) { - *result = ppb_url_util_target()->DocumentCanRequest(instance, - url.Get(dispatcher())); + *result = ppb_url_util_impl_->DocumentCanRequest(instance, + url.Get(dispatcher())); } void PPB_URLUtil_Proxy::OnMsgDocumentCanAccessDocument(PP_Instance active, PP_Instance target, PP_Bool* result) { - *result = ppb_url_util_target()->DocumentCanAccessDocument( + *result = ppb_url_util_impl_->DocumentCanAccessDocument( active, target); } void PPB_URLUtil_Proxy::OnMsgGetDocumentURL(PP_Instance instance, SerializedVarReturnValue result) { result.Return(dispatcher(), - ppb_url_util_target()->GetDocumentURL(instance, NULL)); + ppb_url_util_impl_->GetDocumentURL(instance, NULL)); } void PPB_URLUtil_Proxy::OnMsgGetPluginInstanceURL( PP_Instance instance, SerializedVarReturnValue result) { result.Return(dispatcher(), - ppb_url_util_target()->GetPluginInstanceURL(instance, NULL)); + ppb_url_util_impl_->GetPluginInstanceURL(instance, NULL)); } } // namespace proxy diff --git a/ppapi/proxy/ppb_url_util_proxy.h b/ppapi/proxy/ppb_url_util_proxy.h index 2c6cb40..0571377 100644 --- a/ppapi/proxy/ppb_url_util_proxy.h +++ b/ppapi/proxy/ppb_url_util_proxy.h @@ -16,15 +16,11 @@ namespace proxy { class PPB_URLUtil_Proxy : public InterfaceProxy { public: - PPB_URLUtil_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPB_URLUtil_Proxy(Dispatcher* dispatcher); virtual ~PPB_URLUtil_Proxy(); static const Info* GetInfo(); - const PPB_URLUtil_Dev* ppb_url_util_target() const { - return static_cast<const PPB_URLUtil_Dev*>(target_interface()); - } - // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); @@ -44,6 +40,11 @@ class PPB_URLUtil_Proxy : public InterfaceProxy { void OnMsgGetPluginInstanceURL(PP_Instance instance, SerializedVarReturnValue result); + // When this proxy is in the host side, this value caches the interface + // pointer so we don't have to retrieve it from the dispatcher each time. + // In the plugin, this value is always NULL. + const PPB_URLUtil_Dev* ppb_url_util_impl_; + DISALLOW_COPY_AND_ASSIGN(PPB_URLUtil_Proxy); }; diff --git a/ppapi/proxy/ppb_var_deprecated_proxy.cc b/ppapi/proxy/ppb_var_deprecated_proxy.cc index 396e50e..1850dc0f 100644 --- a/ppapi/proxy/ppb_var_deprecated_proxy.cc +++ b/ppapi/proxy/ppb_var_deprecated_proxy.cc @@ -288,18 +288,21 @@ const PPB_Var_Deprecated var_deprecated_interface = { &CreateObject }; -InterfaceProxy* CreateVarDeprecatedProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Var_Deprecated_Proxy(dispatcher, target_interface); +InterfaceProxy* CreateVarDeprecatedProxy(Dispatcher* dispatcher) { + return new PPB_Var_Deprecated_Proxy(dispatcher ); } } // namespace PPB_Var_Deprecated_Proxy::PPB_Var_Deprecated_Proxy( - Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface), - task_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { + Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), + task_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), + ppb_var_impl_(NULL) { + if (!dispatcher->IsPlugin()) { + ppb_var_impl_ = static_cast<const PPB_Var_Deprecated*>( + dispatcher->local_get_interface()(PPB_VAR_DEPRECATED_INTERFACE)); + } } PPB_Var_Deprecated_Proxy::~PPB_Var_Deprecated_Proxy() { @@ -360,7 +363,7 @@ void PPB_Var_Deprecated_Proxy::OnMsgAddRefObject(int64 object_id, PP_Var var; var.type = PP_VARTYPE_OBJECT; var.value.as_id = object_id; - ppb_var_target()->AddRef(var); + ppb_var_impl_->AddRef(var); } void PPB_Var_Deprecated_Proxy::OnMsgReleaseObject(int64 object_id) { @@ -393,7 +396,7 @@ void PPB_Var_Deprecated_Proxy::OnMsgHasProperty( SerializedVarOutParam exception, PP_Bool* result) { SetAllowPluginReentrancy(); - *result = PP_FromBool(ppb_var_target()->HasProperty( + *result = PP_FromBool(ppb_var_impl_->HasProperty( var.Get(dispatcher()), name.Get(dispatcher()), exception.OutParam(dispatcher()))); @@ -405,7 +408,7 @@ void PPB_Var_Deprecated_Proxy::OnMsgHasMethodDeprecated( SerializedVarOutParam exception, PP_Bool* result) { SetAllowPluginReentrancy(); - *result = PP_FromBool(ppb_var_target()->HasMethod( + *result = PP_FromBool(ppb_var_impl_->HasMethod( var.Get(dispatcher()), name.Get(dispatcher()), exception.OutParam(dispatcher()))); @@ -417,7 +420,7 @@ void PPB_Var_Deprecated_Proxy::OnMsgGetProperty( SerializedVarOutParam exception, SerializedVarReturnValue result) { SetAllowPluginReentrancy(); - result.Return(dispatcher(), ppb_var_target()->GetProperty( + result.Return(dispatcher(), ppb_var_impl_->GetProperty( var.Get(dispatcher()), name.Get(dispatcher()), exception.OutParam(dispatcher()))); } @@ -427,7 +430,7 @@ void PPB_Var_Deprecated_Proxy::OnMsgEnumerateProperties( SerializedVarVectorOutParam props, SerializedVarOutParam exception) { SetAllowPluginReentrancy(); - ppb_var_target()->GetAllPropertyNames(var.Get(dispatcher()), + ppb_var_impl_->GetAllPropertyNames(var.Get(dispatcher()), props.CountOutParam(), props.ArrayOutParam(dispatcher()), exception.OutParam(dispatcher())); } @@ -438,7 +441,7 @@ void PPB_Var_Deprecated_Proxy::OnMsgSetPropertyDeprecated( SerializedVarReceiveInput value, SerializedVarOutParam exception) { SetAllowPluginReentrancy(); - ppb_var_target()->SetProperty(var.Get(dispatcher()), + ppb_var_impl_->SetProperty(var.Get(dispatcher()), name.Get(dispatcher()), value.Get(dispatcher()), exception.OutParam(dispatcher())); @@ -450,7 +453,7 @@ void PPB_Var_Deprecated_Proxy::OnMsgDeleteProperty( SerializedVarOutParam exception, PP_Bool* result) { SetAllowPluginReentrancy(); - ppb_var_target()->RemoveProperty(var.Get(dispatcher()), + ppb_var_impl_->RemoveProperty(var.Get(dispatcher()), name.Get(dispatcher()), exception.OutParam(dispatcher())); // This deprecated function doesn't actually return a value, but we re-use @@ -467,7 +470,7 @@ void PPB_Var_Deprecated_Proxy::OnMsgCallDeprecated( SetAllowPluginReentrancy(); uint32_t arg_count = 0; PP_Var* args = arg_vector.Get(dispatcher(), &arg_count); - result.Return(dispatcher(), ppb_var_target()->Call( + result.Return(dispatcher(), ppb_var_impl_->Call( object.Get(dispatcher()), method_name.Get(dispatcher()), arg_count, args, @@ -482,7 +485,7 @@ void PPB_Var_Deprecated_Proxy::OnMsgConstruct( SetAllowPluginReentrancy(); uint32_t arg_count = 0; PP_Var* args = arg_vector.Get(dispatcher(), &arg_count); - result.Return(dispatcher(), ppb_var_target()->Construct( + result.Return(dispatcher(), ppb_var_impl_->Construct( var.Get(dispatcher()), arg_count, args, exception.OutParam(dispatcher()))); } @@ -502,7 +505,7 @@ void PPB_Var_Deprecated_Proxy::OnMsgCreateObjectDeprecated( SerializedVarReturnValue result) { SetAllowPluginReentrancy(); result.Return(dispatcher(), PPP_Class_Proxy::CreateProxiedObject( - ppb_var_target(), dispatcher(), instance, ppp_class, class_data)); + ppb_var_impl_, dispatcher(), instance, ppp_class, class_data)); } void PPB_Var_Deprecated_Proxy::SetAllowPluginReentrancy() { @@ -516,7 +519,7 @@ void PPB_Var_Deprecated_Proxy::DoReleaseObject(int64 object_id) { PP_Var var; var.type = PP_VARTYPE_OBJECT; var.value.as_id = object_id; - ppb_var_target()->Release(var); + ppb_var_impl_->Release(var); } } // namespace proxy diff --git a/ppapi/proxy/ppb_var_deprecated_proxy.h b/ppapi/proxy/ppb_var_deprecated_proxy.h index d1a45a0..ac8c1fd 100644 --- a/ppapi/proxy/ppb_var_deprecated_proxy.h +++ b/ppapi/proxy/ppb_var_deprecated_proxy.h @@ -26,16 +26,11 @@ class SerializedVarReturnValue; class PPB_Var_Deprecated_Proxy : public InterfaceProxy { public: - PPB_Var_Deprecated_Proxy(Dispatcher* dispatcher, - const void* target_interface); + PPB_Var_Deprecated_Proxy(Dispatcher* dispatcher); virtual ~PPB_Var_Deprecated_Proxy(); static const Info* GetInfo(); - const PPB_Var_Deprecated* ppb_var_target() const { - return static_cast<const PPB_Var_Deprecated*>(target_interface()); - } - // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); @@ -96,6 +91,10 @@ class PPB_Var_Deprecated_Proxy : public InterfaceProxy { void DoReleaseObject(int64 object_id); ScopedRunnableMethodFactory<PPB_Var_Deprecated_Proxy> task_factory_; + + const PPB_Var_Deprecated* ppb_var_impl_; + + DISALLOW_COPY_AND_ASSIGN(PPB_Var_Deprecated_Proxy); }; } // namespace proxy diff --git a/ppapi/proxy/ppb_var_proxy.cc b/ppapi/proxy/ppb_var_proxy.cc index 765deef..4ee6cc1 100644 --- a/ppapi/proxy/ppb_var_proxy.cc +++ b/ppapi/proxy/ppb_var_proxy.cc @@ -46,37 +46,10 @@ const PPB_Var var_interface = { &VarToUtf8 }; -InterfaceProxy* CreateVarProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Var_Proxy(dispatcher, target_interface); -} - } // namespace -PPB_Var_Proxy::PPB_Var_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { -} - -PPB_Var_Proxy::~PPB_Var_Proxy() { -} - -// static -const InterfaceProxy::Info* PPB_Var_Proxy::GetInfo() { - static const Info info = { - &var_interface, - PPB_VAR_INTERFACE, - INTERFACE_ID_PPB_VAR, - false, - &CreateVarProxy, - }; - return &info; -} - -bool PPB_Var_Proxy::OnMessageReceived(const IPC::Message& msg) { - // All PPB_Var calls are handled locally; there is no need to send or receive - // messages here. - return false; +const PPB_Var* GetPPB_Var_Interface() { + return &var_interface; } } // namespace proxy diff --git a/ppapi/proxy/ppb_var_proxy.h b/ppapi/proxy/ppb_var_proxy.h index 6e060b9..465042b9 100644 --- a/ppapi/proxy/ppb_var_proxy.h +++ b/ppapi/proxy/ppb_var_proxy.h @@ -5,6 +5,7 @@ #ifndef PPAPI_PPB_VAR_PROXY_H_ #define PPAPI_PPB_VAR_PROXY_H_ +#include "ppapi/proxy/ppapi_proxy_export.h" #include "ppapi/proxy/interface_proxy.h" struct PPB_Var; @@ -12,23 +13,9 @@ struct PPB_Var; namespace ppapi { namespace proxy { -class PPB_Var_Proxy : public InterfaceProxy { - public: - PPB_Var_Proxy(Dispatcher* dispatcher, - const void* target_interface); - virtual ~PPB_Var_Proxy(); - - static const Info* GetInfo(); - - const PPB_Var* ppb_var_target() const { - return static_cast<const PPB_Var*>(target_interface()); - } - - // InterfaceProxy implementation. In this case, no messages are sent or - // received, so this always returns false. - virtual bool OnMessageReceived(const IPC::Message& msg); - -}; +// Returns a pointer to the plugin-specific implementation of PPB_Var. +// There is no proxy object since this is implemented entirely in-process. +PPAPI_PROXY_EXPORT const PPB_Var* GetPPB_Var_Interface(); } // namespace proxy } // namespace ppapi diff --git a/ppapi/proxy/ppb_var_unittest.cc b/ppapi/proxy/ppb_var_unittest.cc index 485b599..79abf39 100644 --- a/ppapi/proxy/ppb_var_unittest.cc +++ b/ppapi/proxy/ppb_var_unittest.cc @@ -9,6 +9,7 @@ #include "ppapi/c/pp_var.h" #include "ppapi/c/ppb_var.h" #include "ppapi/proxy/ppapi_proxy_test.h" +#include "ppapi/proxy/ppb_var_proxy.h" // TODO(dmichael): Make PPB_Var_Proxy and PluginResourceTracker thread-safe and // add thread-safety tests here. @@ -30,8 +31,7 @@ class PPB_VarTest : public PluginProxyTest { }; TEST_F(PPB_VarTest, Strings) { - const PPB_Var* ppb_var = static_cast<const PPB_Var*>( - plugin_dispatcher()->GetInterfaceFromDispatcher(PPB_VAR_INTERFACE)); + const PPB_Var* ppb_var = GetPPB_Var_Interface(); // Make a vector of strings, where the value of test_strings[i] is "i". const int kNumStrings = 5; diff --git a/ppapi/proxy/ppb_video_capture_proxy.cc b/ppapi/proxy/ppb_video_capture_proxy.cc index cae0b22..9f40c1f 100644 --- a/ppapi/proxy/ppb_video_capture_proxy.cc +++ b/ppapi/proxy/ppb_video_capture_proxy.cc @@ -21,6 +21,7 @@ #include "ppapi/thunk/ppb_buffer_api.h" #include "ppapi/thunk/ppb_buffer_trusted_api.h" #include "ppapi/thunk/ppb_video_capture_api.h" +#include "ppapi/thunk/resource_creation_api.h" #include "ppapi/thunk/thunk.h" using ppapi::thunk::EnterResourceNoLock; @@ -33,14 +34,8 @@ namespace proxy { namespace { -InterfaceProxy* CreatePPBVideoCaptureProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_VideoCapture_Proxy(dispatcher, target_interface); -} - -InterfaceProxy* CreatePPPVideoCaptureProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPP_VideoCapture_Proxy(dispatcher, target_interface); +InterfaceProxy* CreatePPPVideoCaptureProxy(Dispatcher* dispatcher) { + return new PPP_VideoCapture_Proxy(dispatcher); } void OnDeviceInfo(PP_Instance instance, @@ -57,7 +52,7 @@ void OnDeviceInfo(PP_Instance instance, host_resource.SetHostResource(instance, resource); std::vector<PPPVideoCapture_Buffer> buffers(buffer_count); const PPB_Core* core = static_cast<const PPB_Core*>( - dispatcher->GetLocalInterface(PPB_CORE_INTERFACE)); + dispatcher->local_get_interface()(PPB_CORE_INTERFACE)); DCHECK(core); for (uint32_t i = 0; i < buffer_count; ++i) { // We need to take a ref on the resource now. The browser may drop @@ -265,27 +260,14 @@ ppapi::thunk::PPB_VideoCapture_API* VideoCapture::AsPPB_VideoCapture_API() { return this; } -PPB_VideoCapture_Proxy::PPB_VideoCapture_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { +PPB_VideoCapture_Proxy::PPB_VideoCapture_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher) { } PPB_VideoCapture_Proxy::~PPB_VideoCapture_Proxy() { } // static -const InterfaceProxy::Info* PPB_VideoCapture_Proxy::GetInfo() { - static const Info info = { - ppapi::thunk::GetPPB_VideoCapture_Thunk(), - PPB_VIDEO_CAPTURE_DEV_INTERFACE, - INTERFACE_ID_PPB_VIDEO_CAPTURE_DEV, - false, - &CreatePPBVideoCaptureProxy, - }; - return &info; -} - -// static PP_Resource PPB_VideoCapture_Proxy::CreateProxyResource(PP_Instance instance) { PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); if (!dispatcher) @@ -317,11 +299,12 @@ bool PPB_VideoCapture_Proxy::OnMessageReceived(const IPC::Message& msg) { void PPB_VideoCapture_Proxy::OnMsgCreate(PP_Instance instance, HostResource* result_resource) { - HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); - if (!dispatcher) - return; - PP_Resource resource = ppb_video_capture_target()->Create(instance); - result_resource->SetHostResource(instance, resource); + thunk::EnterResourceCreation enter(instance); + if (enter.succeeded()) { + result_resource->SetHostResource( + instance, + enter.functions()->CreateVideoCapture(instance)); + } } void PPB_VideoCapture_Proxy::OnMsgStartCapture( @@ -346,9 +329,13 @@ void PPB_VideoCapture_Proxy::OnMsgStopCapture(const HostResource& resource) { enter.object()->StopCapture(); } -PPP_VideoCapture_Proxy::PPP_VideoCapture_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { +PPP_VideoCapture_Proxy::PPP_VideoCapture_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), + ppp_video_capture_impl_(NULL) { + if (dispatcher->IsPlugin()) { + ppp_video_capture_impl_ = static_cast<const PPP_VideoCapture_Dev*>( + dispatcher->local_get_interface()(PPP_VIDEO_CAPTURE_DEV_INTERFACE)); + } } PPP_VideoCapture_Proxy::~PPP_VideoCapture_Proxy() { @@ -388,7 +375,7 @@ void PPP_VideoCapture_Proxy::OnMsgOnDeviceInfo( EnterPluginFromHostResource<PPB_VideoCapture_API> enter(host_resource); PluginResourceTracker* tracker = PluginResourceTracker::GetInstance(); PP_Resource resource = tracker->PluginResourceForHostResource(host_resource); - if (!resource || !ppp_video_capture_target() || enter.failed()) + if (!resource || !ppp_video_capture_impl_ || enter.failed()) return; scoped_array<PP_Resource> resources(new PP_Resource[buffers.size()]); @@ -400,7 +387,7 @@ void PPP_VideoCapture_Proxy::OnMsgOnDeviceInfo( buffers[i].size); } static_cast<VideoCapture*>(enter.object())->SetBufferCount(buffers.size()); - ppp_video_capture_target()->OnDeviceInfo( + ppp_video_capture_impl_->OnDeviceInfo( host_resource.instance(), resource, &info, @@ -415,12 +402,12 @@ void PPP_VideoCapture_Proxy::OnMsgOnStatus(const HostResource& host_resource, EnterPluginFromHostResource<PPB_VideoCapture_API> enter(host_resource); PluginResourceTracker* tracker = PluginResourceTracker::GetInstance(); PP_Resource resource = tracker->PluginResourceForHostResource(host_resource); - if (!resource || !ppp_video_capture_target() || enter.failed()) + if (!resource || !ppp_video_capture_impl_ || enter.failed()) return; if (!static_cast<VideoCapture*>(enter.object())->OnStatus(status)) return; - ppp_video_capture_target()->OnStatus( + ppp_video_capture_impl_->OnStatus( host_resource.instance(), resource, status); } @@ -429,11 +416,11 @@ void PPP_VideoCapture_Proxy::OnMsgOnError(const HostResource& host_resource, EnterPluginFromHostResource<PPB_VideoCapture_API> enter(host_resource); PluginResourceTracker* tracker = PluginResourceTracker::GetInstance(); PP_Resource resource = tracker->PluginResourceForHostResource(host_resource); - if (!resource || !ppp_video_capture_target() || enter.failed()) + if (!resource || !ppp_video_capture_impl_ || enter.failed()) return; static_cast<VideoCapture*>(enter.object())->set_status( PP_VIDEO_CAPTURE_STATUS_STOPPED); - ppp_video_capture_target()->OnError( + ppp_video_capture_impl_->OnError( host_resource.instance(), resource, error_code); } @@ -442,10 +429,10 @@ void PPP_VideoCapture_Proxy::OnMsgOnBufferReady( EnterPluginFromHostResource<PPB_VideoCapture_API> enter(host_resource); PluginResourceTracker* tracker = PluginResourceTracker::GetInstance(); PP_Resource resource = tracker->PluginResourceForHostResource(host_resource); - if (!resource || !ppp_video_capture_target() || enter.failed()) + if (!resource || !ppp_video_capture_impl_ || enter.failed()) return; static_cast<VideoCapture*>(enter.object())->SetBufferInUse(buffer); - ppp_video_capture_target()->OnBufferReady( + ppp_video_capture_impl_->OnBufferReady( host_resource.instance(), resource, buffer); } diff --git a/ppapi/proxy/ppb_video_capture_proxy.h b/ppapi/proxy/ppb_video_capture_proxy.h index e882700..5695579 100644 --- a/ppapi/proxy/ppb_video_capture_proxy.h +++ b/ppapi/proxy/ppb_video_capture_proxy.h @@ -21,20 +21,16 @@ namespace proxy { class PPB_VideoCapture_Proxy : public InterfaceProxy { public: - PPB_VideoCapture_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPB_VideoCapture_Proxy(Dispatcher* dispatcher); virtual ~PPB_VideoCapture_Proxy(); - static const Info* GetInfo(); - static PP_Resource CreateProxyResource(PP_Instance instance); - const PPB_VideoCapture_Dev* ppb_video_capture_target() const { - return static_cast<const PPB_VideoCapture_Dev*>(target_interface()); - } - // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); + static const InterfaceID kInterfaceID = INTERFACE_ID_PPB_VIDEO_CAPTURE_DEV; + private: // Message handlers. void OnMsgCreate(PP_Instance instance, ppapi::HostResource* result_resource); @@ -44,22 +40,22 @@ class PPB_VideoCapture_Proxy : public InterfaceProxy { void OnMsgReuseBuffer(const ppapi::HostResource& resource, uint32_t buffer); void OnMsgStopCapture(const ppapi::HostResource& resource); + + DISALLOW_COPY_AND_ASSIGN(PPB_VideoCapture_Proxy); }; class PPP_VideoCapture_Proxy : public InterfaceProxy { public: - PPP_VideoCapture_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPP_VideoCapture_Proxy(Dispatcher* dispatcher); virtual ~PPP_VideoCapture_Proxy(); static const Info* GetInfo(); - const PPP_VideoCapture_Dev* ppp_video_capture_target() const { - return static_cast<const PPP_VideoCapture_Dev*>(target_interface()); - } - // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); + static const InterfaceID kInterfaceID = INTERFACE_ID_PPP_VIDEO_CAPTURE_DEV; + private: // Message handlers. void OnMsgOnDeviceInfo(const ppapi::HostResource& video_capture, @@ -71,6 +67,13 @@ class PPP_VideoCapture_Proxy : public InterfaceProxy { uint32_t error_code); void OnMsgOnBufferReady(const ppapi::HostResource& video_capture, uint32_t buffer); + + // When this proxy is in the plugin side, this value caches the interface + // pointer so we don't have to retrieve it from the dispatcher each time. + // In the host, this value is always NULL. + const PPP_VideoCapture_Dev* ppp_video_capture_impl_; + + DISALLOW_COPY_AND_ASSIGN(PPP_VideoCapture_Proxy); }; } // namespace proxy diff --git a/ppapi/proxy/ppb_video_decoder_proxy.cc b/ppapi/proxy/ppb_video_decoder_proxy.cc index f9e4379..023b8c9 100644 --- a/ppapi/proxy/ppb_video_decoder_proxy.cc +++ b/ppapi/proxy/ppb_video_decoder_proxy.cc @@ -154,36 +154,14 @@ void VideoDecoder::EndOfBitstreamACK( RunBitstreamBufferCallback(bitstream_buffer_id, result); } -namespace { - -InterfaceProxy* CreateVideoDecoderProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_VideoDecoder_Proxy(dispatcher, target_interface); -} - -} // namespace - -PPB_VideoDecoder_Proxy::PPB_VideoDecoder_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface), +PPB_VideoDecoder_Proxy::PPB_VideoDecoder_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { } PPB_VideoDecoder_Proxy::~PPB_VideoDecoder_Proxy() { } -// static -const InterfaceProxy::Info* PPB_VideoDecoder_Proxy::GetInfo() { - static const Info info = { - thunk::GetPPB_VideoDecoder_Thunk(), - PPB_VIDEODECODER_DEV_INTERFACE, - INTERFACE_ID_PPB_VIDEO_DECODER_DEV, - false, - &CreateVideoDecoderProxy, - }; - return &info; -} - bool PPB_VideoDecoder_Proxy::OnMessageReceived(const IPC::Message& msg) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(PPB_VideoDecoder_Proxy, msg) @@ -252,8 +230,7 @@ void PPB_VideoDecoder_Proxy::OnMsgCreate( PP_Instance instance, const HostResource& graphics_context, PP_VideoDecoder_Profile profile, HostResource* result) { - thunk::EnterFunction<thunk::ResourceCreationAPI> resource_creation(instance, - true); + thunk::EnterResourceCreation resource_creation(instance); if (resource_creation.failed()) return; @@ -266,46 +243,52 @@ void PPB_VideoDecoder_Proxy::OnMsgCreate( void PPB_VideoDecoder_Proxy::OnMsgDecode( const HostResource& decoder, const HostResource& buffer, int32 id, int32 size) { - pp::CompletionCallback callback = callback_factory_.NewRequiredCallback( + EnterHostFromHostResourceForceCallback<PPB_VideoDecoder_API> enter( + decoder, callback_factory_, &PPB_VideoDecoder_Proxy::SendMsgEndOfBitstreamACKToPlugin, decoder, id); - + if (enter.failed()) + return; PP_VideoBitstreamBuffer_Dev bitstream = { id, buffer.host_resource(), size }; - ppb_video_decoder_target()->Decode( - decoder.host_resource(), &bitstream, callback.pp_completion_callback()); + enter.SetResult(enter.object()->Decode(&bitstream, enter.callback())); } void PPB_VideoDecoder_Proxy::OnMsgAssignPictureBuffers( const HostResource& decoder, const std::vector<PP_PictureBuffer_Dev>& buffers) { - DCHECK(!buffers.empty()); - const PP_PictureBuffer_Dev* buffer_array = &buffers.front(); - - ppb_video_decoder_target()->AssignPictureBuffers( - decoder.host_resource(), buffers.size(), buffer_array); + EnterHostFromHostResource<PPB_VideoDecoder_API> enter(decoder); + if (enter.succeeded() && !buffers.empty()) { + const PP_PictureBuffer_Dev* buffer_array = &buffers.front(); + enter.object()->AssignPictureBuffers(buffers.size(), buffer_array); + } } void PPB_VideoDecoder_Proxy::OnMsgReusePictureBuffer( const HostResource& decoder, int32 picture_buffer_id) { - ppb_video_decoder_target()->ReusePictureBuffer( - decoder.host_resource(), picture_buffer_id); + EnterHostFromHostResource<PPB_VideoDecoder_API> enter(decoder); + if (enter.succeeded()) + enter.object()->ReusePictureBuffer(picture_buffer_id); } void PPB_VideoDecoder_Proxy::OnMsgFlush(const HostResource& decoder) { - pp::CompletionCallback callback = callback_factory_.NewRequiredCallback( + EnterHostFromHostResourceForceCallback<PPB_VideoDecoder_API> enter( + decoder, callback_factory_, &PPB_VideoDecoder_Proxy::SendMsgFlushACKToPlugin, decoder); - ppb_video_decoder_target()->Flush( - decoder.host_resource(), callback.pp_completion_callback()); + if (enter.succeeded()) + enter.SetResult(enter.object()->Flush(enter.callback())); } void PPB_VideoDecoder_Proxy::OnMsgReset(const HostResource& decoder) { - pp::CompletionCallback callback = callback_factory_.NewRequiredCallback( + EnterHostFromHostResourceForceCallback<PPB_VideoDecoder_API> enter( + decoder, callback_factory_, &PPB_VideoDecoder_Proxy::SendMsgResetACKToPlugin, decoder); - ppb_video_decoder_target()->Reset( - decoder.host_resource(), callback.pp_completion_callback()); + if (enter.succeeded()) + enter.SetResult(enter.object()->Reset(enter.callback())); } void PPB_VideoDecoder_Proxy::OnMsgDestroy(const HostResource& decoder) { - ppb_video_decoder_target()->Destroy(decoder.host_resource()); + EnterHostFromHostResource<PPB_VideoDecoder_API> enter(decoder); + if (enter.succeeded()) + enter.object()->Destroy(); } void PPB_VideoDecoder_Proxy::SendMsgEndOfBitstreamACKToPlugin( diff --git a/ppapi/proxy/ppb_video_decoder_proxy.h b/ppapi/proxy/ppb_video_decoder_proxy.h index b34cb22..32d1ec6 100644 --- a/ppapi/proxy/ppb_video_decoder_proxy.h +++ b/ppapi/proxy/ppb_video_decoder_proxy.h @@ -17,11 +17,9 @@ namespace proxy { class PPB_VideoDecoder_Proxy : public InterfaceProxy { public: - PPB_VideoDecoder_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPB_VideoDecoder_Proxy(Dispatcher* dispatcher); virtual ~PPB_VideoDecoder_Proxy(); - static const Info* GetInfo(); - // Creates a VideoDecoder object in the plugin process. static PP_Resource CreateProxyResource( PP_Instance instance, @@ -31,9 +29,7 @@ class PPB_VideoDecoder_Proxy : public InterfaceProxy { // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); - const PPB_VideoDecoder_Dev* ppb_video_decoder_target() const { - return static_cast<const PPB_VideoDecoder_Dev*>(target_interface()); - } + static const InterfaceID kInterfaceID = INTERFACE_ID_PPB_VIDEO_DECODER_DEV; private: // Message handlers in the renderer process to receive messages from the diff --git a/ppapi/proxy/ppp_class_proxy.cc b/ppapi/proxy/ppp_class_proxy.cc index 8ab109f..9a616f42 100644 --- a/ppapi/proxy/ppp_class_proxy.cc +++ b/ppapi/proxy/ppp_class_proxy.cc @@ -175,13 +175,18 @@ void* ToUserData(int64 value) { // PPP_Class_Proxy ------------------------------------------------------------- PPP_Class_Proxy::PPP_Class_Proxy(Dispatcher* dispatcher) - : InterfaceProxy(dispatcher, NULL) { + : InterfaceProxy(dispatcher) { } PPP_Class_Proxy::~PPP_Class_Proxy() { } // static +InterfaceProxy* PPP_Class_Proxy::Create(Dispatcher* dispatcher) { + return new PPP_Class_Proxy(dispatcher); +} + +// static PP_Var PPP_Class_Proxy::CreateProxiedObject(const PPB_Var_Deprecated* var, Dispatcher* dispatcher, PP_Module module_id, diff --git a/ppapi/proxy/ppp_class_proxy.h b/ppapi/proxy/ppp_class_proxy.h index ce93770..299c3ec 100644 --- a/ppapi/proxy/ppp_class_proxy.h +++ b/ppapi/proxy/ppp_class_proxy.h @@ -31,6 +31,10 @@ class PPP_Class_Proxy : public InterfaceProxy { PPP_Class_Proxy(Dispatcher* dispatcher); virtual ~PPP_Class_Proxy(); + // Factory function used for registration (normal code can just use the + // constructor). + static InterfaceProxy* Create(Dispatcher* dispatcher); + // Creates a proxied object in the browser process. This takes the browser's // PPB_Var_Deprecated interface to use to create the object. The class and static PP_Var CreateProxiedObject(const PPB_Var_Deprecated* var, diff --git a/ppapi/proxy/ppp_graphics_3d_proxy.cc b/ppapi/proxy/ppp_graphics_3d_proxy.cc index a477227..3cac4646 100644 --- a/ppapi/proxy/ppp_graphics_3d_proxy.cc +++ b/ppapi/proxy/ppp_graphics_3d_proxy.cc @@ -24,16 +24,19 @@ static const PPP_Graphics3D graphics_3d_interface = { &ContextLost }; -InterfaceProxy* CreateGraphics3DProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPP_Graphics3D_Proxy(dispatcher, target_interface); +InterfaceProxy* CreateGraphics3DProxy(Dispatcher* dispatcher) { + return new PPP_Graphics3D_Proxy(dispatcher); } } // namespace -PPP_Graphics3D_Proxy::PPP_Graphics3D_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { +PPP_Graphics3D_Proxy::PPP_Graphics3D_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), + ppp_graphics_3d_impl_(NULL) { + if (dispatcher->IsPlugin()) { + ppp_graphics_3d_impl_ = static_cast<const PPP_Graphics3D*>( + dispatcher->local_get_interface()(PPP_GRAPHICS_3D_INTERFACE)); + } } PPP_Graphics3D_Proxy::~PPP_Graphics3D_Proxy() { @@ -62,8 +65,8 @@ bool PPP_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) { } void PPP_Graphics3D_Proxy::OnMsgContextLost(PP_Instance instance) { - if (ppp_graphics_3d_target()) - ppp_graphics_3d_target()->Graphics3DContextLost(instance); + if (ppp_graphics_3d_impl_) + ppp_graphics_3d_impl_->Graphics3DContextLost(instance); } } // namespace proxy diff --git a/ppapi/proxy/ppp_graphics_3d_proxy.h b/ppapi/proxy/ppp_graphics_3d_proxy.h index eb3d3b0..e340424 100644 --- a/ppapi/proxy/ppp_graphics_3d_proxy.h +++ b/ppapi/proxy/ppp_graphics_3d_proxy.h @@ -16,21 +16,24 @@ namespace proxy { class PPP_Graphics3D_Proxy : public InterfaceProxy { public: - PPP_Graphics3D_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPP_Graphics3D_Proxy(Dispatcher* dispatcher); virtual ~PPP_Graphics3D_Proxy(); static const Info* GetInfo(); - const PPP_Graphics3D* ppp_graphics_3d_target() const { - return reinterpret_cast<const PPP_Graphics3D*>(target_interface()); - } - // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); private: // Message handlers. void OnMsgContextLost(PP_Instance instance); + + // When this proxy is in the plugin side, this value caches the interface + // pointer so we don't have to retrieve it from the dispatcher each time. + // In the host, this value is always NULL. + const PPP_Graphics3D* ppp_graphics_3d_impl_; + + DISALLOW_COPY_AND_ASSIGN(PPP_Graphics3D_Proxy); }; } // namespace proxy diff --git a/ppapi/proxy/ppp_input_event_proxy.cc b/ppapi/proxy/ppp_input_event_proxy.cc index a8843f5..7d72dfe 100644 --- a/ppapi/proxy/ppp_input_event_proxy.cc +++ b/ppapi/proxy/ppp_input_event_proxy.cc @@ -11,7 +11,6 @@ #include "ppapi/proxy/plugin_dispatcher.h" #include "ppapi/proxy/plugin_resource_tracker.h" #include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/proxy/ppb_input_event_proxy.h" #include "ppapi/shared_impl/input_event_impl.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_input_event_api.h" @@ -53,16 +52,19 @@ static const PPP_InputEvent input_event_interface = { &HandleInputEvent }; -InterfaceProxy* CreateInputEventProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPP_InputEvent_Proxy(dispatcher, target_interface); +InterfaceProxy* CreateInputEventProxy(Dispatcher* dispatcher) { + return new PPP_InputEvent_Proxy(dispatcher); } } // namespace -PPP_InputEvent_Proxy::PPP_InputEvent_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { +PPP_InputEvent_Proxy::PPP_InputEvent_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), + ppp_input_event_impl_(NULL) { + if (dispatcher->IsPlugin()) { + ppp_input_event_impl_ = static_cast<const PPP_InputEvent*>( + dispatcher->local_get_interface()(PPP_INPUT_EVENT_INTERFACE)); + } } PPP_InputEvent_Proxy::~PPP_InputEvent_Proxy() { @@ -96,7 +98,7 @@ void PPP_InputEvent_Proxy::OnMsgHandleInputEvent(PP_Instance instance, const InputEventData& data) { scoped_refptr<InputEventImpl> resource(new InputEventImpl( InputEventImpl::InitAsProxy(), instance, data)); - ppp_input_event_target()->HandleInputEvent(instance, resource->pp_resource()); + ppp_input_event_impl_->HandleInputEvent(instance, resource->pp_resource()); } void PPP_InputEvent_Proxy::OnMsgHandleFilteredInputEvent( @@ -105,8 +107,8 @@ void PPP_InputEvent_Proxy::OnMsgHandleFilteredInputEvent( PP_Bool* result) { scoped_refptr<InputEventImpl> resource(new InputEventImpl( InputEventImpl::InitAsProxy(), instance, data)); - *result = ppp_input_event_target()->HandleInputEvent(instance, - resource->pp_resource()); + *result = ppp_input_event_impl_->HandleInputEvent(instance, + resource->pp_resource()); } } // namespace proxy diff --git a/ppapi/proxy/ppp_input_event_proxy.h b/ppapi/proxy/ppp_input_event_proxy.h index e286250..ffe5e868 100644 --- a/ppapi/proxy/ppp_input_event_proxy.h +++ b/ppapi/proxy/ppp_input_event_proxy.h @@ -18,15 +18,11 @@ namespace proxy { class PPP_InputEvent_Proxy : public InterfaceProxy { public: - PPP_InputEvent_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPP_InputEvent_Proxy(Dispatcher* dispatcher); virtual ~PPP_InputEvent_Proxy(); static const Info* GetInfo(); - const PPP_InputEvent* ppp_input_event_target() const { - return static_cast<const PPP_InputEvent*>(target_interface()); - } - // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); @@ -37,6 +33,13 @@ class PPP_InputEvent_Proxy : public InterfaceProxy { void OnMsgHandleFilteredInputEvent(PP_Instance instance, const ppapi::InputEventData& data, PP_Bool* result); + + // When this proxy is in the plugin side, this value caches the interface + // pointer so we don't have to retrieve it from the dispatcher each time. + // In the host, this value is always NULL. + const PPP_InputEvent* ppp_input_event_impl_; + + DISALLOW_COPY_AND_ASSIGN(PPP_InputEvent_Proxy); }; } // namespace proxy diff --git a/ppapi/proxy/ppp_instance_private_proxy.cc b/ppapi/proxy/ppp_instance_private_proxy.cc index 4ecd6a6..82057a6 100644 --- a/ppapi/proxy/ppp_instance_private_proxy.cc +++ b/ppapi/proxy/ppp_instance_private_proxy.cc @@ -30,16 +30,19 @@ static const PPP_Instance_Private instance_private_interface = { &GetInstanceObject }; -InterfaceProxy* CreateInstancePrivateProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPP_Instance_Private_Proxy(dispatcher, target_interface); +InterfaceProxy* CreateInstancePrivateProxy(Dispatcher* dispatcher) { + return new PPP_Instance_Private_Proxy(dispatcher); } } // namespace -PPP_Instance_Private_Proxy::PPP_Instance_Private_Proxy( - Dispatcher* dispatcher, const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { +PPP_Instance_Private_Proxy::PPP_Instance_Private_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), + ppp_instance_private_impl_(NULL) { + if (dispatcher->IsPlugin()) { + ppp_instance_private_impl_ = static_cast<const PPP_Instance_Private*>( + dispatcher->local_get_interface()(PPP_INSTANCE_PRIVATE_INTERFACE)); + } } PPP_Instance_Private_Proxy::~PPP_Instance_Private_Proxy() { @@ -71,7 +74,7 @@ void PPP_Instance_Private_Proxy::OnMsgGetInstanceObject( PP_Instance instance, SerializedVarReturnValue result) { result.Return(dispatcher(), - ppp_instance_private_target()->GetInstanceObject(instance)); + ppp_instance_private_impl_->GetInstanceObject(instance)); } } // namespace proxy diff --git a/ppapi/proxy/ppp_instance_private_proxy.h b/ppapi/proxy/ppp_instance_private_proxy.h index afab722..1759eb9 100644 --- a/ppapi/proxy/ppp_instance_private_proxy.h +++ b/ppapi/proxy/ppp_instance_private_proxy.h @@ -20,16 +20,11 @@ class SerializedVarReturnValue; class PPP_Instance_Private_Proxy : public InterfaceProxy { public: - PPP_Instance_Private_Proxy(Dispatcher* dispatcher, - const void* target_interface); + PPP_Instance_Private_Proxy(Dispatcher* dispatcher); virtual ~PPP_Instance_Private_Proxy(); static const Info* GetInfo(); - const PPP_Instance_Private* ppp_instance_private_target() const { - return reinterpret_cast<const PPP_Instance_Private*>(target_interface()); - } - private: // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); @@ -37,6 +32,13 @@ class PPP_Instance_Private_Proxy : public InterfaceProxy { // Message handlers. void OnMsgGetInstanceObject(PP_Instance instance, SerializedVarReturnValue result); + + // When this proxy is in the plugin side, this value caches the interface + // pointer so we don't have to retrieve it from the dispatcher each time. + // In the host, this value is always NULL. + const PPP_Instance_Private* ppp_instance_private_impl_; + + DISALLOW_COPY_AND_ASSIGN(PPP_Instance_Private_Proxy); }; } // namespace proxy diff --git a/ppapi/proxy/ppp_instance_proxy.cc b/ppapi/proxy/ppp_instance_proxy.cc index 1da10be..aa4b7e7 100644 --- a/ppapi/proxy/ppp_instance_proxy.cc +++ b/ppapi/proxy/ppp_instance_proxy.cc @@ -50,7 +50,7 @@ void DidChangeView(PP_Instance instance, HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); const PPB_Fullscreen_Dev* fullscreen_interface = static_cast<const PPB_Fullscreen_Dev*>( - dispatcher->GetLocalInterface(PPB_FULLSCREEN_DEV_INTERFACE)); + dispatcher->local_get_interface()(PPB_FULLSCREEN_DEV_INTERFACE)); DCHECK(fullscreen_interface); PP_Bool fullscreen = fullscreen_interface->IsFullscreen(instance); dispatcher->Send( @@ -73,7 +73,7 @@ PP_Bool HandleDocumentLoad(PP_Instance instance, // Set up the URLLoader for proxying. PPB_URLLoader_Proxy* url_loader_proxy = static_cast<PPB_URLLoader_Proxy*>( - dispatcher->GetOrCreatePPBInterfaceProxy(INTERFACE_ID_PPB_URL_LOADER)); + dispatcher->GetInterfaceProxy(INTERFACE_ID_PPB_URL_LOADER)); url_loader_proxy->PrepareURLLoaderForSendingToPlugin(url_loader); // PluginResourceTracker in the plugin process assumes that resources that it @@ -83,7 +83,7 @@ PP_Bool HandleDocumentLoad(PP_Instance instance, // Please also see comments in PPP_Instance_Proxy::OnMsgHandleDocumentLoad() // about releasing of this extra reference. const PPB_Core* core = reinterpret_cast<const PPB_Core*>( - dispatcher->GetLocalInterface(PPB_CORE_INTERFACE)); + dispatcher->local_get_interface()(PPB_CORE_INTERFACE)); if (!core) { NOTREACHED(); return PP_FALSE; @@ -105,16 +105,21 @@ static const PPP_Instance_1_0 instance_interface_1_0 = { &HandleDocumentLoad }; -template <class PPP_Instance_Type> -InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPP_Instance_Proxy( - dispatcher, - static_cast<const PPP_Instance_Type*>(target_interface)); +InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher) { + return new PPP_Instance_Proxy(dispatcher); } } // namespace +PPP_Instance_Proxy::PPP_Instance_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher) { + if (dispatcher->IsPlugin()) { + combined_interface_.reset( + new PPP_Instance_Combined(*static_cast<const PPP_Instance_1_0*>( + dispatcher->local_get_interface()(PPP_INSTANCE_INTERFACE_1_0)))); + } +} + PPP_Instance_Proxy::~PPP_Instance_Proxy() { } @@ -125,7 +130,7 @@ const InterfaceProxy::Info* PPP_Instance_Proxy::GetInfo1_0() { PPP_INSTANCE_INTERFACE_1_0, INTERFACE_ID_PPP_INSTANCE, false, - &CreateInstanceProxy<PPP_Instance_1_0>, + &CreateInstanceProxy }; return &info; } diff --git a/ppapi/proxy/ppp_instance_proxy.h b/ppapi/proxy/ppp_instance_proxy.h index f9b471c..7b70245 100644 --- a/ppapi/proxy/ppp_instance_proxy.h +++ b/ppapi/proxy/ppp_instance_proxy.h @@ -25,12 +25,7 @@ class SerializedVarReturnValue; class PPP_Instance_Proxy : public InterfaceProxy { public: - template <class PPP_Instance_Type> - PPP_Instance_Proxy(Dispatcher* dispatcher, - const PPP_Instance_Type* target_interface) - : InterfaceProxy(dispatcher, static_cast<const void*>(target_interface)), - combined_interface_(new PPP_Instance_Combined(*target_interface)) { - } + PPP_Instance_Proxy(Dispatcher* dispatcher); virtual ~PPP_Instance_Proxy(); // Return the info for the 1.0 (latest, canonical) version of the interface. diff --git a/ppapi/proxy/ppp_messaging_proxy.cc b/ppapi/proxy/ppp_messaging_proxy.cc index 59f4574..390794a 100644 --- a/ppapi/proxy/ppp_messaging_proxy.cc +++ b/ppapi/proxy/ppp_messaging_proxy.cc @@ -37,16 +37,19 @@ static const PPP_Messaging messaging_interface = { &HandleMessage }; -InterfaceProxy* CreateMessagingProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPP_Messaging_Proxy(dispatcher, target_interface); +InterfaceProxy* CreateMessagingProxy(Dispatcher* dispatcher) { + return new PPP_Messaging_Proxy(dispatcher); } } // namespace -PPP_Messaging_Proxy::PPP_Messaging_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { +PPP_Messaging_Proxy::PPP_Messaging_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), + ppp_messaging_impl_(NULL) { + if (dispatcher->IsPlugin()) { + ppp_messaging_impl_ = static_cast<const PPP_Messaging*>( + dispatcher->local_get_interface()(PPP_MESSAGING_INTERFACE)); + } } PPP_Messaging_Proxy::~PPP_Messaging_Proxy() { @@ -80,7 +83,7 @@ void PPP_Messaging_Proxy::OnMsgHandleMessage( // SerializedVarReceiveInput will decrement the reference count, but we want // to give the recipient a reference. PluginResourceTracker::GetInstance()->var_tracker().AddRefVar(received_var); - ppp_messaging_target()->HandleMessage(instance, received_var); + ppp_messaging_impl_->HandleMessage(instance, received_var); } } // namespace proxy diff --git a/ppapi/proxy/ppp_messaging_proxy.h b/ppapi/proxy/ppp_messaging_proxy.h index 2deb40f..bc898f31 100644 --- a/ppapi/proxy/ppp_messaging_proxy.h +++ b/ppapi/proxy/ppp_messaging_proxy.h @@ -17,15 +17,11 @@ class SerializedVarReceiveInput; class PPP_Messaging_Proxy : public InterfaceProxy { public: - PPP_Messaging_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPP_Messaging_Proxy(Dispatcher* dispatcher); virtual ~PPP_Messaging_Proxy(); static const Info* GetInfo(); - const PPP_Messaging* ppp_messaging_target() const { - return static_cast<const PPP_Messaging*>(target_interface()); - } - // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; @@ -33,6 +29,13 @@ class PPP_Messaging_Proxy : public InterfaceProxy { // Message handlers. void OnMsgHandleMessage(PP_Instance instance, SerializedVarReceiveInput data); + + // When this proxy is in the plugin side, this value caches the interface + // pointer so we don't have to retrieve it from the dispatcher each time. + // In the host, this value is always NULL. + const PPP_Messaging* ppp_messaging_impl_; + + DISALLOW_COPY_AND_ASSIGN(PPP_Messaging_Proxy); }; } // namespace proxy diff --git a/ppapi/proxy/ppp_mouse_lock_proxy.cc b/ppapi/proxy/ppp_mouse_lock_proxy.cc index 8980bcf..e39a914 100644 --- a/ppapi/proxy/ppp_mouse_lock_proxy.cc +++ b/ppapi/proxy/ppp_mouse_lock_proxy.cc @@ -29,16 +29,18 @@ static const PPP_MouseLock_Dev mouse_lock_interface = { &MouseLockLost }; -InterfaceProxy* CreateMouseLockProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPP_MouseLock_Proxy(dispatcher, target_interface); +InterfaceProxy* CreateMouseLockProxy(Dispatcher* dispatcher) { + return new PPP_MouseLock_Proxy(dispatcher); } } // namespace -PPP_MouseLock_Proxy::PPP_MouseLock_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { +PPP_MouseLock_Proxy::PPP_MouseLock_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher) { + if (dispatcher->IsPlugin()) { + ppp_mouse_lock_impl_ = static_cast<const PPP_MouseLock_Dev*>( + dispatcher->local_get_interface()(PPP_MOUSELOCK_DEV_INTERFACE)); + } } PPP_MouseLock_Proxy::~PPP_MouseLock_Proxy() { @@ -67,8 +69,8 @@ bool PPP_MouseLock_Proxy::OnMessageReceived(const IPC::Message& msg) { } void PPP_MouseLock_Proxy::OnMsgMouseLockLost(PP_Instance instance) { - if (ppp_mouse_lock_target()) - ppp_mouse_lock_target()->MouseLockLost(instance); + if (ppp_mouse_lock_impl_) + ppp_mouse_lock_impl_->MouseLockLost(instance); } } // namespace proxy diff --git a/ppapi/proxy/ppp_mouse_lock_proxy.h b/ppapi/proxy/ppp_mouse_lock_proxy.h index cfd451c..752e97a 100644 --- a/ppapi/proxy/ppp_mouse_lock_proxy.h +++ b/ppapi/proxy/ppp_mouse_lock_proxy.h @@ -15,21 +15,24 @@ namespace proxy { class PPP_MouseLock_Proxy : public InterfaceProxy { public: - PPP_MouseLock_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPP_MouseLock_Proxy(Dispatcher* dispatcher); virtual ~PPP_MouseLock_Proxy(); static const Info* GetInfo(); - const PPP_MouseLock_Dev* ppp_mouse_lock_target() const { - return static_cast<const PPP_MouseLock_Dev*>(target_interface()); - } - // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; private: // Message handlers. void OnMsgMouseLockLost(PP_Instance instance); + + // When this proxy is in the plugin side, this value caches the interface + // pointer so we don't have to retrieve it from the dispatcher each time. + // In the host, this value is always NULL. + const PPP_MouseLock_Dev* ppp_mouse_lock_impl_; + + DISALLOW_COPY_AND_ASSIGN(PPP_MouseLock_Proxy); }; } // namespace proxy diff --git a/ppapi/proxy/ppp_video_decoder_proxy.cc b/ppapi/proxy/ppp_video_decoder_proxy.cc index 35a29c0..325a695 100644 --- a/ppapi/proxy/ppp_video_decoder_proxy.cc +++ b/ppapi/proxy/ppp_video_decoder_proxy.cc @@ -78,16 +78,19 @@ static const PPP_VideoDecoder_Dev video_decoder_interface = { &NotifyError }; -InterfaceProxy* CreateVideoDecoderPPPProxy( - Dispatcher* dispatcher, const void* target_interface) { - return new PPP_VideoDecoder_Proxy(dispatcher, target_interface); +InterfaceProxy* CreateVideoDecoderPPPProxy(Dispatcher* dispatcher) { + return new PPP_VideoDecoder_Proxy(dispatcher); } } // namespace -PPP_VideoDecoder_Proxy::PPP_VideoDecoder_Proxy( - Dispatcher* dispatcher, const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { +PPP_VideoDecoder_Proxy::PPP_VideoDecoder_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), + ppp_video_decoder_impl_(NULL) { + if (dispatcher->IsPlugin()) { + ppp_video_decoder_impl_ = static_cast<const PPP_VideoDecoder_Dev*>( + dispatcher->local_get_interface()(PPP_VIDEODECODER_DEV_INTERFACE)); + } } PPP_VideoDecoder_Proxy::~PPP_VideoDecoder_Proxy() { @@ -129,7 +132,7 @@ void PPP_VideoDecoder_Proxy::OnMsgProvidePictureBuffers( const PP_Size& dimensions) { PP_Resource plugin_decoder = PluginResourceTracker::GetInstance()-> PluginResourceForHostResource(decoder); - ppp_video_decoder_target()->ProvidePictureBuffers( + ppp_video_decoder_impl_->ProvidePictureBuffers( decoder.instance(), plugin_decoder, req_num_of_bufs, dimensions); } @@ -137,7 +140,7 @@ void PPP_VideoDecoder_Proxy::OnMsgDismissPictureBuffer( const HostResource& decoder, int32_t picture_id) { PP_Resource plugin_decoder = PluginResourceTracker::GetInstance()-> PluginResourceForHostResource(decoder); - ppp_video_decoder_target()->DismissPictureBuffer( + ppp_video_decoder_impl_->DismissPictureBuffer( decoder.instance(), plugin_decoder, picture_id); } @@ -145,7 +148,7 @@ void PPP_VideoDecoder_Proxy::OnMsgPictureReady( const HostResource& decoder, const PP_Picture_Dev& picture) { PP_Resource plugin_decoder = PluginResourceTracker::GetInstance()-> PluginResourceForHostResource(decoder); - ppp_video_decoder_target()->PictureReady( + ppp_video_decoder_impl_->PictureReady( decoder.instance(), plugin_decoder, picture); } @@ -153,7 +156,7 @@ void PPP_VideoDecoder_Proxy::OnMsgNotifyEndOfStream( const HostResource& decoder) { PP_Resource plugin_decoder = PluginResourceTracker::GetInstance()-> PluginResourceForHostResource(decoder); - ppp_video_decoder_target()->EndOfStream(decoder.instance(), + ppp_video_decoder_impl_->EndOfStream(decoder.instance(), plugin_decoder); } @@ -161,7 +164,7 @@ void PPP_VideoDecoder_Proxy::OnMsgNotifyError( const HostResource& decoder, PP_VideoDecodeError_Dev error) { PP_Resource plugin_decoder = PluginResourceTracker::GetInstance()-> PluginResourceForHostResource(decoder); - ppp_video_decoder_target()->NotifyError( + ppp_video_decoder_impl_->NotifyError( decoder.instance(), plugin_decoder, error); } diff --git a/ppapi/proxy/ppp_video_decoder_proxy.h b/ppapi/proxy/ppp_video_decoder_proxy.h index 84346ba..e12c668 100644 --- a/ppapi/proxy/ppp_video_decoder_proxy.h +++ b/ppapi/proxy/ppp_video_decoder_proxy.h @@ -18,15 +18,11 @@ namespace proxy { class PPP_VideoDecoder_Proxy : public InterfaceProxy { public: - PPP_VideoDecoder_Proxy(Dispatcher* dispatcher, const void* target_interface); + PPP_VideoDecoder_Proxy(Dispatcher* dispatcher); virtual ~PPP_VideoDecoder_Proxy(); static const Info* GetInfo(); - const PPP_VideoDecoder_Dev* ppp_video_decoder_target() const { - return static_cast<const PPP_VideoDecoder_Dev*>(target_interface()); - } - // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); @@ -43,6 +39,11 @@ class PPP_VideoDecoder_Proxy : public InterfaceProxy { void OnMsgNotifyError(const ppapi::HostResource& decoder, PP_VideoDecodeError_Dev error); + // When this proxy is in the plugin side, this value caches the interface + // pointer so we don't have to retrieve it from the dispatcher each time. + // In the host, this value is always NULL. + const PPP_VideoDecoder_Dev* ppp_video_decoder_impl_; + DISALLOW_COPY_AND_ASSIGN(PPP_VideoDecoder_Proxy); }; diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc index 0a0c791..f3ee425 100644 --- a/ppapi/proxy/resource_creation_proxy.cc +++ b/ppapi/proxy/resource_creation_proxy.cc @@ -45,12 +45,17 @@ namespace ppapi { namespace proxy { ResourceCreationProxy::ResourceCreationProxy(Dispatcher* dispatcher) - : dispatcher_(dispatcher) { + : InterfaceProxy(dispatcher) { } ResourceCreationProxy::~ResourceCreationProxy() { } +// static +InterfaceProxy* ResourceCreationProxy::Create(Dispatcher* dispatcher) { + return new ResourceCreationProxy(dispatcher); +} + ResourceCreationAPI* ResourceCreationProxy::AsResourceCreationAPI() { return this; } @@ -337,7 +342,7 @@ PP_Resource ResourceCreationProxy::CreateWheelInputEvent( } bool ResourceCreationProxy::Send(IPC::Message* msg) { - return dispatcher_->Send(msg); + return dispatcher()->Send(msg); } bool ResourceCreationProxy::OnMessageReceived(const IPC::Message& msg) { @@ -395,14 +400,14 @@ void ResourceCreationProxy::OnMsgCreateImageData( // Get the shared memory handle. const PPB_ImageDataTrusted* trusted = reinterpret_cast<const PPB_ImageDataTrusted*>( - dispatcher_->GetLocalInterface(PPB_IMAGEDATA_TRUSTED_INTERFACE)); + dispatcher()->local_get_interface()(PPB_IMAGEDATA_TRUSTED_INTERFACE)); uint32_t byte_count = 0; if (trusted) { int32_t handle; if (trusted->GetSharedMemory(resource, &handle, &byte_count) == PP_OK) { #if defined(OS_WIN) ImageHandle ih = ImageData::HandleFromInt(handle); - *result_image_handle = dispatcher_->ShareHandleWithRemote(ih, false); + *result_image_handle = dispatcher()->ShareHandleWithRemote(ih, false); #else *result_image_handle = ImageData::HandleFromInt(handle); #endif diff --git a/ppapi/proxy/resource_creation_proxy.h b/ppapi/proxy/resource_creation_proxy.h index 0f1589b..1db9164 100644 --- a/ppapi/proxy/resource_creation_proxy.h +++ b/ppapi/proxy/resource_creation_proxy.h @@ -11,8 +11,8 @@ #include "ipc/ipc_channel.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" +#include "ppapi/proxy/interface_proxy.h" #include "ppapi/proxy/serialized_structs.h" -#include "ppapi/shared_impl/function_group_base.h" #include "ppapi/thunk/resource_creation_api.h" struct PP_Size; @@ -25,14 +25,16 @@ namespace proxy { class Dispatcher; -class ResourceCreationProxy : public FunctionGroupBase, - public thunk::ResourceCreationAPI, - public IPC::Channel::Listener, - public IPC::Message::Sender { +class ResourceCreationProxy : public InterfaceProxy, + public thunk::ResourceCreationAPI { public: explicit ResourceCreationProxy(Dispatcher* dispatcher); virtual ~ResourceCreationProxy(); + // Factory function used for registration (normal code can just use the + // constructor). + static InterfaceProxy* Create(Dispatcher* dispatcher); + virtual thunk::ResourceCreationAPI* AsResourceCreationAPI() OVERRIDE; // ResourceCreationAPI (called in plugin). @@ -149,8 +151,6 @@ class ResourceCreationProxy : public FunctionGroupBase, std::string* image_data_desc, ImageHandle* result_image_handle); - Dispatcher* dispatcher_; - DISALLOW_COPY_AND_ASSIGN(ResourceCreationProxy); }; diff --git a/ppapi/thunk/enter.cc b/ppapi/thunk/enter.cc new file mode 100644 index 0000000..da3f85c --- /dev/null +++ b/ppapi/thunk/enter.cc @@ -0,0 +1,28 @@ +// Copyright (c) 2011 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. + +#include "ppapi/thunk/enter.h" + +#include "ppapi/thunk/ppb_instance_api.h" +#include "ppapi/thunk/resource_creation_api.h" + +namespace ppapi { +namespace thunk { + +EnterResourceCreation::EnterResourceCreation(PP_Instance instance) + : EnterFunctionNoLock<ResourceCreationAPI>(instance, true) { +} + +EnterResourceCreation::~EnterResourceCreation() { +} + +EnterInstance::EnterInstance(PP_Instance instance) + : EnterFunctionNoLock<PPB_Instance_FunctionAPI>(instance, true) { +} + +EnterInstance::~EnterInstance() { +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/enter.h b/ppapi/thunk/enter.h index e83a1a1..45cee70 100644 --- a/ppapi/thunk/enter.h +++ b/ppapi/thunk/enter.h @@ -12,6 +12,7 @@ #include "ppapi/shared_impl/resource.h" #include "ppapi/shared_impl/tracker_base.h" #include "ppapi/shared_impl/resource_tracker.h" +#include "ppapi/thunk/ppapi_thunk_export.h" namespace ppapi { namespace thunk { @@ -128,6 +129,26 @@ class EnterResourceNoLock : public EnterResource<ResourceT> { } }; +// Simpler wrapper to enter the resource creation API. This is used for every +// class so we have this helper function to save template instantiations and +// typing. +class PPAPI_THUNK_EXPORT EnterResourceCreation + : public EnterFunctionNoLock<ResourceCreationAPI> { + public: + EnterResourceCreation(PP_Instance instance); + ~EnterResourceCreation(); +}; + +// Simpler wrapper to enter the instance API from proxy code. This is used for +// many interfaces so we have this helper function to save template +// instantiations and typing. +class PPAPI_THUNK_EXPORT EnterInstance + : public EnterFunctionNoLock<PPB_Instance_FunctionAPI> { + public: + EnterInstance(PP_Instance instance); + ~EnterInstance(); +}; + } // namespace thunk } // namespace ppapi diff --git a/ppapi/thunk/interfaces_postamble.h b/ppapi/thunk/interfaces_postamble.h new file mode 100644 index 0000000..cebfe74 --- /dev/null +++ b/ppapi/thunk/interfaces_postamble.h @@ -0,0 +1,25 @@ +// Copyright (c) 2011 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. + +// Cleans up after interfaces_preamble.h, see that file for more. + +#ifdef UNDEFINE_PROXIED_API +#undef UNDEFINE_PROXIED_API +#undef PROXIED_API +#endif + +#ifdef UNDEFINE_UNPROXIED_API +#undef UNDEFINE_UNPROXIED_API +#undef UNPROXIED_API +#endif + +#ifdef UNDEFINE_PROXIED_IFACE +#undef UNDEFINE_PROXIED_IFACE +#undef PROXIED_IFACE +#endif + +#ifdef UNDEFINE_UNPROXIED_IFACE +#undef UNDEFINE_UNPROXIED_IFACE +#undef UNPROXIED_IFACE +#endif diff --git a/ppapi/thunk/interfaces_ppb_private.h b/ppapi/thunk/interfaces_ppb_private.h new file mode 100644 index 0000000..19e9065 --- /dev/null +++ b/ppapi/thunk/interfaces_ppb_private.h @@ -0,0 +1,14 @@ +// Copyright (c) 2011 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. + +// Please see inteface_ppb_public_stable for the documentation on the format of +// this file. + +#include "ppapi/thunk/interfaces_preamble.h" + +PROXIED_API(PPB_Broker) + +PROXIED_IFACE(PPB_Broker, PPB_BROKER_TRUSTED_INTERFACE_0_2, PPB_Broker) + +#include "ppapi/thunk/interfaces_postamble.h" diff --git a/ppapi/thunk/interfaces_ppb_public_dev.h b/ppapi/thunk/interfaces_ppb_public_dev.h new file mode 100644 index 0000000..3e202a5 --- /dev/null +++ b/ppapi/thunk/interfaces_ppb_public_dev.h @@ -0,0 +1,42 @@ +// Copyright (c) 2011 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. + +// Please see inteface_ppb_public_stable for the documentation on the format of +// this file. + +#include "ppapi/thunk/interfaces_preamble.h" + +PROXIED_API(PPB_Buffer) +PROXIED_API(PPB_CharSet) +PROXIED_API(PPB_Context3D) +PROXIED_API(PPB_CursorControl) +PROXIED_API(PPB_FileChooser) +PROXIED_API(PPB_Font) +PROXIED_API(PPB_Graphics3D) +PROXIED_API(PPB_Surface3D) +PROXIED_API(PPB_VideoCapture) +PROXIED_API(PPB_VideoDecoder) + +PROXIED_IFACE(PPB_Buffer, PPB_BUFFER_DEV_INTERFACE_0_4, PPB_Buffer_Dev) +PROXIED_IFACE(PPB_CharSet, PPB_CHAR_SET_DEV_INTERFACE_0_4, PPB_CharSet_Dev) +PROXIED_IFACE(PPB_Context3D, PPB_CONTEXT_3D_DEV_INTERFACE_0_1, + PPB_Context3D_Dev) +PROXIED_IFACE(PPB_Context3D, PPB_GLES_CHROMIUM_TEXTURE_MAPPING_DEV_INTERFACE, + PPB_GLESChromiumTextureMapping_Dev) +PROXIED_IFACE(PPB_CursorControl, PPB_CURSOR_CONTROL_DEV_INTERFACE_0_4, + PPB_CursorControl_Dev) +PROXIED_IFACE(PPB_FileChooser, PPB_FILECHOOSER_DEV_INTERFACE_0_5, + PPB_FileChooser_Dev) +PROXIED_IFACE(PPB_Font, PPB_FONT_DEV_INTERFACE_0_6, PPB_Font_Dev) +PROXIED_IFACE(PPB_Instance, PPB_CONSOLE_DEV_INTERFACE, PPB_Console_Dev) +PROXIED_IFACE(PPB_Instance, PPB_MOUSELOCK_DEV_INTERFACE_0_1, + PPB_MouseLock_Dev) +PROXIED_IFACE(PPB_Surface3D, PPB_SURFACE_3D_DEV_INTERFACE_0_2, + PPB_Surface3D_Dev) +PROXIED_IFACE(PPB_VideoCapture, PPB_VIDEO_CAPTURE_DEV_INTERFACE_0_1, + PPB_VideoCapture_Dev) +PROXIED_IFACE(PPB_VideoDecoder, PPB_VIDEODECODER_DEV_INTERFACE_0_16, + PPB_VideoDecoder_Dev) + +#include "ppapi/thunk/interfaces_postamble.h" diff --git a/ppapi/thunk/interfaces_ppb_public_stable.h b/ppapi/thunk/interfaces_ppb_public_stable.h new file mode 100644 index 0000000..579ce15 --- /dev/null +++ b/ppapi/thunk/interfaces_ppb_public_stable.h @@ -0,0 +1,78 @@ +// Copyright (c) 2011 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. + +#include "ppapi/thunk/interfaces_preamble.h" + +// This file contains lists of interfaces. It's intended to be included by +// another file which defines implementations of the macros. This allows files +// to do specific registration tasks for each supported interface. + + +// Api categories +// -------------- +// Enumerates the categories of APIs. These correspnd to the *_api.h files in +// this directory. One API may implement one or more actual interfaces. +// +// For PROXIED_APIs, these also correspond to *_Proxy objects. The proxied ones +// define factory functions for each of these classes. UNPROXIED_APIs are ones +// that exist in the webkit/plugins/ppapi/*_impl.h, but not in the proxy. +PROXIED_API(PPB_Audio) +// AudioConfig isn't proxied in the normal way, we have only local classes and +// serialize it to a struct when we need it on the host side. +UNPROXIED_API(PPB_AudioConfig) +PROXIED_API(PPB_Core) +UNPROXIED_API(PPB_FileIO) +PROXIED_API(PPB_FileRef) +PROXIED_API(PPB_FileSystem) +PROXIED_API(PPB_Graphics2D) +UNPROXIED_API(PPB_ImageData) +PROXIED_API(PPB_Instance) +PROXIED_API(PPB_URLLoader) +PROXIED_API(PPB_URLResponseInfo) + +// Interfaces +// ---------- +// Enumerates interfaces as (api_name, interface_name, interface_struct). +// +// The api_name corresponds to the class in the list above for the object +// that implements the API. Some things may be special and aren't implemented +// by any specific API object, and we use "NoAPIName" for those. Implementors +// of these macros should handle this case. There can be more than one line +// referring to the same api_name (typically different versions of the +// same interface). +// +// The interface_name is the string that corresponds to the interface. +// +// The interface_struct is the typename of the struct corresponding to the +// interface string. +PROXIED_IFACE(PPB_Audio, PPB_AUDIO_INTERFACE_1_0, PPB_Audio) +// This has no corresponding _Proxy object since it does no IPC. +PROXIED_IFACE(NoAPIName, PPB_AUDIO_CONFIG_INTERFACE_1_0, PPB_AudioConfig) +// Note: Core is special and is registered manually. +UNPROXIED_IFACE(PPB_FileIO, PPB_FILEIO_INTERFACE_1_0, PPB_FileIO) +PROXIED_IFACE(PPB_FileRef, PPB_FILEREF_INTERFACE_1_0, PPB_FileRef) +PROXIED_IFACE(PPB_FileSystem, PPB_FILESYSTEM_INTERFACE_1_0, PPB_FileSystem) +PROXIED_IFACE(PPB_Graphics2D, PPB_GRAPHICS_2D_INTERFACE_1_0, PPB_Graphics2D) +PROXIED_IFACE(PPB_Graphics3D, PPB_GRAPHICS_3D_INTERFACE_1_0, PPB_Graphics3D) +// ImageData doesn't have a normal _Proxy object since it only uses Create +// to proxy, and that happens in the ResourceCreationAPI. +PROXIED_IFACE(NoAPIName, PPB_IMAGEDATA_INTERFACE_1_0, PPB_ImageData) +PROXIED_IFACE(PPB_Instance, PPB_INSTANCE_INTERFACE_1_0, PPB_Instance) +PROXIED_IFACE(NoAPIName, PPB_INPUT_EVENT_INTERFACE_1_0, PPB_InputEvent) +PROXIED_IFACE(NoAPIName, PPB_KEYBOARD_INPUT_EVENT_INTERFACE_1_0, + PPB_KeyboardInputEvent) +PROXIED_IFACE(NoAPIName, PPB_MOUSE_INPUT_EVENT_INTERFACE_1_0, + PPB_MouseInputEvent_1_0) +PROXIED_IFACE(NoAPIName, PPB_MOUSE_INPUT_EVENT_INTERFACE_1_1, + PPB_MouseInputEvent) +PROXIED_IFACE(NoAPIName, PPB_WHEEL_INPUT_EVENT_INTERFACE_1_0, + PPB_WheelInputEvent) +PROXIED_IFACE(PPB_Instance, PPB_MESSAGING_INTERFACE_1_0, PPB_Messaging) +PROXIED_IFACE(PPB_URLLoader, PPB_URLLOADER_INTERFACE_1_0, PPB_URLLoader) +PROXIED_IFACE(NoAPIName, PPB_URLREQUESTINFO_INTERFACE_1_0, PPB_URLRequestInfo) +PROXIED_IFACE(PPB_URLResponseInfo, PPB_URLRESPONSEINFO_INTERFACE_1_0, + PPB_URLResponseInfo) +// Note: PPB_Var is special and registered manually. + +#include "ppapi/thunk/interfaces_postamble.h" diff --git a/ppapi/thunk/interfaces_preamble.h b/ppapi/thunk/interfaces_preamble.h new file mode 100644 index 0000000..7fe1d77 --- /dev/null +++ b/ppapi/thunk/interfaces_preamble.h @@ -0,0 +1,31 @@ +// Copyright (c) 2011 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. + +// This file defines empty versions of the macros used in the interfaces_*.h +// files, as long as they aren't already defined. This allows users of those +// files to only implement the macros they need, and everything else will +// compile. +// +// Include this file at the top, and interfaces_postamble.h at the bottom. The +// postamble will clean up these definitions. + +#ifndef PROXIED_API +#define PROXIED_API(api_name) +#define UNDEFINE_PROXIED_API +#endif + +#ifndef UNPROXIED_API +#define UNPROXIED_API(api_name) +#define UNDEFINE_UNPROXIED_API +#endif + +#ifndef PROXIED_IFACE +#define PROXIED_IFACE(api_name, iface_str, iface_struct) +#define UNDEFINE_PROXIED_IFACE +#endif + +#ifndef UNPROXIED_IFACE +#define UNPROXIED_IFACE(api_name, iface_str, iface_struct) +#define UNDEFINE_UNPROXIED_IFACE +#endif diff --git a/ppapi/thunk/ppb_buffer_thunk.cc b/ppapi/thunk/ppb_buffer_thunk.cc index cf4952c..1772048 100644 --- a/ppapi/thunk/ppb_buffer_thunk.cc +++ b/ppapi/thunk/ppb_buffer_thunk.cc @@ -57,7 +57,7 @@ const PPB_Buffer_Dev g_ppb_buffer_thunk = { } // namespace -const PPB_Buffer_Dev* GetPPB_Buffer_Thunk() { +const PPB_Buffer_Dev* GetPPB_Buffer_Dev_Thunk() { return &g_ppb_buffer_thunk; } diff --git a/ppapi/thunk/ppb_char_set_thunk.cc b/ppapi/thunk/ppb_char_set_thunk.cc index bc36bad..1b02038 100644 --- a/ppapi/thunk/ppb_char_set_thunk.cc +++ b/ppapi/thunk/ppb_char_set_thunk.cc @@ -54,7 +54,7 @@ const PPB_CharSet_Dev g_ppb_char_set_thunk = { } // namespace -const PPB_CharSet_Dev* GetPPB_CharSet_Thunk() { +const PPB_CharSet_Dev* GetPPB_CharSet_Dev_Thunk() { return &g_ppb_char_set_thunk; } diff --git a/ppapi/thunk/ppb_console_thunk.cc b/ppapi/thunk/ppb_console_thunk.cc new file mode 100644 index 0000000..509c128 --- /dev/null +++ b/ppapi/thunk/ppb_console_thunk.cc @@ -0,0 +1,42 @@ +// Copyright (c) 2011 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. + +#include "ppapi/c/dev/ppb_console_dev.h" +#include "ppapi/thunk/thunk.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_instance_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +void Log(PP_Instance instance, PP_LogLevel_Dev level, struct PP_Var value) { + EnterInstance enter(instance); + if (enter.succeeded()) + return enter.functions()->Log(instance, level, value); +} + +void LogWithSource(PP_Instance instance, + PP_LogLevel_Dev level, + PP_Var source, + PP_Var value) { + EnterInstance enter(instance); + if (enter.succeeded()) + return enter.functions()->LogWithSource(instance, level, source, value); +} + +const PPB_Console_Dev g_ppb_console_thunk = { + &Log, + &LogWithSource +}; + +} // namespace + +const PPB_Console_Dev* GetPPB_Console_Dev_Thunk() { + return &g_ppb_console_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/ppb_context_3d_thunk.cc b/ppapi/thunk/ppb_context_3d_thunk.cc index cbb035a..200e044 100644 --- a/ppapi/thunk/ppb_context_3d_thunk.cc +++ b/ppapi/thunk/ppb_context_3d_thunk.cc @@ -64,7 +64,7 @@ const PPB_Context3D_Dev g_ppb_context_3d_thunk = { } // namespace -const PPB_Context3D_Dev* GetPPB_Context3D_Thunk() { +const PPB_Context3D_Dev* GetPPB_Context3D_Dev_Thunk() { return &g_ppb_context_3d_thunk; } diff --git a/ppapi/thunk/ppb_cursor_control_thunk.cc b/ppapi/thunk/ppb_cursor_control_thunk.cc index 56ba078..b1f5409 100644 --- a/ppapi/thunk/ppb_cursor_control_thunk.cc +++ b/ppapi/thunk/ppb_cursor_control_thunk.cc @@ -59,7 +59,7 @@ const PPB_CursorControl_Dev g_ppb_cursor_control_thunk = { } // namespace -const PPB_CursorControl_Dev* GetPPB_CursorControl_Thunk() { +const PPB_CursorControl_Dev* GetPPB_CursorControl_Dev_Thunk() { return &g_ppb_cursor_control_thunk; } diff --git a/ppapi/thunk/ppb_directory_reader_thunk.cc b/ppapi/thunk/ppb_directory_reader_thunk.cc index c631194..f8e95537 100644 --- a/ppapi/thunk/ppb_directory_reader_thunk.cc +++ b/ppapi/thunk/ppb_directory_reader_thunk.cc @@ -46,7 +46,7 @@ const PPB_DirectoryReader_Dev g_ppb_directory_reader_thunk = { } // namespace -const PPB_DirectoryReader_Dev* GetPPB_DirectoryReader_Thunk() { +const PPB_DirectoryReader_Dev* GetPPB_DirectoryReader_Dev_Thunk() { return &g_ppb_directory_reader_thunk; } diff --git a/ppapi/thunk/ppb_file_chooser_thunk.cc b/ppapi/thunk/ppb_file_chooser_thunk.cc index c58f052..774ef03 100644 --- a/ppapi/thunk/ppb_file_chooser_thunk.cc +++ b/ppapi/thunk/ppb_file_chooser_thunk.cc @@ -55,7 +55,7 @@ const PPB_FileChooser_Dev g_ppb_file_chooser_thunk = { } // namespace -const PPB_FileChooser_Dev* GetPPB_FileChooser_Thunk() { +const PPB_FileChooser_Dev* GetPPB_FileChooser_Dev_Thunk() { return &g_ppb_file_chooser_thunk; } diff --git a/ppapi/thunk/ppb_font_thunk.cc b/ppapi/thunk/ppb_font_thunk.cc index ae13e01..841170a 100644 --- a/ppapi/thunk/ppb_font_thunk.cc +++ b/ppapi/thunk/ppb_font_thunk.cc @@ -93,7 +93,7 @@ const PPB_Font_Dev g_ppb_font_thunk = { } // namespace -const PPB_Font_Dev* GetPPB_Font_Thunk() { +const PPB_Font_Dev* GetPPB_Font_Dev_Thunk() { return &g_ppb_font_thunk; } diff --git a/ppapi/thunk/ppb_gles_chromium_texture_mapping_thunk.cc b/ppapi/thunk/ppb_gles_chromium_texture_mapping_thunk.cc index 6e8e7c5..085578a 100644 --- a/ppapi/thunk/ppb_gles_chromium_texture_mapping_thunk.cc +++ b/ppapi/thunk/ppb_gles_chromium_texture_mapping_thunk.cc @@ -69,7 +69,7 @@ g_ppb_gles_chromium_texture_mapping_thunk = { } // namespace const PPB_GLESChromiumTextureMapping_Dev* -GetPPB_GLESChromiumTextureMapping_Thunk() { +GetPPB_GLESChromiumTextureMapping_Dev_Thunk() { return &g_ppb_gles_chromium_texture_mapping_thunk; } diff --git a/ppapi/thunk/ppb_input_event_thunk.cc b/ppapi/thunk/ppb_input_event_thunk.cc index bd28495..6028c6e 100644 --- a/ppapi/thunk/ppb_input_event_thunk.cc +++ b/ppapi/thunk/ppb_input_event_thunk.cc @@ -281,7 +281,7 @@ const PPB_MouseInputEvent_1_0* GetPPB_MouseInputEvent_1_0_Thunk() { return &g_ppb_mouse_input_event_1_0_thunk; } -const PPB_MouseInputEvent* GetPPB_MouseInputEvent_1_1_Thunk() { +const PPB_MouseInputEvent* GetPPB_MouseInputEvent_Thunk() { return &g_ppb_mouse_input_event_1_1_thunk; } diff --git a/ppapi/thunk/ppb_instance_api.h b/ppapi/thunk/ppb_instance_api.h index e9cacef..9a5628b 100644 --- a/ppapi/thunk/ppb_instance_api.h +++ b/ppapi/thunk/ppb_instance_api.h @@ -29,6 +29,15 @@ class PPB_Instance_FunctionAPI { PP_Var script, PP_Var* exception) = 0; + // Console. + virtual void Log(PP_Instance instance, + int log_level, + PP_Var value) = 0; + virtual void LogWithSource(PP_Instance instance, + int log_level, + PP_Var source, + PP_Var value) = 0; + // Fullscreen. virtual PP_Bool IsFullscreen(PP_Instance instance) = 0; virtual PP_Bool SetFullscreen(PP_Instance instance, PP_Bool fullscreen) = 0; diff --git a/ppapi/thunk/ppb_instance_thunk.cc b/ppapi/thunk/ppb_instance_thunk.cc index a05f030..9cc9bd5 100644 --- a/ppapi/thunk/ppb_instance_thunk.cc +++ b/ppapi/thunk/ppb_instance_thunk.cc @@ -49,7 +49,7 @@ PP_Var ExecuteScript(PP_Instance instance, return enter.functions()->ExecuteScript(instance, script, exception); } -const PPB_Instance_1_0 g_ppb_instance_1_0_thunk = { +const PPB_Instance g_ppb_instance_thunk = { &BindGraphics, &IsFullFrame }; @@ -62,8 +62,8 @@ const PPB_Instance_Private g_ppb_instance_private_thunk = { } // namespace -const PPB_Instance_1_0* GetPPB_Instance_1_0_Thunk() { - return &g_ppb_instance_1_0_thunk; +const PPB_Instance* GetPPB_Instance_Thunk() { + return &g_ppb_instance_thunk; } const PPB_Instance_Private* GetPPB_Instance_Private_Thunk() { return &g_ppb_instance_private_thunk; diff --git a/ppapi/thunk/ppb_mouse_lock_thunk.cc b/ppapi/thunk/ppb_mouse_lock_thunk.cc index d9116b0..3f1d6d3 100644 --- a/ppapi/thunk/ppb_mouse_lock_thunk.cc +++ b/ppapi/thunk/ppb_mouse_lock_thunk.cc @@ -36,7 +36,7 @@ const PPB_MouseLock_Dev g_ppb_mouse_lock_thunk = { } // namespace -const PPB_MouseLock_Dev* GetPPB_MouseLock_Thunk() { +const PPB_MouseLock_Dev* GetPPB_MouseLock_Dev_Thunk() { return &g_ppb_mouse_lock_thunk; } diff --git a/ppapi/thunk/ppb_surface_3d_thunk.cc b/ppapi/thunk/ppb_surface_3d_thunk.cc index e7034cb..ba1df6f 100644 --- a/ppapi/thunk/ppb_surface_3d_thunk.cc +++ b/ppapi/thunk/ppb_surface_3d_thunk.cc @@ -63,7 +63,7 @@ const PPB_Surface3D_Dev g_ppb_surface_3d_thunk = { } // namespace -const PPB_Surface3D_Dev* GetPPB_Surface3D_Thunk() { +const PPB_Surface3D_Dev* GetPPB_Surface3D_Dev_Thunk() { return &g_ppb_surface_3d_thunk; } diff --git a/ppapi/thunk/ppb_transport_thunk.cc b/ppapi/thunk/ppb_transport_thunk.cc index b245514..17c572e 100644 --- a/ppapi/thunk/ppb_transport_thunk.cc +++ b/ppapi/thunk/ppb_transport_thunk.cc @@ -108,7 +108,7 @@ const PPB_Transport_Dev g_ppb_transport_thunk = { } // namespace -const PPB_Transport_Dev* GetPPB_Transport_Thunk() { +const PPB_Transport_Dev* GetPPB_Transport_Dev_Thunk() { return &g_ppb_transport_thunk; } diff --git a/ppapi/thunk/ppb_video_capture_thunk.cc b/ppapi/thunk/ppb_video_capture_thunk.cc index c320cb5..f8704d0 100644 --- a/ppapi/thunk/ppb_video_capture_thunk.cc +++ b/ppapi/thunk/ppb_video_capture_thunk.cc @@ -65,7 +65,7 @@ const PPB_VideoCapture_Dev g_ppb_videocapture_thunk = { } // namespace -const PPB_VideoCapture_Dev* GetPPB_VideoCapture_Thunk() { +const PPB_VideoCapture_Dev* GetPPB_VideoCapture_Dev_Thunk() { return &g_ppb_videocapture_thunk; } diff --git a/ppapi/thunk/ppb_video_decoder_thunk.cc b/ppapi/thunk/ppb_video_decoder_thunk.cc index b7a72d9..40b837b 100644 --- a/ppapi/thunk/ppb_video_decoder_thunk.cc +++ b/ppapi/thunk/ppb_video_decoder_thunk.cc @@ -90,7 +90,7 @@ const PPB_VideoDecoder_Dev g_ppb_videodecoder_thunk = { } // namespace -const PPB_VideoDecoder_Dev* GetPPB_VideoDecoder_Thunk() { +const PPB_VideoDecoder_Dev* GetPPB_VideoDecoder_Dev_Thunk() { return &g_ppb_videodecoder_thunk; } diff --git a/ppapi/thunk/ppb_video_layer_thunk.cc b/ppapi/thunk/ppb_video_layer_thunk.cc index 4a1a258..ea31b9f 100644 --- a/ppapi/thunk/ppb_video_layer_thunk.cc +++ b/ppapi/thunk/ppb_video_layer_thunk.cc @@ -73,7 +73,7 @@ const PPB_VideoLayer_Dev g_ppb_videolayer_thunk = { } // namespace -const PPB_VideoLayer_Dev* GetPPB_VideoLayer_Thunk() { +const PPB_VideoLayer_Dev* GetPPB_VideoLayer_Dev_Thunk() { return &g_ppb_videolayer_thunk; } diff --git a/ppapi/thunk/ppb_widget_thunk.cc b/ppapi/thunk/ppb_widget_thunk.cc index 374296b..ec77352 100644 --- a/ppapi/thunk/ppb_widget_thunk.cc +++ b/ppapi/thunk/ppb_widget_thunk.cc @@ -54,7 +54,7 @@ const PPB_Widget_Dev g_ppb_widget_thunk = { } // namespace -const PPB_Widget_Dev* GetPPB_Widget_Thunk() { +const PPB_Widget_Dev* GetPPB_Widget_Dev_Thunk() { return &g_ppb_widget_thunk; } diff --git a/ppapi/thunk/thunk.h b/ppapi/thunk/thunk.h index 94c31a7..47d3660 100644 --- a/ppapi/thunk/thunk.h +++ b/ppapi/thunk/thunk.h @@ -7,55 +7,56 @@ #include "ppapi/thunk/ppapi_thunk_export.h" -struct PPB_Audio; -struct PPB_AudioConfig; +// Declares a getter for the interface thunk of the form: +// +// const PPB_Foo* ppapi::thunk::GetPPB_Foo_Thunk(); +// +#define IFACE(api_name, interface_name, InterfaceType) \ + struct InterfaceType; \ + namespace ppapi { namespace thunk { \ + PPAPI_THUNK_EXPORT const InterfaceType* Get##InterfaceType##_Thunk(); \ + } } +#define PROXIED_IFACE IFACE +#define UNPROXIED_IFACE IFACE + +#include "ppapi/thunk/interfaces_ppb_public_stable.h" +#include "ppapi/thunk/interfaces_ppb_public_dev.h" + +#undef UNPROXIED_IFACE +#undef PROXIED_IFACE +#undef IFACE + struct PPB_AudioTrusted; struct PPB_BrokerTrusted; struct PPB_Buffer_Dev; struct PPB_BufferTrusted; struct PPB_CharSet_Dev; -struct PPB_Context3D_Dev; +struct PPB_Console_Dev; struct PPB_Context3DTrusted_Dev; struct PPB_CursorControl_Dev; struct PPB_DirectoryReader_Dev; struct PPB_FileChooser_Dev; -struct PPB_FileIO; struct PPB_FileIOTrusted; -struct PPB_FileRef; -struct PPB_FileSystem; struct PPB_Find_Dev; struct PPB_Flash_Menu; struct PPB_Flash_NetConnector; struct PPB_Flash_TCPSocket; struct PPB_Font_Dev; struct PPB_Fullscreen_Dev; -struct PPB_GLESChromiumTextureMapping_Dev; -struct PPB_Graphics2D; struct PPB_Graphics3D; struct PPB_Graphics3DTrusted; struct PPB_ImageData; struct PPB_ImageDataTrusted; -struct PPB_InputEvent; -struct PPB_Instance; struct PPB_Instance_Private; -struct PPB_KeyboardInputEvent; struct PPB_LayerCompositor_Dev; -struct PPB_Messaging; -struct PPB_MouseInputEvent_1_0; -struct PPB_MouseInputEvent; -struct PPB_MouseLock_Dev; struct PPB_QueryPolicy_Dev; struct PPB_Scrollbar_0_5_Dev; struct PPB_Surface3D_Dev; struct PPB_Transport_Dev; -struct PPB_URLLoader; struct PPB_URLLoaderTrusted; -struct PPB_URLRequestInfo; -struct PPB_URLResponseInfo; struct PPB_VideoCapture_Dev; struct PPB_VideoDecoder_Dev; struct PPB_VideoLayer_Dev; -struct PPB_WheelInputEvent; struct PPB_Widget_Dev; struct PPB_Zoom_Dev; @@ -64,65 +65,34 @@ typedef PPB_Instance PPB_Instance_1_0; namespace ppapi { namespace thunk { -PPAPI_THUNK_EXPORT const PPB_Audio* GetPPB_Audio_Thunk(); -PPAPI_THUNK_EXPORT const PPB_AudioConfig* GetPPB_AudioConfig_Thunk(); PPAPI_THUNK_EXPORT const PPB_AudioTrusted* GetPPB_AudioTrusted_Thunk(); PPAPI_THUNK_EXPORT const PPB_BrokerTrusted* GetPPB_Broker_Thunk(); -PPAPI_THUNK_EXPORT const PPB_Buffer_Dev* GetPPB_Buffer_Thunk(); PPAPI_THUNK_EXPORT const PPB_BufferTrusted* GetPPB_BufferTrusted_Thunk(); -PPAPI_THUNK_EXPORT const PPB_CharSet_Dev* GetPPB_CharSet_Thunk(); -PPAPI_THUNK_EXPORT const PPB_Context3D_Dev* GetPPB_Context3D_Thunk(); +PPAPI_THUNK_EXPORT const PPB_Console_Dev* GetPPB_Console_Dev_Thunk(); PPAPI_THUNK_EXPORT const PPB_Context3DTrusted_Dev* GetPPB_Context3DTrusted_Thunk(); PPAPI_THUNK_EXPORT const PPB_CursorControl_Dev* GetPPB_CursorControl_Thunk(); PPAPI_THUNK_EXPORT const PPB_DirectoryReader_Dev* - GetPPB_DirectoryReader_Thunk(); -PPAPI_THUNK_EXPORT const PPB_FileChooser_Dev* GetPPB_FileChooser_Thunk(); -PPAPI_THUNK_EXPORT const PPB_FileIO* GetPPB_FileIO_Thunk(); + GetPPB_DirectoryReader_Dev_Thunk(); PPAPI_THUNK_EXPORT const PPB_FileIOTrusted* GetPPB_FileIOTrusted_Thunk(); -PPAPI_THUNK_EXPORT const PPB_FileRef* GetPPB_FileRef_Thunk(); -PPAPI_THUNK_EXPORT const PPB_FileSystem* GetPPB_FileSystem_Thunk(); PPAPI_THUNK_EXPORT const PPB_Find_Dev* GetPPB_Find_Thunk(); PPAPI_THUNK_EXPORT const PPB_Flash_Menu* GetPPB_Flash_Menu_Thunk(); PPAPI_THUNK_EXPORT const PPB_Flash_NetConnector* GetPPB_Flash_NetConnector_Thunk(); PPAPI_THUNK_EXPORT const PPB_Flash_TCPSocket* GetPPB_Flash_TCPSocket_Thunk(); -PPAPI_THUNK_EXPORT const PPB_Font_Dev* GetPPB_Font_Thunk(); PPAPI_THUNK_EXPORT const PPB_Fullscreen_Dev* GetPPB_Fullscreen_Thunk(); -PPAPI_THUNK_EXPORT const PPB_GLESChromiumTextureMapping_Dev* - GetPPB_GLESChromiumTextureMapping_Thunk(); -PPAPI_THUNK_EXPORT const PPB_Graphics2D* GetPPB_Graphics2D_Thunk(); -PPAPI_THUNK_EXPORT const PPB_Graphics3D* GetPPB_Graphics3D_Thunk(); PPAPI_THUNK_EXPORT const PPB_Graphics3DTrusted* GetPPB_Graphics3DTrusted_Thunk(); -PPAPI_THUNK_EXPORT const PPB_InputEvent* GetPPB_InputEvent_Thunk(); -PPAPI_THUNK_EXPORT const PPB_ImageData* GetPPB_ImageData_Thunk(); PPAPI_THUNK_EXPORT const PPB_ImageDataTrusted* GetPPB_ImageDataTrusted_Thunk(); -PPAPI_THUNK_EXPORT const PPB_Instance_1_0* GetPPB_Instance_1_0_Thunk(); PPAPI_THUNK_EXPORT const PPB_Instance_Private* GetPPB_Instance_Private_Thunk(); -PPAPI_THUNK_EXPORT const PPB_KeyboardInputEvent* - GetPPB_KeyboardInputEvent_Thunk(); PPAPI_THUNK_EXPORT const PPB_LayerCompositor_Dev* GetPPB_LayerCompositor_Thunk(); PPAPI_THUNK_EXPORT const PPB_QueryPolicy_Dev* GetPPB_QueryPolicy_Thunk(); -PPAPI_THUNK_EXPORT const PPB_Messaging* GetPPB_Messaging_Thunk(); -PPAPI_THUNK_EXPORT const PPB_MouseInputEvent_1_0* - GetPPB_MouseInputEvent_1_0_Thunk(); -PPAPI_THUNK_EXPORT const PPB_MouseInputEvent* - GetPPB_MouseInputEvent_1_1_Thunk(); -PPAPI_THUNK_EXPORT const PPB_MouseLock_Dev* GetPPB_MouseLock_Thunk(); PPAPI_THUNK_EXPORT const PPB_Scrollbar_0_5_Dev* GetPPB_Scrollbar_Thunk(); -PPAPI_THUNK_EXPORT const PPB_Surface3D_Dev* GetPPB_Surface3D_Thunk(); -PPAPI_THUNK_EXPORT const PPB_Transport_Dev* GetPPB_Transport_Thunk(); -PPAPI_THUNK_EXPORT const PPB_URLLoader* GetPPB_URLLoader_Thunk(); +PPAPI_THUNK_EXPORT const PPB_Transport_Dev* GetPPB_Transport_Dev_Thunk(); PPAPI_THUNK_EXPORT const PPB_URLLoaderTrusted* GetPPB_URLLoaderTrusted_Thunk(); -PPAPI_THUNK_EXPORT const PPB_URLRequestInfo* GetPPB_URLRequestInfo_Thunk(); -PPAPI_THUNK_EXPORT const PPB_URLResponseInfo* GetPPB_URLResponseInfo_Thunk(); -PPAPI_THUNK_EXPORT const PPB_VideoCapture_Dev* GetPPB_VideoCapture_Thunk(); -PPAPI_THUNK_EXPORT const PPB_VideoDecoder_Dev* GetPPB_VideoDecoder_Thunk(); -PPAPI_THUNK_EXPORT const PPB_VideoLayer_Dev* GetPPB_VideoLayer_Thunk(); -PPAPI_THUNK_EXPORT const PPB_WheelInputEvent* GetPPB_WheelInputEvent_Thunk(); -PPAPI_THUNK_EXPORT const PPB_Widget_Dev* GetPPB_Widget_Thunk(); +PPAPI_THUNK_EXPORT const PPB_VideoLayer_Dev* GetPPB_VideoLayer_Dev_Thunk(); +PPAPI_THUNK_EXPORT const PPB_Widget_Dev* GetPPB_Widget_Dev_Thunk(); PPAPI_THUNK_EXPORT const PPB_Zoom_Dev* GetPPB_Zoom_Thunk(); } // namespace thunk |