| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/proxy/dispatcher.h" | 5 #include "ppapi/proxy/dispatcher.h" |
| 6 | 6 |
| 7 #include <string.h> // For memset. | 7 #include <string.h> // For memset. |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "ipc/ipc_message.h" | 13 #include "ipc/ipc_message.h" |
| 14 #include "ipc/ipc_sync_channel.h" | 14 #include "ipc/ipc_sync_channel.h" |
| 15 #include "ipc/ipc_test_sink.h" | 15 #include "ipc/ipc_test_sink.h" |
| 16 #include "ppapi/c/dev/ppb_buffer_dev.h" | 16 #include "ppapi/c/dev/ppb_buffer_dev.h" |
| 17 #include "ppapi/c/dev/ppb_char_set_dev.h" | 17 #include "ppapi/c/dev/ppb_char_set_dev.h" |
| 18 #include "ppapi/c/dev/ppb_context_3d_dev.h" |
| 18 #include "ppapi/c/dev/ppb_cursor_control_dev.h" | 19 #include "ppapi/c/dev/ppb_cursor_control_dev.h" |
| 19 #include "ppapi/c/dev/ppb_cursor_control_dev.h" | 20 #include "ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h" |
| 20 #include "ppapi/c/dev/ppb_font_dev.h" | 21 #include "ppapi/c/dev/ppb_font_dev.h" |
| 21 #include "ppapi/c/dev/ppb_fullscreen_dev.h" | 22 #include "ppapi/c/dev/ppb_fullscreen_dev.h" |
| 22 #include "ppapi/c/dev/ppb_fullscreen_dev.h" | 23 #include "ppapi/c/dev/ppb_opengles_dev.h" |
| 24 #include "ppapi/c/dev/ppb_surface_3d_dev.h" |
| 23 #include "ppapi/c/dev/ppb_testing_dev.h" | 25 #include "ppapi/c/dev/ppb_testing_dev.h" |
| 24 #include "ppapi/c/dev/ppb_var_deprecated.h" | 26 #include "ppapi/c/dev/ppb_var_deprecated.h" |
| 25 #include "ppapi/c/pp_errors.h" | 27 #include "ppapi/c/pp_errors.h" |
| 26 #include "ppapi/c/ppb_audio.h" | 28 #include "ppapi/c/ppb_audio.h" |
| 27 #include "ppapi/c/ppb_audio_config.h" | 29 #include "ppapi/c/ppb_audio_config.h" |
| 28 #include "ppapi/c/ppb_core.h" | 30 #include "ppapi/c/ppb_core.h" |
| 29 #include "ppapi/c/ppb_graphics_2d.h" | 31 #include "ppapi/c/ppb_graphics_2d.h" |
| 30 #include "ppapi/c/ppb_image_data.h" | 32 #include "ppapi/c/ppb_image_data.h" |
| 31 #include "ppapi/c/ppb_instance.h" | 33 #include "ppapi/c/ppb_instance.h" |
| 32 #include "ppapi/c/ppb_url_loader.h" | 34 #include "ppapi/c/ppb_url_loader.h" |
| 33 #include "ppapi/c/ppb_url_request_info.h" | 35 #include "ppapi/c/ppb_url_request_info.h" |
| 34 #include "ppapi/c/ppb_url_response_info.h" | 36 #include "ppapi/c/ppb_url_response_info.h" |
| 35 #include "ppapi/c/ppp_instance.h" | 37 #include "ppapi/c/ppp_instance.h" |
| 36 #include "ppapi/c/private/ppb_flash.h" | 38 #include "ppapi/c/private/ppb_flash.h" |
| 37 #include "ppapi/c/private/ppb_pdf.h" | 39 #include "ppapi/c/private/ppb_pdf.h" |
| 38 #include "ppapi/c/trusted/ppb_url_loader_trusted.h" | 40 #include "ppapi/c/trusted/ppb_url_loader_trusted.h" |
| 39 #include "ppapi/proxy/ppapi_messages.h" | 41 #include "ppapi/proxy/ppapi_messages.h" |
| 40 #include "ppapi/proxy/ppb_audio_config_proxy.h" | 42 #include "ppapi/proxy/ppb_audio_config_proxy.h" |
| 41 #include "ppapi/proxy/ppb_audio_proxy.h" | 43 #include "ppapi/proxy/ppb_audio_proxy.h" |
| 42 #include "ppapi/proxy/ppb_buffer_proxy.h" | 44 #include "ppapi/proxy/ppb_buffer_proxy.h" |
| 43 #include "ppapi/proxy/ppb_char_set_proxy.h" | 45 #include "ppapi/proxy/ppb_char_set_proxy.h" |
| 46 #include "ppapi/proxy/ppb_context_3d_proxy.h" |
| 44 #include "ppapi/proxy/ppb_core_proxy.h" | 47 #include "ppapi/proxy/ppb_core_proxy.h" |
| 45 #include "ppapi/proxy/ppb_cursor_control_proxy.h" | 48 #include "ppapi/proxy/ppb_cursor_control_proxy.h" |
| 46 #include "ppapi/proxy/ppb_flash_proxy.h" | 49 #include "ppapi/proxy/ppb_flash_proxy.h" |
| 47 #include "ppapi/proxy/ppb_font_proxy.h" | 50 #include "ppapi/proxy/ppb_font_proxy.h" |
| 48 #include "ppapi/proxy/ppb_fullscreen_proxy.h" | 51 #include "ppapi/proxy/ppb_fullscreen_proxy.h" |
| 52 #include "ppapi/proxy/ppb_gles_chromium_texture_mapping_proxy.h" |
| 49 #include "ppapi/proxy/ppb_graphics_2d_proxy.h" | 53 #include "ppapi/proxy/ppb_graphics_2d_proxy.h" |
| 50 #include "ppapi/proxy/ppb_image_data_proxy.h" | 54 #include "ppapi/proxy/ppb_image_data_proxy.h" |
| 51 #include "ppapi/proxy/ppb_instance_proxy.h" | 55 #include "ppapi/proxy/ppb_instance_proxy.h" |
| 56 #include "ppapi/proxy/ppb_opengles2_proxy.h" |
| 52 #include "ppapi/proxy/ppb_pdf_proxy.h" | 57 #include "ppapi/proxy/ppb_pdf_proxy.h" |
| 58 #include "ppapi/proxy/ppb_surface_3d_proxy.h" |
| 53 #include "ppapi/proxy/ppb_testing_proxy.h" | 59 #include "ppapi/proxy/ppb_testing_proxy.h" |
| 54 #include "ppapi/proxy/ppb_url_loader_proxy.h" | 60 #include "ppapi/proxy/ppb_url_loader_proxy.h" |
| 55 #include "ppapi/proxy/ppb_url_request_info_proxy.h" | 61 #include "ppapi/proxy/ppb_url_request_info_proxy.h" |
| 56 #include "ppapi/proxy/ppb_url_response_info_proxy.h" | 62 #include "ppapi/proxy/ppb_url_response_info_proxy.h" |
| 57 #include "ppapi/proxy/ppb_var_deprecated_proxy.h" | 63 #include "ppapi/proxy/ppb_var_deprecated_proxy.h" |
| 58 #include "ppapi/proxy/ppp_class_proxy.h" | 64 #include "ppapi/proxy/ppp_class_proxy.h" |
| 59 #include "ppapi/proxy/ppp_instance_proxy.h" | 65 #include "ppapi/proxy/ppp_instance_proxy.h" |
| 60 #include "ppapi/proxy/var_serialization_rules.h" | 66 #include "ppapi/proxy/var_serialization_rules.h" |
| 61 | 67 |
| 62 namespace pp { | 68 namespace pp { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 158 |
| 153 if (!RemoteSupportsTargetInterface(interface)) | 159 if (!RemoteSupportsTargetInterface(interface)) |
| 154 return NULL; | 160 return NULL; |
| 155 | 161 |
| 156 linked_ptr<InterfaceProxy> proxy(CreateProxyForInterface(interface, NULL)); | 162 linked_ptr<InterfaceProxy> proxy(CreateProxyForInterface(interface, NULL)); |
| 157 if (!proxy.get()) | 163 if (!proxy.get()) |
| 158 return NULL; // Don't know how to proxy this interface. | 164 return NULL; // Don't know how to proxy this interface. |
| 159 | 165 |
| 160 // Save our proxy. | 166 // Save our proxy. |
| 161 proxies_[interface] = proxy; | 167 proxies_[interface] = proxy; |
| 162 id_to_proxy_[proxy->GetInterfaceId()] = proxy.get(); | 168 InterfaceID id = proxy->GetInterfaceId(); |
| 169 if (id != INTERFACE_ID_NONE) |
| 170 id_to_proxy_[id] = proxy.get(); |
| 163 return proxy->GetSourceInterface(); | 171 return proxy->GetSourceInterface(); |
| 164 } | 172 } |
| 165 | 173 |
| 166 bool Dispatcher::Send(IPC::Message* msg) { | 174 bool Dispatcher::Send(IPC::Message* msg) { |
| 167 if (test_sink_) | 175 if (test_sink_) |
| 168 return test_sink_->Send(msg); | 176 return test_sink_->Send(msg); |
| 169 return channel_->Send(msg); | 177 return channel_->Send(msg); |
| 170 } | 178 } |
| 171 | 179 |
| 172 bool Dispatcher::RemoteSupportsTargetInterface(const std::string& interface) { | 180 bool Dispatcher::RemoteSupportsTargetInterface(const std::string& interface) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 const std::string& interface_name, | 247 const std::string& interface_name, |
| 240 const void* interface_functions) { | 248 const void* interface_functions) { |
| 241 if (interface_name == PPB_AUDIO_CONFIG_INTERFACE) | 249 if (interface_name == PPB_AUDIO_CONFIG_INTERFACE) |
| 242 return new PPB_AudioConfig_Proxy(this, interface_functions); | 250 return new PPB_AudioConfig_Proxy(this, interface_functions); |
| 243 if (interface_name == PPB_AUDIO_INTERFACE) | 251 if (interface_name == PPB_AUDIO_INTERFACE) |
| 244 return new PPB_Audio_Proxy(this, interface_functions); | 252 return new PPB_Audio_Proxy(this, interface_functions); |
| 245 if (interface_name == PPB_BUFFER_DEV_INTERFACE) | 253 if (interface_name == PPB_BUFFER_DEV_INTERFACE) |
| 246 return new PPB_Buffer_Proxy(this, interface_functions); | 254 return new PPB_Buffer_Proxy(this, interface_functions); |
| 247 if (interface_name == PPB_CHAR_SET_DEV_INTERFACE) | 255 if (interface_name == PPB_CHAR_SET_DEV_INTERFACE) |
| 248 return new PPB_CharSet_Proxy(this, interface_functions); | 256 return new PPB_CharSet_Proxy(this, interface_functions); |
| 257 if (interface_name == PPB_CONTEXT_3D_DEV_INTERFACE) |
| 258 return new PPB_Context3D_Proxy(this, interface_functions); |
| 249 if (interface_name == PPB_CORE_INTERFACE) | 259 if (interface_name == PPB_CORE_INTERFACE) |
| 250 return new PPB_Core_Proxy(this, interface_functions); | 260 return new PPB_Core_Proxy(this, interface_functions); |
| 251 if (interface_name == PPB_CURSOR_CONTROL_DEV_INTERFACE) | 261 if (interface_name == PPB_CURSOR_CONTROL_DEV_INTERFACE) |
| 252 return new PPB_CursorControl_Proxy(this, interface_functions); | 262 return new PPB_CursorControl_Proxy(this, interface_functions); |
| 253 if (interface_name == PPB_FONT_DEV_INTERFACE) | 263 if (interface_name == PPB_FONT_DEV_INTERFACE) |
| 254 return new PPB_Font_Proxy(this, interface_functions); | 264 return new PPB_Font_Proxy(this, interface_functions); |
| 255 if (interface_name == PPB_FULLSCREEN_DEV_INTERFACE) | 265 if (interface_name == PPB_FULLSCREEN_DEV_INTERFACE) |
| 256 return new PPB_Fullscreen_Proxy(this, interface_functions); | 266 return new PPB_Fullscreen_Proxy(this, interface_functions); |
| 267 if (interface_name == PPB_GLES_CHROMIUM_TEXTURE_MAPPING_DEV_INTERFACE) |
| 268 return new PPB_GLESChromiumTextureMapping_Proxy(this, interface_functions); |
| 257 if (interface_name == PPB_GRAPHICS_2D_INTERFACE) | 269 if (interface_name == PPB_GRAPHICS_2D_INTERFACE) |
| 258 return new PPB_Graphics2D_Proxy(this, interface_functions); | 270 return new PPB_Graphics2D_Proxy(this, interface_functions); |
| 259 if (interface_name == PPB_IMAGEDATA_INTERFACE) | 271 if (interface_name == PPB_IMAGEDATA_INTERFACE) |
| 260 return new PPB_ImageData_Proxy(this, interface_functions); | 272 return new PPB_ImageData_Proxy(this, interface_functions); |
| 261 if (interface_name == PPB_INSTANCE_INTERFACE) | 273 if (interface_name == PPB_INSTANCE_INTERFACE) |
| 262 return new PPB_Instance_Proxy(this, interface_functions); | 274 return new PPB_Instance_Proxy(this, interface_functions); |
| 275 if (interface_name == PPB_OPENGLES2_DEV_INTERFACE) |
| 276 return new PPB_OpenGLES2_Proxy(this, interface_functions); |
| 277 if (interface_name == PPB_SURFACE_3D_DEV_INTERFACE) |
| 278 return new PPB_Surface3D_Proxy(this, interface_functions); |
| 263 if (interface_name == PPB_TESTING_DEV_INTERFACE) | 279 if (interface_name == PPB_TESTING_DEV_INTERFACE) |
| 264 return new PPB_Testing_Proxy(this, interface_functions); | 280 return new PPB_Testing_Proxy(this, interface_functions); |
| 265 if (interface_name == PPB_URLLOADER_INTERFACE) | 281 if (interface_name == PPB_URLLOADER_INTERFACE) |
| 266 return new PPB_URLLoader_Proxy(this, interface_functions); | 282 return new PPB_URLLoader_Proxy(this, interface_functions); |
| 267 if (interface_name == PPB_URLREQUESTINFO_INTERFACE) | 283 if (interface_name == PPB_URLREQUESTINFO_INTERFACE) |
| 268 return new PPB_URLRequestInfo_Proxy(this, interface_functions); | 284 return new PPB_URLRequestInfo_Proxy(this, interface_functions); |
| 269 if (interface_name == PPB_URLRESPONSEINFO_INTERFACE) | 285 if (interface_name == PPB_URLRESPONSEINFO_INTERFACE) |
| 270 return new PPB_URLResponseInfo_Proxy(this, interface_functions); | 286 return new PPB_URLResponseInfo_Proxy(this, interface_functions); |
| 271 if (interface_name == PPB_VAR_DEPRECATED_INTERFACE) | 287 if (interface_name == PPB_VAR_DEPRECATED_INTERFACE) |
| 272 return new PPB_Var_Deprecated_Proxy(this, interface_functions); | 288 return new PPB_Var_Deprecated_Proxy(this, interface_functions); |
| 273 if (interface_name == PPP_INSTANCE_INTERFACE) | 289 if (interface_name == PPP_INSTANCE_INTERFACE) |
| 274 return new PPP_Instance_Proxy(this, interface_functions); | 290 return new PPP_Instance_Proxy(this, interface_functions); |
| 275 | 291 |
| 276 // Trusted interfaces. | 292 // Trusted interfaces. |
| 277 if (!disallow_trusted_interfaces_) { | 293 if (!disallow_trusted_interfaces_) { |
| 278 if (interface_name == PPB_FLASH_INTERFACE) | 294 if (interface_name == PPB_FLASH_INTERFACE) |
| 279 return new PPB_Flash_Proxy(this, interface_functions); | 295 return new PPB_Flash_Proxy(this, interface_functions); |
| 280 if (interface_name == PPB_PDF_INTERFACE) | 296 if (interface_name == PPB_PDF_INTERFACE) |
| 281 return new PPB_PDF_Proxy(this, interface_functions); | 297 return new PPB_PDF_Proxy(this, interface_functions); |
| 282 if (interface_name == PPB_URLLOADERTRUSTED_INTERFACE) | 298 if (interface_name == PPB_URLLOADERTRUSTED_INTERFACE) |
| 283 return new PPB_URLLoaderTrusted_Proxy(this, interface_functions); | 299 return new PPB_URLLoaderTrusted_Proxy(this, interface_functions); |
| 284 } | 300 } |
| 285 | 301 |
| 286 return NULL; | 302 return NULL; |
| 287 } | 303 } |
| 288 | 304 |
| 289 } // namespace proxy | 305 } // namespace proxy |
| 290 } // namespace pp | 306 } // namespace pp |
| 291 | 307 |
| OLD | NEW |