diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-13 04:00:33 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-13 04:00:33 +0000 |
commit | 37fe036a2c3e907a5790561e11292904426db144 (patch) | |
tree | 4b4c928830476c7450ffd5c69ca9f222ddbcfded /ppapi/proxy/dispatcher.cc | |
parent | ad432d686c8529838448f6639130f1290db9d5a5 (diff) | |
download | chromium_src-37fe036a2c3e907a5790561e11292904426db144.zip chromium_src-37fe036a2c3e907a5790561e11292904426db144.tar.gz chromium_src-37fe036a2c3e907a5790561e11292904426db144.tar.bz2 |
Revert r100853, 100851. Win_shared build is broken.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100854 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy/dispatcher.cc')
-rw-r--r-- | ppapi/proxy/dispatcher.cc | 275 |
1 files changed, 237 insertions, 38 deletions
diff --git a/ppapi/proxy/dispatcher.cc b/ppapi/proxy/dispatcher.cc index 8381c6a..d77c905 100644 --- a/ppapi/proxy/dispatcher.cc +++ b/ppapi/proxy/dispatcher.cc @@ -11,12 +11,209 @@ #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), @@ -28,32 +225,6 @@ 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) { @@ -65,19 +236,37 @@ bool Dispatcher::OnMessageReceived(const IPC::Message& msg) { IPC_END_MESSAGE_MAP() return handled; } + return false; +} - if (msg.routing_id() <= 0 || msg.routing_id() >= INTERFACE_ID_COUNT) { - OnInvalidMessageReceived(); - return true; - } +// 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; +} - InterfaceProxy* proxy = GetInterfaceProxy( - static_cast<InterfaceID>(msg.routing_id())); - if (!proxy) { - NOTREACHED(); - return true; - } - return proxy->OnMessageReceived(msg); +// 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]; +} + +// 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; } void Dispatcher::SetSerializationRules( @@ -85,7 +274,17 @@ void Dispatcher::SetSerializationRules( serialization_rules_.reset(var_serialization_rules); } -void Dispatcher::OnInvalidMessageReceived() { +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); } } // namespace proxy |