From 65165551604da0f53f5f17fbe8e97363b9436cf5 Mon Sep 17 00:00:00 2001 From: "brettw@chromium.org" Date: Tue, 6 Dec 2011 23:42:21 +0000 Subject: Rename the shared_impl resource files to give them more regular names. I keep getting confused between things like AudioImpl and PPB_Audio_Impl. This uses _shared for the names, so now we have _impl, _proxy, and _shared which makes more sense. I also removed the ppb_opengles2_impl file since it was just a forward to the shared version. BUG= TEST= Review URL: http://codereview.chromium.org/8790004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113290 0039d316-1c4b-4281-b951-d872f2087c98 --- gpu/command_buffer/build_gles2_cmd_buffer.py | 11 +- ppapi/ppapi_shared.gypi | 63 +- ppapi/proxy/interface_list.cc | 4 +- ppapi/proxy/ppapi_messages.h | 4 +- ppapi/proxy/ppapi_param_traits.h | 2 +- ppapi/proxy/ppb_audio_input_proxy.cc | 4 +- ppapi/proxy/ppb_audio_proxy.cc | 4 +- ppapi/proxy/ppb_file_ref_proxy.cc | 8 +- ppapi/proxy/ppb_graphics_3d_proxy.h | 4 +- ppapi/proxy/ppb_image_data_proxy.h | 4 +- ppapi/proxy/ppb_instance_proxy.cc | 17 +- ppapi/proxy/ppb_instance_proxy.h | 6 +- ppapi/proxy/ppb_testing_proxy.cc | 8 +- ppapi/proxy/ppb_video_decoder_proxy.cc | 4 +- ppapi/proxy/ppb_video_decoder_proxy.h | 2 +- ppapi/proxy/ppp_input_event_proxy.cc | 10 +- ppapi/proxy/resource_creation_proxy.cc | 32 +- ppapi/shared_impl/audio_config_impl.cc | 76 -- ppapi/shared_impl/audio_config_impl.h | 52 -- ppapi/shared_impl/audio_impl.cc | 92 --- ppapi/shared_impl/audio_impl.h | 87 --- ppapi/shared_impl/audio_input_impl.cc | 94 --- ppapi/shared_impl/audio_input_impl.h | 88 --- ppapi/shared_impl/char_set_impl.cc | 152 ---- ppapi/shared_impl/char_set_impl.h | 33 - ppapi/shared_impl/crypto_impl.cc | 36 - ppapi/shared_impl/file_ref_impl.cc | 65 -- ppapi/shared_impl/file_ref_impl.h | 65 -- ppapi/shared_impl/font_impl.cc | 34 - ppapi/shared_impl/font_impl.h | 32 - ppapi/shared_impl/graphics_3d_impl.cc | 137 ---- ppapi/shared_impl/graphics_3d_impl.h | 76 -- ppapi/shared_impl/image_data_impl.cc | 27 - ppapi/shared_impl/image_data_impl.h | 31 - ppapi/shared_impl/input_event_impl.cc | 131 ---- ppapi/shared_impl/input_event_impl.h | 100 --- ppapi/shared_impl/instance_impl.cc | 30 - ppapi/shared_impl/instance_impl.h | 24 - ppapi/shared_impl/memory_impl.cc | 43 -- ppapi/shared_impl/opengles2_impl.cc | 898 ---------------------- ppapi/shared_impl/opengles2_impl.h | 21 - ppapi/shared_impl/ppb_audio_config_shared.cc | 80 ++ ppapi/shared_impl/ppb_audio_config_shared.h | 54 ++ ppapi/shared_impl/ppb_audio_input_shared.cc | 94 +++ ppapi/shared_impl/ppb_audio_input_shared.h | 91 +++ ppapi/shared_impl/ppb_audio_shared.cc | 94 +++ ppapi/shared_impl/ppb_audio_shared.h | 89 +++ ppapi/shared_impl/ppb_char_set_shared.cc | 154 ++++ ppapi/shared_impl/ppb_char_set_shared.h | 33 + ppapi/shared_impl/ppb_crypto_shared.cc | 36 + ppapi/shared_impl/ppb_file_ref_shared.cc | 67 ++ ppapi/shared_impl/ppb_file_ref_shared.h | 66 ++ ppapi/shared_impl/ppb_font_shared.cc | 35 + ppapi/shared_impl/ppb_font_shared.h | 32 + ppapi/shared_impl/ppb_graphics_3d_shared.cc | 137 ++++ ppapi/shared_impl/ppb_graphics_3d_shared.h | 77 ++ ppapi/shared_impl/ppb_image_data_shared.cc | 28 + ppapi/shared_impl/ppb_image_data_shared.h | 31 + ppapi/shared_impl/ppb_input_event_shared.cc | 131 ++++ ppapi/shared_impl/ppb_input_event_shared.h | 100 +++ ppapi/shared_impl/ppb_instance_shared.cc | 31 + ppapi/shared_impl/ppb_instance_shared.h | 24 + ppapi/shared_impl/ppb_memory_shared.cc | 43 ++ ppapi/shared_impl/ppb_opengles2_shared.cc | 898 ++++++++++++++++++++++ ppapi/shared_impl/ppb_opengles2_shared.h | 21 + ppapi/shared_impl/ppb_url_request_info_shared.cc | 272 +++++++ ppapi/shared_impl/ppb_url_request_info_shared.h | 136 ++++ ppapi/shared_impl/ppb_url_util_shared.cc | 115 +++ ppapi/shared_impl/ppb_url_util_shared.h | 53 ++ ppapi/shared_impl/ppb_video_decoder_shared.cc | 88 +++ ppapi/shared_impl/ppb_video_decoder_shared.h | 77 ++ ppapi/shared_impl/url_request_info_impl.cc | 264 ------- ppapi/shared_impl/url_request_info_impl.h | 136 ---- ppapi/shared_impl/url_util_impl.cc | 113 --- ppapi/shared_impl/url_util_impl.h | 53 -- ppapi/shared_impl/video_decoder_impl.cc | 88 --- ppapi/shared_impl/video_decoder_impl.h | 77 -- ppapi/thunk/ppb_char_set_thunk.cc | 10 +- ppapi/thunk/ppb_image_data_thunk.cc | 6 +- ppapi/thunk/ppb_url_request_info_thunk.cc | 2 +- ppapi/thunk/ppb_url_util_thunk.cc | 8 +- webkit/glue/webkit_glue.gypi | 2 - webkit/plugins/ppapi/plugin_module.cc | 6 +- webkit/plugins/ppapi/ppapi_plugin_instance.cc | 29 +- webkit/plugins/ppapi/ppapi_plugin_instance.h | 4 +- webkit/plugins/ppapi/ppb_audio_impl.h | 10 +- webkit/plugins/ppapi/ppb_audio_input_impl.h | 6 +- webkit/plugins/ppapi/ppb_file_ref_impl.cc | 4 +- webkit/plugins/ppapi/ppb_file_ref_impl.h | 6 +- webkit/plugins/ppapi/ppb_font_impl.cc | 4 +- webkit/plugins/ppapi/ppb_graphics_3d_impl.h | 6 +- webkit/plugins/ppapi/ppb_image_data_impl.h | 4 +- webkit/plugins/ppapi/ppb_opengles_impl.cc | 18 - webkit/plugins/ppapi/ppb_opengles_impl.h | 22 - webkit/plugins/ppapi/ppb_url_loader_impl.h | 2 +- webkit/plugins/ppapi/ppb_url_request_info_impl.cc | 2 +- webkit/plugins/ppapi/ppb_url_request_info_impl.h | 4 +- webkit/plugins/ppapi/ppb_video_decoder_impl.cc | 2 +- webkit/plugins/ppapi/ppb_video_decoder_impl.h | 4 +- webkit/plugins/ppapi/resource_creation_impl.cc | 22 +- webkit/plugins/ppapi/url_request_info_unittest.cc | 1 - 101 files changed, 3353 insertions(+), 3360 deletions(-) delete mode 100644 ppapi/shared_impl/audio_config_impl.cc delete mode 100644 ppapi/shared_impl/audio_config_impl.h delete mode 100644 ppapi/shared_impl/audio_impl.cc delete mode 100644 ppapi/shared_impl/audio_impl.h delete mode 100644 ppapi/shared_impl/audio_input_impl.cc delete mode 100644 ppapi/shared_impl/audio_input_impl.h delete mode 100644 ppapi/shared_impl/char_set_impl.cc delete mode 100644 ppapi/shared_impl/char_set_impl.h delete mode 100644 ppapi/shared_impl/crypto_impl.cc delete mode 100644 ppapi/shared_impl/file_ref_impl.cc delete mode 100644 ppapi/shared_impl/file_ref_impl.h delete mode 100644 ppapi/shared_impl/font_impl.cc delete mode 100644 ppapi/shared_impl/font_impl.h delete mode 100644 ppapi/shared_impl/graphics_3d_impl.cc delete mode 100644 ppapi/shared_impl/graphics_3d_impl.h delete mode 100644 ppapi/shared_impl/image_data_impl.cc delete mode 100644 ppapi/shared_impl/image_data_impl.h delete mode 100644 ppapi/shared_impl/input_event_impl.cc delete mode 100644 ppapi/shared_impl/input_event_impl.h delete mode 100644 ppapi/shared_impl/instance_impl.cc delete mode 100644 ppapi/shared_impl/instance_impl.h delete mode 100644 ppapi/shared_impl/memory_impl.cc delete mode 100644 ppapi/shared_impl/opengles2_impl.cc delete mode 100644 ppapi/shared_impl/opengles2_impl.h create mode 100644 ppapi/shared_impl/ppb_audio_config_shared.cc create mode 100644 ppapi/shared_impl/ppb_audio_config_shared.h create mode 100644 ppapi/shared_impl/ppb_audio_input_shared.cc create mode 100644 ppapi/shared_impl/ppb_audio_input_shared.h create mode 100644 ppapi/shared_impl/ppb_audio_shared.cc create mode 100644 ppapi/shared_impl/ppb_audio_shared.h create mode 100644 ppapi/shared_impl/ppb_char_set_shared.cc create mode 100644 ppapi/shared_impl/ppb_char_set_shared.h create mode 100644 ppapi/shared_impl/ppb_crypto_shared.cc create mode 100644 ppapi/shared_impl/ppb_file_ref_shared.cc create mode 100644 ppapi/shared_impl/ppb_file_ref_shared.h create mode 100644 ppapi/shared_impl/ppb_font_shared.cc create mode 100644 ppapi/shared_impl/ppb_font_shared.h create mode 100644 ppapi/shared_impl/ppb_graphics_3d_shared.cc create mode 100644 ppapi/shared_impl/ppb_graphics_3d_shared.h create mode 100644 ppapi/shared_impl/ppb_image_data_shared.cc create mode 100644 ppapi/shared_impl/ppb_image_data_shared.h create mode 100644 ppapi/shared_impl/ppb_input_event_shared.cc create mode 100644 ppapi/shared_impl/ppb_input_event_shared.h create mode 100644 ppapi/shared_impl/ppb_instance_shared.cc create mode 100644 ppapi/shared_impl/ppb_instance_shared.h create mode 100644 ppapi/shared_impl/ppb_memory_shared.cc create mode 100644 ppapi/shared_impl/ppb_opengles2_shared.cc create mode 100644 ppapi/shared_impl/ppb_opengles2_shared.h create mode 100644 ppapi/shared_impl/ppb_url_request_info_shared.cc create mode 100644 ppapi/shared_impl/ppb_url_request_info_shared.h create mode 100644 ppapi/shared_impl/ppb_url_util_shared.cc create mode 100644 ppapi/shared_impl/ppb_url_util_shared.h create mode 100644 ppapi/shared_impl/ppb_video_decoder_shared.cc create mode 100644 ppapi/shared_impl/ppb_video_decoder_shared.h delete mode 100644 ppapi/shared_impl/url_request_info_impl.cc delete mode 100644 ppapi/shared_impl/url_request_info_impl.h delete mode 100644 ppapi/shared_impl/url_util_impl.cc delete mode 100644 ppapi/shared_impl/url_util_impl.h delete mode 100644 ppapi/shared_impl/video_decoder_impl.cc delete mode 100644 ppapi/shared_impl/video_decoder_impl.h delete mode 100644 webkit/plugins/ppapi/ppb_opengles_impl.cc delete mode 100644 webkit/plugins/ppapi/ppb_opengles_impl.h diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index c3ce764..bdbd683 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -5805,10 +5805,10 @@ const size_t GLES2Util::enum_to_string_table_len_ = file.Write(_LICENSE) file.Write(_DO_NOT_EDIT_WARNING) - file.Write("#include \"ppapi/shared_impl/opengles2_impl.h\"\n\n") + file.Write("#include \"ppapi/shared_impl/ppb_opengles2_shared.h\"\n\n") file.Write("#include \"base/logging.h\"\n") file.Write("#include \"gpu/command_buffer/client/gles2_implementation.h\"\n") - file.Write("#include \"ppapi/shared_impl/graphics_3d_impl.h\"\n") + file.Write("#include \"ppapi/shared_impl/ppb_graphics_3d_shared.h\"\n") file.Write("#include \"ppapi/thunk/enter.h\"\n\n") file.Write("namespace ppapi {\n\n") @@ -5819,7 +5819,7 @@ const size_t GLES2Util::enum_to_string_table_len_ = file.Write(" thunk::EnterResource" " enter_g3d(context, false);\n") file.Write(" DCHECK(enter_g3d.succeeded());\n") - file.Write(" return static_cast" + file.Write(" return static_cast" "(enter_g3d.object())->gles2_impl();\n") file.Write("}\n\n") @@ -5851,7 +5851,7 @@ const size_t GLES2Util::enum_to_string_table_len_ = file.Write("} // namespace\n") file.Write(""" -const PPB_OpenGLES2* OpenGLES2Impl::GetInterface() { +const PPB_OpenGLES2* PPB_OpenGLES2_Shared::GetInterface() { return &ppb_opengles2; } @@ -5989,7 +5989,8 @@ def main(argv): elif options.alternate_mode == "chrome_ppapi": # To trigger this action, do "make ppapi_gles_implementation" - gen.WritePepperGLES2Implementation("ppapi/shared_impl/opengles2_impl.cc") + gen.WritePepperGLES2Implementation( + "ppapi/shared_impl/ppb_opengles2_shared.cc") elif options.alternate_mode == "nacl_ppapi": gen.WritePepperGLES2NaClProxy( diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi index 5303b49..7b67ec1 100644 --- a/ppapi/ppapi_shared.gypi +++ b/ppapi/ppapi_shared.gypi @@ -30,41 +30,47 @@ '../base/base.gyp:base', ], 'sources': [ - 'shared_impl/audio_config_impl.cc', - 'shared_impl/audio_config_impl.h', - 'shared_impl/audio_impl.cc', - 'shared_impl/audio_impl.h', - 'shared_impl/audio_input_impl.cc', - 'shared_impl/audio_input_impl.h', - 'shared_impl/char_set_impl.cc', - 'shared_impl/char_set_impl.h', - 'shared_impl/crypto_impl.cc', - 'shared_impl/file_ref_impl.cc', - 'shared_impl/file_ref_impl.h', - 'shared_impl/font_impl.cc', - 'shared_impl/font_impl.h', 'shared_impl/function_group_base.cc', 'shared_impl/function_group_base.h', - 'shared_impl/graphics_3d_impl.cc', - 'shared_impl/graphics_3d_impl.h', 'shared_impl/host_resource.h', 'shared_impl/id_assignment.cc', 'shared_impl/id_assignment.h', - 'shared_impl/image_data_impl.cc', - 'shared_impl/image_data_impl.h', - 'shared_impl/input_event_impl.cc', - 'shared_impl/input_event_impl.h', - 'shared_impl/instance_impl.cc', - 'shared_impl/instance_impl.h', - 'shared_impl/memory_impl.cc', - 'shared_impl/opengles2_impl.cc', - 'shared_impl/opengles2_impl.h', - 'shared_impl/ppapi_globals.cc', 'shared_impl/platform_file.cc', 'shared_impl/platform_file.h', + 'shared_impl/ppapi_globals.cc', 'shared_impl/ppapi_globals.h', 'shared_impl/ppapi_preferences.cc', 'shared_impl/ppapi_preferences.h', + 'shared_impl/ppb_audio_config_shared.cc', + 'shared_impl/ppb_audio_config_shared.h', + 'shared_impl/ppb_audio_input_shared.cc', + 'shared_impl/ppb_audio_input_shared.h', + 'shared_impl/ppb_audio_shared.cc', + 'shared_impl/ppb_audio_shared.h', + 'shared_impl/ppb_char_set_shared.cc', + 'shared_impl/ppb_char_set_shared.h', + 'shared_impl/ppb_crypto_shared.cc', + 'shared_impl/ppb_file_ref_shared.cc', + 'shared_impl/ppb_file_ref_shared.h', + 'shared_impl/ppb_font_shared.cc', + 'shared_impl/ppb_font_shared.h', + 'shared_impl/ppb_graphics_3d_shared.cc', + 'shared_impl/ppb_graphics_3d_shared.h', + 'shared_impl/ppb_image_data_shared.cc', + 'shared_impl/ppb_image_data_shared.h', + 'shared_impl/ppb_input_event_shared.cc', + 'shared_impl/ppb_input_event_shared.h', + 'shared_impl/ppb_instance_shared.cc', + 'shared_impl/ppb_instance_shared.h', + 'shared_impl/ppb_memory_shared.cc', + 'shared_impl/ppb_opengles2_shared.cc', + 'shared_impl/ppb_opengles2_shared.h', + 'shared_impl/ppb_url_request_info_shared.cc', + 'shared_impl/ppb_url_request_info_shared.h', + 'shared_impl/ppb_url_util_shared.cc', + 'shared_impl/ppb_url_util_shared.h', + 'shared_impl/ppb_video_decoder_shared.cc', + 'shared_impl/ppb_video_decoder_shared.h', 'shared_impl/ppp_instance_combined.cc', 'shared_impl/ppp_instance_combined.h', 'shared_impl/proxy_lock.cc', @@ -77,19 +83,12 @@ 'shared_impl/scoped_pp_resource.h', 'shared_impl/time_conversion.cc', 'shared_impl/time_conversion.h', - 'shared_impl/url_request_info_impl.cc', - 'shared_impl/url_request_info_impl.h', - 'shared_impl/url_util_impl.cc', - 'shared_impl/url_util_impl.h', 'shared_impl/var.cc', 'shared_impl/var.h', 'shared_impl/var_tracker.cc', 'shared_impl/var_tracker.h', - 'shared_impl/video_decoder_impl.cc', - 'shared_impl/video_decoder_impl.h', 'shared_impl/webkit_forwarding.cc', 'shared_impl/webkit_forwarding.h', - # TODO(viettrungluu): Split these out; it won't be used in NaCl. 'shared_impl/private/net_address_private_impl.cc', 'shared_impl/private/net_address_private_impl.h', diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc index af36b88..a1c100e 100644 --- a/ppapi/proxy/interface_list.cc +++ b/ppapi/proxy/interface_list.cc @@ -94,7 +94,7 @@ #include "ppapi/proxy/ppp_mouse_lock_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/shared_impl/ppb_opengles2_shared.h" #include "ppapi/thunk/thunk.h" // Helper to get the proxy name PPB_Foo_Proxy given the API name PPB_Foo. @@ -164,7 +164,7 @@ InterfaceList::InterfaceList() { AddPPB(PPB_CORE_INTERFACE, API_ID_PPB_CORE, PPB_Core_Proxy::GetPPB_Core_Interface()); AddPPB(PPB_OPENGLES2_INTERFACE, API_ID_NONE, - OpenGLES2Impl::GetInterface()); + PPB_OpenGLES2_Shared::GetInterface()); AddPPB(PPB_VAR_INTERFACE, API_ID_NONE, GetPPB_Var_Interface()); diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index d6f0515..b894db9 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -34,9 +34,9 @@ #include "ppapi/proxy/ppapi_proxy_export.h" #include "ppapi/proxy/serialized_flash_menu.h" #include "ppapi/proxy/serialized_structs.h" -#include "ppapi/shared_impl/input_event_impl.h" #include "ppapi/shared_impl/ppapi_preferences.h" -#include "ppapi/shared_impl/url_request_info_impl.h" +#include "ppapi/shared_impl/ppb_input_event_shared.h" +#include "ppapi/shared_impl/ppb_url_request_info_shared.h" #undef IPC_MESSAGE_EXPORT #define IPC_MESSAGE_EXPORT PPAPI_PROXY_EXPORT diff --git a/ppapi/proxy/ppapi_param_traits.h b/ppapi/proxy/ppapi_param_traits.h index 4787dca..57706c5 100644 --- a/ppapi/proxy/ppapi_param_traits.h +++ b/ppapi/proxy/ppapi_param_traits.h @@ -14,7 +14,7 @@ #include "ppapi/c/pp_rect.h" #include "ppapi/c/pp_var.h" #include "ppapi/proxy/ppapi_proxy_export.h" -#include "ppapi/shared_impl/file_ref_impl.h" +#include "ppapi/shared_impl/ppb_file_ref_shared.h" struct PP_FileInfo; struct PP_ObjectProperty; diff --git a/ppapi/proxy/ppb_audio_input_proxy.cc b/ppapi/proxy/ppb_audio_input_proxy.cc index 2933edd..5126f7d 100644 --- a/ppapi/proxy/ppb_audio_input_proxy.cc +++ b/ppapi/proxy/ppb_audio_input_proxy.cc @@ -15,9 +15,9 @@ #include "ppapi/proxy/plugin_dispatcher.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/shared_impl/api_id.h" -#include "ppapi/shared_impl/audio_input_impl.h" #include "ppapi/shared_impl/platform_file.h" #include "ppapi/shared_impl/ppapi_globals.h" +#include "ppapi/shared_impl/ppb_audio_input_shared.h" #include "ppapi/shared_impl/resource.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_audio_config_api.h" @@ -32,7 +32,7 @@ using ppapi::thunk::PPB_AudioConfig_API; namespace ppapi { namespace proxy { -class AudioInput : public Resource, public AudioInputImpl { +class AudioInput : public Resource, public PPB_AudioInput_Shared { public: AudioInput(const HostResource& audio_input_id, PP_Resource config_id, diff --git a/ppapi/proxy/ppb_audio_proxy.cc b/ppapi/proxy/ppb_audio_proxy.cc index 0c4ddc4..8e64c85 100644 --- a/ppapi/proxy/ppb_audio_proxy.cc +++ b/ppapi/proxy/ppb_audio_proxy.cc @@ -15,9 +15,9 @@ #include "ppapi/proxy/plugin_dispatcher.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/shared_impl/api_id.h" -#include "ppapi/shared_impl/audio_impl.h" #include "ppapi/shared_impl/platform_file.h" #include "ppapi/shared_impl/ppapi_globals.h" +#include "ppapi/shared_impl/ppb_audio_shared.h" #include "ppapi/shared_impl/resource.h" #include "ppapi/thunk/ppb_audio_config_api.h" #include "ppapi/thunk/enter.h" @@ -32,7 +32,7 @@ using ppapi::thunk::PPB_AudioConfig_API; namespace ppapi { namespace proxy { -class Audio : public Resource, public AudioImpl { +class Audio : public Resource, public PPB_Audio_Shared { public: Audio(const HostResource& audio_id, PP_Resource config_id, diff --git a/ppapi/proxy/ppb_file_ref_proxy.cc b/ppapi/proxy/ppb_file_ref_proxy.cc index 5f1a05f..20b522c 100644 --- a/ppapi/proxy/ppb_file_ref_proxy.cc +++ b/ppapi/proxy/ppb_file_ref_proxy.cc @@ -16,7 +16,7 @@ #include "ppapi/proxy/plugin_dispatcher.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/serialized_var.h" -#include "ppapi/shared_impl/file_ref_impl.h" +#include "ppapi/shared_impl/ppb_file_ref_shared.h" #include "ppapi/thunk/resource_creation_api.h" #include "ppapi/thunk/thunk.h" @@ -28,12 +28,12 @@ using ppapi::thunk::ResourceCreationAPI; namespace ppapi { namespace proxy { -class FileRef : public FileRefImpl { +class FileRef : public PPB_FileRef_Shared { public: explicit FileRef(const PPB_FileRef_CreateInfo& info); virtual ~FileRef(); - // PPB_FileRef_API implementation (not provided by FileRefImpl). + // PPB_FileRef_API implementation (not provided by PPB_FileRef_Shared). virtual PP_Resource GetParent() OVERRIDE; virtual int32_t MakeDirectory(PP_Bool make_ancestors, PP_CompletionCallback callback) OVERRIDE; @@ -72,7 +72,7 @@ class FileRef : public FileRefImpl { }; FileRef::FileRef(const PPB_FileRef_CreateInfo& info) - : FileRefImpl(FileRefImpl::InitAsProxy(), info), + : PPB_FileRef_Shared(PPB_FileRef_Shared::InitAsProxy(), info), next_callback_id_(1) { } diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.h b/ppapi/proxy/ppb_graphics_3d_proxy.h index 472c2a7..887ae46 100644 --- a/ppapi/proxy/ppb_graphics_3d_proxy.h +++ b/ppapi/proxy/ppb_graphics_3d_proxy.h @@ -14,7 +14,7 @@ #include "ppapi/cpp/completion_callback.h" #include "ppapi/proxy/interface_proxy.h" #include "ppapi/proxy/proxy_non_thread_safe_ref_count.h" -#include "ppapi/shared_impl/graphics_3d_impl.h" +#include "ppapi/shared_impl/ppb_graphics_3d_shared.h" #include "ppapi/shared_impl/resource.h" namespace ppapi { @@ -23,7 +23,7 @@ class HostResource; namespace proxy { -class Graphics3D : public Resource, public Graphics3DImpl { +class Graphics3D : public Resource, public PPB_Graphics3D_Shared { public: explicit Graphics3D(const HostResource& resource); virtual ~Graphics3D(); diff --git a/ppapi/proxy/ppb_image_data_proxy.h b/ppapi/proxy/ppb_image_data_proxy.h index 9250948..6fd64f6 100644 --- a/ppapi/proxy/ppb_image_data_proxy.h +++ b/ppapi/proxy/ppb_image_data_proxy.h @@ -15,7 +15,7 @@ #include "ppapi/c/pp_var.h" #include "ppapi/proxy/interface_proxy.h" #include "ppapi/proxy/serialized_structs.h" -#include "ppapi/shared_impl/image_data_impl.h" +#include "ppapi/shared_impl/ppb_image_data_shared.h" #include "ppapi/shared_impl/resource.h" #include "ppapi/thunk/ppb_image_data_api.h" @@ -36,7 +36,7 @@ namespace proxy { // public in the header since a number of other resources need to access it. class ImageData : public ppapi::Resource, public ppapi::thunk::PPB_ImageData_API, - public ppapi::ImageDataImpl { + public ppapi::PPB_ImageData_Shared { public: ImageData(const ppapi::HostResource& resource, const PP_ImageDataDesc& desc, diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc index 28bb17e..af417e8 100644 --- a/ppapi/proxy/ppb_instance_proxy.cc +++ b/ppapi/proxy/ppb_instance_proxy.cc @@ -15,7 +15,7 @@ #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/serialized_var.h" #include "ppapi/shared_impl/ppapi_globals.h" -#include "ppapi/shared_impl/url_util_impl.h" +#include "ppapi/shared_impl/ppb_url_util_shared.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/thunk.h" @@ -317,8 +317,9 @@ PP_Var PPB_Instance_Proxy::ResolveRelativeToDocument( API_ID_PPB_INSTANCE, instance, SerializedVarSendInput(dispatcher(), relative), &result)); - return URLUtilImpl::ConvertComponentsAndReturnURL(result.Return(dispatcher()), - components); + return PPB_URLUtil_Shared::ConvertComponentsAndReturnURL( + result.Return(dispatcher()), + components); } PP_Bool PPB_Instance_Proxy::DocumentCanRequest(PP_Instance instance, @@ -344,8 +345,9 @@ PP_Var PPB_Instance_Proxy::GetDocumentURL(PP_Instance instance, ReceiveSerializedVarReturnValue result; dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetDocumentURL( API_ID_PPB_INSTANCE, instance, &result)); - return URLUtilImpl::ConvertComponentsAndReturnURL(result.Return(dispatcher()), - components); + return PPB_URLUtil_Shared::ConvertComponentsAndReturnURL( + result.Return(dispatcher()), + components); } PP_Var PPB_Instance_Proxy::GetPluginInstanceURL( @@ -354,8 +356,9 @@ PP_Var PPB_Instance_Proxy::GetPluginInstanceURL( ReceiveSerializedVarReturnValue result; dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetPluginInstanceURL( API_ID_PPB_INSTANCE, instance, &result)); - return URLUtilImpl::ConvertComponentsAndReturnURL(result.Return(dispatcher()), - components); + return PPB_URLUtil_Shared::ConvertComponentsAndReturnURL( + result.Return(dispatcher()), + components); } void PPB_Instance_Proxy::PostMessage(PP_Instance instance, diff --git a/ppapi/proxy/ppb_instance_proxy.h b/ppapi/proxy/ppb_instance_proxy.h index 5de8f9e..eeb791c 100644 --- a/ppapi/proxy/ppb_instance_proxy.h +++ b/ppapi/proxy/ppb_instance_proxy.h @@ -13,7 +13,7 @@ #include "ppapi/proxy/proxy_non_thread_safe_ref_count.h" #include "ppapi/shared_impl/function_group_base.h" #include "ppapi/shared_impl/host_resource.h" -#include "ppapi/shared_impl/instance_impl.h" +#include "ppapi/shared_impl/ppb_instance_shared.h" #include "ppapi/thunk/ppb_instance_api.h" // Windows headers interfere with this file. @@ -29,8 +29,8 @@ class SerializedVarOutParam; class SerializedVarReturnValue; class PPB_Instance_Proxy : public InterfaceProxy, - public ppapi::InstanceImpl, - public ppapi::thunk::PPB_Instance_FunctionAPI { + public PPB_Instance_Shared, + public thunk::PPB_Instance_FunctionAPI { public: PPB_Instance_Proxy(Dispatcher* dispatcher); virtual ~PPB_Instance_Proxy(); diff --git a/ppapi/proxy/ppb_testing_proxy.cc b/ppapi/proxy/ppb_testing_proxy.cc index d9f90f2..bb9bad0 100644 --- a/ppapi/proxy/ppb_testing_proxy.cc +++ b/ppapi/proxy/ppb_testing_proxy.cc @@ -165,10 +165,10 @@ void PPB_Testing_Proxy::OnMsgGetLiveObjectsForInstance(PP_Instance instance, void PPB_Testing_Proxy::OnMsgSimulateInputEvent( PP_Instance instance, const InputEventData& input_event) { - scoped_refptr input_event_impl( - new InputEventImpl(InputEventImpl::InitAsProxy(), - instance, - input_event)); + scoped_refptr input_event_impl( + new PPB_InputEvent_Shared(PPB_InputEvent_Shared::InitAsProxy(), + instance, + input_event)); ppb_testing_impl_->SimulateInputEvent(instance, input_event_impl->pp_resource()); } diff --git a/ppapi/proxy/ppb_video_decoder_proxy.cc b/ppapi/proxy/ppb_video_decoder_proxy.cc index 91b91c6..850ae6e 100644 --- a/ppapi/proxy/ppb_video_decoder_proxy.cc +++ b/ppapi/proxy/ppb_video_decoder_proxy.cc @@ -23,7 +23,7 @@ using ppapi::thunk::PPB_VideoDecoder_API; namespace ppapi { namespace proxy { -class VideoDecoder : public Resource, public VideoDecoderImpl { +class VideoDecoder : public Resource, public PPB_VideoDecoder_Shared { public: // You must call Init() before using this class. explicit VideoDecoder(const HostResource& resource); @@ -132,7 +132,7 @@ void VideoDecoder::Destroy() { FlushCommandBuffer(); GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_Destroy( API_ID_PPB_VIDEO_DECODER_DEV, host_resource())); - VideoDecoderImpl::Destroy(); + PPB_VideoDecoder_Shared::Destroy(); } PluginDispatcher* VideoDecoder::GetDispatcher() const { diff --git a/ppapi/proxy/ppb_video_decoder_proxy.h b/ppapi/proxy/ppb_video_decoder_proxy.h index edebb0e..1185d16 100644 --- a/ppapi/proxy/ppb_video_decoder_proxy.h +++ b/ppapi/proxy/ppb_video_decoder_proxy.h @@ -9,7 +9,7 @@ #include "ppapi/cpp/completion_callback.h" #include "ppapi/proxy/interface_proxy.h" #include "ppapi/proxy/proxy_non_thread_safe_ref_count.h" -#include "ppapi/shared_impl/video_decoder_impl.h" +#include "ppapi/shared_impl/ppb_video_decoder_shared.h" #include "ppapi/thunk/ppb_video_decoder_api.h" namespace ppapi { diff --git a/ppapi/proxy/ppp_input_event_proxy.cc b/ppapi/proxy/ppp_input_event_proxy.cc index 0215e72..cfce397 100644 --- a/ppapi/proxy/ppp_input_event_proxy.cc +++ b/ppapi/proxy/ppp_input_event_proxy.cc @@ -11,7 +11,7 @@ #include "ppapi/proxy/plugin_dispatcher.h" #include "ppapi/proxy/plugin_resource_tracker.h" #include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/shared_impl/input_event_impl.h" +#include "ppapi/shared_impl/ppb_input_event_shared.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_input_event_api.h" @@ -96,8 +96,8 @@ bool PPP_InputEvent_Proxy::OnMessageReceived(const IPC::Message& msg) { void PPP_InputEvent_Proxy::OnMsgHandleInputEvent(PP_Instance instance, const InputEventData& data) { - scoped_refptr resource(new InputEventImpl( - InputEventImpl::InitAsProxy(), instance, data)); + scoped_refptr resource(new PPB_InputEvent_Shared( + PPB_InputEvent_Shared::InitAsProxy(), instance, data)); ppp_input_event_impl_->HandleInputEvent(instance, resource->pp_resource()); } @@ -105,8 +105,8 @@ void PPP_InputEvent_Proxy::OnMsgHandleFilteredInputEvent( PP_Instance instance, const InputEventData& data, PP_Bool* result) { - scoped_refptr resource(new InputEventImpl( - InputEventImpl::InitAsProxy(), instance, data)); + scoped_refptr resource(new PPB_InputEvent_Shared( + PPB_InputEvent_Shared::InitAsProxy(), instance, data)); *result = ppp_input_event_impl_->HandleInputEvent(instance, resource->pp_resource()); } diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc index 0a0846e..52cce18 100644 --- a/ppapi/proxy/resource_creation_proxy.cc +++ b/ppapi/proxy/resource_creation_proxy.cc @@ -29,12 +29,12 @@ #include "ppapi/proxy/ppb_video_capture_proxy.h" #include "ppapi/proxy/ppb_video_decoder_proxy.h" #include "ppapi/shared_impl/api_id.h" -#include "ppapi/shared_impl/audio_config_impl.h" -#include "ppapi/shared_impl/font_impl.h" #include "ppapi/shared_impl/function_group_base.h" #include "ppapi/shared_impl/host_resource.h" -#include "ppapi/shared_impl/input_event_impl.h" -#include "ppapi/shared_impl/url_request_info_impl.h" +#include "ppapi/shared_impl/ppb_audio_config_shared.h" +#include "ppapi/shared_impl/ppb_font_shared.h" +#include "ppapi/shared_impl/ppb_input_event_shared.h" +#include "ppapi/shared_impl/ppb_url_request_info_shared.h" #include "ppapi/shared_impl/var.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_image_data_api.h" @@ -73,7 +73,7 @@ PP_Resource ResourceCreationProxy::CreateAudioConfig( PP_Instance instance, PP_AudioSampleRate sample_rate, uint32_t sample_frame_count) { - return AudioConfigImpl::CreateAsProxy( + return PPB_AudioConfig_Shared::CreateAsProxy( instance, sample_rate, sample_frame_count); } @@ -151,7 +151,7 @@ PP_Resource ResourceCreationProxy::CreateFlashNetConnector( PP_Resource ResourceCreationProxy::CreateFontObject( PP_Instance instance, const PP_FontDescription_Dev* description) { - if (!ppapi::FontImpl::IsPPFontDescriptionValid(*description)) + if (!PPB_Font_Shared::IsPPFontDescriptionValid(*description)) return 0; return (new Font(HostResource::MakeInstanceOnly(instance), *description))-> GetReference(); @@ -184,7 +184,7 @@ PP_Resource ResourceCreationProxy::CreateKeyboardInputEvent( type != PP_INPUTEVENT_TYPE_KEYUP && type != PP_INPUTEVENT_TYPE_CHAR) return 0; - ppapi::InputEventData data; + InputEventData data; data.event_type = type; data.event_time_stamp = time_stamp; data.event_modifiers = modifiers; @@ -196,8 +196,8 @@ PP_Resource ResourceCreationProxy::CreateKeyboardInputEvent( data.character_text = text_str->value(); } - return (new InputEventImpl(InputEventImpl::InitAsProxy(), - instance, data))->GetReference(); + return (new PPB_InputEvent_Shared(PPB_InputEvent_Shared::InitAsProxy(), + instance, data))->GetReference(); } PP_Resource ResourceCreationProxy::CreateMouseInputEvent( @@ -216,7 +216,7 @@ PP_Resource ResourceCreationProxy::CreateMouseInputEvent( type != PP_INPUTEVENT_TYPE_MOUSELEAVE) return 0; - ppapi::InputEventData data; + InputEventData data; data.event_type = type; data.event_time_stamp = time_stamp; data.event_modifiers = modifiers; @@ -225,8 +225,8 @@ PP_Resource ResourceCreationProxy::CreateMouseInputEvent( data.mouse_click_count = click_count; data.mouse_movement = *mouse_movement; - return (new InputEventImpl(InputEventImpl::InitAsProxy(), - instance, data))->GetReference(); + return (new PPB_InputEvent_Shared(PPB_InputEvent_Shared::InitAsProxy(), + instance, data))->GetReference(); } PP_Resource ResourceCreationProxy::CreateGraphics3D( @@ -276,7 +276,7 @@ PP_Resource ResourceCreationProxy::CreateURLLoader(PP_Instance instance) { PP_Resource ResourceCreationProxy::CreateURLRequestInfo( PP_Instance instance, const PPB_URLRequestInfo_Data& data) { - return (new URLRequestInfoImpl( + return (new PPB_URLRequestInfo_Shared( HostResource::MakeInstanceOnly(instance), data))->GetReference(); } @@ -311,7 +311,7 @@ PP_Resource ResourceCreationProxy::CreateWheelInputEvent( const PP_FloatPoint* wheel_delta, const PP_FloatPoint* wheel_ticks, PP_Bool scroll_by_page) { - ppapi::InputEventData data; + InputEventData data; data.event_type = PP_INPUTEVENT_TYPE_WHEEL; data.event_time_stamp = time_stamp; data.event_modifiers = modifiers; @@ -319,8 +319,8 @@ PP_Resource ResourceCreationProxy::CreateWheelInputEvent( data.wheel_ticks = *wheel_ticks; data.wheel_scroll_by_page = PP_ToBool(scroll_by_page); - return (new InputEventImpl(InputEventImpl::InitAsProxy(), - instance, data))->GetReference(); + return (new PPB_InputEvent_Shared(PPB_InputEvent_Shared::InitAsProxy(), + instance, data))->GetReference(); } bool ResourceCreationProxy::Send(IPC::Message* msg) { diff --git a/ppapi/shared_impl/audio_config_impl.cc b/ppapi/shared_impl/audio_config_impl.cc deleted file mode 100644 index 843f2d1..0000000 --- a/ppapi/shared_impl/audio_config_impl.cc +++ /dev/null @@ -1,76 +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/shared_impl/audio_config_impl.h" - -namespace ppapi { - -AudioConfigImpl::AudioConfigImpl(PP_Instance instance) - : Resource(instance), - sample_rate_(PP_AUDIOSAMPLERATE_NONE), - sample_frame_count_(0) { -} - -AudioConfigImpl::AudioConfigImpl(const HostResource& host_resource) - : Resource(host_resource), - sample_rate_(PP_AUDIOSAMPLERATE_NONE), - sample_frame_count_(0) { -} - -AudioConfigImpl::~AudioConfigImpl() { -} - -// static -PP_Resource AudioConfigImpl::CreateAsImpl(PP_Instance instance, - PP_AudioSampleRate sample_rate, - uint32_t sample_frame_count) { - scoped_refptr object(new AudioConfigImpl(instance)); - if (!object->Init(sample_rate, sample_frame_count)) - return 0; - return object->GetReference(); -} - -// static -PP_Resource AudioConfigImpl::CreateAsProxy(PP_Instance instance, - PP_AudioSampleRate sample_rate, - uint32_t sample_frame_count) { - scoped_refptr object(new AudioConfigImpl( - HostResource::MakeInstanceOnly(instance))); - if (!object->Init(sample_rate, sample_frame_count)) - return 0; - return object->GetReference(); -} - -thunk::PPB_AudioConfig_API* AudioConfigImpl::AsPPB_AudioConfig_API() { - return this; -} - -PP_AudioSampleRate AudioConfigImpl::GetSampleRate() { - return sample_rate_; -} - -uint32_t AudioConfigImpl::GetSampleFrameCount() { - return sample_frame_count_; -} - -bool AudioConfigImpl::Init(PP_AudioSampleRate sample_rate, - uint32_t sample_frame_count) { - // TODO(brettw): Currently we don't actually check what the hardware - // supports, so just allow sample rates of the "guaranteed working" ones. - if (sample_rate != PP_AUDIOSAMPLERATE_44100 && - sample_rate != PP_AUDIOSAMPLERATE_48000) - return false; - - // TODO(brettw): Currently we don't actually query to get a value from the - // hardware, so just validate the range. - if (sample_frame_count > PP_AUDIOMAXSAMPLEFRAMECOUNT || - sample_frame_count < PP_AUDIOMINSAMPLEFRAMECOUNT) - return false; - - sample_rate_ = sample_rate; - sample_frame_count_ = sample_frame_count; - return true; -} - -} // namespace ppapi diff --git a/ppapi/shared_impl/audio_config_impl.h b/ppapi/shared_impl/audio_config_impl.h deleted file mode 100644 index 7577e00..0000000 --- a/ppapi/shared_impl/audio_config_impl.h +++ /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. - -#ifndef PPAPI_SHARED_IMPL_AUDIO_CONFIG_IMPL_H_ -#define PPAPI_SHARED_IMPL_AUDIO_CONFIG_IMPL_H_ - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "ppapi/shared_impl/resource.h" -#include "ppapi/thunk/ppb_audio_config_api.h" - -namespace ppapi { - -class PPAPI_SHARED_EXPORT AudioConfigImpl - : public Resource, - public thunk::PPB_AudioConfig_API { - public: - virtual ~AudioConfigImpl(); - - static PP_Resource CreateAsImpl(PP_Instance instance, - PP_AudioSampleRate sample_rate, - uint32_t sample_frame_count); - static PP_Resource CreateAsProxy(PP_Instance instance, - PP_AudioSampleRate sample_rate, - uint32_t sample_frame_count); - - // Resource overrides. - virtual thunk::PPB_AudioConfig_API* AsPPB_AudioConfig_API() OVERRIDE; - - // PPB_AudioConfig_API implementation. - virtual PP_AudioSampleRate GetSampleRate() OVERRIDE; - virtual uint32_t GetSampleFrameCount() OVERRIDE; - - private: - // You must call Init before using this object. - explicit AudioConfigImpl(PP_Instance instance); // Impl c'tor. - explicit AudioConfigImpl(const HostResource& host_resource); // Proxy c'tor. - - // Returns false if the arguments are invalid, the object should not be - // used in this case. - bool Init(PP_AudioSampleRate sample_rate, uint32_t sample_frame_count); - - PP_AudioSampleRate sample_rate_; - uint32_t sample_frame_count_; - - DISALLOW_COPY_AND_ASSIGN(AudioConfigImpl); -}; - -} // namespace ppapi - -#endif // PPAPI_SHARED_IMPL_AUDIO_CONFIG_IMPL_H_ diff --git a/ppapi/shared_impl/audio_impl.cc b/ppapi/shared_impl/audio_impl.cc deleted file mode 100644 index b684ab1..0000000 --- a/ppapi/shared_impl/audio_impl.cc +++ /dev/null @@ -1,92 +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/shared_impl/audio_impl.h" - -#include "base/logging.h" - -namespace ppapi { - -AudioImpl::AudioImpl() - : playing_(false), - shared_memory_size_(0), - callback_(NULL), - user_data_(NULL) { -} - -AudioImpl::~AudioImpl() { - // Closing the socket causes the thread to exit - wait for it. - if (socket_.get()) - socket_->Close(); - if (audio_thread_.get()) { - audio_thread_->Join(); - audio_thread_.reset(); - } -} - -void AudioImpl::SetCallback(PPB_Audio_Callback callback, void* user_data) { - callback_ = callback; - user_data_ = user_data; -} - -void AudioImpl::SetStartPlaybackState() { - DCHECK(!playing_); - DCHECK(!audio_thread_.get()); - - // If the socket doesn't exist, that means that the plugin has started before - // the browser has had a chance to create all the shared memory info and - // notify us. This is a common case. In this case, we just set the playing_ - // flag and the playback will automatically start when that data is available - // in SetStreamInfo. - if (callback_ && socket_.get()) - StartThread(); - playing_ = true; -} - -void AudioImpl::SetStopPlaybackState() { - DCHECK(playing_); - - if (audio_thread_.get()) { - audio_thread_->Join(); - audio_thread_.reset(); - } - playing_ = false; -} - -void AudioImpl::SetStreamInfo(base::SharedMemoryHandle shared_memory_handle, - size_t shared_memory_size, - base::SyncSocket::Handle socket_handle) { - socket_.reset(new base::SyncSocket(socket_handle)); - shared_memory_.reset(new base::SharedMemory(shared_memory_handle, false)); - shared_memory_size_ = shared_memory_size; - - if (callback_) { - shared_memory_->Map(shared_memory_size_); - - // In common case StartPlayback() was called before StreamCreated(). - if (playing_) - StartThread(); - } -} - -void AudioImpl::StartThread() { - DCHECK(callback_); - DCHECK(!audio_thread_.get()); - audio_thread_.reset(new base::DelegateSimpleThread( - this, "plugin_audio_thread")); - audio_thread_->Start(); -} - -void AudioImpl::Run() { - int pending_data; - void* buffer = shared_memory_->memory(); - - while (sizeof(pending_data) == - socket_->Receive(&pending_data, sizeof(pending_data)) && - pending_data >= 0) { - callback_(buffer, shared_memory_size_, user_data_); - } -} - -} // namespace ppapi diff --git a/ppapi/shared_impl/audio_impl.h b/ppapi/shared_impl/audio_impl.h deleted file mode 100644 index 201582d..0000000 --- a/ppapi/shared_impl/audio_impl.h +++ /dev/null @@ -1,87 +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_SHARED_IMPL_AUDIO_IMPL_H_ -#define PPAPI_SHARED_IMPL_AUDIO_IMPL_H_ - -#include "base/memory/scoped_ptr.h" -#include "base/shared_memory.h" -#include "base/sync_socket.h" -#include "base/threading/simple_thread.h" -#include "ppapi/c/ppb_audio.h" -#include "ppapi/shared_impl/resource.h" -#include "ppapi/thunk/ppb_audio_api.h" - -namespace ppapi { - -// Implements the logic to map shared memory and run the audio thread signaled -// from the sync socket. Both the proxy and the renderer implementation use -// this code. -class PPAPI_SHARED_EXPORT AudioImpl - : public thunk::PPB_Audio_API, - public base::DelegateSimpleThread::Delegate { - public: - AudioImpl(); - virtual ~AudioImpl(); - - bool playing() const { return playing_; } - - // Sets the callback information that the background thread will use. This - // is optional. Without a callback, the thread will not be run. This - // non-callback mode is used in the renderer with the proxy, since the proxy - // handles the callback entirely within the plugin process. - void SetCallback(PPB_Audio_Callback callback, void* user_data); - - // Configures the current state to be playing or not. The caller is - // responsible for ensuring the new state is the opposite of the current one. - // - // This is the implementation for PPB_Audio.Start/StopPlayback, except that - // it does not actually notify the audio system to stop playback, it just - // configures our object to stop generating callbacks. The actual stop - // playback request will be done in the derived classes and will be different - // from the proxy and the renderer. - void SetStartPlaybackState(); - void SetStopPlaybackState(); - - // Sets the shared memory and socket handles. This will automatically start - // playback if we're currently set to play. - void SetStreamInfo(base::SharedMemoryHandle shared_memory_handle, - size_t shared_memory_size, - base::SyncSocket::Handle socket_handle); - - private: - // Starts execution of the audio thread. - void StartThread(); - - // DelegateSimpleThread::Delegate implementation. Run on the audio thread. - virtual void Run(); - - // True if playing the stream. - bool playing_; - - // Socket used to notify us when audio is ready to accept new samples. This - // pointer is created in StreamCreated(). - scoped_ptr socket_; - - // Sample buffer in shared memory. This pointer is created in - // StreamCreated(). The memory is only mapped when the audio thread is - // created. - scoped_ptr shared_memory_; - - // The size of the sample buffer in bytes. - size_t shared_memory_size_; - - // When the callback is set, this thread is spawned for calling it. - scoped_ptr audio_thread_; - - // Callback to call when audio is ready to accept new samples. - PPB_Audio_Callback callback_; - - // User data pointer passed verbatim to the callback function. - void* user_data_; -}; - -} // namespace ppapi - -#endif // PPAPI_SHARED_IMPL_AUDIO_IMPL_H_ diff --git a/ppapi/shared_impl/audio_input_impl.cc b/ppapi/shared_impl/audio_input_impl.cc deleted file mode 100644 index 659cd47..0000000 --- a/ppapi/shared_impl/audio_input_impl.cc +++ /dev/null @@ -1,94 +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/shared_impl/audio_input_impl.h" - -#include "base/logging.h" - -namespace ppapi { - -AudioInputImpl::AudioInputImpl() - : capturing_(false), - shared_memory_size_(0), - callback_(NULL), - user_data_(NULL) { -} - -AudioInputImpl::~AudioInputImpl() { - // Closing the socket causes the thread to exit - wait for it. - if (socket_.get()) - socket_->Close(); - if (audio_input_thread_.get()) { - audio_input_thread_->Join(); - audio_input_thread_.reset(); - } -} - -void AudioInputImpl::SetCallback(PPB_AudioInput_Callback callback, - void* user_data) { - callback_ = callback; - user_data_ = user_data; -} - -void AudioInputImpl::SetStartCaptureState() { - DCHECK(!capturing_); - DCHECK(!audio_input_thread_.get()); - - // If the socket doesn't exist, that means that the plugin has started before - // the browser has had a chance to create all the shared memory info and - // notify us. This is a common case. In this case, we just set the playing_ - // flag and the capture will automatically start when that data is available - // in SetStreamInfo. - if (socket_.get()) - StartThread(); - capturing_ = true; -} - -void AudioInputImpl::SetStopCaptureState() { - DCHECK(capturing_); - - if (audio_input_thread_.get()) { - audio_input_thread_->Join(); - audio_input_thread_.reset(); - } - capturing_ = false; -} - -void AudioInputImpl::SetStreamInfo( - base::SharedMemoryHandle shared_memory_handle, - size_t shared_memory_size, - base::SyncSocket::Handle socket_handle) { - socket_.reset(new base::SyncSocket(socket_handle)); - shared_memory_.reset(new base::SharedMemory(shared_memory_handle, false)); - shared_memory_size_ = shared_memory_size; - - if (callback_) { - shared_memory_->Map(shared_memory_size_); - - // In common case StartCapture() was called before StreamCreated(). - if (capturing_) - StartThread(); - } -} - -void AudioInputImpl::StartThread() { - DCHECK(callback_); - DCHECK(!audio_input_thread_.get()); - audio_input_thread_.reset(new base::DelegateSimpleThread( - this, "plugin_audio_input_thread")); - audio_input_thread_->Start(); -} - -void AudioInputImpl::Run() { - int pending_data; - void* buffer = shared_memory_->memory(); - - while (sizeof(pending_data) == socket_->Receive(&pending_data, - sizeof(pending_data)) && - pending_data >= 0) { - callback_(buffer, shared_memory_size_, user_data_); - } -} - -} // namespace ppapi diff --git a/ppapi/shared_impl/audio_input_impl.h b/ppapi/shared_impl/audio_input_impl.h deleted file mode 100644 index e7604c3..0000000 --- a/ppapi/shared_impl/audio_input_impl.h +++ /dev/null @@ -1,88 +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_SHARED_IMPL_AUDIO_INPUT_IMPL_H_ -#define PPAPI_SHARED_IMPL_AUDIO_INPUT_IMPL_H_ - -#include "base/memory/scoped_ptr.h" -#include "base/shared_memory.h" -#include "base/sync_socket.h" -#include "base/threading/simple_thread.h" -#include "ppapi/c/dev/ppb_audio_input_dev.h" -#include "ppapi/shared_impl/resource.h" -#include "ppapi/thunk/ppb_audio_input_api.h" - -namespace ppapi { - -// Implements the logic to map shared memory and run the audio thread signaled -// from the sync socket. Both the proxy and the renderer implementation use -// this code. -class PPAPI_SHARED_EXPORT AudioInputImpl - : public thunk::PPB_AudioInput_API, - public base::DelegateSimpleThread::Delegate { - public: - AudioInputImpl(); - virtual ~AudioInputImpl(); - - bool capturing() const { return capturing_; } - - // Sets the callback information that the background thread will use. This - // is optional. Without a callback, the thread will not be run. This - // non-callback mode is used in the renderer with the proxy, since the proxy - // handles the callback entirely within the plugin process. - void SetCallback(PPB_AudioInput_Callback callback, void* user_data); - - // Configures the current state to be playing or not. The caller is - // responsible for ensuring the new state is the opposite of the current one. - // - // This is the implementation for PPB_AudioInput.Start/StopCapture, except - // that it does not actually notify the audio system to stop capture, it just - // configures our object to stop generating callbacks. The actual stop - // playback request will be done in the derived classes and will be different - // from the proxy and the renderer. - void SetStartCaptureState(); - void SetStopCaptureState(); - - // Sets the shared memory and socket handles. This will automatically start - // playback if we're currently set to play. - void SetStreamInfo(base::SharedMemoryHandle shared_memory_handle, - size_t shared_memory_size, - base::SyncSocket::Handle socket_handle); - - private: - // Starts execution of the audio input thread. - void StartThread(); - - // DelegateSimpleThread::Delegate implementation. - // Run on the audio input thread. - virtual void Run(); - - // True if capturing the stream. - bool capturing_; - - // Socket used to notify us when audio is ready to accept new samples. This - // pointer is created in StreamCreated(). - scoped_ptr socket_; - - // Sample buffer in shared memory. This pointer is created in - // StreamCreated(). The memory is only mapped when the audio thread is - // created. - scoped_ptr shared_memory_; - - // The size of the sample buffer in bytes. - size_t shared_memory_size_; - - // When the callback is set, this thread is spawned for calling it. - scoped_ptr audio_input_thread_; - - // Callback to call when audio is ready to produce new samples. - PPB_AudioInput_Callback callback_; - - // User data pointer passed verbatim to the callback function. - void* user_data_; -}; - -} // namespace ppapi - -#endif // PPAPI_SHARED_IMPL_AUDIO_INPUT_IMPL_H_ diff --git a/ppapi/shared_impl/char_set_impl.cc b/ppapi/shared_impl/char_set_impl.cc deleted file mode 100644 index c18d4c7..0000000 --- a/ppapi/shared_impl/char_set_impl.cc +++ /dev/null @@ -1,152 +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/shared_impl/char_set_impl.h" - -#include "base/i18n/icu_string_conversions.h" -#include "ppapi/c/dev/ppb_memory_dev.h" -#include "ppapi/thunk/thunk.h" -#include "unicode/ucnv.h" -#include "unicode/ucnv_cb.h" -#include "unicode/ucnv_err.h" -#include "unicode/ustring.h" - -namespace ppapi { - -namespace { - -// Converts the given PP error handling behavior to the version in base, -// placing the result in |*result| and returning true on success. Returns false -// if the enum is invalid. -bool PPToBaseConversionError(PP_CharSet_ConversionError on_error, - base::OnStringConversionError::Type* result) { - switch (on_error) { - case PP_CHARSET_CONVERSIONERROR_FAIL: - *result = base::OnStringConversionError::FAIL; - return true; - case PP_CHARSET_CONVERSIONERROR_SKIP: - *result = base::OnStringConversionError::SKIP; - return true; - case PP_CHARSET_CONVERSIONERROR_SUBSTITUTE: - *result = base::OnStringConversionError::SUBSTITUTE; - return true; - default: - return false; - } -} - -} // namespace - -// static -// The "substitution" behavior of this function does not match the -// implementation in base, so we partially duplicate the code from -// icu_string_conversions.cc with the correct error handling setup required -// by the PPAPI interface. -char* CharSetImpl::UTF16ToCharSet(const uint16_t* utf16, - uint32_t utf16_len, - const char* output_char_set, - PP_CharSet_ConversionError on_error, - uint32_t* output_length) { - if (!utf16 || !output_char_set || !output_length) - return NULL; - - *output_length = 0; - - UErrorCode status = U_ZERO_ERROR; - UConverter* converter = ucnv_open(output_char_set, &status); - if (!U_SUCCESS(status)) - return NULL; - - int encoded_max_length = UCNV_GET_MAX_BYTES_FOR_STRING(utf16_len, - ucnv_getMaxCharSize(converter)); - - // Setup our error handler. - switch (on_error) { - case PP_CHARSET_CONVERSIONERROR_FAIL: - ucnv_setFromUCallBack(converter, UCNV_FROM_U_CALLBACK_STOP, 0, - NULL, NULL, &status); - break; - case PP_CHARSET_CONVERSIONERROR_SKIP: - ucnv_setFromUCallBack(converter, UCNV_FROM_U_CALLBACK_SKIP, 0, - NULL, NULL, &status); - break; - case PP_CHARSET_CONVERSIONERROR_SUBSTITUTE: { - // ICU sets the substitution char for some character sets (like latin1) - // to be the ASCII "substitution character" (26). We want to use '?' - // instead for backwards-compat with Windows behavior. - char subst_chars[32]; - int8_t subst_chars_len = 32; - ucnv_getSubstChars(converter, subst_chars, &subst_chars_len, &status); - if (subst_chars_len == 1 && subst_chars[0] == 26) { - // Override to the question mark character if possible. When using - // setSubstString, the input is a Unicode character. The function will - // try to convert it to the destination character set and fail if that - // can not be converted to the destination character set. - // - // We just ignore any failure. If the dest char set has no - // representation for '?', then we'll just stick to the ICU default - // substitution character. - UErrorCode subst_status = U_ZERO_ERROR; - UChar question_mark = '?'; - ucnv_setSubstString(converter, &question_mark, 1, &subst_status); - } - - ucnv_setFromUCallBack(converter, UCNV_FROM_U_CALLBACK_SUBSTITUTE, 0, - NULL, NULL, &status); - break; - } - default: - return NULL; - } - - // ucnv_fromUChars returns size not including terminating null. - char* encoded = static_cast( - thunk::GetPPB_Memory_Dev_Thunk()->MemAlloc(encoded_max_length + 1)); - int actual_size = ucnv_fromUChars(converter, encoded, - encoded_max_length, reinterpret_cast(utf16), utf16_len, - &status); - ucnv_close(converter); - if (!U_SUCCESS(status)) { - thunk::GetPPB_Memory_Dev_Thunk()->MemFree(encoded); - return NULL; - } - encoded[actual_size] = 0; - *output_length = actual_size; - return encoded; -} - -// static -uint16_t* CharSetImpl::CharSetToUTF16(const char* input, - uint32_t input_len, - const char* input_char_set, - PP_CharSet_ConversionError on_error, - uint32_t* output_length) { - if (!input || !input_char_set || !output_length) - return NULL; - - *output_length = 0; - - base::OnStringConversionError::Type base_on_error; - if (!PPToBaseConversionError(on_error, &base_on_error)) - return NULL; // Invalid enum value. - - // We can convert this call to the implementation in base to avoid code - // duplication, although this does introduce an extra copy of the data. - string16 output; - if (!base::CodepageToUTF16(std::string(input, input_len), input_char_set, - base_on_error, &output)) - return NULL; - - uint16_t* ret_buf = static_cast( - thunk::GetPPB_Memory_Dev_Thunk()->MemAlloc( - (output.size() + 1) * sizeof(uint16_t))); - if (!ret_buf) - return NULL; - - *output_length = static_cast(output.size()); - memcpy(ret_buf, output.c_str(), (output.size() + 1) * sizeof(uint16_t)); - return ret_buf; -} - -} // namespace ppapi diff --git a/ppapi/shared_impl/char_set_impl.h b/ppapi/shared_impl/char_set_impl.h deleted file mode 100644 index e6f5c10..0000000 --- a/ppapi/shared_impl/char_set_impl.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_SHARED_IMPL_CHAR_SET_IMPL_H_ -#define PPAPI_SHARED_IMPL_CHAR_SET_IMPL_H_ - -#include "base/basictypes.h" -#include "ppapi/c/dev/ppb_char_set_dev.h" -#include "ppapi/shared_impl/ppapi_shared_export.h" - -namespace ppapi { - -// Contains the implementation of character set conversion that is shared -// between the proxy and the renderer. -class PPAPI_SHARED_EXPORT CharSetImpl { - public: - static char* UTF16ToCharSet(const uint16_t* utf16, - uint32_t utf16_len, - const char* output_char_set, - PP_CharSet_ConversionError on_error, - uint32_t* output_length); - - static uint16_t* CharSetToUTF16(const char* input, - uint32_t input_len, - const char* input_char_set, - PP_CharSet_ConversionError on_error, - uint32_t* output_length); -}; - -} // namespace ppapi - -#endif // PPAPI_SHARED_IMPL_CHAR_SET_IMPL_H_ diff --git a/ppapi/shared_impl/crypto_impl.cc b/ppapi/shared_impl/crypto_impl.cc deleted file mode 100644 index 42694d0..0000000 --- a/ppapi/shared_impl/crypto_impl.cc +++ /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. - -#include "base/rand_util.h" -#include "ppapi/c/dev/ppb_crypto_dev.h" -#include "ppapi/thunk/thunk.h" - -// The crypto interface doesn't have a normal C -> C++ thunk since it doesn't -// actually have any proxy wrapping or associated objects; it's just a call -// into base. So we implement the entire interface here, using the thunk -// namespace so it magically gets hooked up in the proper places. - -namespace ppapi { - -namespace { - -void GetRandomBytes(char* buffer, uint32_t num_bytes) { - base::RandBytes(buffer, num_bytes); -} - -const PPB_Crypto_Dev crypto_interface = { - &GetRandomBytes -}; - -} // namespace - -namespace thunk { - -PPAPI_THUNK_EXPORT const PPB_Crypto_Dev* GetPPB_Crypto_Dev_Thunk() { - return &crypto_interface; -} - -} // namespace thunk - -} // namespace ppapi diff --git a/ppapi/shared_impl/file_ref_impl.cc b/ppapi/shared_impl/file_ref_impl.cc deleted file mode 100644 index 274d944..0000000 --- a/ppapi/shared_impl/file_ref_impl.cc +++ /dev/null @@ -1,65 +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/shared_impl/file_ref_impl.h" - -#include "base/logging.h" -#include "ppapi/shared_impl/ppapi_globals.h" -#include "ppapi/shared_impl/var.h" - -namespace ppapi { - -FileRefImpl::FileRefImpl(const InitAsImpl&, const PPB_FileRef_CreateInfo& info) - : Resource(info.resource.instance()), - create_info_(info) { - // Should not have been passed a host resource for the trusted constructor. - DCHECK(info.resource.is_null()); - - // Resource's constructor assigned a PP_Resource, so we can fill out our - // host resource now. - create_info_.resource = host_resource(); - DCHECK(!create_info_.resource.is_null()); -} - -FileRefImpl::FileRefImpl(const InitAsProxy&, const PPB_FileRef_CreateInfo& info) - : Resource(info.resource), - create_info_(info) { -} - -FileRefImpl::~FileRefImpl() { -} - -thunk::PPB_FileRef_API* FileRefImpl::AsPPB_FileRef_API() { - return this; -} - -PP_FileSystemType FileRefImpl::GetFileSystemType() const { - return static_cast(create_info_.file_system_type); -} - -PP_Var FileRefImpl::GetName() const { - if (!name_var_.get()) { - name_var_ = new StringVar( - PpapiGlobals::Get()->GetModuleForInstance(pp_instance()), - create_info_.name); - } - return name_var_->GetPPVar(); -} - -PP_Var FileRefImpl::GetPath() const { - if (create_info_.file_system_type == PP_FILESYSTEMTYPE_EXTERNAL) - return PP_MakeUndefined(); - if (!path_var_.get()) { - path_var_ = new StringVar( - PpapiGlobals::Get()->GetModuleForInstance(pp_instance()), - create_info_.path); - } - return path_var_->GetPPVar(); -} - -const PPB_FileRef_CreateInfo& FileRefImpl::GetCreateInfo() const { - return create_info_; -} - -} // namespace ppapi diff --git a/ppapi/shared_impl/file_ref_impl.h b/ppapi/shared_impl/file_ref_impl.h deleted file mode 100644 index 58ee0fe..0000000 --- a/ppapi/shared_impl/file_ref_impl.h +++ /dev/null @@ -1,65 +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_SHARED_IMPL_FILE_REF_IMPL_H_ -#define PPAPI_SHARED_IMPL_FILE_REF_IMPL_H_ - -#include - -#include "base/compiler_specific.h" -#include "ppapi/shared_impl/resource.h" -#include "ppapi/thunk/ppb_file_ref_api.h" - -namespace ppapi { - -class StringVar; - -// FileRefs are created in a number of places and they include a number of -// return values. This struct encapsulates everything in one place. -struct PPB_FileRef_CreateInfo { - PPB_FileRef_CreateInfo() : file_system_type(PP_FILESYSTEMTYPE_EXTERNAL) {} - - ppapi::HostResource resource; - int file_system_type; // One of PP_FileSystemType values. - std::string path; - std::string name; -}; - -// This class provides the shared implementation of a FileRef. The functions -// that actually "do stuff" like Touch and MakeDirectory are implemented -// differently for the proxied and non-proxied derived classes. -class PPAPI_SHARED_EXPORT FileRefImpl : public Resource, - public thunk::PPB_FileRef_API { - public: - struct InitAsImpl {}; - struct InitAsProxy {}; - - FileRefImpl(const InitAsImpl&, const PPB_FileRef_CreateInfo& info); - FileRefImpl(const InitAsProxy&, const PPB_FileRef_CreateInfo& info); - virtual ~FileRefImpl(); - - // Resource overrides. - virtual thunk::PPB_FileRef_API* AsPPB_FileRef_API() OVERRIDE; - - // PPB_FileRef_API implementation (partial). - virtual PP_FileSystemType GetFileSystemType() const OVERRIDE; - virtual PP_Var GetName() const OVERRIDE; - virtual PP_Var GetPath() const OVERRIDE; - virtual const PPB_FileRef_CreateInfo& GetCreateInfo() const OVERRIDE; - virtual PP_Var GetAbsolutePath() = 0; - - private: - PPB_FileRef_CreateInfo create_info_; - - // Lazily initialized vars created from the create_info_. This is so we can - // return the identical string object every time they're requested. - mutable scoped_refptr name_var_; - mutable scoped_refptr path_var_; - - DISALLOW_IMPLICIT_CONSTRUCTORS(FileRefImpl); -}; - -} // namespace ppapi - -#endif // PPAPI_SHARED_IMPL_FILE_REF_IMPL_H_ diff --git a/ppapi/shared_impl/font_impl.cc b/ppapi/shared_impl/font_impl.cc deleted file mode 100644 index 66ac5a6..0000000 --- a/ppapi/shared_impl/font_impl.cc +++ /dev/null @@ -1,34 +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/shared_impl/font_impl.h" - -#include "ppapi/c/dev/ppb_font_dev.h" - -namespace ppapi { - -// static -bool FontImpl::IsPPFontDescriptionValid(const PP_FontDescription_Dev& desc) { - // Check validity of string. We can't check the actual text since we could - // be on the wrong thread and don't know if we're in the plugin or the host. - if (desc.face.type != PP_VARTYPE_STRING && - desc.face.type != PP_VARTYPE_UNDEFINED) - return false; - - // Check enum ranges. - if (static_cast(desc.family) < PP_FONTFAMILY_DEFAULT || - static_cast(desc.family) > PP_FONTFAMILY_MONOSPACE) - return false; - if (static_cast(desc.weight) < PP_FONTWEIGHT_100 || - static_cast(desc.weight) > PP_FONTWEIGHT_900) - return false; - - // Check for excessive sizes which may cause layout to get confused. - if (desc.size > 200) - return false; - - return true; -} - -} // namespace ppapi diff --git a/ppapi/shared_impl/font_impl.h b/ppapi/shared_impl/font_impl.h deleted file mode 100644 index a8ab2df..0000000 --- a/ppapi/shared_impl/font_impl.h +++ /dev/null @@ -1,32 +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_SHARED_IMPL_FONT_IMPL_H_ -#define PPAPI_SHARED_IMPL_FONT_IMPL_H_ -#pragma once - -#include - -#include "base/basictypes.h" -#include "base/memory/scoped_ptr.h" -#include "ppapi/c/pp_bool.h" -#include "ppapi/c/pp_stdint.h" -#include "ppapi/shared_impl/ppapi_shared_export.h" - -struct PP_FontDescription_Dev; - -namespace ppapi { - -class PPAPI_SHARED_EXPORT FontImpl { - public: - // Validates the parameters in thee description. Can be called on any thread. - static bool IsPPFontDescriptionValid(const PP_FontDescription_Dev& desc); - - private: - DISALLOW_COPY_AND_ASSIGN(FontImpl); -}; - -} // namespace ppapi - -#endif // PPAPI_SHARED_IMPL_FONT_IMPL_H_ diff --git a/ppapi/shared_impl/graphics_3d_impl.cc b/ppapi/shared_impl/graphics_3d_impl.cc deleted file mode 100644 index 00555de..0000000 --- a/ppapi/shared_impl/graphics_3d_impl.cc +++ /dev/null @@ -1,137 +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/shared_impl/graphics_3d_impl.h" - -#include "base/logging.h" -#include "gpu/command_buffer/client/gles2_cmd_helper.h" -#include "gpu/command_buffer/client/gles2_implementation.h" -#include "ppapi/c/pp_errors.h" - -namespace ppapi { - -Graphics3DImpl::Graphics3DImpl() - : transfer_buffer_id_(-1), - swap_callback_(PP_BlockUntilComplete()) { -} - -Graphics3DImpl::~Graphics3DImpl() { - // Make sure that GLES2 implementation has already been destroyed. - DCHECK_EQ(transfer_buffer_id_, -1); - DCHECK(!gles2_helper_.get()); - DCHECK(!gles2_impl_.get()); -} - -int32_t Graphics3DImpl::GetAttribs(int32_t* attrib_list) { - // TODO(alokp): Implement me. - return PP_ERROR_FAILED; -} - -int32_t Graphics3DImpl::SetAttribs(int32_t* attrib_list) { - // TODO(alokp): Implement me. - return PP_ERROR_FAILED; -} - -int32_t Graphics3DImpl::GetError() { - // TODO(alokp): Implement me. - return PP_ERROR_FAILED; -} - -int32_t Graphics3DImpl::ResizeBuffers(int32_t width, int32_t height) { - if ((width < 0) || (height < 0)) - return PP_ERROR_BADARGUMENT; - - gles2_impl()->ResizeCHROMIUM(width, height); - // TODO(alokp): Check if resize succeeded and return appropriate error code. - return PP_OK; -} - -int32_t Graphics3DImpl::SwapBuffers(PP_CompletionCallback callback) { - if (!callback.func) { - // Blocking SwapBuffers isn't supported (since we have to be on the main - // thread). - return PP_ERROR_BADARGUMENT; - } - - if (HasPendingSwap()) { - // Already a pending SwapBuffers that hasn't returned yet. - return PP_ERROR_INPROGRESS; - } - - swap_callback_ = callback; - return DoSwapBuffers(); -} - -void* Graphics3DImpl::MapTexSubImage2DCHROMIUM(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLenum access) { - return gles2_impl_->MapTexSubImage2DCHROMIUM( - target, level, xoffset, yoffset, width, height, format, type, access); -} - -void Graphics3DImpl::UnmapTexSubImage2DCHROMIUM(const void* mem) { - gles2_impl_->UnmapTexSubImage2DCHROMIUM(mem); -} - -void Graphics3DImpl::SwapBuffersACK(int32_t pp_error) { - DCHECK(HasPendingSwap()); - PP_RunAndClearCompletionCallback(&swap_callback_, pp_error); -} - -bool Graphics3DImpl::CreateGLES2Impl(int32 command_buffer_size, - int32 transfer_buffer_size) { - gpu::CommandBuffer* command_buffer = GetCommandBuffer(); - DCHECK(command_buffer); - - // Create the GLES2 helper, which writes the command buffer protocol. - gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer)); - if (!gles2_helper_->Initialize(command_buffer_size)) - return false; - - // Create a transfer buffer used to copy resources between the renderer - // process and the GPU process. - transfer_buffer_id_ = - command_buffer->CreateTransferBuffer(transfer_buffer_size, -1); - if (transfer_buffer_id_ < 0) - return false; - - // Map the buffer into the renderer process's address space. - gpu::Buffer transfer_buffer = - command_buffer->GetTransferBuffer(transfer_buffer_id_); - if (!transfer_buffer.ptr) - return false; - - // Create the object exposing the OpenGL API. - gles2_impl_.reset(new gpu::gles2::GLES2Implementation( - gles2_helper_.get(), - transfer_buffer.size, - transfer_buffer.ptr, - transfer_buffer_id_, - false, - true)); - - return true; -} - -void Graphics3DImpl::DestroyGLES2Impl() { - gles2_impl_.reset(); - - if (transfer_buffer_id_ != -1) { - gpu::CommandBuffer* command_buffer = GetCommandBuffer(); - DCHECK(command_buffer); - command_buffer->DestroyTransferBuffer(transfer_buffer_id_); - transfer_buffer_id_ = -1; - } - - gles2_helper_.reset(); -} - -} // namespace ppapi - diff --git a/ppapi/shared_impl/graphics_3d_impl.h b/ppapi/shared_impl/graphics_3d_impl.h deleted file mode 100644 index 07fe967..0000000 --- a/ppapi/shared_impl/graphics_3d_impl.h +++ /dev/null @@ -1,76 +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_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ -#define PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ - -#include "base/basictypes.h" -#include "base/memory/scoped_ptr.h" -#include "ppapi/c/pp_completion_callback.h" -#include "ppapi/shared_impl/ppapi_shared_export.h" -#include "ppapi/thunk/ppb_graphics_3d_api.h" - -namespace gpu { -class CommandBuffer; -namespace gles2 { -class GLES2CmdHelper; -class GLES2Implementation; -} // namespace gles2 -} // namespace gpu. - -namespace ppapi { - -class PPAPI_SHARED_EXPORT Graphics3DImpl : public thunk::PPB_Graphics3D_API { - public: - // PPB_Graphics3D_API implementation. - virtual int32_t GetAttribs(int32_t* attrib_list) OVERRIDE; - virtual int32_t SetAttribs(int32_t* attrib_list) OVERRIDE; - virtual int32_t GetError() OVERRIDE; - virtual int32_t ResizeBuffers(int32_t width, int32_t height) OVERRIDE; - virtual int32_t SwapBuffers(PP_CompletionCallback callback) OVERRIDE; - virtual void* MapTexSubImage2DCHROMIUM(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLenum access) OVERRIDE; - virtual void UnmapTexSubImage2DCHROMIUM(const void* mem) OVERRIDE; - - gpu::gles2::GLES2Implementation* gles2_impl() { - return gles2_impl_.get(); - } - - // Sends swap-buffers notification to the plugin. - void SwapBuffersACK(int32_t pp_error); - - protected: - Graphics3DImpl(); - virtual ~Graphics3DImpl(); - - virtual gpu::CommandBuffer* GetCommandBuffer() = 0; - virtual int32 DoSwapBuffers() = 0; - - bool HasPendingSwap() { return swap_callback_.func != NULL; } - bool CreateGLES2Impl(int32 command_buffer_size, - int32 transfer_buffer_size); - void DestroyGLES2Impl(); - - private: - int32 transfer_buffer_id_; - scoped_ptr gles2_helper_; - scoped_ptr gles2_impl_; - - // Callback that needs to be executed when swap-buffers is completed. - PP_CompletionCallback swap_callback_; - - DISALLOW_COPY_AND_ASSIGN(Graphics3DImpl); -}; - -} // namespace ppapi - -#endif // PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ - diff --git a/ppapi/shared_impl/image_data_impl.cc b/ppapi/shared_impl/image_data_impl.cc deleted file mode 100644 index e07d2cb..0000000 --- a/ppapi/shared_impl/image_data_impl.cc +++ /dev/null @@ -1,27 +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/shared_impl/image_data_impl.h" - -#include "third_party/skia/include/core/SkTypes.h" - -namespace ppapi { - -// static -PP_ImageDataFormat ImageDataImpl::GetNativeImageDataFormat() { - if (SK_B32_SHIFT == 0) - return PP_IMAGEDATAFORMAT_BGRA_PREMUL; - else if (SK_R32_SHIFT == 0) - return PP_IMAGEDATAFORMAT_RGBA_PREMUL; - else - return PP_IMAGEDATAFORMAT_BGRA_PREMUL; // Default to something on failure. -} - -// static -bool ImageDataImpl::IsImageDataFormatSupported(PP_ImageDataFormat format) { - return format == PP_IMAGEDATAFORMAT_BGRA_PREMUL || - format == PP_IMAGEDATAFORMAT_RGBA_PREMUL; -} - -} // namespace ppapi diff --git a/ppapi/shared_impl/image_data_impl.h b/ppapi/shared_impl/image_data_impl.h deleted file mode 100644 index f931c78..0000000 --- a/ppapi/shared_impl/image_data_impl.h +++ /dev/null @@ -1,31 +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_SHARED_IMPL_IMAGE_DATA_IMPL_H_ -#define PPAPI_SHARED_IMPL_IMAGE_DATA_IMPL_H_ - -#include "ppapi/c/pp_bool.h" -#include "ppapi/c/ppb_image_data.h" -#include "ppapi/shared_impl/ppapi_shared_export.h" - -namespace ppapi { - -// Contains the implementation of some simple image data functions that are -// shared between the proxy and Chrome's implementation. Since these functions -// are just lists of what we support, it's much easier to just have the same -// code run in the plugin process than to proxy it. -// -// It's possible the implementation will get more complex. In this case, it's -// probably best to have some kind of "configuration" message that the renderer -// sends to the plugin process on startup that contains all of these kind of -// settings. -class PPAPI_SHARED_EXPORT ImageDataImpl { - public: - static PP_ImageDataFormat GetNativeImageDataFormat(); - static bool IsImageDataFormatSupported(PP_ImageDataFormat format); -}; - -} // namespace ppapi - -#endif // PPAPI_SHARED_IMPL_IMAGE_DATA_IMPL_H_ diff --git a/ppapi/shared_impl/input_event_impl.cc b/ppapi/shared_impl/input_event_impl.cc deleted file mode 100644 index d502a62..0000000 --- a/ppapi/shared_impl/input_event_impl.cc +++ /dev/null @@ -1,131 +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/shared_impl/input_event_impl.h" - -#include "ppapi/shared_impl/ppapi_globals.h" -#include "ppapi/shared_impl/var.h" - -using ppapi::thunk::PPB_InputEvent_API; - -namespace ppapi { - -InputEventData::InputEventData() - : is_filtered(false), - event_type(PP_INPUTEVENT_TYPE_UNDEFINED), - event_time_stamp(0.0), - event_modifiers(0), - mouse_button(PP_INPUTEVENT_MOUSEBUTTON_NONE), - mouse_position(PP_MakePoint(0, 0)), - mouse_click_count(0), - mouse_movement(PP_MakePoint(0, 0)), - wheel_delta(PP_MakeFloatPoint(0.0f, 0.0f)), - wheel_ticks(PP_MakeFloatPoint(0.0f, 0.0f)), - wheel_scroll_by_page(false), - key_code(0), - character_text(), - composition_target_segment(-1), - composition_selection_start(0), - composition_selection_end(0) { -} - -InputEventData::~InputEventData() { -} - -InputEventImpl::InputEventImpl(const InitAsImpl&, - PP_Instance instance, - const InputEventData& data) - : Resource(instance), - data_(data) { -} - -InputEventImpl::InputEventImpl(const InitAsProxy&, - PP_Instance instance, - const InputEventData& data) - : Resource(HostResource::MakeInstanceOnly(instance)), - data_(data) { -} - -PPB_InputEvent_API* InputEventImpl::AsPPB_InputEvent_API() { - return this; -} - -const InputEventData& InputEventImpl::GetInputEventData() const { - return data_; -} - -PP_InputEvent_Type InputEventImpl::GetType() { - return data_.event_type; -} - -PP_TimeTicks InputEventImpl::GetTimeStamp() { - return data_.event_time_stamp; -} - -uint32_t InputEventImpl::GetModifiers() { - return data_.event_modifiers; -} - -PP_InputEvent_MouseButton InputEventImpl::GetMouseButton() { - return data_.mouse_button; -} - -PP_Point InputEventImpl::GetMousePosition() { - return data_.mouse_position; -} - -int32_t InputEventImpl::GetMouseClickCount() { - return data_.mouse_click_count; -} - -PP_Point InputEventImpl::GetMouseMovement() { - return data_.mouse_movement; -} - -PP_FloatPoint InputEventImpl::GetWheelDelta() { - return data_.wheel_delta; -} - -PP_FloatPoint InputEventImpl::GetWheelTicks() { - return data_.wheel_ticks; -} - -PP_Bool InputEventImpl::GetWheelScrollByPage() { - return PP_FromBool(data_.wheel_scroll_by_page); -} - -uint32_t InputEventImpl::GetKeyCode() { - return data_.key_code; -} - -PP_Var InputEventImpl::GetCharacterText() { - return StringVar::StringToPPVar( - PpapiGlobals::Get()->GetModuleForInstance(pp_instance()), - data_.character_text); -} - -uint32_t InputEventImpl::GetIMESegmentNumber() { - if (data_.composition_segment_offsets.empty()) - return 0; - return data_.composition_segment_offsets.size() - 1; -} - -uint32_t InputEventImpl::GetIMESegmentOffset(uint32_t index) { - if (index >= data_.composition_segment_offsets.size()) - return 0; - return data_.composition_segment_offsets[index]; -} - -int32_t InputEventImpl::GetIMETargetSegment() { - return data_.composition_target_segment; -} - -void InputEventImpl::GetIMESelection(uint32_t* start, uint32_t* end) { - if (start) - *start = data_.composition_selection_start; - if (end) - *end = data_.composition_selection_end; -} - -} // namespace ppapi diff --git a/ppapi/shared_impl/input_event_impl.h b/ppapi/shared_impl/input_event_impl.h deleted file mode 100644 index 094eb8c..0000000 --- a/ppapi/shared_impl/input_event_impl.h +++ /dev/null @@ -1,100 +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_SHARED_IMPL_INPUT_EVENT_IMPL_H_ -#define PPAPI_SHARED_IMPL_INPUT_EVENT_IMPL_H_ - -#include -#include - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "ppapi/shared_impl/resource.h" -#include "ppapi/thunk/ppb_input_event_api.h" - -namespace ppapi { - -// IF YOU ADD STUFF TO THIS CLASS -// ============================== -// Be sure to add it to the STRUCT_TRAITS at the top of ppapi_messages.h -struct PPAPI_SHARED_EXPORT InputEventData { - InputEventData(); - ~InputEventData(); - - // Internal-only value. Set to true when this input event is filtered, that - // is, should be delivered synchronously. This is used by the proxy. - bool is_filtered; - - PP_InputEvent_Type event_type; - PP_TimeTicks event_time_stamp; - uint32_t event_modifiers; - - PP_InputEvent_MouseButton mouse_button; - PP_Point mouse_position; - int32_t mouse_click_count; - PP_Point mouse_movement; - - PP_FloatPoint wheel_delta; - PP_FloatPoint wheel_ticks; - bool wheel_scroll_by_page; - - uint32_t key_code; - - std::string character_text; - - std::vector composition_segment_offsets; - int32_t composition_target_segment; - uint32_t composition_selection_start; - uint32_t composition_selection_end; -}; - -// This simple class implements the PPB_InputEvent_API in terms of the -// shared InputEventData structure -class PPAPI_SHARED_EXPORT InputEventImpl - : public Resource, - public thunk::PPB_InputEvent_API { - public: - struct InitAsImpl {}; - struct InitAsProxy {}; - - // The dummy arguments control which version of Resource's constructor is - // called for this base class. - InputEventImpl(const InitAsImpl&, - PP_Instance instance, - const InputEventData& data); - InputEventImpl(const InitAsProxy&, - PP_Instance instance, - const InputEventData& data); - - // Resource overrides. - virtual PPB_InputEvent_API* AsPPB_InputEvent_API() OVERRIDE; - - // PPB_InputEvent_API implementation. - virtual const InputEventData& GetInputEventData() const OVERRIDE; - virtual PP_InputEvent_Type GetType() OVERRIDE; - virtual PP_TimeTicks GetTimeStamp() OVERRIDE; - virtual uint32_t GetModifiers() OVERRIDE; - virtual PP_InputEvent_MouseButton GetMouseButton() OVERRIDE; - virtual PP_Point GetMousePosition() OVERRIDE; - virtual int32_t GetMouseClickCount() OVERRIDE; - virtual PP_Point GetMouseMovement() OVERRIDE; - virtual PP_FloatPoint GetWheelDelta() OVERRIDE; - virtual PP_FloatPoint GetWheelTicks() OVERRIDE; - virtual PP_Bool GetWheelScrollByPage() OVERRIDE; - virtual uint32_t GetKeyCode() OVERRIDE; - virtual PP_Var GetCharacterText() OVERRIDE; - virtual uint32_t GetIMESegmentNumber() OVERRIDE; - virtual uint32_t GetIMESegmentOffset(uint32_t index) OVERRIDE; - virtual int32_t GetIMETargetSegment() OVERRIDE; - virtual void GetIMESelection(uint32_t* start, uint32_t* end) OVERRIDE; - - private: - InputEventData data_; - - DISALLOW_IMPLICIT_CONSTRUCTORS(InputEventImpl); -}; - -} // namespace ppapi - -#endif // PPAPI_SHARED_IMPL_INPUT_EVENT_IMPL_H_ diff --git a/ppapi/shared_impl/instance_impl.cc b/ppapi/shared_impl/instance_impl.cc deleted file mode 100644 index ad1674a..0000000 --- a/ppapi/shared_impl/instance_impl.cc +++ /dev/null @@ -1,30 +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/shared_impl/instance_impl.h" - -#include "ppapi/c/pp_errors.h" -#include "ppapi/c/ppb_input_event.h" - -namespace ppapi { - -InstanceImpl::~InstanceImpl() { -} - -int32_t InstanceImpl::ValidateRequestInputEvents(bool is_filtering, - uint32_t event_classes) { - // See if any bits are set we don't know about. - if (event_classes & - ~static_cast(PP_INPUTEVENT_CLASS_MOUSE | - PP_INPUTEVENT_CLASS_KEYBOARD | - PP_INPUTEVENT_CLASS_WHEEL | - PP_INPUTEVENT_CLASS_TOUCH | - PP_INPUTEVENT_CLASS_IME)) - return PP_ERROR_NOTSUPPORTED; - - // Everything else is valid. - return PP_OK; -} - -} // namespace ppapi diff --git a/ppapi/shared_impl/instance_impl.h b/ppapi/shared_impl/instance_impl.h deleted file mode 100644 index fdc741f..0000000 --- a/ppapi/shared_impl/instance_impl.h +++ /dev/null @@ -1,24 +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_SHARED_IMPL_INSTANCE_IMPL_H_ -#define PPAPI_SHARED_IMPL_INSTANCE_IMPL_H_ - -#include "ppapi/c/pp_stdint.h" -#include "ppapi/shared_impl/ppapi_shared_export.h" - -namespace ppapi { - -class PPAPI_SHARED_EXPORT InstanceImpl { - public: - virtual ~InstanceImpl(); - - // Error checks the given resquest to Request[Filtering]InputEvents. Returns - // PP_OK if the given classes are all valid, PP_ERROR_NOTSUPPORTED if not. - int32_t ValidateRequestInputEvents(bool is_filtering, uint32_t event_classes); -}; - -} // namespace ppapi - -#endif // PPAPI_SHARED_IMPL_INSTANCE_IMPL_H_ diff --git a/ppapi/shared_impl/memory_impl.cc b/ppapi/shared_impl/memory_impl.cc deleted file mode 100644 index 2cf8aa7..0000000 --- a/ppapi/shared_impl/memory_impl.cc +++ /dev/null @@ -1,43 +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 - -#include "ppapi/c/dev/ppb_memory_dev.h" -#include "ppapi/shared_impl/ppapi_shared_export.h" - -// The memory interface doesn't have a normal C -> C++ thunk since it doesn't -// actually have any proxy wrapping or associated objects; it's just a call -// into base. So we implement the entire interface here, using the thunk -// namespace so it magically gets hooked up in the proper places. - -namespace ppapi { - -namespace { - -void* MemAlloc(uint32_t num_bytes) { - return malloc(num_bytes); -} - -void MemFree(void* ptr) { - free(ptr); -} - -const PPB_Memory_Dev ppb_memory = { - &MemAlloc, - &MemFree -}; - -} // namespace - -namespace thunk { - -// static -PPAPI_SHARED_EXPORT const PPB_Memory_Dev* GetPPB_Memory_Dev_Thunk() { - return &ppb_memory; -} - -} // namespace thunk - -} // namespace ppapi diff --git a/ppapi/shared_impl/opengles2_impl.cc b/ppapi/shared_impl/opengles2_impl.cc deleted file mode 100644 index 2743d2e..0000000 --- a/ppapi/shared_impl/opengles2_impl.cc +++ /dev/null @@ -1,898 +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. - -// This file is auto-generated from -// gpu/command_buffer/build_gles2_cmd_buffer.py -// DO NOT EDIT! - -#include "ppapi/shared_impl/opengles2_impl.h" - -#include "base/logging.h" -#include "gpu/command_buffer/client/gles2_implementation.h" -#include "ppapi/shared_impl/graphics_3d_impl.h" -#include "ppapi/thunk/enter.h" - -namespace ppapi { - -namespace { - -gpu::gles2::GLES2Implementation* GetGLES(PP_Resource context) { - thunk::EnterResource enter_g3d(context, false); - DCHECK(enter_g3d.succeeded()); - return static_cast(enter_g3d.object())->gles2_impl(); -} - -void ActiveTexture(PP_Resource context_id, GLenum texture) { - GetGLES(context_id)->ActiveTexture(texture); -} - -void AttachShader(PP_Resource context_id, GLuint program, GLuint shader) { - GetGLES(context_id)->AttachShader(program, shader); -} - -void BindAttribLocation( - PP_Resource context_id, GLuint program, GLuint index, const char* name) { - GetGLES(context_id)->BindAttribLocation(program, index, name); -} - -void BindBuffer(PP_Resource context_id, GLenum target, GLuint buffer) { - GetGLES(context_id)->BindBuffer(target, buffer); -} - -void BindFramebuffer( - PP_Resource context_id, GLenum target, GLuint framebuffer) { - GetGLES(context_id)->BindFramebuffer(target, framebuffer); -} - -void BindRenderbuffer( - PP_Resource context_id, GLenum target, GLuint renderbuffer) { - GetGLES(context_id)->BindRenderbuffer(target, renderbuffer); -} - -void BindTexture(PP_Resource context_id, GLenum target, GLuint texture) { - GetGLES(context_id)->BindTexture(target, texture); -} - -void BlendColor( - PP_Resource context_id, GLclampf red, GLclampf green, GLclampf blue, - GLclampf alpha) { - GetGLES(context_id)->BlendColor(red, green, blue, alpha); -} - -void BlendEquation(PP_Resource context_id, GLenum mode) { - GetGLES(context_id)->BlendEquation(mode); -} - -void BlendEquationSeparate( - PP_Resource context_id, GLenum modeRGB, GLenum modeAlpha) { - GetGLES(context_id)->BlendEquationSeparate(modeRGB, modeAlpha); -} - -void BlendFunc(PP_Resource context_id, GLenum sfactor, GLenum dfactor) { - GetGLES(context_id)->BlendFunc(sfactor, dfactor); -} - -void BlendFuncSeparate( - PP_Resource context_id, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, - GLenum dstAlpha) { - GetGLES(context_id)->BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); -} - -void BufferData( - PP_Resource context_id, GLenum target, GLsizeiptr size, const void* data, - GLenum usage) { - GetGLES(context_id)->BufferData(target, size, data, usage); -} - -void BufferSubData( - PP_Resource context_id, GLenum target, GLintptr offset, GLsizeiptr size, - const void* data) { - GetGLES(context_id)->BufferSubData(target, offset, size, data); -} - -GLenum CheckFramebufferStatus(PP_Resource context_id, GLenum target) { - return GetGLES(context_id)->CheckFramebufferStatus(target); -} - -void Clear(PP_Resource context_id, GLbitfield mask) { - GetGLES(context_id)->Clear(mask); -} - -void ClearColor( - PP_Resource context_id, GLclampf red, GLclampf green, GLclampf blue, - GLclampf alpha) { - GetGLES(context_id)->ClearColor(red, green, blue, alpha); -} - -void ClearDepthf(PP_Resource context_id, GLclampf depth) { - GetGLES(context_id)->ClearDepthf(depth); -} - -void ClearStencil(PP_Resource context_id, GLint s) { - GetGLES(context_id)->ClearStencil(s); -} - -void ColorMask( - PP_Resource context_id, GLboolean red, GLboolean green, GLboolean blue, - GLboolean alpha) { - GetGLES(context_id)->ColorMask(red, green, blue, alpha); -} - -void CompileShader(PP_Resource context_id, GLuint shader) { - GetGLES(context_id)->CompileShader(shader); -} - -void CompressedTexImage2D( - PP_Resource context_id, GLenum target, GLint level, GLenum internalformat, - GLsizei width, GLsizei height, GLint border, GLsizei imageSize, - const void* data) { - GetGLES( - context_id)->CompressedTexImage2D( - target, level, internalformat, width, height, border, imageSize, - data); -} - -void CompressedTexSubImage2D( - PP_Resource context_id, GLenum target, GLint level, GLint xoffset, - GLint yoffset, GLsizei width, GLsizei height, GLenum format, - GLsizei imageSize, const void* data) { - GetGLES( - context_id)->CompressedTexSubImage2D( - target, level, xoffset, yoffset, width, height, format, imageSize, - data); -} - -void CopyTexImage2D( - PP_Resource context_id, GLenum target, GLint level, GLenum internalformat, - GLint x, GLint y, GLsizei width, GLsizei height, GLint border) { - GetGLES( - context_id)->CopyTexImage2D( - target, level, internalformat, x, y, width, height, border); -} - -void CopyTexSubImage2D( - PP_Resource context_id, GLenum target, GLint level, GLint xoffset, - GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) { - GetGLES( - context_id)->CopyTexSubImage2D( - target, level, xoffset, yoffset, x, y, width, height); -} - -GLuint CreateProgram(PP_Resource context_id) { - return GetGLES(context_id)->CreateProgram(); -} - -GLuint CreateShader(PP_Resource context_id, GLenum type) { - return GetGLES(context_id)->CreateShader(type); -} - -void CullFace(PP_Resource context_id, GLenum mode) { - GetGLES(context_id)->CullFace(mode); -} - -void DeleteBuffers(PP_Resource context_id, GLsizei n, const GLuint* buffers) { - GetGLES(context_id)->DeleteBuffers(n, buffers); -} - -void DeleteFramebuffers( - PP_Resource context_id, GLsizei n, const GLuint* framebuffers) { - GetGLES(context_id)->DeleteFramebuffers(n, framebuffers); -} - -void DeleteProgram(PP_Resource context_id, GLuint program) { - GetGLES(context_id)->DeleteProgram(program); -} - -void DeleteRenderbuffers( - PP_Resource context_id, GLsizei n, const GLuint* renderbuffers) { - GetGLES(context_id)->DeleteRenderbuffers(n, renderbuffers); -} - -void DeleteShader(PP_Resource context_id, GLuint shader) { - GetGLES(context_id)->DeleteShader(shader); -} - -void DeleteTextures( - PP_Resource context_id, GLsizei n, const GLuint* textures) { - GetGLES(context_id)->DeleteTextures(n, textures); -} - -void DepthFunc(PP_Resource context_id, GLenum func) { - GetGLES(context_id)->DepthFunc(func); -} - -void DepthMask(PP_Resource context_id, GLboolean flag) { - GetGLES(context_id)->DepthMask(flag); -} - -void DepthRangef(PP_Resource context_id, GLclampf zNear, GLclampf zFar) { - GetGLES(context_id)->DepthRangef(zNear, zFar); -} - -void DetachShader(PP_Resource context_id, GLuint program, GLuint shader) { - GetGLES(context_id)->DetachShader(program, shader); -} - -void Disable(PP_Resource context_id, GLenum cap) { - GetGLES(context_id)->Disable(cap); -} - -void DisableVertexAttribArray(PP_Resource context_id, GLuint index) { - GetGLES(context_id)->DisableVertexAttribArray(index); -} - -void DrawArrays( - PP_Resource context_id, GLenum mode, GLint first, GLsizei count) { - GetGLES(context_id)->DrawArrays(mode, first, count); -} - -void DrawElements( - PP_Resource context_id, GLenum mode, GLsizei count, GLenum type, - const void* indices) { - GetGLES(context_id)->DrawElements(mode, count, type, indices); -} - -void Enable(PP_Resource context_id, GLenum cap) { - GetGLES(context_id)->Enable(cap); -} - -void EnableVertexAttribArray(PP_Resource context_id, GLuint index) { - GetGLES(context_id)->EnableVertexAttribArray(index); -} - -void Finish(PP_Resource context_id) { - GetGLES(context_id)->Finish(); -} - -void Flush(PP_Resource context_id) { - GetGLES(context_id)->Flush(); -} - -void FramebufferRenderbuffer( - PP_Resource context_id, GLenum target, GLenum attachment, - GLenum renderbuffertarget, GLuint renderbuffer) { - GetGLES( - context_id)->FramebufferRenderbuffer( - target, attachment, renderbuffertarget, renderbuffer); -} - -void FramebufferTexture2D( - PP_Resource context_id, GLenum target, GLenum attachment, GLenum textarget, - GLuint texture, GLint level) { - GetGLES( - context_id)->FramebufferTexture2D( - target, attachment, textarget, texture, level); -} - -void FrontFace(PP_Resource context_id, GLenum mode) { - GetGLES(context_id)->FrontFace(mode); -} - -void GenBuffers(PP_Resource context_id, GLsizei n, GLuint* buffers) { - GetGLES(context_id)->GenBuffers(n, buffers); -} - -void GenerateMipmap(PP_Resource context_id, GLenum target) { - GetGLES(context_id)->GenerateMipmap(target); -} - -void GenFramebuffers(PP_Resource context_id, GLsizei n, GLuint* framebuffers) { - GetGLES(context_id)->GenFramebuffers(n, framebuffers); -} - -void GenRenderbuffers( - PP_Resource context_id, GLsizei n, GLuint* renderbuffers) { - GetGLES(context_id)->GenRenderbuffers(n, renderbuffers); -} - -void GenTextures(PP_Resource context_id, GLsizei n, GLuint* textures) { - GetGLES(context_id)->GenTextures(n, textures); -} - -void GetActiveAttrib( - PP_Resource context_id, GLuint program, GLuint index, GLsizei bufsize, - GLsizei* length, GLint* size, GLenum* type, char* name) { - GetGLES( - context_id)->GetActiveAttrib( - program, index, bufsize, length, size, type, name); -} - -void GetActiveUniform( - PP_Resource context_id, GLuint program, GLuint index, GLsizei bufsize, - GLsizei* length, GLint* size, GLenum* type, char* name) { - GetGLES( - context_id)->GetActiveUniform( - program, index, bufsize, length, size, type, name); -} - -void GetAttachedShaders( - PP_Resource context_id, GLuint program, GLsizei maxcount, GLsizei* count, - GLuint* shaders) { - GetGLES(context_id)->GetAttachedShaders(program, maxcount, count, shaders); -} - -GLint GetAttribLocation( - PP_Resource context_id, GLuint program, const char* name) { - return GetGLES(context_id)->GetAttribLocation(program, name); -} - -void GetBooleanv(PP_Resource context_id, GLenum pname, GLboolean* params) { - GetGLES(context_id)->GetBooleanv(pname, params); -} - -void GetBufferParameteriv( - PP_Resource context_id, GLenum target, GLenum pname, GLint* params) { - GetGLES(context_id)->GetBufferParameteriv(target, pname, params); -} - -GLenum GetError(PP_Resource context_id) { - return GetGLES(context_id)->GetError(); -} - -void GetFloatv(PP_Resource context_id, GLenum pname, GLfloat* params) { - GetGLES(context_id)->GetFloatv(pname, params); -} - -void GetFramebufferAttachmentParameteriv( - PP_Resource context_id, GLenum target, GLenum attachment, GLenum pname, - GLint* params) { - GetGLES( - context_id)->GetFramebufferAttachmentParameteriv( - target, attachment, pname, params); -} - -void GetIntegerv(PP_Resource context_id, GLenum pname, GLint* params) { - GetGLES(context_id)->GetIntegerv(pname, params); -} - -void GetProgramiv( - PP_Resource context_id, GLuint program, GLenum pname, GLint* params) { - GetGLES(context_id)->GetProgramiv(program, pname, params); -} - -void GetProgramInfoLog( - PP_Resource context_id, GLuint program, GLsizei bufsize, GLsizei* length, - char* infolog) { - GetGLES(context_id)->GetProgramInfoLog(program, bufsize, length, infolog); -} - -void GetRenderbufferParameteriv( - PP_Resource context_id, GLenum target, GLenum pname, GLint* params) { - GetGLES(context_id)->GetRenderbufferParameteriv(target, pname, params); -} - -void GetShaderiv( - PP_Resource context_id, GLuint shader, GLenum pname, GLint* params) { - GetGLES(context_id)->GetShaderiv(shader, pname, params); -} - -void GetShaderInfoLog( - PP_Resource context_id, GLuint shader, GLsizei bufsize, GLsizei* length, - char* infolog) { - GetGLES(context_id)->GetShaderInfoLog(shader, bufsize, length, infolog); -} - -void GetShaderPrecisionFormat( - PP_Resource context_id, GLenum shadertype, GLenum precisiontype, - GLint* range, GLint* precision) { - GetGLES( - context_id)->GetShaderPrecisionFormat( - shadertype, precisiontype, range, precision); -} - -void GetShaderSource( - PP_Resource context_id, GLuint shader, GLsizei bufsize, GLsizei* length, - char* source) { - GetGLES(context_id)->GetShaderSource(shader, bufsize, length, source); -} - -const GLubyte* GetString(PP_Resource context_id, GLenum name) { - return GetGLES(context_id)->GetString(name); -} - -void GetTexParameterfv( - PP_Resource context_id, GLenum target, GLenum pname, GLfloat* params) { - GetGLES(context_id)->GetTexParameterfv(target, pname, params); -} - -void GetTexParameteriv( - PP_Resource context_id, GLenum target, GLenum pname, GLint* params) { - GetGLES(context_id)->GetTexParameteriv(target, pname, params); -} - -void GetUniformfv( - PP_Resource context_id, GLuint program, GLint location, GLfloat* params) { - GetGLES(context_id)->GetUniformfv(program, location, params); -} - -void GetUniformiv( - PP_Resource context_id, GLuint program, GLint location, GLint* params) { - GetGLES(context_id)->GetUniformiv(program, location, params); -} - -GLint GetUniformLocation( - PP_Resource context_id, GLuint program, const char* name) { - return GetGLES(context_id)->GetUniformLocation(program, name); -} - -void GetVertexAttribfv( - PP_Resource context_id, GLuint index, GLenum pname, GLfloat* params) { - GetGLES(context_id)->GetVertexAttribfv(index, pname, params); -} - -void GetVertexAttribiv( - PP_Resource context_id, GLuint index, GLenum pname, GLint* params) { - GetGLES(context_id)->GetVertexAttribiv(index, pname, params); -} - -void GetVertexAttribPointerv( - PP_Resource context_id, GLuint index, GLenum pname, void** pointer) { - GetGLES(context_id)->GetVertexAttribPointerv(index, pname, pointer); -} - -void Hint(PP_Resource context_id, GLenum target, GLenum mode) { - GetGLES(context_id)->Hint(target, mode); -} - -GLboolean IsBuffer(PP_Resource context_id, GLuint buffer) { - return GetGLES(context_id)->IsBuffer(buffer); -} - -GLboolean IsEnabled(PP_Resource context_id, GLenum cap) { - return GetGLES(context_id)->IsEnabled(cap); -} - -GLboolean IsFramebuffer(PP_Resource context_id, GLuint framebuffer) { - return GetGLES(context_id)->IsFramebuffer(framebuffer); -} - -GLboolean IsProgram(PP_Resource context_id, GLuint program) { - return GetGLES(context_id)->IsProgram(program); -} - -GLboolean IsRenderbuffer(PP_Resource context_id, GLuint renderbuffer) { - return GetGLES(context_id)->IsRenderbuffer(renderbuffer); -} - -GLboolean IsShader(PP_Resource context_id, GLuint shader) { - return GetGLES(context_id)->IsShader(shader); -} - -GLboolean IsTexture(PP_Resource context_id, GLuint texture) { - return GetGLES(context_id)->IsTexture(texture); -} - -void LineWidth(PP_Resource context_id, GLfloat width) { - GetGLES(context_id)->LineWidth(width); -} - -void LinkProgram(PP_Resource context_id, GLuint program) { - GetGLES(context_id)->LinkProgram(program); -} - -void PixelStorei(PP_Resource context_id, GLenum pname, GLint param) { - GetGLES(context_id)->PixelStorei(pname, param); -} - -void PolygonOffset(PP_Resource context_id, GLfloat factor, GLfloat units) { - GetGLES(context_id)->PolygonOffset(factor, units); -} - -void ReadPixels( - PP_Resource context_id, GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, void* pixels) { - GetGLES(context_id)->ReadPixels(x, y, width, height, format, type, pixels); -} - -void ReleaseShaderCompiler(PP_Resource context_id) { - GetGLES(context_id)->ReleaseShaderCompiler(); -} - -void RenderbufferStorage( - PP_Resource context_id, GLenum target, GLenum internalformat, GLsizei width, - GLsizei height) { - GetGLES( - context_id)->RenderbufferStorage(target, internalformat, width, height); -} - -void SampleCoverage(PP_Resource context_id, GLclampf value, GLboolean invert) { - GetGLES(context_id)->SampleCoverage(value, invert); -} - -void Scissor( - PP_Resource context_id, GLint x, GLint y, GLsizei width, GLsizei height) { - GetGLES(context_id)->Scissor(x, y, width, height); -} - -void ShaderBinary( - PP_Resource context_id, GLsizei n, const GLuint* shaders, - GLenum binaryformat, const void* binary, GLsizei length) { - GetGLES(context_id)->ShaderBinary(n, shaders, binaryformat, binary, length); -} - -void ShaderSource( - PP_Resource context_id, GLuint shader, GLsizei count, const char** str, - const GLint* length) { - GetGLES(context_id)->ShaderSource(shader, count, str, length); -} - -void StencilFunc(PP_Resource context_id, GLenum func, GLint ref, GLuint mask) { - GetGLES(context_id)->StencilFunc(func, ref, mask); -} - -void StencilFuncSeparate( - PP_Resource context_id, GLenum face, GLenum func, GLint ref, GLuint mask) { - GetGLES(context_id)->StencilFuncSeparate(face, func, ref, mask); -} - -void StencilMask(PP_Resource context_id, GLuint mask) { - GetGLES(context_id)->StencilMask(mask); -} - -void StencilMaskSeparate(PP_Resource context_id, GLenum face, GLuint mask) { - GetGLES(context_id)->StencilMaskSeparate(face, mask); -} - -void StencilOp( - PP_Resource context_id, GLenum fail, GLenum zfail, GLenum zpass) { - GetGLES(context_id)->StencilOp(fail, zfail, zpass); -} - -void StencilOpSeparate( - PP_Resource context_id, GLenum face, GLenum fail, GLenum zfail, - GLenum zpass) { - GetGLES(context_id)->StencilOpSeparate(face, fail, zfail, zpass); -} - -void TexImage2D( - PP_Resource context_id, GLenum target, GLint level, GLint internalformat, - GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, - const void* pixels) { - GetGLES( - context_id)->TexImage2D( - target, level, internalformat, width, height, border, format, type, - pixels); -} - -void TexParameterf( - PP_Resource context_id, GLenum target, GLenum pname, GLfloat param) { - GetGLES(context_id)->TexParameterf(target, pname, param); -} - -void TexParameterfv( - PP_Resource context_id, GLenum target, GLenum pname, - const GLfloat* params) { - GetGLES(context_id)->TexParameterfv(target, pname, params); -} - -void TexParameteri( - PP_Resource context_id, GLenum target, GLenum pname, GLint param) { - GetGLES(context_id)->TexParameteri(target, pname, param); -} - -void TexParameteriv( - PP_Resource context_id, GLenum target, GLenum pname, const GLint* params) { - GetGLES(context_id)->TexParameteriv(target, pname, params); -} - -void TexSubImage2D( - PP_Resource context_id, GLenum target, GLint level, GLint xoffset, - GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, - const void* pixels) { - GetGLES( - context_id)->TexSubImage2D( - target, level, xoffset, yoffset, width, height, format, type, - pixels); -} - -void Uniform1f(PP_Resource context_id, GLint location, GLfloat x) { - GetGLES(context_id)->Uniform1f(location, x); -} - -void Uniform1fv( - PP_Resource context_id, GLint location, GLsizei count, const GLfloat* v) { - GetGLES(context_id)->Uniform1fv(location, count, v); -} - -void Uniform1i(PP_Resource context_id, GLint location, GLint x) { - GetGLES(context_id)->Uniform1i(location, x); -} - -void Uniform1iv( - PP_Resource context_id, GLint location, GLsizei count, const GLint* v) { - GetGLES(context_id)->Uniform1iv(location, count, v); -} - -void Uniform2f(PP_Resource context_id, GLint location, GLfloat x, GLfloat y) { - GetGLES(context_id)->Uniform2f(location, x, y); -} - -void Uniform2fv( - PP_Resource context_id, GLint location, GLsizei count, const GLfloat* v) { - GetGLES(context_id)->Uniform2fv(location, count, v); -} - -void Uniform2i(PP_Resource context_id, GLint location, GLint x, GLint y) { - GetGLES(context_id)->Uniform2i(location, x, y); -} - -void Uniform2iv( - PP_Resource context_id, GLint location, GLsizei count, const GLint* v) { - GetGLES(context_id)->Uniform2iv(location, count, v); -} - -void Uniform3f( - PP_Resource context_id, GLint location, GLfloat x, GLfloat y, GLfloat z) { - GetGLES(context_id)->Uniform3f(location, x, y, z); -} - -void Uniform3fv( - PP_Resource context_id, GLint location, GLsizei count, const GLfloat* v) { - GetGLES(context_id)->Uniform3fv(location, count, v); -} - -void Uniform3i( - PP_Resource context_id, GLint location, GLint x, GLint y, GLint z) { - GetGLES(context_id)->Uniform3i(location, x, y, z); -} - -void Uniform3iv( - PP_Resource context_id, GLint location, GLsizei count, const GLint* v) { - GetGLES(context_id)->Uniform3iv(location, count, v); -} - -void Uniform4f( - PP_Resource context_id, GLint location, GLfloat x, GLfloat y, GLfloat z, - GLfloat w) { - GetGLES(context_id)->Uniform4f(location, x, y, z, w); -} - -void Uniform4fv( - PP_Resource context_id, GLint location, GLsizei count, const GLfloat* v) { - GetGLES(context_id)->Uniform4fv(location, count, v); -} - -void Uniform4i( - PP_Resource context_id, GLint location, GLint x, GLint y, GLint z, - GLint w) { - GetGLES(context_id)->Uniform4i(location, x, y, z, w); -} - -void Uniform4iv( - PP_Resource context_id, GLint location, GLsizei count, const GLint* v) { - GetGLES(context_id)->Uniform4iv(location, count, v); -} - -void UniformMatrix2fv( - PP_Resource context_id, GLint location, GLsizei count, GLboolean transpose, - const GLfloat* value) { - GetGLES(context_id)->UniformMatrix2fv(location, count, transpose, value); -} - -void UniformMatrix3fv( - PP_Resource context_id, GLint location, GLsizei count, GLboolean transpose, - const GLfloat* value) { - GetGLES(context_id)->UniformMatrix3fv(location, count, transpose, value); -} - -void UniformMatrix4fv( - PP_Resource context_id, GLint location, GLsizei count, GLboolean transpose, - const GLfloat* value) { - GetGLES(context_id)->UniformMatrix4fv(location, count, transpose, value); -} - -void UseProgram(PP_Resource context_id, GLuint program) { - GetGLES(context_id)->UseProgram(program); -} - -void ValidateProgram(PP_Resource context_id, GLuint program) { - GetGLES(context_id)->ValidateProgram(program); -} - -void VertexAttrib1f(PP_Resource context_id, GLuint indx, GLfloat x) { - GetGLES(context_id)->VertexAttrib1f(indx, x); -} - -void VertexAttrib1fv( - PP_Resource context_id, GLuint indx, const GLfloat* values) { - GetGLES(context_id)->VertexAttrib1fv(indx, values); -} - -void VertexAttrib2f( - PP_Resource context_id, GLuint indx, GLfloat x, GLfloat y) { - GetGLES(context_id)->VertexAttrib2f(indx, x, y); -} - -void VertexAttrib2fv( - PP_Resource context_id, GLuint indx, const GLfloat* values) { - GetGLES(context_id)->VertexAttrib2fv(indx, values); -} - -void VertexAttrib3f( - PP_Resource context_id, GLuint indx, GLfloat x, GLfloat y, GLfloat z) { - GetGLES(context_id)->VertexAttrib3f(indx, x, y, z); -} - -void VertexAttrib3fv( - PP_Resource context_id, GLuint indx, const GLfloat* values) { - GetGLES(context_id)->VertexAttrib3fv(indx, values); -} - -void VertexAttrib4f( - PP_Resource context_id, GLuint indx, GLfloat x, GLfloat y, GLfloat z, - GLfloat w) { - GetGLES(context_id)->VertexAttrib4f(indx, x, y, z, w); -} - -void VertexAttrib4fv( - PP_Resource context_id, GLuint indx, const GLfloat* values) { - GetGLES(context_id)->VertexAttrib4fv(indx, values); -} - -void VertexAttribPointer( - PP_Resource context_id, GLuint indx, GLint size, GLenum type, - GLboolean normalized, GLsizei stride, const void* ptr) { - GetGLES( - context_id)->VertexAttribPointer( - indx, size, type, normalized, stride, ptr); -} - -void Viewport( - PP_Resource context_id, GLint x, GLint y, GLsizei width, GLsizei height) { - GetGLES(context_id)->Viewport(x, y, width, height); -} - - -const struct PPB_OpenGLES2 ppb_opengles2 = { - &ActiveTexture, - &AttachShader, - &BindAttribLocation, - &BindBuffer, - &BindFramebuffer, - &BindRenderbuffer, - &BindTexture, - &BlendColor, - &BlendEquation, - &BlendEquationSeparate, - &BlendFunc, - &BlendFuncSeparate, - &BufferData, - &BufferSubData, - &CheckFramebufferStatus, - &Clear, - &ClearColor, - &ClearDepthf, - &ClearStencil, - &ColorMask, - &CompileShader, - &CompressedTexImage2D, - &CompressedTexSubImage2D, - &CopyTexImage2D, - &CopyTexSubImage2D, - &CreateProgram, - &CreateShader, - &CullFace, - &DeleteBuffers, - &DeleteFramebuffers, - &DeleteProgram, - &DeleteRenderbuffers, - &DeleteShader, - &DeleteTextures, - &DepthFunc, - &DepthMask, - &DepthRangef, - &DetachShader, - &Disable, - &DisableVertexAttribArray, - &DrawArrays, - &DrawElements, - &Enable, - &EnableVertexAttribArray, - &Finish, - &Flush, - &FramebufferRenderbuffer, - &FramebufferTexture2D, - &FrontFace, - &GenBuffers, - &GenerateMipmap, - &GenFramebuffers, - &GenRenderbuffers, - &GenTextures, - &GetActiveAttrib, - &GetActiveUniform, - &GetAttachedShaders, - &GetAttribLocation, - &GetBooleanv, - &GetBufferParameteriv, - &GetError, - &GetFloatv, - &GetFramebufferAttachmentParameteriv, - &GetIntegerv, - &GetProgramiv, - &GetProgramInfoLog, - &GetRenderbufferParameteriv, - &GetShaderiv, - &GetShaderInfoLog, - &GetShaderPrecisionFormat, - &GetShaderSource, - &GetString, - &GetTexParameterfv, - &GetTexParameteriv, - &GetUniformfv, - &GetUniformiv, - &GetUniformLocation, - &GetVertexAttribfv, - &GetVertexAttribiv, - &GetVertexAttribPointerv, - &Hint, - &IsBuffer, - &IsEnabled, - &IsFramebuffer, - &IsProgram, - &IsRenderbuffer, - &IsShader, - &IsTexture, - &LineWidth, - &LinkProgram, - &PixelStorei, - &PolygonOffset, - &ReadPixels, - &ReleaseShaderCompiler, - &RenderbufferStorage, - &SampleCoverage, - &Scissor, - &ShaderBinary, - &ShaderSource, - &StencilFunc, - &StencilFuncSeparate, - &StencilMask, - &StencilMaskSeparate, - &StencilOp, - &StencilOpSeparate, - &TexImage2D, - &TexParameterf, - &TexParameterfv, - &TexParameteri, - &TexParameteriv, - &TexSubImage2D, - &Uniform1f, - &Uniform1fv, - &Uniform1i, - &Uniform1iv, - &Uniform2f, - &Uniform2fv, - &Uniform2i, - &Uniform2iv, - &Uniform3f, - &Uniform3fv, - &Uniform3i, - &Uniform3iv, - &Uniform4f, - &Uniform4fv, - &Uniform4i, - &Uniform4iv, - &UniformMatrix2fv, - &UniformMatrix3fv, - &UniformMatrix4fv, - &UseProgram, - &ValidateProgram, - &VertexAttrib1f, - &VertexAttrib1fv, - &VertexAttrib2f, - &VertexAttrib2fv, - &VertexAttrib3f, - &VertexAttrib3fv, - &VertexAttrib4f, - &VertexAttrib4fv, - &VertexAttribPointer, - &Viewport -}; - -} // namespace - -const PPB_OpenGLES2* OpenGLES2Impl::GetInterface() { - return &ppb_opengles2; -} - -} // namespace ppapi diff --git a/ppapi/shared_impl/opengles2_impl.h b/ppapi/shared_impl/opengles2_impl.h deleted file mode 100644 index 4ed6e90..0000000 --- a/ppapi/shared_impl/opengles2_impl.h +++ /dev/null @@ -1,21 +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_SHARED_IMPL_OPENGLES2_IMPL_H_ -#define PPAPI_SHARED_IMPL_OPENGLES2_IMPL_H_ - -#include "ppapi/c/ppb_opengles2.h" -#include "ppapi/shared_impl/ppapi_shared_export.h" - -namespace ppapi { - -class PPAPI_SHARED_EXPORT OpenGLES2Impl { - public: - static const PPB_OpenGLES2* GetInterface(); -}; - -} // namespace ppapi - -#endif // PPAPI_SHARED_IMPL_OPENGLES2_IMPL_H_ - diff --git a/ppapi/shared_impl/ppb_audio_config_shared.cc b/ppapi/shared_impl/ppb_audio_config_shared.cc new file mode 100644 index 0000000..78df9ad --- /dev/null +++ b/ppapi/shared_impl/ppb_audio_config_shared.cc @@ -0,0 +1,80 @@ +// 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/shared_impl/ppb_audio_config_shared.h" + +namespace ppapi { + +PPB_AudioConfig_Shared::PPB_AudioConfig_Shared(PP_Instance instance) + : Resource(instance), + sample_rate_(PP_AUDIOSAMPLERATE_NONE), + sample_frame_count_(0) { +} + +PPB_AudioConfig_Shared::PPB_AudioConfig_Shared( + const HostResource& host_resource) + : Resource(host_resource), + sample_rate_(PP_AUDIOSAMPLERATE_NONE), + sample_frame_count_(0) { +} + +PPB_AudioConfig_Shared::~PPB_AudioConfig_Shared() { +} + +// static +PP_Resource PPB_AudioConfig_Shared::CreateAsImpl( + PP_Instance instance, + PP_AudioSampleRate sample_rate, + uint32_t sample_frame_count) { + scoped_refptr object( + new PPB_AudioConfig_Shared(instance)); + if (!object->Init(sample_rate, sample_frame_count)) + return 0; + return object->GetReference(); +} + +// static +PP_Resource PPB_AudioConfig_Shared::CreateAsProxy( + PP_Instance instance, + PP_AudioSampleRate sample_rate, + uint32_t sample_frame_count) { + scoped_refptr object(new PPB_AudioConfig_Shared( + HostResource::MakeInstanceOnly(instance))); + if (!object->Init(sample_rate, sample_frame_count)) + return 0; + return object->GetReference(); +} + +thunk::PPB_AudioConfig_API* PPB_AudioConfig_Shared::AsPPB_AudioConfig_API() { + return this; +} + +PP_AudioSampleRate PPB_AudioConfig_Shared::GetSampleRate() { + return sample_rate_; +} + +uint32_t PPB_AudioConfig_Shared::GetSampleFrameCount() { + return sample_frame_count_; +} + +bool PPB_AudioConfig_Shared::Init(PP_AudioSampleRate sample_rate, + uint32_t sample_frame_count) { + // TODO(brettw): Currently we don't actually check what the hardware + // supports, so just allow sample rates of the "guaranteed working" ones. + if (sample_rate != PP_AUDIOSAMPLERATE_44100 && + sample_rate != PP_AUDIOSAMPLERATE_48000) + return false; + + // TODO(brettw): Currently we don't actually query to get a value from the + // hardware, so just validate the range. + if (sample_frame_count > PP_AUDIOMAXSAMPLEFRAMECOUNT || + sample_frame_count < PP_AUDIOMINSAMPLEFRAMECOUNT) + return false; + + sample_rate_ = sample_rate; + sample_frame_count_ = sample_frame_count; + return true; +} + +} // namespace ppapi diff --git a/ppapi/shared_impl/ppb_audio_config_shared.h b/ppapi/shared_impl/ppb_audio_config_shared.h new file mode 100644 index 0000000..65e3b2b --- /dev/null +++ b/ppapi/shared_impl/ppb_audio_config_shared.h @@ -0,0 +1,54 @@ +// 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_SHARED_IMPL_PPB_AUDIO_CONFIG_SHARED_H_ +#define PPAPI_SHARED_IMPL_PPB_AUDIO_CONFIG_SHARED_H_ + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "ppapi/shared_impl/resource.h" +#include "ppapi/thunk/ppb_audio_config_api.h" + +namespace ppapi { + +class PPAPI_SHARED_EXPORT PPB_AudioConfig_Shared + : public Resource, + public thunk::PPB_AudioConfig_API { + public: + virtual ~PPB_AudioConfig_Shared(); + + static PP_Resource CreateAsImpl(PP_Instance instance, + PP_AudioSampleRate sample_rate, + uint32_t sample_frame_count); + static PP_Resource CreateAsProxy(PP_Instance instance, + PP_AudioSampleRate sample_rate, + uint32_t sample_frame_count); + + // Resource overrides. + virtual thunk::PPB_AudioConfig_API* AsPPB_AudioConfig_API() OVERRIDE; + + // PPB_AudioConfig_API implementation. + virtual PP_AudioSampleRate GetSampleRate() OVERRIDE; + virtual uint32_t GetSampleFrameCount() OVERRIDE; + + private: + // You must call Init before using this object. + // Construct as implementation. + explicit PPB_AudioConfig_Shared(PP_Instance instance); + // Construct as proxy. + explicit PPB_AudioConfig_Shared(const HostResource& host_resource); + + // Returns false if the arguments are invalid, the object should not be + // used in this case. + bool Init(PP_AudioSampleRate sample_rate, uint32_t sample_frame_count); + + PP_AudioSampleRate sample_rate_; + uint32_t sample_frame_count_; + + DISALLOW_COPY_AND_ASSIGN(PPB_AudioConfig_Shared); +}; + +} // namespace ppapi + +#endif // PPAPI_SHARED_IMPL_PPB_AUDIO_CONFIG_SHARED_H_ diff --git a/ppapi/shared_impl/ppb_audio_input_shared.cc b/ppapi/shared_impl/ppb_audio_input_shared.cc new file mode 100644 index 0000000..ae5b37e --- /dev/null +++ b/ppapi/shared_impl/ppb_audio_input_shared.cc @@ -0,0 +1,94 @@ +// 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/shared_impl/ppb_audio_input_shared.h" + +#include "base/logging.h" + +namespace ppapi { + +PPB_AudioInput_Shared::PPB_AudioInput_Shared() + : capturing_(false), + shared_memory_size_(0), + callback_(NULL), + user_data_(NULL) { +} + +PPB_AudioInput_Shared::~PPB_AudioInput_Shared() { + // Closing the socket causes the thread to exit - wait for it. + if (socket_.get()) + socket_->Close(); + if (audio_input_thread_.get()) { + audio_input_thread_->Join(); + audio_input_thread_.reset(); + } +} + +void PPB_AudioInput_Shared::SetCallback(PPB_AudioInput_Callback callback, + void* user_data) { + callback_ = callback; + user_data_ = user_data; +} + +void PPB_AudioInput_Shared::SetStartCaptureState() { + DCHECK(!capturing_); + DCHECK(!audio_input_thread_.get()); + + // If the socket doesn't exist, that means that the plugin has started before + // the browser has had a chance to create all the shared memory info and + // notify us. This is a common case. In this case, we just set the playing_ + // flag and the capture will automatically start when that data is available + // in SetStreamInfo. + if (socket_.get()) + StartThread(); + capturing_ = true; +} + +void PPB_AudioInput_Shared::SetStopCaptureState() { + DCHECK(capturing_); + + if (audio_input_thread_.get()) { + audio_input_thread_->Join(); + audio_input_thread_.reset(); + } + capturing_ = false; +} + +void PPB_AudioInput_Shared::SetStreamInfo( + base::SharedMemoryHandle shared_memory_handle, + size_t shared_memory_size, + base::SyncSocket::Handle socket_handle) { + socket_.reset(new base::SyncSocket(socket_handle)); + shared_memory_.reset(new base::SharedMemory(shared_memory_handle, false)); + shared_memory_size_ = shared_memory_size; + + if (callback_) { + shared_memory_->Map(shared_memory_size_); + + // In common case StartCapture() was called before StreamCreated(). + if (capturing_) + StartThread(); + } +} + +void PPB_AudioInput_Shared::StartThread() { + DCHECK(callback_); + DCHECK(!audio_input_thread_.get()); + audio_input_thread_.reset(new base::DelegateSimpleThread( + this, "plugin_audio_input_thread")); + audio_input_thread_->Start(); +} + +void PPB_AudioInput_Shared::Run() { + int pending_data; + void* buffer = shared_memory_->memory(); + + while (sizeof(pending_data) == socket_->Receive(&pending_data, + sizeof(pending_data)) && + pending_data >= 0) { + callback_(buffer, shared_memory_size_, user_data_); + } +} + +} // namespace ppapi diff --git a/ppapi/shared_impl/ppb_audio_input_shared.h b/ppapi/shared_impl/ppb_audio_input_shared.h new file mode 100644 index 0000000..5c5e88d --- /dev/null +++ b/ppapi/shared_impl/ppb_audio_input_shared.h @@ -0,0 +1,91 @@ +// 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_SHARED_IMPL_PPB_AUDIO_INPUT_SHARED_H_ +#define PPAPI_SHARED_IMPL_PPB_AUDIO_INPUT_SHARED_H_ + +#include "base/basictypes.h" +#include "base/memory/scoped_ptr.h" +#include "base/shared_memory.h" +#include "base/sync_socket.h" +#include "base/threading/simple_thread.h" +#include "ppapi/c/dev/ppb_audio_input_dev.h" +#include "ppapi/shared_impl/resource.h" +#include "ppapi/thunk/ppb_audio_input_api.h" + +namespace ppapi { + +// Implements the logic to map shared memory and run the audio thread signaled +// from the sync socket. Both the proxy and the renderer implementation use +// this code. +class PPAPI_SHARED_EXPORT PPB_AudioInput_Shared + : public thunk::PPB_AudioInput_API, + public base::DelegateSimpleThread::Delegate { + public: + PPB_AudioInput_Shared(); + virtual ~PPB_AudioInput_Shared(); + + bool capturing() const { return capturing_; } + + // Sets the callback information that the background thread will use. This + // is optional. Without a callback, the thread will not be run. This + // non-callback mode is used in the renderer with the proxy, since the proxy + // handles the callback entirely within the plugin process. + void SetCallback(PPB_AudioInput_Callback callback, void* user_data); + + // Configures the current state to be playing or not. The caller is + // responsible for ensuring the new state is the opposite of the current one. + // + // This is the implementation for PPB_AudioInput.Start/StopCapture, except + // that it does not actually notify the audio system to stop capture, it just + // configures our object to stop generating callbacks. The actual stop + // playback request will be done in the derived classes and will be different + // from the proxy and the renderer. + void SetStartCaptureState(); + void SetStopCaptureState(); + + // Sets the shared memory and socket handles. This will automatically start + // playback if we're currently set to play. + void SetStreamInfo(base::SharedMemoryHandle shared_memory_handle, + size_t shared_memory_size, + base::SyncSocket::Handle socket_handle); + + private: + // Starts execution of the audio input thread. + void StartThread(); + + // DelegateSimpleThread::Delegate implementation. + // Run on the audio input thread. + virtual void Run(); + + // True if capturing the stream. + bool capturing_; + + // Socket used to notify us when audio is ready to accept new samples. This + // pointer is created in StreamCreated(). + scoped_ptr socket_; + + // Sample buffer in shared memory. This pointer is created in + // StreamCreated(). The memory is only mapped when the audio thread is + // created. + scoped_ptr shared_memory_; + + // The size of the sample buffer in bytes. + size_t shared_memory_size_; + + // When the callback is set, this thread is spawned for calling it. + scoped_ptr audio_input_thread_; + + // Callback to call when audio is ready to produce new samples. + PPB_AudioInput_Callback callback_; + + // User data pointer passed verbatim to the callback function. + void* user_data_; + + DISALLOW_COPY_AND_ASSIGN(PPB_AudioInput_Shared); +}; + +} // namespace ppapi + +#endif // PPAPI_SHARED_IMPL_PPB_AUDIO_INPUT_SHARED_H_ diff --git a/ppapi/shared_impl/ppb_audio_shared.cc b/ppapi/shared_impl/ppb_audio_shared.cc new file mode 100644 index 0000000..5385106 --- /dev/null +++ b/ppapi/shared_impl/ppb_audio_shared.cc @@ -0,0 +1,94 @@ +// 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/shared_impl/ppb_audio_shared.h" + +#include "base/logging.h" + +namespace ppapi { + +PPB_Audio_Shared::PPB_Audio_Shared() + : playing_(false), + shared_memory_size_(0), + callback_(NULL), + user_data_(NULL) { +} + +PPB_Audio_Shared::~PPB_Audio_Shared() { + // Closing the socket causes the thread to exit - wait for it. + if (socket_.get()) + socket_->Close(); + if (audio_thread_.get()) { + audio_thread_->Join(); + audio_thread_.reset(); + } +} + +void PPB_Audio_Shared::SetCallback(PPB_Audio_Callback callback, + void* user_data) { + callback_ = callback; + user_data_ = user_data; +} + +void PPB_Audio_Shared::SetStartPlaybackState() { + DCHECK(!playing_); + DCHECK(!audio_thread_.get()); + + // If the socket doesn't exist, that means that the plugin has started before + // the browser has had a chance to create all the shared memory info and + // notify us. This is a common case. In this case, we just set the playing_ + // flag and the playback will automatically start when that data is available + // in SetStreamInfo. + if (callback_ && socket_.get()) + StartThread(); + playing_ = true; +} + +void PPB_Audio_Shared::SetStopPlaybackState() { + DCHECK(playing_); + + if (audio_thread_.get()) { + audio_thread_->Join(); + audio_thread_.reset(); + } + playing_ = false; +} + +void PPB_Audio_Shared::SetStreamInfo( + base::SharedMemoryHandle shared_memory_handle, + size_t shared_memory_size, + base::SyncSocket::Handle socket_handle) { + socket_.reset(new base::SyncSocket(socket_handle)); + shared_memory_.reset(new base::SharedMemory(shared_memory_handle, false)); + shared_memory_size_ = shared_memory_size; + + if (callback_) { + shared_memory_->Map(shared_memory_size_); + + // In common case StartPlayback() was called before StreamCreated(). + if (playing_) + StartThread(); + } +} + +void PPB_Audio_Shared::StartThread() { + DCHECK(callback_); + DCHECK(!audio_thread_.get()); + audio_thread_.reset(new base::DelegateSimpleThread( + this, "plugin_audio_thread")); + audio_thread_->Start(); +} + +void PPB_Audio_Shared::Run() { + int pending_data; + void* buffer = shared_memory_->memory(); + + while (sizeof(pending_data) == + socket_->Receive(&pending_data, sizeof(pending_data)) && + pending_data >= 0) { + callback_(buffer, shared_memory_size_, user_data_); + } +} + +} // namespace ppapi diff --git a/ppapi/shared_impl/ppb_audio_shared.h b/ppapi/shared_impl/ppb_audio_shared.h new file mode 100644 index 0000000..99f45de --- /dev/null +++ b/ppapi/shared_impl/ppb_audio_shared.h @@ -0,0 +1,89 @@ +// 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_SHARED_IMPL_PPB_AUDIO_SHARED_H_ +#define PPAPI_SHARED_IMPL_PPB_AUDIO_SHARED_H_ + +#include "base/memory/scoped_ptr.h" +#include "base/shared_memory.h" +#include "base/sync_socket.h" +#include "base/threading/simple_thread.h" +#include "ppapi/c/ppb_audio.h" +#include "ppapi/shared_impl/resource.h" +#include "ppapi/thunk/ppb_audio_api.h" + +namespace ppapi { + +// Implements the logic to map shared memory and run the audio thread signaled +// from the sync socket. Both the proxy and the renderer implementation use +// this code. +class PPAPI_SHARED_EXPORT PPB_Audio_Shared + : public thunk::PPB_Audio_API, + public base::DelegateSimpleThread::Delegate { + public: + PPB_Audio_Shared(); + virtual ~PPB_Audio_Shared(); + + bool playing() const { return playing_; } + + // Sets the callback information that the background thread will use. This + // is optional. Without a callback, the thread will not be run. This + // non-callback mode is used in the renderer with the proxy, since the proxy + // handles the callback entirely within the plugin process. + void SetCallback(PPB_Audio_Callback callback, void* user_data); + + // Configures the current state to be playing or not. The caller is + // responsible for ensuring the new state is the opposite of the current one. + // + // This is the implementation for PPB_Audio.Start/StopPlayback, except that + // it does not actually notify the audio system to stop playback, it just + // configures our object to stop generating callbacks. The actual stop + // playback request will be done in the derived classes and will be different + // from the proxy and the renderer. + void SetStartPlaybackState(); + void SetStopPlaybackState(); + + // Sets the shared memory and socket handles. This will automatically start + // playback if we're currently set to play. + void SetStreamInfo(base::SharedMemoryHandle shared_memory_handle, + size_t shared_memory_size, + base::SyncSocket::Handle socket_handle); + + private: + // Starts execution of the audio thread. + void StartThread(); + + // DelegateSimpleThread::Delegate implementation. Run on the audio thread. + virtual void Run(); + + // True if playing the stream. + bool playing_; + + // Socket used to notify us when audio is ready to accept new samples. This + // pointer is created in StreamCreated(). + scoped_ptr socket_; + + // Sample buffer in shared memory. This pointer is created in + // StreamCreated(). The memory is only mapped when the audio thread is + // created. + scoped_ptr shared_memory_; + + // The size of the sample buffer in bytes. + size_t shared_memory_size_; + + // When the callback is set, this thread is spawned for calling it. + scoped_ptr audio_thread_; + + // Callback to call when audio is ready to accept new samples. + PPB_Audio_Callback callback_; + + // User data pointer passed verbatim to the callback function. + void* user_data_; + + DISALLOW_COPY_AND_ASSIGN(PPB_Audio_Shared); +}; + +} // namespace ppapi + +#endif // PPAPI_SHARED_IMPL_PPB_AUDIO_SHARED_H_ diff --git a/ppapi/shared_impl/ppb_char_set_shared.cc b/ppapi/shared_impl/ppb_char_set_shared.cc new file mode 100644 index 0000000..70ecd39 --- /dev/null +++ b/ppapi/shared_impl/ppb_char_set_shared.cc @@ -0,0 +1,154 @@ +// 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/shared_impl/ppb_char_set_shared.h" + +#include "base/i18n/icu_string_conversions.h" +#include "ppapi/c/dev/ppb_memory_dev.h" +#include "ppapi/thunk/thunk.h" +#include "unicode/ucnv.h" +#include "unicode/ucnv_cb.h" +#include "unicode/ucnv_err.h" +#include "unicode/ustring.h" + +namespace ppapi { + +namespace { + +// Converts the given PP error handling behavior to the version in base, +// placing the result in |*result| and returning true on success. Returns false +// if the enum is invalid. +bool PPToBaseConversionError(PP_CharSet_ConversionError on_error, + base::OnStringConversionError::Type* result) { + switch (on_error) { + case PP_CHARSET_CONVERSIONERROR_FAIL: + *result = base::OnStringConversionError::FAIL; + return true; + case PP_CHARSET_CONVERSIONERROR_SKIP: + *result = base::OnStringConversionError::SKIP; + return true; + case PP_CHARSET_CONVERSIONERROR_SUBSTITUTE: + *result = base::OnStringConversionError::SUBSTITUTE; + return true; + default: + return false; + } +} + +} // namespace + +// static +// The "substitution" behavior of this function does not match the +// implementation in base, so we partially duplicate the code from +// icu_string_conversions.cc with the correct error handling setup required +// by the PPAPI interface. +char* PPB_CharSet_Shared::UTF16ToCharSet( + const uint16_t* utf16, + uint32_t utf16_len, + const char* output_char_set, + PP_CharSet_ConversionError on_error, + uint32_t* output_length) { + if (!utf16 || !output_char_set || !output_length) + return NULL; + + *output_length = 0; + + UErrorCode status = U_ZERO_ERROR; + UConverter* converter = ucnv_open(output_char_set, &status); + if (!U_SUCCESS(status)) + return NULL; + + int encoded_max_length = UCNV_GET_MAX_BYTES_FOR_STRING(utf16_len, + ucnv_getMaxCharSize(converter)); + + // Setup our error handler. + switch (on_error) { + case PP_CHARSET_CONVERSIONERROR_FAIL: + ucnv_setFromUCallBack(converter, UCNV_FROM_U_CALLBACK_STOP, 0, + NULL, NULL, &status); + break; + case PP_CHARSET_CONVERSIONERROR_SKIP: + ucnv_setFromUCallBack(converter, UCNV_FROM_U_CALLBACK_SKIP, 0, + NULL, NULL, &status); + break; + case PP_CHARSET_CONVERSIONERROR_SUBSTITUTE: { + // ICU sets the substitution char for some character sets (like latin1) + // to be the ASCII "substitution character" (26). We want to use '?' + // instead for backwards-compat with Windows behavior. + char subst_chars[32]; + int8_t subst_chars_len = 32; + ucnv_getSubstChars(converter, subst_chars, &subst_chars_len, &status); + if (subst_chars_len == 1 && subst_chars[0] == 26) { + // Override to the question mark character if possible. When using + // setSubstString, the input is a Unicode character. The function will + // try to convert it to the destination character set and fail if that + // can not be converted to the destination character set. + // + // We just ignore any failure. If the dest char set has no + // representation for '?', then we'll just stick to the ICU default + // substitution character. + UErrorCode subst_status = U_ZERO_ERROR; + UChar question_mark = '?'; + ucnv_setSubstString(converter, &question_mark, 1, &subst_status); + } + + ucnv_setFromUCallBack(converter, UCNV_FROM_U_CALLBACK_SUBSTITUTE, 0, + NULL, NULL, &status); + break; + } + default: + return NULL; + } + + // ucnv_fromUChars returns size not including terminating null. + char* encoded = static_cast( + thunk::GetPPB_Memory_Dev_Thunk()->MemAlloc(encoded_max_length + 1)); + int actual_size = ucnv_fromUChars(converter, encoded, + encoded_max_length, reinterpret_cast(utf16), utf16_len, + &status); + ucnv_close(converter); + if (!U_SUCCESS(status)) { + thunk::GetPPB_Memory_Dev_Thunk()->MemFree(encoded); + return NULL; + } + encoded[actual_size] = 0; + *output_length = actual_size; + return encoded; +} + +// static +uint16_t* PPB_CharSet_Shared::CharSetToUTF16( + const char* input, + uint32_t input_len, + const char* input_char_set, + PP_CharSet_ConversionError on_error, + uint32_t* output_length) { + if (!input || !input_char_set || !output_length) + return NULL; + + *output_length = 0; + + base::OnStringConversionError::Type base_on_error; + if (!PPToBaseConversionError(on_error, &base_on_error)) + return NULL; // Invalid enum value. + + // We can convert this call to the implementation in base to avoid code + // duplication, although this does introduce an extra copy of the data. + string16 output; + if (!base::CodepageToUTF16(std::string(input, input_len), input_char_set, + base_on_error, &output)) + return NULL; + + uint16_t* ret_buf = static_cast( + thunk::GetPPB_Memory_Dev_Thunk()->MemAlloc( + (output.size() + 1) * sizeof(uint16_t))); + if (!ret_buf) + return NULL; + + *output_length = static_cast(output.size()); + memcpy(ret_buf, output.c_str(), (output.size() + 1) * sizeof(uint16_t)); + return ret_buf; +} + +} // namespace ppapi diff --git a/ppapi/shared_impl/ppb_char_set_shared.h b/ppapi/shared_impl/ppb_char_set_shared.h new file mode 100644 index 0000000..4243267 --- /dev/null +++ b/ppapi/shared_impl/ppb_char_set_shared.h @@ -0,0 +1,33 @@ +// 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_SHARED_IMPL_PPB_CHAR_SET_SHARED_H_ +#define PPAPI_SHARED_IMPL_PPB_CHAR_SET_SHARED_H_ + +#include "base/basictypes.h" +#include "ppapi/c/dev/ppb_char_set_dev.h" +#include "ppapi/shared_impl/ppapi_shared_export.h" + +namespace ppapi { + +// Contains the implementation of character set conversion that is shared +// between the proxy and the renderer. +class PPAPI_SHARED_EXPORT PPB_CharSet_Shared { + public: + static char* UTF16ToCharSet(const uint16_t* utf16, + uint32_t utf16_len, + const char* output_char_set, + PP_CharSet_ConversionError on_error, + uint32_t* output_length); + + static uint16_t* CharSetToUTF16(const char* input, + uint32_t input_len, + const char* input_char_set, + PP_CharSet_ConversionError on_error, + uint32_t* output_length); +}; + +} // namespace ppapi + +#endif // PPAPI_SHARED_IMPL_PPB_CHAR_SET_SHARED_H_ diff --git a/ppapi/shared_impl/ppb_crypto_shared.cc b/ppapi/shared_impl/ppb_crypto_shared.cc new file mode 100644 index 0000000..42694d0 --- /dev/null +++ b/ppapi/shared_impl/ppb_crypto_shared.cc @@ -0,0 +1,36 @@ +// 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 "base/rand_util.h" +#include "ppapi/c/dev/ppb_crypto_dev.h" +#include "ppapi/thunk/thunk.h" + +// The crypto interface doesn't have a normal C -> C++ thunk since it doesn't +// actually have any proxy wrapping or associated objects; it's just a call +// into base. So we implement the entire interface here, using the thunk +// namespace so it magically gets hooked up in the proper places. + +namespace ppapi { + +namespace { + +void GetRandomBytes(char* buffer, uint32_t num_bytes) { + base::RandBytes(buffer, num_bytes); +} + +const PPB_Crypto_Dev crypto_interface = { + &GetRandomBytes +}; + +} // namespace + +namespace thunk { + +PPAPI_THUNK_EXPORT const PPB_Crypto_Dev* GetPPB_Crypto_Dev_Thunk() { + return &crypto_interface; +} + +} // namespace thunk + +} // namespace ppapi diff --git a/ppapi/shared_impl/ppb_file_ref_shared.cc b/ppapi/shared_impl/ppb_file_ref_shared.cc new file mode 100644 index 0000000..6e748e1 --- /dev/null +++ b/ppapi/shared_impl/ppb_file_ref_shared.cc @@ -0,0 +1,67 @@ +// 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/shared_impl/ppb_file_ref_shared.h" + +#include "base/logging.h" +#include "ppapi/shared_impl/ppapi_globals.h" +#include "ppapi/shared_impl/var.h" + +namespace ppapi { + +PPB_FileRef_Shared::PPB_FileRef_Shared(const InitAsImpl&, + const PPB_FileRef_CreateInfo& info) + : Resource(info.resource.instance()), + create_info_(info) { + // Should not have been passed a host resource for the trusted constructor. + DCHECK(info.resource.is_null()); + + // Resource's constructor assigned a PP_Resource, so we can fill out our + // host resource now. + create_info_.resource = host_resource(); + DCHECK(!create_info_.resource.is_null()); +} + +PPB_FileRef_Shared::PPB_FileRef_Shared(const InitAsProxy&, + const PPB_FileRef_CreateInfo& info) + : Resource(info.resource), + create_info_(info) { +} + +PPB_FileRef_Shared::~PPB_FileRef_Shared() { +} + +thunk::PPB_FileRef_API* PPB_FileRef_Shared::AsPPB_FileRef_API() { + return this; +} + +PP_FileSystemType PPB_FileRef_Shared::GetFileSystemType() const { + return static_cast(create_info_.file_system_type); +} + +PP_Var PPB_FileRef_Shared::GetName() const { + if (!name_var_.get()) { + name_var_ = new StringVar( + PpapiGlobals::Get()->GetModuleForInstance(pp_instance()), + create_info_.name); + } + return name_var_->GetPPVar(); +} + +PP_Var PPB_FileRef_Shared::GetPath() const { + if (create_info_.file_system_type == PP_FILESYSTEMTYPE_EXTERNAL) + return PP_MakeUndefined(); + if (!path_var_.get()) { + path_var_ = new StringVar( + PpapiGlobals::Get()->GetModuleForInstance(pp_instance()), + create_info_.path); + } + return path_var_->GetPPVar(); +} + +const PPB_FileRef_CreateInfo& PPB_FileRef_Shared::GetCreateInfo() const { + return create_info_; +} + +} // namespace ppapi diff --git a/ppapi/shared_impl/ppb_file_ref_shared.h b/ppapi/shared_impl/ppb_file_ref_shared.h new file mode 100644 index 0000000..3d0a9f8 --- /dev/null +++ b/ppapi/shared_impl/ppb_file_ref_shared.h @@ -0,0 +1,66 @@ +// 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_SHARED_IMPL_PPB_FILE_REF_SHARED_H_ +#define PPAPI_SHARED_IMPL_PPB_FILE_REF_SHARED_H_ + +#include + +#include "base/compiler_specific.h" +#include "ppapi/shared_impl/resource.h" +#include "ppapi/thunk/ppb_file_ref_api.h" + +namespace ppapi { + +class StringVar; + +// FileRefs are created in a number of places and they include a number of +// return values. This struct encapsulates everything in one place. +struct PPB_FileRef_CreateInfo { + PPB_FileRef_CreateInfo() : file_system_type(PP_FILESYSTEMTYPE_EXTERNAL) {} + + ppapi::HostResource resource; + int file_system_type; // One of PP_FileSystemType values. + std::string path; + std::string name; +}; + +// This class provides the shared implementation of a FileRef. The functions +// that actually "do stuff" like Touch and MakeDirectory are implemented +// differently for the proxied and non-proxied derived classes. +class PPAPI_SHARED_EXPORT PPB_FileRef_Shared + : public Resource, + public thunk::PPB_FileRef_API { + public: + struct InitAsImpl {}; + struct InitAsProxy {}; + + PPB_FileRef_Shared(const InitAsImpl&, const PPB_FileRef_CreateInfo& info); + PPB_FileRef_Shared(const InitAsProxy&, const PPB_FileRef_CreateInfo& info); + virtual ~PPB_FileRef_Shared(); + + // Resource overrides. + virtual thunk::PPB_FileRef_API* AsPPB_FileRef_API() OVERRIDE; + + // PPB_FileRef_API implementation (partial). + virtual PP_FileSystemType GetFileSystemType() const OVERRIDE; + virtual PP_Var GetName() const OVERRIDE; + virtual PP_Var GetPath() const OVERRIDE; + virtual const PPB_FileRef_CreateInfo& GetCreateInfo() const OVERRIDE; + virtual PP_Var GetAbsolutePath() = 0; + + private: + PPB_FileRef_CreateInfo create_info_; + + // Lazily initialized vars created from the create_info_. This is so we can + // return the identical string object every time they're requested. + mutable scoped_refptr name_var_; + mutable scoped_refptr path_var_; + + DISALLOW_IMPLICIT_CONSTRUCTORS(PPB_FileRef_Shared); +}; + +} // namespace ppapi + +#endif // PPAPI_SHARED_IMPL_PPB_FILE_REF_SHARED_H_ diff --git a/ppapi/shared_impl/ppb_font_shared.cc b/ppapi/shared_impl/ppb_font_shared.cc new file mode 100644 index 0000000..a714643 --- /dev/null +++ b/ppapi/shared_impl/ppb_font_shared.cc @@ -0,0 +1,35 @@ +// 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/shared_impl/ppb_font_shared.h" + +#include "ppapi/c/dev/ppb_font_dev.h" + +namespace ppapi { + +// static +bool PPB_Font_Shared::IsPPFontDescriptionValid( + const PP_FontDescription_Dev& desc) { + // Check validity of string. We can't check the actual text since we could + // be on the wrong thread and don't know if we're in the plugin or the host. + if (desc.face.type != PP_VARTYPE_STRING && + desc.face.type != PP_VARTYPE_UNDEFINED) + return false; + + // Check enum ranges. + if (static_cast(desc.family) < PP_FONTFAMILY_DEFAULT || + static_cast(desc.family) > PP_FONTFAMILY_MONOSPACE) + return false; + if (static_cast(desc.weight) < PP_FONTWEIGHT_100 || + static_cast(desc.weight) > PP_FONTWEIGHT_900) + return false; + + // Check for excessive sizes which may cause layout to get confused. + if (desc.size > 200) + return false; + + return true; +} + +} // namespace ppapi diff --git a/ppapi/shared_impl/ppb_font_shared.h b/ppapi/shared_impl/ppb_font_shared.h new file mode 100644 index 0000000..af0f681 --- /dev/null +++ b/ppapi/shared_impl/ppb_font_shared.h @@ -0,0 +1,32 @@ +// 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_SHARED_IMPL_PPB_FONT_SHARED_H_ +#define PPAPI_SHARED_IMPL_PPB_FONT_SHARED_H_ +#pragma once + +#include + +#include "base/basictypes.h" +#include "base/memory/scoped_ptr.h" +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_stdint.h" +#include "ppapi/shared_impl/ppapi_shared_export.h" + +struct PP_FontDescription_Dev; + +namespace ppapi { + +class PPAPI_SHARED_EXPORT PPB_Font_Shared { + public: + // Validates the parameters in thee description. Can be called on any thread. + static bool IsPPFontDescriptionValid(const PP_FontDescription_Dev& desc); + + private: + DISALLOW_COPY_AND_ASSIGN(PPB_Font_Shared); +}; + +} // namespace ppapi + +#endif // PPAPI_SHARED_IMPL_PPB_FONT_SHARED_H_ diff --git a/ppapi/shared_impl/ppb_graphics_3d_shared.cc b/ppapi/shared_impl/ppb_graphics_3d_shared.cc new file mode 100644 index 0000000..9e0c155 --- /dev/null +++ b/ppapi/shared_impl/ppb_graphics_3d_shared.cc @@ -0,0 +1,137 @@ +// 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/shared_impl/ppb_graphics_3d_shared.h" + +#include "base/logging.h" +#include "gpu/command_buffer/client/gles2_cmd_helper.h" +#include "gpu/command_buffer/client/gles2_implementation.h" +#include "ppapi/c/pp_errors.h" + +namespace ppapi { + +PPB_Graphics3D_Shared::PPB_Graphics3D_Shared() + : transfer_buffer_id_(-1), + swap_callback_(PP_BlockUntilComplete()) { +} + +PPB_Graphics3D_Shared::~PPB_Graphics3D_Shared() { + // Make sure that GLES2 implementation has already been destroyed. + DCHECK_EQ(transfer_buffer_id_, -1); + DCHECK(!gles2_helper_.get()); + DCHECK(!gles2_impl_.get()); +} + +int32_t PPB_Graphics3D_Shared::GetAttribs(int32_t* attrib_list) { + // TODO(alokp): Implement me. + return PP_ERROR_FAILED; +} + +int32_t PPB_Graphics3D_Shared::SetAttribs(int32_t* attrib_list) { + // TODO(alokp): Implement me. + return PP_ERROR_FAILED; +} + +int32_t PPB_Graphics3D_Shared::GetError() { + // TODO(alokp): Implement me. + return PP_ERROR_FAILED; +} + +int32_t PPB_Graphics3D_Shared::ResizeBuffers(int32_t width, int32_t height) { + if ((width < 0) || (height < 0)) + return PP_ERROR_BADARGUMENT; + + gles2_impl()->ResizeCHROMIUM(width, height); + // TODO(alokp): Check if resize succeeded and return appropriate error code. + return PP_OK; +} + +int32_t PPB_Graphics3D_Shared::SwapBuffers(PP_CompletionCallback callback) { + if (!callback.func) { + // Blocking SwapBuffers isn't supported (since we have to be on the main + // thread). + return PP_ERROR_BADARGUMENT; + } + + if (HasPendingSwap()) { + // Already a pending SwapBuffers that hasn't returned yet. + return PP_ERROR_INPROGRESS; + } + + swap_callback_ = callback; + return DoSwapBuffers(); +} + +void* PPB_Graphics3D_Shared::MapTexSubImage2DCHROMIUM(GLenum target, + GLint level, + GLint xoffset, + GLint yoffset, + GLsizei width, + GLsizei height, + GLenum format, + GLenum type, + GLenum access) { + return gles2_impl_->MapTexSubImage2DCHROMIUM( + target, level, xoffset, yoffset, width, height, format, type, access); +} + +void PPB_Graphics3D_Shared::UnmapTexSubImage2DCHROMIUM(const void* mem) { + gles2_impl_->UnmapTexSubImage2DCHROMIUM(mem); +} + +void PPB_Graphics3D_Shared::SwapBuffersACK(int32_t pp_error) { + DCHECK(HasPendingSwap()); + PP_RunAndClearCompletionCallback(&swap_callback_, pp_error); +} + +bool PPB_Graphics3D_Shared::CreateGLES2Impl(int32 command_buffer_size, + int32 transfer_buffer_size) { + gpu::CommandBuffer* command_buffer = GetCommandBuffer(); + DCHECK(command_buffer); + + // Create the GLES2 helper, which writes the command buffer protocol. + gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer)); + if (!gles2_helper_->Initialize(command_buffer_size)) + return false; + + // Create a transfer buffer used to copy resources between the renderer + // process and the GPU process. + transfer_buffer_id_ = + command_buffer->CreateTransferBuffer(transfer_buffer_size, -1); + if (transfer_buffer_id_ < 0) + return false; + + // Map the buffer into the renderer process's address space. + gpu::Buffer transfer_buffer = + command_buffer->GetTransferBuffer(transfer_buffer_id_); + if (!transfer_buffer.ptr) + return false; + + // Create the object exposing the OpenGL API. + gles2_impl_.reset(new gpu::gles2::GLES2Implementation( + gles2_helper_.get(), + transfer_buffer.size, + transfer_buffer.ptr, + transfer_buffer_id_, + false, + true)); + + return true; +} + +void PPB_Graphics3D_Shared::DestroyGLES2Impl() { + gles2_impl_.reset(); + + if (transfer_buffer_id_ != -1) { + gpu::CommandBuffer* command_buffer = GetCommandBuffer(); + DCHECK(command_buffer); + command_buffer->DestroyTransferBuffer(transfer_buffer_id_); + transfer_buffer_id_ = -1; + } + + gles2_helper_.reset(); +} + +} // namespace ppapi + diff --git a/ppapi/shared_impl/ppb_graphics_3d_shared.h b/ppapi/shared_impl/ppb_graphics_3d_shared.h new file mode 100644 index 0000000..6f3a04f --- /dev/null +++ b/ppapi/shared_impl/ppb_graphics_3d_shared.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_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ +#define PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ + +#include "base/basictypes.h" +#include "base/memory/scoped_ptr.h" +#include "ppapi/c/pp_completion_callback.h" +#include "ppapi/shared_impl/ppapi_shared_export.h" +#include "ppapi/thunk/ppb_graphics_3d_api.h" + +namespace gpu { +class CommandBuffer; +namespace gles2 { +class GLES2CmdHelper; +class GLES2Implementation; +} // namespace gles2 +} // namespace gpu. + +namespace ppapi { + +class PPAPI_SHARED_EXPORT PPB_Graphics3D_Shared + : public thunk::PPB_Graphics3D_API { + public: + // PPB_Graphics3D_API implementation. + virtual int32_t GetAttribs(int32_t* attrib_list) OVERRIDE; + virtual int32_t SetAttribs(int32_t* attrib_list) OVERRIDE; + virtual int32_t GetError() OVERRIDE; + virtual int32_t ResizeBuffers(int32_t width, int32_t height) OVERRIDE; + virtual int32_t SwapBuffers(PP_CompletionCallback callback) OVERRIDE; + virtual void* MapTexSubImage2DCHROMIUM(GLenum target, + GLint level, + GLint xoffset, + GLint yoffset, + GLsizei width, + GLsizei height, + GLenum format, + GLenum type, + GLenum access) OVERRIDE; + virtual void UnmapTexSubImage2DCHROMIUM(const void* mem) OVERRIDE; + + gpu::gles2::GLES2Implementation* gles2_impl() { + return gles2_impl_.get(); + } + + // Sends swap-buffers notification to the plugin. + void SwapBuffersACK(int32_t pp_error); + + protected: + PPB_Graphics3D_Shared(); + virtual ~PPB_Graphics3D_Shared(); + + virtual gpu::CommandBuffer* GetCommandBuffer() = 0; + virtual int32 DoSwapBuffers() = 0; + + bool HasPendingSwap() { return swap_callback_.func != NULL; } + bool CreateGLES2Impl(int32 command_buffer_size, + int32 transfer_buffer_size); + void DestroyGLES2Impl(); + + private: + int32 transfer_buffer_id_; + scoped_ptr gles2_helper_; + scoped_ptr gles2_impl_; + + // Callback that needs to be executed when swap-buffers is completed. + PP_CompletionCallback swap_callback_; + + DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Shared); +}; + +} // namespace ppapi + +#endif // PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ + diff --git a/ppapi/shared_impl/ppb_image_data_shared.cc b/ppapi/shared_impl/ppb_image_data_shared.cc new file mode 100644 index 0000000..b0935e4 --- /dev/null +++ b/ppapi/shared_impl/ppb_image_data_shared.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/shared_impl/ppb_image_data_shared.h" + +#include "third_party/skia/include/core/SkTypes.h" + +namespace ppapi { + +// static +PP_ImageDataFormat PPB_ImageData_Shared::GetNativeImageDataFormat() { + if (SK_B32_SHIFT == 0) + return PP_IMAGEDATAFORMAT_BGRA_PREMUL; + else if (SK_R32_SHIFT == 0) + return PP_IMAGEDATAFORMAT_RGBA_PREMUL; + else + return PP_IMAGEDATAFORMAT_BGRA_PREMUL; // Default to something on failure. +} + +// static +bool PPB_ImageData_Shared::IsImageDataFormatSupported( + PP_ImageDataFormat format) { + return format == PP_IMAGEDATAFORMAT_BGRA_PREMUL || + format == PP_IMAGEDATAFORMAT_RGBA_PREMUL; +} + +} // namespace ppapi diff --git a/ppapi/shared_impl/ppb_image_data_shared.h b/ppapi/shared_impl/ppb_image_data_shared.h new file mode 100644 index 0000000..4f9a4d5 --- /dev/null +++ b/ppapi/shared_impl/ppb_image_data_shared.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. + +#ifndef PPAPI_SHARED_IMPL_PPB_IMAGE_DATA_SHARED_H_ +#define PPAPI_SHARED_IMPL_PPB_IMAGE_DATA_SHARED_H_ + +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/ppb_image_data.h" +#include "ppapi/shared_impl/ppapi_shared_export.h" + +namespace ppapi { + +// Contains the implementation of some simple image data functions that are +// shared between the proxy and Chrome's implementation. Since these functions +// are just lists of what we support, it's much easier to just have the same +// code run in the plugin process than to proxy it. +// +// It's possible the implementation will get more complex. In this case, it's +// probably best to have some kind of "configuration" message that the renderer +// sends to the plugin process on startup that contains all of these kind of +// settings. +class PPAPI_SHARED_EXPORT PPB_ImageData_Shared { + public: + static PP_ImageDataFormat GetNativeImageDataFormat(); + static bool IsImageDataFormatSupported(PP_ImageDataFormat format); +}; + +} // namespace ppapi + +#endif // PPAPI_SHARED_IMPL_PPB_IMAGE_DATA_SHARED_H_ diff --git a/ppapi/shared_impl/ppb_input_event_shared.cc b/ppapi/shared_impl/ppb_input_event_shared.cc new file mode 100644 index 0000000..962f701 --- /dev/null +++ b/ppapi/shared_impl/ppb_input_event_shared.cc @@ -0,0 +1,131 @@ +// 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/shared_impl/ppb_input_event_shared.h" + +#include "ppapi/shared_impl/ppapi_globals.h" +#include "ppapi/shared_impl/var.h" + +using ppapi::thunk::PPB_InputEvent_API; + +namespace ppapi { + +InputEventData::InputEventData() + : is_filtered(false), + event_type(PP_INPUTEVENT_TYPE_UNDEFINED), + event_time_stamp(0.0), + event_modifiers(0), + mouse_button(PP_INPUTEVENT_MOUSEBUTTON_NONE), + mouse_position(PP_MakePoint(0, 0)), + mouse_click_count(0), + mouse_movement(PP_MakePoint(0, 0)), + wheel_delta(PP_MakeFloatPoint(0.0f, 0.0f)), + wheel_ticks(PP_MakeFloatPoint(0.0f, 0.0f)), + wheel_scroll_by_page(false), + key_code(0), + character_text(), + composition_target_segment(-1), + composition_selection_start(0), + composition_selection_end(0) { +} + +InputEventData::~InputEventData() { +} + +PPB_InputEvent_Shared::PPB_InputEvent_Shared(const InitAsImpl&, + PP_Instance instance, + const InputEventData& data) + : Resource(instance), + data_(data) { +} + +PPB_InputEvent_Shared::PPB_InputEvent_Shared(const InitAsProxy&, + PP_Instance instance, + const InputEventData& data) + : Resource(HostResource::MakeInstanceOnly(instance)), + data_(data) { +} + +PPB_InputEvent_API* PPB_InputEvent_Shared::AsPPB_InputEvent_API() { + return this; +} + +const InputEventData& PPB_InputEvent_Shared::GetInputEventData() const { + return data_; +} + +PP_InputEvent_Type PPB_InputEvent_Shared::GetType() { + return data_.event_type; +} + +PP_TimeTicks PPB_InputEvent_Shared::GetTimeStamp() { + return data_.event_time_stamp; +} + +uint32_t PPB_InputEvent_Shared::GetModifiers() { + return data_.event_modifiers; +} + +PP_InputEvent_MouseButton PPB_InputEvent_Shared::GetMouseButton() { + return data_.mouse_button; +} + +PP_Point PPB_InputEvent_Shared::GetMousePosition() { + return data_.mouse_position; +} + +int32_t PPB_InputEvent_Shared::GetMouseClickCount() { + return data_.mouse_click_count; +} + +PP_Point PPB_InputEvent_Shared::GetMouseMovement() { + return data_.mouse_movement; +} + +PP_FloatPoint PPB_InputEvent_Shared::GetWheelDelta() { + return data_.wheel_delta; +} + +PP_FloatPoint PPB_InputEvent_Shared::GetWheelTicks() { + return data_.wheel_ticks; +} + +PP_Bool PPB_InputEvent_Shared::GetWheelScrollByPage() { + return PP_FromBool(data_.wheel_scroll_by_page); +} + +uint32_t PPB_InputEvent_Shared::GetKeyCode() { + return data_.key_code; +} + +PP_Var PPB_InputEvent_Shared::GetCharacterText() { + return StringVar::StringToPPVar( + PpapiGlobals::Get()->GetModuleForInstance(pp_instance()), + data_.character_text); +} + +uint32_t PPB_InputEvent_Shared::GetIMESegmentNumber() { + if (data_.composition_segment_offsets.empty()) + return 0; + return data_.composition_segment_offsets.size() - 1; +} + +uint32_t PPB_InputEvent_Shared::GetIMESegmentOffset(uint32_t index) { + if (index >= data_.composition_segment_offsets.size()) + return 0; + return data_.composition_segment_offsets[index]; +} + +int32_t PPB_InputEvent_Shared::GetIMETargetSegment() { + return data_.composition_target_segment; +} + +void PPB_InputEvent_Shared::GetIMESelection(uint32_t* start, uint32_t* end) { + if (start) + *start = data_.composition_selection_start; + if (end) + *end = data_.composition_selection_end; +} + +} // namespace ppapi diff --git a/ppapi/shared_impl/ppb_input_event_shared.h b/ppapi/shared_impl/ppb_input_event_shared.h new file mode 100644 index 0000000..1a29750 --- /dev/null +++ b/ppapi/shared_impl/ppb_input_event_shared.h @@ -0,0 +1,100 @@ +// 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_SHARED_IMPL_PPB_INPUT_EVENT_SHARED_H_ +#define PPAPI_SHARED_IMPL_PPB_INPUT_EVENT_SHARED_H_ + +#include +#include + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "ppapi/shared_impl/resource.h" +#include "ppapi/thunk/ppb_input_event_api.h" + +namespace ppapi { + +// IF YOU ADD STUFF TO THIS CLASS +// ============================== +// Be sure to add it to the STRUCT_TRAITS at the top of ppapi_messages.h +struct PPAPI_SHARED_EXPORT InputEventData { + InputEventData(); + ~InputEventData(); + + // Internal-only value. Set to true when this input event is filtered, that + // is, should be delivered synchronously. This is used by the proxy. + bool is_filtered; + + PP_InputEvent_Type event_type; + PP_TimeTicks event_time_stamp; + uint32_t event_modifiers; + + PP_InputEvent_MouseButton mouse_button; + PP_Point mouse_position; + int32_t mouse_click_count; + PP_Point mouse_movement; + + PP_FloatPoint wheel_delta; + PP_FloatPoint wheel_ticks; + bool wheel_scroll_by_page; + + uint32_t key_code; + + std::string character_text; + + std::vector composition_segment_offsets; + int32_t composition_target_segment; + uint32_t composition_selection_start; + uint32_t composition_selection_end; +}; + +// This simple class implements the PPB_InputEvent_API in terms of the +// shared InputEventData structure +class PPAPI_SHARED_EXPORT PPB_InputEvent_Shared + : public Resource, + public thunk::PPB_InputEvent_API { + public: + struct InitAsImpl {}; + struct InitAsProxy {}; + + // The dummy arguments control which version of Resource's constructor is + // called for this base class. + PPB_InputEvent_Shared(const InitAsImpl&, + PP_Instance instance, + const InputEventData& data); + PPB_InputEvent_Shared(const InitAsProxy&, + PP_Instance instance, + const InputEventData& data); + + // Resource overrides. + virtual PPB_InputEvent_API* AsPPB_InputEvent_API() OVERRIDE; + + // PPB_InputEvent_API implementation. + virtual const InputEventData& GetInputEventData() const OVERRIDE; + virtual PP_InputEvent_Type GetType() OVERRIDE; + virtual PP_TimeTicks GetTimeStamp() OVERRIDE; + virtual uint32_t GetModifiers() OVERRIDE; + virtual PP_InputEvent_MouseButton GetMouseButton() OVERRIDE; + virtual PP_Point GetMousePosition() OVERRIDE; + virtual int32_t GetMouseClickCount() OVERRIDE; + virtual PP_Point GetMouseMovement() OVERRIDE; + virtual PP_FloatPoint GetWheelDelta() OVERRIDE; + virtual PP_FloatPoint GetWheelTicks() OVERRIDE; + virtual PP_Bool GetWheelScrollByPage() OVERRIDE; + virtual uint32_t GetKeyCode() OVERRIDE; + virtual PP_Var GetCharacterText() OVERRIDE; + virtual uint32_t GetIMESegmentNumber() OVERRIDE; + virtual uint32_t GetIMESegmentOffset(uint32_t index) OVERRIDE; + virtual int32_t GetIMETargetSegment() OVERRIDE; + virtual void GetIMESelection(uint32_t* start, uint32_t* end) OVERRIDE; + + private: + InputEventData data_; + + DISALLOW_IMPLICIT_CONSTRUCTORS(PPB_InputEvent_Shared); +}; + +} // namespace ppapi + +#endif // PPAPI_SHARED_IMPL_PPB_INPUT_EVENT_SHARED_H_ diff --git a/ppapi/shared_impl/ppb_instance_shared.cc b/ppapi/shared_impl/ppb_instance_shared.cc new file mode 100644 index 0000000..a2416ce --- /dev/null +++ b/ppapi/shared_impl/ppb_instance_shared.cc @@ -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. + +#include "ppapi/shared_impl/ppb_instance_shared.h" + +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/ppb_input_event.h" + +namespace ppapi { + +PPB_Instance_Shared::~PPB_Instance_Shared() { +} + +int32_t PPB_Instance_Shared::ValidateRequestInputEvents( + bool is_filtering, + uint32_t event_classes) { + // See if any bits are set we don't know about. + if (event_classes & + ~static_cast(PP_INPUTEVENT_CLASS_MOUSE | + PP_INPUTEVENT_CLASS_KEYBOARD | + PP_INPUTEVENT_CLASS_WHEEL | + PP_INPUTEVENT_CLASS_TOUCH | + PP_INPUTEVENT_CLASS_IME)) + return PP_ERROR_NOTSUPPORTED; + + // Everything else is valid. + return PP_OK; +} + +} // namespace ppapi diff --git a/ppapi/shared_impl/ppb_instance_shared.h b/ppapi/shared_impl/ppb_instance_shared.h new file mode 100644 index 0000000..353a822 --- /dev/null +++ b/ppapi/shared_impl/ppb_instance_shared.h @@ -0,0 +1,24 @@ +// 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_SHARED_IMPL_PPB_INSTANCE_SHARED_H_ +#define PPAPI_SHARED_IMPL_PPB_INSTANCE_SHARED_H_ + +#include "ppapi/c/pp_stdint.h" +#include "ppapi/shared_impl/ppapi_shared_export.h" + +namespace ppapi { + +class PPAPI_SHARED_EXPORT PPB_Instance_Shared { + public: + virtual ~PPB_Instance_Shared(); + + // Error checks the given resquest to Request[Filtering]InputEvents. Returns + // PP_OK if the given classes are all valid, PP_ERROR_NOTSUPPORTED if not. + int32_t ValidateRequestInputEvents(bool is_filtering, uint32_t event_classes); +}; + +} // namespace ppapi + +#endif // PPAPI_SHARED_IMPL_PPB_INSTANCE_SHARED_H_ diff --git a/ppapi/shared_impl/ppb_memory_shared.cc b/ppapi/shared_impl/ppb_memory_shared.cc new file mode 100644 index 0000000..2cf8aa7 --- /dev/null +++ b/ppapi/shared_impl/ppb_memory_shared.cc @@ -0,0 +1,43 @@ +// 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 + +#include "ppapi/c/dev/ppb_memory_dev.h" +#include "ppapi/shared_impl/ppapi_shared_export.h" + +// The memory interface doesn't have a normal C -> C++ thunk since it doesn't +// actually have any proxy wrapping or associated objects; it's just a call +// into base. So we implement the entire interface here, using the thunk +// namespace so it magically gets hooked up in the proper places. + +namespace ppapi { + +namespace { + +void* MemAlloc(uint32_t num_bytes) { + return malloc(num_bytes); +} + +void MemFree(void* ptr) { + free(ptr); +} + +const PPB_Memory_Dev ppb_memory = { + &MemAlloc, + &MemFree +}; + +} // namespace + +namespace thunk { + +// static +PPAPI_SHARED_EXPORT const PPB_Memory_Dev* GetPPB_Memory_Dev_Thunk() { + return &ppb_memory; +} + +} // namespace thunk + +} // namespace ppapi diff --git a/ppapi/shared_impl/ppb_opengles2_shared.cc b/ppapi/shared_impl/ppb_opengles2_shared.cc new file mode 100644 index 0000000..635ea41 --- /dev/null +++ b/ppapi/shared_impl/ppb_opengles2_shared.cc @@ -0,0 +1,898 @@ +// 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 is auto-generated from +// gpu/command_buffer/build_gles2_cmd_buffer.py +// DO NOT EDIT! + +#include "ppapi/shared_impl/ppb_opengles2_shared.h" + +#include "base/logging.h" +#include "gpu/command_buffer/client/gles2_implementation.h" +#include "ppapi/shared_impl/ppb_graphics_3d_shared.h" +#include "ppapi/thunk/enter.h" + +namespace ppapi { + +namespace { + +gpu::gles2::GLES2Implementation* GetGLES(PP_Resource context) { + thunk::EnterResource enter_g3d(context, false); + DCHECK(enter_g3d.succeeded()); + return static_cast(enter_g3d.object())->gles2_impl(); +} + +void ActiveTexture(PP_Resource context_id, GLenum texture) { + GetGLES(context_id)->ActiveTexture(texture); +} + +void AttachShader(PP_Resource context_id, GLuint program, GLuint shader) { + GetGLES(context_id)->AttachShader(program, shader); +} + +void BindAttribLocation( + PP_Resource context_id, GLuint program, GLuint index, const char* name) { + GetGLES(context_id)->BindAttribLocation(program, index, name); +} + +void BindBuffer(PP_Resource context_id, GLenum target, GLuint buffer) { + GetGLES(context_id)->BindBuffer(target, buffer); +} + +void BindFramebuffer( + PP_Resource context_id, GLenum target, GLuint framebuffer) { + GetGLES(context_id)->BindFramebuffer(target, framebuffer); +} + +void BindRenderbuffer( + PP_Resource context_id, GLenum target, GLuint renderbuffer) { + GetGLES(context_id)->BindRenderbuffer(target, renderbuffer); +} + +void BindTexture(PP_Resource context_id, GLenum target, GLuint texture) { + GetGLES(context_id)->BindTexture(target, texture); +} + +void BlendColor( + PP_Resource context_id, GLclampf red, GLclampf green, GLclampf blue, + GLclampf alpha) { + GetGLES(context_id)->BlendColor(red, green, blue, alpha); +} + +void BlendEquation(PP_Resource context_id, GLenum mode) { + GetGLES(context_id)->BlendEquation(mode); +} + +void BlendEquationSeparate( + PP_Resource context_id, GLenum modeRGB, GLenum modeAlpha) { + GetGLES(context_id)->BlendEquationSeparate(modeRGB, modeAlpha); +} + +void BlendFunc(PP_Resource context_id, GLenum sfactor, GLenum dfactor) { + GetGLES(context_id)->BlendFunc(sfactor, dfactor); +} + +void BlendFuncSeparate( + PP_Resource context_id, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, + GLenum dstAlpha) { + GetGLES(context_id)->BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); +} + +void BufferData( + PP_Resource context_id, GLenum target, GLsizeiptr size, const void* data, + GLenum usage) { + GetGLES(context_id)->BufferData(target, size, data, usage); +} + +void BufferSubData( + PP_Resource context_id, GLenum target, GLintptr offset, GLsizeiptr size, + const void* data) { + GetGLES(context_id)->BufferSubData(target, offset, size, data); +} + +GLenum CheckFramebufferStatus(PP_Resource context_id, GLenum target) { + return GetGLES(context_id)->CheckFramebufferStatus(target); +} + +void Clear(PP_Resource context_id, GLbitfield mask) { + GetGLES(context_id)->Clear(mask); +} + +void ClearColor( + PP_Resource context_id, GLclampf red, GLclampf green, GLclampf blue, + GLclampf alpha) { + GetGLES(context_id)->ClearColor(red, green, blue, alpha); +} + +void ClearDepthf(PP_Resource context_id, GLclampf depth) { + GetGLES(context_id)->ClearDepthf(depth); +} + +void ClearStencil(PP_Resource context_id, GLint s) { + GetGLES(context_id)->ClearStencil(s); +} + +void ColorMask( + PP_Resource context_id, GLboolean red, GLboolean green, GLboolean blue, + GLboolean alpha) { + GetGLES(context_id)->ColorMask(red, green, blue, alpha); +} + +void CompileShader(PP_Resource context_id, GLuint shader) { + GetGLES(context_id)->CompileShader(shader); +} + +void CompressedTexImage2D( + PP_Resource context_id, GLenum target, GLint level, GLenum internalformat, + GLsizei width, GLsizei height, GLint border, GLsizei imageSize, + const void* data) { + GetGLES( + context_id)->CompressedTexImage2D( + target, level, internalformat, width, height, border, imageSize, + data); +} + +void CompressedTexSubImage2D( + PP_Resource context_id, GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLsizei width, GLsizei height, GLenum format, + GLsizei imageSize, const void* data) { + GetGLES( + context_id)->CompressedTexSubImage2D( + target, level, xoffset, yoffset, width, height, format, imageSize, + data); +} + +void CopyTexImage2D( + PP_Resource context_id, GLenum target, GLint level, GLenum internalformat, + GLint x, GLint y, GLsizei width, GLsizei height, GLint border) { + GetGLES( + context_id)->CopyTexImage2D( + target, level, internalformat, x, y, width, height, border); +} + +void CopyTexSubImage2D( + PP_Resource context_id, GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) { + GetGLES( + context_id)->CopyTexSubImage2D( + target, level, xoffset, yoffset, x, y, width, height); +} + +GLuint CreateProgram(PP_Resource context_id) { + return GetGLES(context_id)->CreateProgram(); +} + +GLuint CreateShader(PP_Resource context_id, GLenum type) { + return GetGLES(context_id)->CreateShader(type); +} + +void CullFace(PP_Resource context_id, GLenum mode) { + GetGLES(context_id)->CullFace(mode); +} + +void DeleteBuffers(PP_Resource context_id, GLsizei n, const GLuint* buffers) { + GetGLES(context_id)->DeleteBuffers(n, buffers); +} + +void DeleteFramebuffers( + PP_Resource context_id, GLsizei n, const GLuint* framebuffers) { + GetGLES(context_id)->DeleteFramebuffers(n, framebuffers); +} + +void DeleteProgram(PP_Resource context_id, GLuint program) { + GetGLES(context_id)->DeleteProgram(program); +} + +void DeleteRenderbuffers( + PP_Resource context_id, GLsizei n, const GLuint* renderbuffers) { + GetGLES(context_id)->DeleteRenderbuffers(n, renderbuffers); +} + +void DeleteShader(PP_Resource context_id, GLuint shader) { + GetGLES(context_id)->DeleteShader(shader); +} + +void DeleteTextures( + PP_Resource context_id, GLsizei n, const GLuint* textures) { + GetGLES(context_id)->DeleteTextures(n, textures); +} + +void DepthFunc(PP_Resource context_id, GLenum func) { + GetGLES(context_id)->DepthFunc(func); +} + +void DepthMask(PP_Resource context_id, GLboolean flag) { + GetGLES(context_id)->DepthMask(flag); +} + +void DepthRangef(PP_Resource context_id, GLclampf zNear, GLclampf zFar) { + GetGLES(context_id)->DepthRangef(zNear, zFar); +} + +void DetachShader(PP_Resource context_id, GLuint program, GLuint shader) { + GetGLES(context_id)->DetachShader(program, shader); +} + +void Disable(PP_Resource context_id, GLenum cap) { + GetGLES(context_id)->Disable(cap); +} + +void DisableVertexAttribArray(PP_Resource context_id, GLuint index) { + GetGLES(context_id)->DisableVertexAttribArray(index); +} + +void DrawArrays( + PP_Resource context_id, GLenum mode, GLint first, GLsizei count) { + GetGLES(context_id)->DrawArrays(mode, first, count); +} + +void DrawElements( + PP_Resource context_id, GLenum mode, GLsizei count, GLenum type, + const void* indices) { + GetGLES(context_id)->DrawElements(mode, count, type, indices); +} + +void Enable(PP_Resource context_id, GLenum cap) { + GetGLES(context_id)->Enable(cap); +} + +void EnableVertexAttribArray(PP_Resource context_id, GLuint index) { + GetGLES(context_id)->EnableVertexAttribArray(index); +} + +void Finish(PP_Resource context_id) { + GetGLES(context_id)->Finish(); +} + +void Flush(PP_Resource context_id) { + GetGLES(context_id)->Flush(); +} + +void FramebufferRenderbuffer( + PP_Resource context_id, GLenum target, GLenum attachment, + GLenum renderbuffertarget, GLuint renderbuffer) { + GetGLES( + context_id)->FramebufferRenderbuffer( + target, attachment, renderbuffertarget, renderbuffer); +} + +void FramebufferTexture2D( + PP_Resource context_id, GLenum target, GLenum attachment, GLenum textarget, + GLuint texture, GLint level) { + GetGLES( + context_id)->FramebufferTexture2D( + target, attachment, textarget, texture, level); +} + +void FrontFace(PP_Resource context_id, GLenum mode) { + GetGLES(context_id)->FrontFace(mode); +} + +void GenBuffers(PP_Resource context_id, GLsizei n, GLuint* buffers) { + GetGLES(context_id)->GenBuffers(n, buffers); +} + +void GenerateMipmap(PP_Resource context_id, GLenum target) { + GetGLES(context_id)->GenerateMipmap(target); +} + +void GenFramebuffers(PP_Resource context_id, GLsizei n, GLuint* framebuffers) { + GetGLES(context_id)->GenFramebuffers(n, framebuffers); +} + +void GenRenderbuffers( + PP_Resource context_id, GLsizei n, GLuint* renderbuffers) { + GetGLES(context_id)->GenRenderbuffers(n, renderbuffers); +} + +void GenTextures(PP_Resource context_id, GLsizei n, GLuint* textures) { + GetGLES(context_id)->GenTextures(n, textures); +} + +void GetActiveAttrib( + PP_Resource context_id, GLuint program, GLuint index, GLsizei bufsize, + GLsizei* length, GLint* size, GLenum* type, char* name) { + GetGLES( + context_id)->GetActiveAttrib( + program, index, bufsize, length, size, type, name); +} + +void GetActiveUniform( + PP_Resource context_id, GLuint program, GLuint index, GLsizei bufsize, + GLsizei* length, GLint* size, GLenum* type, char* name) { + GetGLES( + context_id)->GetActiveUniform( + program, index, bufsize, length, size, type, name); +} + +void GetAttachedShaders( + PP_Resource context_id, GLuint program, GLsizei maxcount, GLsizei* count, + GLuint* shaders) { + GetGLES(context_id)->GetAttachedShaders(program, maxcount, count, shaders); +} + +GLint GetAttribLocation( + PP_Resource context_id, GLuint program, const char* name) { + return GetGLES(context_id)->GetAttribLocation(program, name); +} + +void GetBooleanv(PP_Resource context_id, GLenum pname, GLboolean* params) { + GetGLES(context_id)->GetBooleanv(pname, params); +} + +void GetBufferParameteriv( + PP_Resource context_id, GLenum target, GLenum pname, GLint* params) { + GetGLES(context_id)->GetBufferParameteriv(target, pname, params); +} + +GLenum GetError(PP_Resource context_id) { + return GetGLES(context_id)->GetError(); +} + +void GetFloatv(PP_Resource context_id, GLenum pname, GLfloat* params) { + GetGLES(context_id)->GetFloatv(pname, params); +} + +void GetFramebufferAttachmentParameteriv( + PP_Resource context_id, GLenum target, GLenum attachment, GLenum pname, + GLint* params) { + GetGLES( + context_id)->GetFramebufferAttachmentParameteriv( + target, attachment, pname, params); +} + +void GetIntegerv(PP_Resource context_id, GLenum pname, GLint* params) { + GetGLES(context_id)->GetIntegerv(pname, params); +} + +void GetProgramiv( + PP_Resource context_id, GLuint program, GLenum pname, GLint* params) { + GetGLES(context_id)->GetProgramiv(program, pname, params); +} + +void GetProgramInfoLog( + PP_Resource context_id, GLuint program, GLsizei bufsize, GLsizei* length, + char* infolog) { + GetGLES(context_id)->GetProgramInfoLog(program, bufsize, length, infolog); +} + +void GetRenderbufferParameteriv( + PP_Resource context_id, GLenum target, GLenum pname, GLint* params) { + GetGLES(context_id)->GetRenderbufferParameteriv(target, pname, params); +} + +void GetShaderiv( + PP_Resource context_id, GLuint shader, GLenum pname, GLint* params) { + GetGLES(context_id)->GetShaderiv(shader, pname, params); +} + +void GetShaderInfoLog( + PP_Resource context_id, GLuint shader, GLsizei bufsize, GLsizei* length, + char* infolog) { + GetGLES(context_id)->GetShaderInfoLog(shader, bufsize, length, infolog); +} + +void GetShaderPrecisionFormat( + PP_Resource context_id, GLenum shadertype, GLenum precisiontype, + GLint* range, GLint* precision) { + GetGLES( + context_id)->GetShaderPrecisionFormat( + shadertype, precisiontype, range, precision); +} + +void GetShaderSource( + PP_Resource context_id, GLuint shader, GLsizei bufsize, GLsizei* length, + char* source) { + GetGLES(context_id)->GetShaderSource(shader, bufsize, length, source); +} + +const GLubyte* GetString(PP_Resource context_id, GLenum name) { + return GetGLES(context_id)->GetString(name); +} + +void GetTexParameterfv( + PP_Resource context_id, GLenum target, GLenum pname, GLfloat* params) { + GetGLES(context_id)->GetTexParameterfv(target, pname, params); +} + +void GetTexParameteriv( + PP_Resource context_id, GLenum target, GLenum pname, GLint* params) { + GetGLES(context_id)->GetTexParameteriv(target, pname, params); +} + +void GetUniformfv( + PP_Resource context_id, GLuint program, GLint location, GLfloat* params) { + GetGLES(context_id)->GetUniformfv(program, location, params); +} + +void GetUniformiv( + PP_Resource context_id, GLuint program, GLint location, GLint* params) { + GetGLES(context_id)->GetUniformiv(program, location, params); +} + +GLint GetUniformLocation( + PP_Resource context_id, GLuint program, const char* name) { + return GetGLES(context_id)->GetUniformLocation(program, name); +} + +void GetVertexAttribfv( + PP_Resource context_id, GLuint index, GLenum pname, GLfloat* params) { + GetGLES(context_id)->GetVertexAttribfv(index, pname, params); +} + +void GetVertexAttribiv( + PP_Resource context_id, GLuint index, GLenum pname, GLint* params) { + GetGLES(context_id)->GetVertexAttribiv(index, pname, params); +} + +void GetVertexAttribPointerv( + PP_Resource context_id, GLuint index, GLenum pname, void** pointer) { + GetGLES(context_id)->GetVertexAttribPointerv(index, pname, pointer); +} + +void Hint(PP_Resource context_id, GLenum target, GLenum mode) { + GetGLES(context_id)->Hint(target, mode); +} + +GLboolean IsBuffer(PP_Resource context_id, GLuint buffer) { + return GetGLES(context_id)->IsBuffer(buffer); +} + +GLboolean IsEnabled(PP_Resource context_id, GLenum cap) { + return GetGLES(context_id)->IsEnabled(cap); +} + +GLboolean IsFramebuffer(PP_Resource context_id, GLuint framebuffer) { + return GetGLES(context_id)->IsFramebuffer(framebuffer); +} + +GLboolean IsProgram(PP_Resource context_id, GLuint program) { + return GetGLES(context_id)->IsProgram(program); +} + +GLboolean IsRenderbuffer(PP_Resource context_id, GLuint renderbuffer) { + return GetGLES(context_id)->IsRenderbuffer(renderbuffer); +} + +GLboolean IsShader(PP_Resource context_id, GLuint shader) { + return GetGLES(context_id)->IsShader(shader); +} + +GLboolean IsTexture(PP_Resource context_id, GLuint texture) { + return GetGLES(context_id)->IsTexture(texture); +} + +void LineWidth(PP_Resource context_id, GLfloat width) { + GetGLES(context_id)->LineWidth(width); +} + +void LinkProgram(PP_Resource context_id, GLuint program) { + GetGLES(context_id)->LinkProgram(program); +} + +void PixelStorei(PP_Resource context_id, GLenum pname, GLint param) { + GetGLES(context_id)->PixelStorei(pname, param); +} + +void PolygonOffset(PP_Resource context_id, GLfloat factor, GLfloat units) { + GetGLES(context_id)->PolygonOffset(factor, units); +} + +void ReadPixels( + PP_Resource context_id, GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, void* pixels) { + GetGLES(context_id)->ReadPixels(x, y, width, height, format, type, pixels); +} + +void ReleaseShaderCompiler(PP_Resource context_id) { + GetGLES(context_id)->ReleaseShaderCompiler(); +} + +void RenderbufferStorage( + PP_Resource context_id, GLenum target, GLenum internalformat, GLsizei width, + GLsizei height) { + GetGLES( + context_id)->RenderbufferStorage(target, internalformat, width, height); +} + +void SampleCoverage(PP_Resource context_id, GLclampf value, GLboolean invert) { + GetGLES(context_id)->SampleCoverage(value, invert); +} + +void Scissor( + PP_Resource context_id, GLint x, GLint y, GLsizei width, GLsizei height) { + GetGLES(context_id)->Scissor(x, y, width, height); +} + +void ShaderBinary( + PP_Resource context_id, GLsizei n, const GLuint* shaders, + GLenum binaryformat, const void* binary, GLsizei length) { + GetGLES(context_id)->ShaderBinary(n, shaders, binaryformat, binary, length); +} + +void ShaderSource( + PP_Resource context_id, GLuint shader, GLsizei count, const char** str, + const GLint* length) { + GetGLES(context_id)->ShaderSource(shader, count, str, length); +} + +void StencilFunc(PP_Resource context_id, GLenum func, GLint ref, GLuint mask) { + GetGLES(context_id)->StencilFunc(func, ref, mask); +} + +void StencilFuncSeparate( + PP_Resource context_id, GLenum face, GLenum func, GLint ref, GLuint mask) { + GetGLES(context_id)->StencilFuncSeparate(face, func, ref, mask); +} + +void StencilMask(PP_Resource context_id, GLuint mask) { + GetGLES(context_id)->StencilMask(mask); +} + +void StencilMaskSeparate(PP_Resource context_id, GLenum face, GLuint mask) { + GetGLES(context_id)->StencilMaskSeparate(face, mask); +} + +void StencilOp( + PP_Resource context_id, GLenum fail, GLenum zfail, GLenum zpass) { + GetGLES(context_id)->StencilOp(fail, zfail, zpass); +} + +void StencilOpSeparate( + PP_Resource context_id, GLenum face, GLenum fail, GLenum zfail, + GLenum zpass) { + GetGLES(context_id)->StencilOpSeparate(face, fail, zfail, zpass); +} + +void TexImage2D( + PP_Resource context_id, GLenum target, GLint level, GLint internalformat, + GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, + const void* pixels) { + GetGLES( + context_id)->TexImage2D( + target, level, internalformat, width, height, border, format, type, + pixels); +} + +void TexParameterf( + PP_Resource context_id, GLenum target, GLenum pname, GLfloat param) { + GetGLES(context_id)->TexParameterf(target, pname, param); +} + +void TexParameterfv( + PP_Resource context_id, GLenum target, GLenum pname, + const GLfloat* params) { + GetGLES(context_id)->TexParameterfv(target, pname, params); +} + +void TexParameteri( + PP_Resource context_id, GLenum target, GLenum pname, GLint param) { + GetGLES(context_id)->TexParameteri(target, pname, param); +} + +void TexParameteriv( + PP_Resource context_id, GLenum target, GLenum pname, const GLint* params) { + GetGLES(context_id)->TexParameteriv(target, pname, params); +} + +void TexSubImage2D( + PP_Resource context_id, GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, + const void* pixels) { + GetGLES( + context_id)->TexSubImage2D( + target, level, xoffset, yoffset, width, height, format, type, + pixels); +} + +void Uniform1f(PP_Resource context_id, GLint location, GLfloat x) { + GetGLES(context_id)->Uniform1f(location, x); +} + +void Uniform1fv( + PP_Resource context_id, GLint location, GLsizei count, const GLfloat* v) { + GetGLES(context_id)->Uniform1fv(location, count, v); +} + +void Uniform1i(PP_Resource context_id, GLint location, GLint x) { + GetGLES(context_id)->Uniform1i(location, x); +} + +void Uniform1iv( + PP_Resource context_id, GLint location, GLsizei count, const GLint* v) { + GetGLES(context_id)->Uniform1iv(location, count, v); +} + +void Uniform2f(PP_Resource context_id, GLint location, GLfloat x, GLfloat y) { + GetGLES(context_id)->Uniform2f(location, x, y); +} + +void Uniform2fv( + PP_Resource context_id, GLint location, GLsizei count, const GLfloat* v) { + GetGLES(context_id)->Uniform2fv(location, count, v); +} + +void Uniform2i(PP_Resource context_id, GLint location, GLint x, GLint y) { + GetGLES(context_id)->Uniform2i(location, x, y); +} + +void Uniform2iv( + PP_Resource context_id, GLint location, GLsizei count, const GLint* v) { + GetGLES(context_id)->Uniform2iv(location, count, v); +} + +void Uniform3f( + PP_Resource context_id, GLint location, GLfloat x, GLfloat y, GLfloat z) { + GetGLES(context_id)->Uniform3f(location, x, y, z); +} + +void Uniform3fv( + PP_Resource context_id, GLint location, GLsizei count, const GLfloat* v) { + GetGLES(context_id)->Uniform3fv(location, count, v); +} + +void Uniform3i( + PP_Resource context_id, GLint location, GLint x, GLint y, GLint z) { + GetGLES(context_id)->Uniform3i(location, x, y, z); +} + +void Uniform3iv( + PP_Resource context_id, GLint location, GLsizei count, const GLint* v) { + GetGLES(context_id)->Uniform3iv(location, count, v); +} + +void Uniform4f( + PP_Resource context_id, GLint location, GLfloat x, GLfloat y, GLfloat z, + GLfloat w) { + GetGLES(context_id)->Uniform4f(location, x, y, z, w); +} + +void Uniform4fv( + PP_Resource context_id, GLint location, GLsizei count, const GLfloat* v) { + GetGLES(context_id)->Uniform4fv(location, count, v); +} + +void Uniform4i( + PP_Resource context_id, GLint location, GLint x, GLint y, GLint z, + GLint w) { + GetGLES(context_id)->Uniform4i(location, x, y, z, w); +} + +void Uniform4iv( + PP_Resource context_id, GLint location, GLsizei count, const GLint* v) { + GetGLES(context_id)->Uniform4iv(location, count, v); +} + +void UniformMatrix2fv( + PP_Resource context_id, GLint location, GLsizei count, GLboolean transpose, + const GLfloat* value) { + GetGLES(context_id)->UniformMatrix2fv(location, count, transpose, value); +} + +void UniformMatrix3fv( + PP_Resource context_id, GLint location, GLsizei count, GLboolean transpose, + const GLfloat* value) { + GetGLES(context_id)->UniformMatrix3fv(location, count, transpose, value); +} + +void UniformMatrix4fv( + PP_Resource context_id, GLint location, GLsizei count, GLboolean transpose, + const GLfloat* value) { + GetGLES(context_id)->UniformMatrix4fv(location, count, transpose, value); +} + +void UseProgram(PP_Resource context_id, GLuint program) { + GetGLES(context_id)->UseProgram(program); +} + +void ValidateProgram(PP_Resource context_id, GLuint program) { + GetGLES(context_id)->ValidateProgram(program); +} + +void VertexAttrib1f(PP_Resource context_id, GLuint indx, GLfloat x) { + GetGLES(context_id)->VertexAttrib1f(indx, x); +} + +void VertexAttrib1fv( + PP_Resource context_id, GLuint indx, const GLfloat* values) { + GetGLES(context_id)->VertexAttrib1fv(indx, values); +} + +void VertexAttrib2f( + PP_Resource context_id, GLuint indx, GLfloat x, GLfloat y) { + GetGLES(context_id)->VertexAttrib2f(indx, x, y); +} + +void VertexAttrib2fv( + PP_Resource context_id, GLuint indx, const GLfloat* values) { + GetGLES(context_id)->VertexAttrib2fv(indx, values); +} + +void VertexAttrib3f( + PP_Resource context_id, GLuint indx, GLfloat x, GLfloat y, GLfloat z) { + GetGLES(context_id)->VertexAttrib3f(indx, x, y, z); +} + +void VertexAttrib3fv( + PP_Resource context_id, GLuint indx, const GLfloat* values) { + GetGLES(context_id)->VertexAttrib3fv(indx, values); +} + +void VertexAttrib4f( + PP_Resource context_id, GLuint indx, GLfloat x, GLfloat y, GLfloat z, + GLfloat w) { + GetGLES(context_id)->VertexAttrib4f(indx, x, y, z, w); +} + +void VertexAttrib4fv( + PP_Resource context_id, GLuint indx, const GLfloat* values) { + GetGLES(context_id)->VertexAttrib4fv(indx, values); +} + +void VertexAttribPointer( + PP_Resource context_id, GLuint indx, GLint size, GLenum type, + GLboolean normalized, GLsizei stride, const void* ptr) { + GetGLES( + context_id)->VertexAttribPointer( + indx, size, type, normalized, stride, ptr); +} + +void Viewport( + PP_Resource context_id, GLint x, GLint y, GLsizei width, GLsizei height) { + GetGLES(context_id)->Viewport(x, y, width, height); +} + + +const struct PPB_OpenGLES2 ppb_opengles2 = { + &ActiveTexture, + &AttachShader, + &BindAttribLocation, + &BindBuffer, + &BindFramebuffer, + &BindRenderbuffer, + &BindTexture, + &BlendColor, + &BlendEquation, + &BlendEquationSeparate, + &BlendFunc, + &BlendFuncSeparate, + &BufferData, + &BufferSubData, + &CheckFramebufferStatus, + &Clear, + &ClearColor, + &ClearDepthf, + &ClearStencil, + &ColorMask, + &CompileShader, + &CompressedTexImage2D, + &CompressedTexSubImage2D, + &CopyTexImage2D, + &CopyTexSubImage2D, + &CreateProgram, + &CreateShader, + &CullFace, + &DeleteBuffers, + &DeleteFramebuffers, + &DeleteProgram, + &DeleteRenderbuffers, + &DeleteShader, + &DeleteTextures, + &DepthFunc, + &DepthMask, + &DepthRangef, + &DetachShader, + &Disable, + &DisableVertexAttribArray, + &DrawArrays, + &DrawElements, + &Enable, + &EnableVertexAttribArray, + &Finish, + &Flush, + &FramebufferRenderbuffer, + &FramebufferTexture2D, + &FrontFace, + &GenBuffers, + &GenerateMipmap, + &GenFramebuffers, + &GenRenderbuffers, + &GenTextures, + &GetActiveAttrib, + &GetActiveUniform, + &GetAttachedShaders, + &GetAttribLocation, + &GetBooleanv, + &GetBufferParameteriv, + &GetError, + &GetFloatv, + &GetFramebufferAttachmentParameteriv, + &GetIntegerv, + &GetProgramiv, + &GetProgramInfoLog, + &GetRenderbufferParameteriv, + &GetShaderiv, + &GetShaderInfoLog, + &GetShaderPrecisionFormat, + &GetShaderSource, + &GetString, + &GetTexParameterfv, + &GetTexParameteriv, + &GetUniformfv, + &GetUniformiv, + &GetUniformLocation, + &GetVertexAttribfv, + &GetVertexAttribiv, + &GetVertexAttribPointerv, + &Hint, + &IsBuffer, + &IsEnabled, + &IsFramebuffer, + &IsProgram, + &IsRenderbuffer, + &IsShader, + &IsTexture, + &LineWidth, + &LinkProgram, + &PixelStorei, + &PolygonOffset, + &ReadPixels, + &ReleaseShaderCompiler, + &RenderbufferStorage, + &SampleCoverage, + &Scissor, + &ShaderBinary, + &ShaderSource, + &StencilFunc, + &StencilFuncSeparate, + &StencilMask, + &StencilMaskSeparate, + &StencilOp, + &StencilOpSeparate, + &TexImage2D, + &TexParameterf, + &TexParameterfv, + &TexParameteri, + &TexParameteriv, + &TexSubImage2D, + &Uniform1f, + &Uniform1fv, + &Uniform1i, + &Uniform1iv, + &Uniform2f, + &Uniform2fv, + &Uniform2i, + &Uniform2iv, + &Uniform3f, + &Uniform3fv, + &Uniform3i, + &Uniform3iv, + &Uniform4f, + &Uniform4fv, + &Uniform4i, + &Uniform4iv, + &UniformMatrix2fv, + &UniformMatrix3fv, + &UniformMatrix4fv, + &UseProgram, + &ValidateProgram, + &VertexAttrib1f, + &VertexAttrib1fv, + &VertexAttrib2f, + &VertexAttrib2fv, + &VertexAttrib3f, + &VertexAttrib3fv, + &VertexAttrib4f, + &VertexAttrib4fv, + &VertexAttribPointer, + &Viewport +}; + +} // namespace + +const PPB_OpenGLES2* PPB_OpenGLES2_Shared::GetInterface() { + return &ppb_opengles2; +} + +} // namespace ppapi diff --git a/ppapi/shared_impl/ppb_opengles2_shared.h b/ppapi/shared_impl/ppb_opengles2_shared.h new file mode 100644 index 0000000..2b4c9f9 --- /dev/null +++ b/ppapi/shared_impl/ppb_opengles2_shared.h @@ -0,0 +1,21 @@ +// 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_SHARED_IMPL_PPB_OPENGLES2_SHARED_H_ +#define PPAPI_SHARED_IMPL_PPB_OPENGLES2_SHARED_H_ + +#include "ppapi/c/ppb_opengles2.h" +#include "ppapi/shared_impl/ppapi_shared_export.h" + +namespace ppapi { + +class PPAPI_SHARED_EXPORT PPB_OpenGLES2_Shared { + public: + static const PPB_OpenGLES2* GetInterface(); +}; + +} // namespace ppapi + +#endif // PPAPI_SHARED_IMPL_PPB_OPENGLES2_SHARED_H_ + diff --git a/ppapi/shared_impl/ppb_url_request_info_shared.cc b/ppapi/shared_impl/ppb_url_request_info_shared.cc new file mode 100644 index 0000000..f582eac --- /dev/null +++ b/ppapi/shared_impl/ppb_url_request_info_shared.cc @@ -0,0 +1,272 @@ +// 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/shared_impl/ppb_url_request_info_shared.h" + +#include "base/string_util.h" +#include "ppapi/shared_impl/var.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_file_ref_api.h" + +using ppapi::thunk::EnterResourceNoLock; + +namespace ppapi { + +namespace { + +const int32_t kDefaultPrefetchBufferUpperThreshold = 100 * 1000 * 1000; +const int32_t kDefaultPrefetchBufferLowerThreshold = 50 * 1000 * 1000; + +} // namespace + +PPB_URLRequestInfo_Data::BodyItem::BodyItem() + : is_file(false), + start_offset(0), + number_of_bytes(-1), + expected_last_modified_time(0.0) { +} + +PPB_URLRequestInfo_Data::BodyItem::BodyItem(const std::string& data) + : is_file(false), + data(data), + start_offset(0), + number_of_bytes(-1), + expected_last_modified_time(0.0) { +} + +PPB_URLRequestInfo_Data::BodyItem::BodyItem( + Resource* file_ref, + int64_t start_offset, + int64_t number_of_bytes, + PP_Time expected_last_modified_time) + : is_file(true), + file_ref(file_ref), + file_ref_host_resource(file_ref->host_resource()), + start_offset(start_offset), + number_of_bytes(number_of_bytes), + expected_last_modified_time(expected_last_modified_time) { +} + +PPB_URLRequestInfo_Data::PPB_URLRequestInfo_Data() + : url(), + method(), + headers(), + stream_to_file(false), + follow_redirects(true), + record_download_progress(false), + record_upload_progress(false), + has_custom_referrer_url(false), + custom_referrer_url(), + allow_cross_origin_requests(false), + allow_credentials(false), + has_custom_content_transfer_encoding(false), + custom_content_transfer_encoding(), + prefetch_buffer_upper_threshold(kDefaultPrefetchBufferUpperThreshold), + prefetch_buffer_lower_threshold(kDefaultPrefetchBufferLowerThreshold), + body() { +} + +PPB_URLRequestInfo_Data::~PPB_URLRequestInfo_Data() { +} + +PPB_URLRequestInfo_Shared::PPB_URLRequestInfo_Shared( + PP_Instance instance, + const PPB_URLRequestInfo_Data& data) + : Resource(instance), + data_(data) { +} + +PPB_URLRequestInfo_Shared::PPB_URLRequestInfo_Shared( + const HostResource& host_resource, + const PPB_URLRequestInfo_Data& data) + : Resource(host_resource), + data_(data) { +} + +PPB_URLRequestInfo_Shared::~PPB_URLRequestInfo_Shared() { +} + +thunk::PPB_URLRequestInfo_API* +PPB_URLRequestInfo_Shared::AsPPB_URLRequestInfo_API() { + return this; +} + +PP_Bool PPB_URLRequestInfo_Shared::SetProperty(PP_URLRequestProperty property, + PP_Var var) { + // IMPORTANT: Do not do security validation of parameters at this level + // without also adding them to PPB_URLRequestInfo_Impl::ValidateData. This + // code is used both in the plugin (which we don't trust) and in the renderer + // (which we trust more). When running out-of-process, the plugin calls this + // function to configure the PPB_URLRequestInfo_Data, which is then sent to + // the renderer and *not* run through SetProperty again. + // + // This means that anything in the PPB_URLRequestInfo_Data needs to be + // validated at the time the URL is requested (which is what ValidateData + // does). If your feature requires security checks, it should be in the + // implementation in the renderer when the WebKit request is actually + // constructed. + // + // It is legal to do some validation here if you want to report failure to + // the plugin as a convenience, as long as you also do it in the renderer + // later. + PP_Bool result = PP_FALSE; + switch (var.type) { + case PP_VARTYPE_UNDEFINED: + result = PP_FromBool(SetUndefinedProperty(property)); + break; + case PP_VARTYPE_BOOL: + result = PP_FromBool( + SetBooleanProperty(property, PP_ToBool(var.value.as_bool))); + break; + case PP_VARTYPE_INT32: + result = PP_FromBool( + SetIntegerProperty(property, var.value.as_int)); + break; + case PP_VARTYPE_STRING: { + StringVar* string = StringVar::FromPPVar(var); + if (string) + result = PP_FromBool(SetStringProperty(property, string->value())); + break; + } + default: + break; + } + return result; +} + +PP_Bool PPB_URLRequestInfo_Shared::AppendDataToBody(const void* data, + uint32_t len) { + if (len > 0) { + data_.body.push_back(PPB_URLRequestInfo_Data::BodyItem( + std::string(static_cast(data), len))); + } + return PP_TRUE; +} + +PP_Bool PPB_URLRequestInfo_Shared::AppendFileToBody( + PP_Resource file_ref, + int64_t start_offset, + int64_t number_of_bytes, + PP_Time expected_last_modified_time) { + EnterResourceNoLock enter(file_ref, true); + if (enter.failed()) + return PP_FALSE; + + // Ignore a call to append nothing. + if (number_of_bytes == 0) + return PP_TRUE; + + // Check for bad values. (-1 means read until end of file.) + if (start_offset < 0 || number_of_bytes < -1) + return PP_FALSE; + + data_.body.push_back(PPB_URLRequestInfo_Data::BodyItem( + enter.resource(), + start_offset, + number_of_bytes, + expected_last_modified_time)); + return PP_TRUE; +} + +const PPB_URLRequestInfo_Data& PPB_URLRequestInfo_Shared::GetData() const { + return data_; +} + +bool PPB_URLRequestInfo_Shared::SetUndefinedProperty( + PP_URLRequestProperty property) { + // IMPORTANT: Do not do security validation of parameters at this level + // without also adding them to PPB_URLRequestInfo_Impl::ValidateData. See + // SetProperty() above for why. + switch (property) { + case PP_URLREQUESTPROPERTY_CUSTOMREFERRERURL: + data_.has_custom_referrer_url = false; + data_.custom_referrer_url = std::string(); + return true; + case PP_URLREQUESTPROPERTY_CUSTOMCONTENTTRANSFERENCODING: + data_.has_custom_content_transfer_encoding = false; + data_.custom_content_transfer_encoding = std::string(); + return true; + default: + return false; + } +} + +bool PPB_URLRequestInfo_Shared::SetBooleanProperty( + PP_URLRequestProperty property, + bool value) { + // IMPORTANT: Do not do security validation of parameters at this level + // without also adding them to PPB_URLRequestInfo_Impl::ValidateData. See + // SetProperty() above for why. + switch (property) { + case PP_URLREQUESTPROPERTY_STREAMTOFILE: + data_.stream_to_file = value; + return true; + case PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS: + data_.follow_redirects = value; + return true; + case PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS: + data_.record_download_progress = value; + return true; + case PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS: + data_.record_upload_progress = value; + return true; + case PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS: + data_.allow_cross_origin_requests = value; + return true; + case PP_URLREQUESTPROPERTY_ALLOWCREDENTIALS: + data_.allow_credentials = value; + return true; + default: + return false; + } +} + +bool PPB_URLRequestInfo_Shared::SetIntegerProperty( + PP_URLRequestProperty property, + int32_t value) { + // IMPORTANT: Do not do security validation of parameters at this level + // without also adding them to PPB_URLRequestInfo_Impl::ValidateData. See + // SetProperty() above for why. + switch (property) { + case PP_URLREQUESTPROPERTY_PREFETCHBUFFERUPPERTHRESHOLD: + data_.prefetch_buffer_upper_threshold = value; + return true; + case PP_URLREQUESTPROPERTY_PREFETCHBUFFERLOWERTHRESHOLD: + data_.prefetch_buffer_lower_threshold = value; + return true; + default: + return false; + } +} + +bool PPB_URLRequestInfo_Shared::SetStringProperty( + PP_URLRequestProperty property, + const std::string& value) { + // IMPORTANT: Do not do security validation of parameters at this level + // without also adding them to PPB_URLRequestInfo_Impl::ValidateData. See + // SetProperty() above for why. + switch (property) { + case PP_URLREQUESTPROPERTY_URL: + data_.url = value; // NOTE: This may be a relative URL. + return true; + case PP_URLREQUESTPROPERTY_METHOD: + data_.method = value; + return true; + case PP_URLREQUESTPROPERTY_HEADERS: + data_.headers = value; + return true; + case PP_URLREQUESTPROPERTY_CUSTOMREFERRERURL: + data_.has_custom_referrer_url = true; + data_.custom_referrer_url = value; + return true; + case PP_URLREQUESTPROPERTY_CUSTOMCONTENTTRANSFERENCODING: + data_.has_custom_content_transfer_encoding = true; + data_.custom_content_transfer_encoding = value; + return true; + default: + return false; + } +} + +} // namespace ppapi diff --git a/ppapi/shared_impl/ppb_url_request_info_shared.h b/ppapi/shared_impl/ppb_url_request_info_shared.h new file mode 100644 index 0000000..c07b9c9 --- /dev/null +++ b/ppapi/shared_impl/ppb_url_request_info_shared.h @@ -0,0 +1,136 @@ +// 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_SHARED_IMPL_PPB_URL_REQUEST_INFO_SHARED_H_ +#define PPAPI_SHARED_IMPL_PPB_URL_REQUEST_INFO_SHARED_H_ + +#include +#include + +#include "base/compiler_specific.h" +#include "ppapi/shared_impl/resource.h" +#include "ppapi/thunk/ppb_url_request_info_api.h" + +namespace ppapi { + +struct PPAPI_SHARED_EXPORT PPB_URLRequestInfo_Data { + struct PPAPI_SHARED_EXPORT BodyItem { + BodyItem(); + explicit BodyItem(const std::string& data); + BodyItem(Resource* file_ref, + int64_t start_offset, + int64_t number_of_bytes, + PP_Time expected_last_modified_time); + + // Set if the input is a file, false means the |data| is valid. + bool is_file; + + std::string data; + + // Is is_file is set, these variables are set. Note that the resource + // may still be NULL in some cases, such as deserialization errors. + // + // This is a bit tricky. In the plugin side of the proxy, both the file ref + // and the file_ref_host_resource will be set and valid. The scoped_ptr + // ensures that the resource is alive for as long as the BodyItem is. + // + // When we deserialize this in the renderer, only the + // file_ref_host_resource's are serialized over IPC. The file_refs won't be + // valid until the host resources are converted to Resource pointers in the + // PPB_URLRequestInfo_Impl. + scoped_refptr file_ref; + HostResource file_ref_host_resource; + + int64_t start_offset; + int64_t number_of_bytes; + PP_Time expected_last_modified_time; + + // If you add more stuff here, be sure to modify the serialization rules in + // ppapi_messages.h + }; + + PPB_URLRequestInfo_Data(); + ~PPB_URLRequestInfo_Data(); + + std::string url; + std::string method; + std::string headers; + + bool stream_to_file; + bool follow_redirects; + bool record_download_progress; + bool record_upload_progress; + + // |has_custom_referrer_url| is set to false if a custom referrer hasn't been + // set (or has been set to an Undefined Var) and the default referrer should + // be used. (Setting the custom referrer to an empty string indicates that no + // referrer header should be generated.) + bool has_custom_referrer_url; + std::string custom_referrer_url; + + bool allow_cross_origin_requests; + bool allow_credentials; + + // Similar to the custom referrer (above), but for custom content transfer + // encoding. + bool has_custom_content_transfer_encoding; + std::string custom_content_transfer_encoding; + + int32_t prefetch_buffer_upper_threshold; + int32_t prefetch_buffer_lower_threshold; + + std::vector body; + + // If you add more stuff here, be sure to modify the serialization rules in + // ppapi_messages.h +}; + +class PPAPI_SHARED_EXPORT PPB_URLRequestInfo_Shared + : public ::ppapi::Resource, + public ::ppapi::thunk::PPB_URLRequestInfo_API { + public: + // This constructor initializes the object as a proxy object with the given + // host resource. + PPB_URLRequestInfo_Shared(const HostResource& host_resource, + const PPB_URLRequestInfo_Data& data); + + ~PPB_URLRequestInfo_Shared(); + + // Resource overrides. + virtual thunk::PPB_URLRequestInfo_API* AsPPB_URLRequestInfo_API() OVERRIDE; + + // PPB_URLRequestInfo_API implementation. + virtual PP_Bool SetProperty(PP_URLRequestProperty property, + PP_Var var) OVERRIDE; + virtual PP_Bool AppendDataToBody(const void* data, uint32_t len) OVERRIDE; + virtual PP_Bool AppendFileToBody( + PP_Resource file_ref, + int64_t start_offset, + int64_t number_of_bytes, + PP_Time expected_last_modified_time) OVERRIDE; + virtual const PPB_URLRequestInfo_Data& GetData() const OVERRIDE; + + protected: + // Constructor used by the webkit implementation. + PPB_URLRequestInfo_Shared(PP_Instance instance, + const PPB_URLRequestInfo_Data& data); + + bool SetUndefinedProperty(PP_URLRequestProperty property); + bool SetBooleanProperty(PP_URLRequestProperty property, bool value); + bool SetIntegerProperty(PP_URLRequestProperty property, int32_t value); + bool SetStringProperty(PP_URLRequestProperty property, + const std::string& value); + + const PPB_URLRequestInfo_Data& data() const { return data_; } + PPB_URLRequestInfo_Data& data() { return data_; } + + private: + PPB_URLRequestInfo_Data data_; + + DISALLOW_IMPLICIT_CONSTRUCTORS(PPB_URLRequestInfo_Shared); +}; + +} // namespace ppapi + +#endif // PPAPI_SHARED_IMPL_PPB_URL_REQUEST_INFO_SHARED_H_ diff --git a/ppapi/shared_impl/ppb_url_util_shared.cc b/ppapi/shared_impl/ppb_url_util_shared.cc new file mode 100644 index 0000000..bdc4950 --- /dev/null +++ b/ppapi/shared_impl/ppb_url_util_shared.cc @@ -0,0 +1,115 @@ +// 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/shared_impl/ppb_url_util_shared.h" + +#include "googleurl/src/gurl.h" +#include "ppapi/shared_impl/ppapi_globals.h" +#include "ppapi/shared_impl/var.h" +#include "ppapi/shared_impl/var_tracker.h" + +namespace ppapi { + +namespace { + +void ConvertComponent(const url_parse::Component& input, + PP_URLComponent_Dev* output) { + output->begin = input.begin; + output->len = input.len; +} + +// Converts components from a GoogleUrl parsed to a PPAPI parsed structure. +// Output can be NULL to specify "do nothing." This rule is followed by all +// the url util functions, so we implement it once here. +// +// Output can be NULL to specify "do nothing." This rule is followed by all the +// url util functions, so we implement it once here. +void ConvertComponents(const url_parse::Parsed& input, + PP_URLComponents_Dev* output) { + if (!output) + return; + + ConvertComponent(input.scheme, &output->scheme); + ConvertComponent(input.username, &output->username); + ConvertComponent(input.password, &output->password); + ConvertComponent(input.host, &output->host); + ConvertComponent(input.port, &output->port); + ConvertComponent(input.path, &output->path); + ConvertComponent(input.query, &output->query); + ConvertComponent(input.ref, &output->ref); +} + +} // namespace + +// static +PP_Var PPB_URLUtil_Shared::Canonicalize(PP_Var url, + PP_URLComponents_Dev* components) { + StringVar* url_string = StringVar::FromPPVar(url); + if (!url_string) + return PP_MakeNull(); + return GenerateURLReturn(url_string->pp_module(), + GURL(url_string->value()), components); +} + +// static +PP_Var PPB_URLUtil_Shared::ResolveRelativeToURL( + PP_Var base_url, + PP_Var relative, + PP_URLComponents_Dev* components) { + StringVar* base_url_string = StringVar::FromPPVar(base_url); + StringVar* relative_string = StringVar::FromPPVar(relative); + if (!base_url_string || !relative_string) + return PP_MakeNull(); + + GURL base_gurl(base_url_string->value()); + if (!base_gurl.is_valid()) + return PP_MakeNull(); + return GenerateURLReturn(base_url_string->pp_module(), + base_gurl.Resolve(relative_string->value()), + components); +} + +// static +PP_Bool PPB_URLUtil_Shared::IsSameSecurityOrigin(PP_Var url_a, PP_Var url_b) { + StringVar* url_a_string = StringVar::FromPPVar(url_a); + StringVar* url_b_string = StringVar::FromPPVar(url_b); + if (!url_a_string || !url_b_string) + return PP_FALSE; + + GURL gurl_a(url_a_string->value()); + GURL gurl_b(url_b_string->value()); + if (!gurl_a.is_valid() || !gurl_b.is_valid()) + return PP_FALSE; + + return gurl_a.GetOrigin() == gurl_b.GetOrigin() ? PP_TRUE : PP_FALSE; +} + +// Used for returning the given GURL from a PPAPI function, with an optional +// out param indicating the components. +PP_Var PPB_URLUtil_Shared::GenerateURLReturn( + PP_Module module, + const GURL& url, + PP_URLComponents_Dev* components) { + if (!url.is_valid()) + return PP_MakeNull(); + ConvertComponents(url.parsed_for_possibly_invalid_spec(), components); + return StringVar::StringToPPVar(module, url.possibly_invalid_spec()); +} + +PP_Var PPB_URLUtil_Shared::ConvertComponentsAndReturnURL( + const PP_Var& url, + PP_URLComponents_Dev* components) { + if (!components) + return url; // Common case - plugin doesn't care about parsing. + + StringVar* url_string = StringVar::FromPPVar(url); + if (!url_string) + return url; + + PP_Var result = Canonicalize(url, components); + PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(url); + return result; +} + +} // namespace ppapi diff --git a/ppapi/shared_impl/ppb_url_util_shared.h b/ppapi/shared_impl/ppb_url_util_shared.h new file mode 100644 index 0000000..54c7573 --- /dev/null +++ b/ppapi/shared_impl/ppb_url_util_shared.h @@ -0,0 +1,53 @@ +// 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_SHARED_IMPL_PPB_URL_UTIL_SHARED_H_ +#define PPAPI_SHARED_IMPL_PPB_URL_UTIL_SHARED_H_ + +#include + +#include "base/basictypes.h" +#include "googleurl/src/url_parse.h" +#include "ppapi/c/dev/ppb_url_util_dev.h" +#include "ppapi/c/pp_module.h" +#include "ppapi/c/pp_var.h" +#include "ppapi/shared_impl/ppapi_shared_export.h" + +class GURL; + +namespace ppapi { + +// Contains the implementation of PPB_URLUtil that is shared between the proxy +// and the renderer. +class PPAPI_SHARED_EXPORT PPB_URLUtil_Shared { + public: + // PPB_URLUtil shared functions. + static PP_Var Canonicalize(PP_Var url, + PP_URLComponents_Dev* components); + static PP_Var ResolveRelativeToURL(PP_Var base_url, + PP_Var relative, + PP_URLComponents_Dev* components); + static PP_Bool IsSameSecurityOrigin(PP_Var url_a, PP_Var url_b); + + // Used for returning the given GURL from a PPAPI function, with an optional + // out param indicating the components. + static PP_Var GenerateURLReturn(PP_Module pp_module, + const GURL& url, + PP_URLComponents_Dev* components); + + // Helper function that optionally take a components structure and fills it + // out with the parsed version of the given URL. If the components pointer is + // NULL, this function will do nothing. + // + // It's annoying to serialze the large PP_URLComponents structure across IPC + // and the data isn't often requested by plugins. This function is used on + // the plugin side to fill in the components for those cases where it's + // actually needed. + static PP_Var ConvertComponentsAndReturnURL(const PP_Var& url, + PP_URLComponents_Dev* components); +}; + +} // namespace ppapi + +#endif // PPAPI_SHARED_IMPL_PPB_URL_UTIL_SHARED_H_ diff --git a/ppapi/shared_impl/ppb_video_decoder_shared.cc b/ppapi/shared_impl/ppb_video_decoder_shared.cc new file mode 100644 index 0000000..190654e --- /dev/null +++ b/ppapi/shared_impl/ppb_video_decoder_shared.cc @@ -0,0 +1,88 @@ +// 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/shared_impl/ppb_video_decoder_shared.h" + +#include "base/logging.h" +#include "gpu/command_buffer/client/gles2_implementation.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/shared_impl/resource_tracker.h" +#include "ppapi/thunk/enter.h" + +namespace ppapi { + +PPB_VideoDecoder_Shared::PPB_VideoDecoder_Shared() + : flush_callback_(PP_MakeCompletionCallback(NULL, NULL)), + reset_callback_(PP_MakeCompletionCallback(NULL, NULL)), + graphics_context_(0), + gles2_impl_(NULL) { +} + +PPB_VideoDecoder_Shared::~PPB_VideoDecoder_Shared() { +} + +void PPB_VideoDecoder_Shared::InitCommon( + PP_Resource graphics_context, + gpu::gles2::GLES2Implementation* gles2_impl) { + DCHECK(graphics_context); + DCHECK(!gles2_impl_ && !graphics_context_); + gles2_impl_ = gles2_impl; + PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(graphics_context); + graphics_context_ = graphics_context; +} + +void PPB_VideoDecoder_Shared::Destroy() { + graphics_context_ = 0; + gles2_impl_ = NULL; + PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(graphics_context_); +} + +bool PPB_VideoDecoder_Shared::SetFlushCallback(PP_CompletionCallback callback) { + CHECK(callback.func); + if (flush_callback_.func) + return false; + flush_callback_ = callback; + return true; +} + +bool PPB_VideoDecoder_Shared::SetResetCallback(PP_CompletionCallback callback) { + CHECK(callback.func); + if (reset_callback_.func) + return false; + reset_callback_ = callback; + return true; +} + +bool PPB_VideoDecoder_Shared::SetBitstreamBufferCallback( + int32 bitstream_buffer_id, PP_CompletionCallback callback) { + return bitstream_buffer_callbacks_.insert( + std::make_pair(bitstream_buffer_id, callback)).second; +} + +void PPB_VideoDecoder_Shared::RunFlushCallback(int32 result) { + DCHECK(flush_callback_.func); + PP_RunAndClearCompletionCallback(&flush_callback_, result); +} + +void PPB_VideoDecoder_Shared::RunResetCallback(int32 result) { + DCHECK(reset_callback_.func); + PP_RunAndClearCompletionCallback(&reset_callback_, result); +} + +void PPB_VideoDecoder_Shared::RunBitstreamBufferCallback( + int32 bitstream_buffer_id, int32 result) { + CallbackById::iterator it = + bitstream_buffer_callbacks_.find(bitstream_buffer_id); + DCHECK(it != bitstream_buffer_callbacks_.end()); + PP_CompletionCallback cc = it->second; + bitstream_buffer_callbacks_.erase(it); + PP_RunCompletionCallback(&cc, PP_OK); +} + +void PPB_VideoDecoder_Shared::FlushCommandBuffer() { + if (gles2_impl_) + gles2_impl_->Flush(); +} + +} // namespace ppapi diff --git a/ppapi/shared_impl/ppb_video_decoder_shared.h b/ppapi/shared_impl/ppb_video_decoder_shared.h new file mode 100644 index 0000000..55b629c --- /dev/null +++ b/ppapi/shared_impl/ppb_video_decoder_shared.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_SHARED_IMPL_PPB_VIDEO_DECODER_SHARED_H_ +#define PPAPI_SHARED_IMPL_PPB_VIDEO_DECODER_SHARED_H_ + +#include +#include + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "ppapi/c/dev/ppb_video_decoder_dev.h" +#include "ppapi/shared_impl/resource.h" +#include "ppapi/thunk/ppb_video_decoder_api.h" + +namespace gpu { +namespace gles2 { +class GLES2Implementation; +} // namespace gles2 +} // namespace gpu + +namespace ppapi { + +// Implements the logic to set and run callbacks for various video decoder +// events. Both the proxy and the renderer implementation share this code. +class PPAPI_SHARED_EXPORT PPB_VideoDecoder_Shared + : NON_EXPORTED_BASE(public thunk::PPB_VideoDecoder_API) { + public: + PPB_VideoDecoder_Shared(); + virtual ~PPB_VideoDecoder_Shared(); + + // PPB_VideoDecoder_API implementation. + virtual void Destroy() OVERRIDE; + + protected: + bool SetFlushCallback(PP_CompletionCallback callback); + bool SetResetCallback(PP_CompletionCallback callback); + bool SetBitstreamBufferCallback( + int32 bitstream_buffer_id, PP_CompletionCallback callback); + + void RunFlushCallback(int32 result); + void RunResetCallback(int32 result); + void RunBitstreamBufferCallback(int32 bitstream_buffer_id, int32 result); + + // Tell command buffer to process all commands it has received so far. + void FlushCommandBuffer(); + + // Initialize the underlying decoder. + void InitCommon(PP_Resource graphics_context, + gpu::gles2::GLES2Implementation* gles2_impl); + + private: + // Key: bitstream_buffer_id, value: callback to run when bitstream decode is + // done. + typedef std::map CallbackById; + + PP_CompletionCallback flush_callback_; + PP_CompletionCallback reset_callback_; + CallbackById bitstream_buffer_callbacks_; + + // The resource ID of the underlying Graphics3D object being used. Used only + // for reference counting to keep it alive for the lifetime of |*this|. + PP_Resource graphics_context_; + + // Reference to the GLES2Implementation owned by |graphics_context_|. + // Graphics3D is guaranteed to be alive for the lifetime of this class. + // In the out-of-process case, Graphics3D's gles2_impl() exists in the plugin + // process only, so gles2_impl_ is NULL in that case. + gpu::gles2::GLES2Implementation* gles2_impl_; + + DISALLOW_COPY_AND_ASSIGN(PPB_VideoDecoder_Shared); +}; + +} // namespace ppapi + +#endif // PPAPI_SHARED_IMPL_PPB_VIDEO_DECODER_SHARED_H_ diff --git a/ppapi/shared_impl/url_request_info_impl.cc b/ppapi/shared_impl/url_request_info_impl.cc deleted file mode 100644 index 5802102..0000000 --- a/ppapi/shared_impl/url_request_info_impl.cc +++ /dev/null @@ -1,264 +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/shared_impl/url_request_info_impl.h" - -#include "base/string_util.h" -#include "ppapi/shared_impl/var.h" -#include "ppapi/thunk/enter.h" -#include "ppapi/thunk/ppb_file_ref_api.h" - -using ppapi::thunk::EnterResourceNoLock; - -namespace ppapi { - -namespace { - -const int32_t kDefaultPrefetchBufferUpperThreshold = 100 * 1000 * 1000; -const int32_t kDefaultPrefetchBufferLowerThreshold = 50 * 1000 * 1000; - -} // namespace - -PPB_URLRequestInfo_Data::BodyItem::BodyItem() - : is_file(false), - start_offset(0), - number_of_bytes(-1), - expected_last_modified_time(0.0) { -} - -PPB_URLRequestInfo_Data::BodyItem::BodyItem(const std::string& data) - : is_file(false), - data(data), - start_offset(0), - number_of_bytes(-1), - expected_last_modified_time(0.0) { -} - -PPB_URLRequestInfo_Data::BodyItem::BodyItem( - Resource* file_ref, - int64_t start_offset, - int64_t number_of_bytes, - PP_Time expected_last_modified_time) - : is_file(true), - file_ref(file_ref), - file_ref_host_resource(file_ref->host_resource()), - start_offset(start_offset), - number_of_bytes(number_of_bytes), - expected_last_modified_time(expected_last_modified_time) { -} - -PPB_URLRequestInfo_Data::PPB_URLRequestInfo_Data() - : url(), - method(), - headers(), - stream_to_file(false), - follow_redirects(true), - record_download_progress(false), - record_upload_progress(false), - has_custom_referrer_url(false), - custom_referrer_url(), - allow_cross_origin_requests(false), - allow_credentials(false), - has_custom_content_transfer_encoding(false), - custom_content_transfer_encoding(), - prefetch_buffer_upper_threshold(kDefaultPrefetchBufferUpperThreshold), - prefetch_buffer_lower_threshold(kDefaultPrefetchBufferLowerThreshold), - body() { -} - -PPB_URLRequestInfo_Data::~PPB_URLRequestInfo_Data() { -} - -URLRequestInfoImpl::URLRequestInfoImpl(PP_Instance instance, - const PPB_URLRequestInfo_Data& data) - : Resource(instance), - data_(data) { -} - -URLRequestInfoImpl::URLRequestInfoImpl(const HostResource& host_resource, - const PPB_URLRequestInfo_Data& data) - : Resource(host_resource), - data_(data) { -} - -URLRequestInfoImpl::~URLRequestInfoImpl() { -} - -thunk::PPB_URLRequestInfo_API* URLRequestInfoImpl::AsPPB_URLRequestInfo_API() { - return this; -} - -PP_Bool URLRequestInfoImpl::SetProperty(PP_URLRequestProperty property, - PP_Var var) { - // IMPORTANT: Do not do security validation of parameters at this level - // without also adding them to PPB_URLRequestInfo_Impl::ValidateData. This - // code is used both in the plugin (which we don't trust) and in the renderer - // (which we trust more). When running out-of-process, the plugin calls this - // function to configure the PPB_URLRequestInfo_Data, which is then sent to - // the renderer and *not* run through SetProperty again. - // - // This means that anything in the PPB_URLRequestInfo_Data needs to be - // validated at the time the URL is requested (which is what ValidateData - // does). If your feature requires security checks, it should be in the - // implementation in the renderer when the WebKit request is actually - // constructed. - // - // It is legal to do some validation here if you want to report failure to - // the plugin as a convenience, as long as you also do it in the renderer - // later. - PP_Bool result = PP_FALSE; - switch (var.type) { - case PP_VARTYPE_UNDEFINED: - result = PP_FromBool(SetUndefinedProperty(property)); - break; - case PP_VARTYPE_BOOL: - result = PP_FromBool( - SetBooleanProperty(property, PP_ToBool(var.value.as_bool))); - break; - case PP_VARTYPE_INT32: - result = PP_FromBool( - SetIntegerProperty(property, var.value.as_int)); - break; - case PP_VARTYPE_STRING: { - StringVar* string = StringVar::FromPPVar(var); - if (string) - result = PP_FromBool(SetStringProperty(property, string->value())); - break; - } - default: - break; - } - return result; -} - -PP_Bool URLRequestInfoImpl::AppendDataToBody(const void* data, uint32_t len) { - if (len > 0) { - data_.body.push_back(PPB_URLRequestInfo_Data::BodyItem( - std::string(static_cast(data), len))); - } - return PP_TRUE; -} - -PP_Bool URLRequestInfoImpl::AppendFileToBody( - PP_Resource file_ref, - int64_t start_offset, - int64_t number_of_bytes, - PP_Time expected_last_modified_time) { - EnterResourceNoLock enter(file_ref, true); - if (enter.failed()) - return PP_FALSE; - - // Ignore a call to append nothing. - if (number_of_bytes == 0) - return PP_TRUE; - - // Check for bad values. (-1 means read until end of file.) - if (start_offset < 0 || number_of_bytes < -1) - return PP_FALSE; - - data_.body.push_back(PPB_URLRequestInfo_Data::BodyItem( - enter.resource(), - start_offset, - number_of_bytes, - expected_last_modified_time)); - return PP_TRUE; -} - -const PPB_URLRequestInfo_Data& URLRequestInfoImpl::GetData() const { - return data_; -} - -bool URLRequestInfoImpl::SetUndefinedProperty(PP_URLRequestProperty property) { - // IMPORTANT: Do not do security validation of parameters at this level - // without also adding them to PPB_URLRequestInfo_Impl::ValidateData. See - // SetProperty() above for why. - switch (property) { - case PP_URLREQUESTPROPERTY_CUSTOMREFERRERURL: - data_.has_custom_referrer_url = false; - data_.custom_referrer_url = std::string(); - return true; - case PP_URLREQUESTPROPERTY_CUSTOMCONTENTTRANSFERENCODING: - data_.has_custom_content_transfer_encoding = false; - data_.custom_content_transfer_encoding = std::string(); - return true; - default: - return false; - } -} - -bool URLRequestInfoImpl::SetBooleanProperty(PP_URLRequestProperty property, - bool value) { - // IMPORTANT: Do not do security validation of parameters at this level - // without also adding them to PPB_URLRequestInfo_Impl::ValidateData. See - // SetProperty() above for why. - switch (property) { - case PP_URLREQUESTPROPERTY_STREAMTOFILE: - data_.stream_to_file = value; - return true; - case PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS: - data_.follow_redirects = value; - return true; - case PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS: - data_.record_download_progress = value; - return true; - case PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS: - data_.record_upload_progress = value; - return true; - case PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS: - data_.allow_cross_origin_requests = value; - return true; - case PP_URLREQUESTPROPERTY_ALLOWCREDENTIALS: - data_.allow_credentials = value; - return true; - default: - return false; - } -} - -bool URLRequestInfoImpl::SetIntegerProperty(PP_URLRequestProperty property, - int32_t value) { - // IMPORTANT: Do not do security validation of parameters at this level - // without also adding them to PPB_URLRequestInfo_Impl::ValidateData. See - // SetProperty() above for why. - switch (property) { - case PP_URLREQUESTPROPERTY_PREFETCHBUFFERUPPERTHRESHOLD: - data_.prefetch_buffer_upper_threshold = value; - return true; - case PP_URLREQUESTPROPERTY_PREFETCHBUFFERLOWERTHRESHOLD: - data_.prefetch_buffer_lower_threshold = value; - return true; - default: - return false; - } -} - -bool URLRequestInfoImpl::SetStringProperty(PP_URLRequestProperty property, - const std::string& value) { - // IMPORTANT: Do not do security validation of parameters at this level - // without also adding them to PPB_URLRequestInfo_Impl::ValidateData. See - // SetProperty() above for why. - switch (property) { - case PP_URLREQUESTPROPERTY_URL: - data_.url = value; // NOTE: This may be a relative URL. - return true; - case PP_URLREQUESTPROPERTY_METHOD: - data_.method = value; - return true; - case PP_URLREQUESTPROPERTY_HEADERS: - data_.headers = value; - return true; - case PP_URLREQUESTPROPERTY_CUSTOMREFERRERURL: - data_.has_custom_referrer_url = true; - data_.custom_referrer_url = value; - return true; - case PP_URLREQUESTPROPERTY_CUSTOMCONTENTTRANSFERENCODING: - data_.has_custom_content_transfer_encoding = true; - data_.custom_content_transfer_encoding = value; - return true; - default: - return false; - } -} - -} // namespace ppapi diff --git a/ppapi/shared_impl/url_request_info_impl.h b/ppapi/shared_impl/url_request_info_impl.h deleted file mode 100644 index 67e2e49..0000000 --- a/ppapi/shared_impl/url_request_info_impl.h +++ /dev/null @@ -1,136 +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_SHARED_IMPL_URL_REQUEST_INFO_IMPL_H_ -#define PPAPI_SHARED_IMPL_URL_REQUEST_INFO_IMPL_H_ - -#include -#include - -#include "base/compiler_specific.h" -#include "ppapi/shared_impl/resource.h" -#include "ppapi/thunk/ppb_url_request_info_api.h" - -namespace ppapi { - -struct PPAPI_SHARED_EXPORT PPB_URLRequestInfo_Data { - struct PPAPI_SHARED_EXPORT BodyItem { - BodyItem(); - explicit BodyItem(const std::string& data); - BodyItem(Resource* file_ref, - int64_t start_offset, - int64_t number_of_bytes, - PP_Time expected_last_modified_time); - - // Set if the input is a file, false means the |data| is valid. - bool is_file; - - std::string data; - - // Is is_file is set, these variables are set. Note that the resource - // may still be NULL in some cases, such as deserialization errors. - // - // This is a bit tricky. In the plugin side of the proxy, both the file ref - // and the file_ref_host_resource will be set and valid. The scoped_ptr - // ensures that the resource is alive for as long as the BodyItem is. - // - // When we deserialize this in the renderer, only the - // file_ref_host_resource's are serialized over IPC. The file_refs won't be - // valid until the host resources are converted to Resource pointers in the - // PPB_URLRequestInfo_Impl. - scoped_refptr file_ref; - HostResource file_ref_host_resource; - - int64_t start_offset; - int64_t number_of_bytes; - PP_Time expected_last_modified_time; - - // If you add more stuff here, be sure to modify the serialization rules in - // ppapi_messages.h - }; - - PPB_URLRequestInfo_Data(); - ~PPB_URLRequestInfo_Data(); - - std::string url; - std::string method; - std::string headers; - - bool stream_to_file; - bool follow_redirects; - bool record_download_progress; - bool record_upload_progress; - - // |has_custom_referrer_url| is set to false if a custom referrer hasn't been - // set (or has been set to an Undefined Var) and the default referrer should - // be used. (Setting the custom referrer to an empty string indicates that no - // referrer header should be generated.) - bool has_custom_referrer_url; - std::string custom_referrer_url; - - bool allow_cross_origin_requests; - bool allow_credentials; - - // Similar to the custom referrer (above), but for custom content transfer - // encoding. - bool has_custom_content_transfer_encoding; - std::string custom_content_transfer_encoding; - - int32_t prefetch_buffer_upper_threshold; - int32_t prefetch_buffer_lower_threshold; - - std::vector body; - - // If you add more stuff here, be sure to modify the serialization rules in - // ppapi_messages.h -}; - -class PPAPI_SHARED_EXPORT URLRequestInfoImpl - : public ::ppapi::Resource, - public ::ppapi::thunk::PPB_URLRequestInfo_API { - public: - // This constructor initializes the object as a proxy object with the given - // host resource. - URLRequestInfoImpl(const HostResource& host_resource, - const PPB_URLRequestInfo_Data& data); - - ~URLRequestInfoImpl(); - - // Resource overrides. - virtual thunk::PPB_URLRequestInfo_API* AsPPB_URLRequestInfo_API() OVERRIDE; - - // PPB_URLRequestInfo_API implementation. - virtual PP_Bool SetProperty(PP_URLRequestProperty property, - PP_Var var) OVERRIDE; - virtual PP_Bool AppendDataToBody(const void* data, uint32_t len) OVERRIDE; - virtual PP_Bool AppendFileToBody( - PP_Resource file_ref, - int64_t start_offset, - int64_t number_of_bytes, - PP_Time expected_last_modified_time) OVERRIDE; - virtual const PPB_URLRequestInfo_Data& GetData() const OVERRIDE; - - protected: - // Constructor used by the webkit implementation. - URLRequestInfoImpl(PP_Instance instance, - const PPB_URLRequestInfo_Data& data); - - bool SetUndefinedProperty(PP_URLRequestProperty property); - bool SetBooleanProperty(PP_URLRequestProperty property, bool value); - bool SetIntegerProperty(PP_URLRequestProperty property, int32_t value); - bool SetStringProperty(PP_URLRequestProperty property, - const std::string& value); - - const PPB_URLRequestInfo_Data& data() const { return data_; } - PPB_URLRequestInfo_Data& data() { return data_; } - - private: - PPB_URLRequestInfo_Data data_; - - DISALLOW_IMPLICIT_CONSTRUCTORS(URLRequestInfoImpl); -}; - -} // namespace ppapi - -#endif // PPAPI_SHARED_IMPL_URL_REQUEST_INFO_IMPL_H_ diff --git a/ppapi/shared_impl/url_util_impl.cc b/ppapi/shared_impl/url_util_impl.cc deleted file mode 100644 index fdccdb6..0000000 --- a/ppapi/shared_impl/url_util_impl.cc +++ /dev/null @@ -1,113 +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/shared_impl/url_util_impl.h" - -#include "googleurl/src/gurl.h" -#include "ppapi/shared_impl/ppapi_globals.h" -#include "ppapi/shared_impl/var.h" -#include "ppapi/shared_impl/var_tracker.h" - -namespace ppapi { - -namespace { - -void ConvertComponent(const url_parse::Component& input, - PP_URLComponent_Dev* output) { - output->begin = input.begin; - output->len = input.len; -} - -// Converts components from a GoogleUrl parsed to a PPAPI parsed structure. -// Output can be NULL to specify "do nothing." This rule is followed by all -// the url util functions, so we implement it once here. -// -// Output can be NULL to specify "do nothing." This rule is followed by all the -// url util functions, so we implement it once here. -void ConvertComponents(const url_parse::Parsed& input, - PP_URLComponents_Dev* output) { - if (!output) - return; - - ConvertComponent(input.scheme, &output->scheme); - ConvertComponent(input.username, &output->username); - ConvertComponent(input.password, &output->password); - ConvertComponent(input.host, &output->host); - ConvertComponent(input.port, &output->port); - ConvertComponent(input.path, &output->path); - ConvertComponent(input.query, &output->query); - ConvertComponent(input.ref, &output->ref); -} - -} // namespace - -// static -PP_Var URLUtilImpl::Canonicalize(PP_Var url, - PP_URLComponents_Dev* components) { - StringVar* url_string = StringVar::FromPPVar(url); - if (!url_string) - return PP_MakeNull(); - return GenerateURLReturn(url_string->pp_module(), - GURL(url_string->value()), components); -} - -// static -PP_Var URLUtilImpl::ResolveRelativeToURL(PP_Var base_url, - PP_Var relative, - PP_URLComponents_Dev* components) { - StringVar* base_url_string = StringVar::FromPPVar(base_url); - StringVar* relative_string = StringVar::FromPPVar(relative); - if (!base_url_string || !relative_string) - return PP_MakeNull(); - - GURL base_gurl(base_url_string->value()); - if (!base_gurl.is_valid()) - return PP_MakeNull(); - return GenerateURLReturn(base_url_string->pp_module(), - base_gurl.Resolve(relative_string->value()), - components); -} - -// static -PP_Bool URLUtilImpl::IsSameSecurityOrigin(PP_Var url_a, PP_Var url_b) { - StringVar* url_a_string = StringVar::FromPPVar(url_a); - StringVar* url_b_string = StringVar::FromPPVar(url_b); - if (!url_a_string || !url_b_string) - return PP_FALSE; - - GURL gurl_a(url_a_string->value()); - GURL gurl_b(url_b_string->value()); - if (!gurl_a.is_valid() || !gurl_b.is_valid()) - return PP_FALSE; - - return gurl_a.GetOrigin() == gurl_b.GetOrigin() ? PP_TRUE : PP_FALSE; -} - -// Used for returning the given GURL from a PPAPI function, with an optional -// out param indicating the components. -PP_Var URLUtilImpl::GenerateURLReturn(PP_Module module, - const GURL& url, - PP_URLComponents_Dev* components) { - if (!url.is_valid()) - return PP_MakeNull(); - ConvertComponents(url.parsed_for_possibly_invalid_spec(), components); - return StringVar::StringToPPVar(module, url.possibly_invalid_spec()); -} - -PP_Var URLUtilImpl::ConvertComponentsAndReturnURL( - const PP_Var& url, - PP_URLComponents_Dev* components) { - if (!components) - return url; // Common case - plugin doesn't care about parsing. - - StringVar* url_string = StringVar::FromPPVar(url); - if (!url_string) - return url; - - PP_Var result = Canonicalize(url, components); - PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(url); - return result; -} - -} // namespace ppapi diff --git a/ppapi/shared_impl/url_util_impl.h b/ppapi/shared_impl/url_util_impl.h deleted file mode 100644 index b7fae83..0000000 --- a/ppapi/shared_impl/url_util_impl.h +++ /dev/null @@ -1,53 +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_SHARED_IMPL_URL_UTIL_IMPL_H_ -#define PPAPI_SHARED_IMPL_URL_UTIL_IMPL_H_ - -#include - -#include "base/basictypes.h" -#include "googleurl/src/url_parse.h" -#include "ppapi/c/dev/ppb_url_util_dev.h" -#include "ppapi/c/pp_module.h" -#include "ppapi/c/pp_var.h" -#include "ppapi/shared_impl/ppapi_shared_export.h" - -class GURL; - -namespace ppapi { - -// Contains the implementation of PPB_URLUtil that is shared between the proxy -// and the renderer. -class PPAPI_SHARED_EXPORT URLUtilImpl { - public: - // PPB_URLUtil shared functions. - static PP_Var Canonicalize(PP_Var url, - PP_URLComponents_Dev* components); - static PP_Var ResolveRelativeToURL(PP_Var base_url, - PP_Var relative, - PP_URLComponents_Dev* components); - static PP_Bool IsSameSecurityOrigin(PP_Var url_a, PP_Var url_b); - - // Used for returning the given GURL from a PPAPI function, with an optional - // out param indicating the components. - static PP_Var GenerateURLReturn(PP_Module pp_module, - const GURL& url, - PP_URLComponents_Dev* components); - - // Helper function that optionally take a components structure and fills it - // out with the parsed version of the given URL. If the components pointer is - // NULL, this function will do nothing. - // - // It's annoying to serialze the large PP_URLComponents structure across IPC - // and the data isn't often requested by plugins. This function is used on - // the plugin side to fill in the components for those cases where it's - // actually needed. - static PP_Var ConvertComponentsAndReturnURL(const PP_Var& url, - PP_URLComponents_Dev* components); -}; - -} // namespace ppapi - -#endif diff --git a/ppapi/shared_impl/video_decoder_impl.cc b/ppapi/shared_impl/video_decoder_impl.cc deleted file mode 100644 index 1ab0a39..0000000 --- a/ppapi/shared_impl/video_decoder_impl.cc +++ /dev/null @@ -1,88 +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/shared_impl/video_decoder_impl.h" - -#include "base/logging.h" -#include "gpu/command_buffer/client/gles2_implementation.h" -#include "ppapi/c/pp_errors.h" -#include "ppapi/shared_impl/resource_tracker.h" -#include "ppapi/thunk/enter.h" - -namespace ppapi { - -VideoDecoderImpl::VideoDecoderImpl() - : flush_callback_(PP_MakeCompletionCallback(NULL, NULL)), - reset_callback_(PP_MakeCompletionCallback(NULL, NULL)), - graphics_context_(0), - gles2_impl_(NULL) { -} - -VideoDecoderImpl::~VideoDecoderImpl() { -} - -void VideoDecoderImpl::InitCommon( - PP_Resource graphics_context, - gpu::gles2::GLES2Implementation* gles2_impl) { - DCHECK(graphics_context); - DCHECK(!gles2_impl_ && !graphics_context_); - gles2_impl_ = gles2_impl; - PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(graphics_context); - graphics_context_ = graphics_context; -} - -void VideoDecoderImpl::Destroy() { - graphics_context_ = 0; - gles2_impl_ = NULL; - PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(graphics_context_); -} - -bool VideoDecoderImpl::SetFlushCallback(PP_CompletionCallback callback) { - CHECK(callback.func); - if (flush_callback_.func) - return false; - flush_callback_ = callback; - return true; -} - -bool VideoDecoderImpl::SetResetCallback(PP_CompletionCallback callback) { - CHECK(callback.func); - if (reset_callback_.func) - return false; - reset_callback_ = callback; - return true; -} - -bool VideoDecoderImpl::SetBitstreamBufferCallback( - int32 bitstream_buffer_id, PP_CompletionCallback callback) { - return bitstream_buffer_callbacks_.insert( - std::make_pair(bitstream_buffer_id, callback)).second; -} - -void VideoDecoderImpl::RunFlushCallback(int32 result) { - DCHECK(flush_callback_.func); - PP_RunAndClearCompletionCallback(&flush_callback_, result); -} - -void VideoDecoderImpl::RunResetCallback(int32 result) { - DCHECK(reset_callback_.func); - PP_RunAndClearCompletionCallback(&reset_callback_, result); -} - -void VideoDecoderImpl::RunBitstreamBufferCallback( - int32 bitstream_buffer_id, int32 result) { - CallbackById::iterator it = - bitstream_buffer_callbacks_.find(bitstream_buffer_id); - DCHECK(it != bitstream_buffer_callbacks_.end()); - PP_CompletionCallback cc = it->second; - bitstream_buffer_callbacks_.erase(it); - PP_RunCompletionCallback(&cc, PP_OK); -} - -void VideoDecoderImpl::FlushCommandBuffer() { - if (gles2_impl_) - gles2_impl_->Flush(); -} - -} // namespace ppapi diff --git a/ppapi/shared_impl/video_decoder_impl.h b/ppapi/shared_impl/video_decoder_impl.h deleted file mode 100644 index 754dd75..0000000 --- a/ppapi/shared_impl/video_decoder_impl.h +++ /dev/null @@ -1,77 +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_SHARED_IMPL_VIDEO_DECODER_IMPL_H_ -#define PPAPI_SHARED_IMPL_VIDEO_DECODER_IMPL_H_ - -#include -#include - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "ppapi/c/dev/ppb_video_decoder_dev.h" -#include "ppapi/shared_impl/resource.h" -#include "ppapi/thunk/ppb_video_decoder_api.h" - -namespace gpu { -namespace gles2 { -class GLES2Implementation; -} // namespace gles2 -} // namespace gpu - -namespace ppapi { - -// Implements the logic to set and run callbacks for various video decoder -// events. Both the proxy and the renderer implementation share this code. -class PPAPI_SHARED_EXPORT VideoDecoderImpl - : NON_EXPORTED_BASE(public thunk::PPB_VideoDecoder_API) { - public: - VideoDecoderImpl(); - virtual ~VideoDecoderImpl(); - - // PPB_VideoDecoder_API implementation. - virtual void Destroy() OVERRIDE; - - protected: - bool SetFlushCallback(PP_CompletionCallback callback); - bool SetResetCallback(PP_CompletionCallback callback); - bool SetBitstreamBufferCallback( - int32 bitstream_buffer_id, PP_CompletionCallback callback); - - void RunFlushCallback(int32 result); - void RunResetCallback(int32 result); - void RunBitstreamBufferCallback(int32 bitstream_buffer_id, int32 result); - - // Tell command buffer to process all commands it has received so far. - void FlushCommandBuffer(); - - // Initialize the underlying decoder. - void InitCommon(PP_Resource graphics_context, - gpu::gles2::GLES2Implementation* gles2_impl); - - private: - // Key: bitstream_buffer_id, value: callback to run when bitstream decode is - // done. - typedef std::map CallbackById; - - PP_CompletionCallback flush_callback_; - PP_CompletionCallback reset_callback_; - CallbackById bitstream_buffer_callbacks_; - - // The resource ID of the underlying Graphics3D object being used. Used only - // for reference counting to keep it alive for the lifetime of |*this|. - PP_Resource graphics_context_; - - // Reference to the GLES2Implementation owned by |graphics_context_|. - // Graphics3D is guaranteed to be alive for the lifetime of this class. - // In the out-of-process case, Graphics3D's gles2_impl() exists in the plugin - // process only, so gles2_impl_ is NULL in that case. - gpu::gles2::GLES2Implementation* gles2_impl_; - - DISALLOW_COPY_AND_ASSIGN(VideoDecoderImpl); -}; - -} // namespace ppapi - -#endif // PPAPI_SHARED_IMPL_VIDEO_DECODER_IMPL_H_ diff --git a/ppapi/thunk/ppb_char_set_thunk.cc b/ppapi/thunk/ppb_char_set_thunk.cc index 3e240e8..27419b4 100644 --- a/ppapi/thunk/ppb_char_set_thunk.cc +++ b/ppapi/thunk/ppb_char_set_thunk.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. #include "ppapi/c/pp_var.h" -#include "ppapi/shared_impl/char_set_impl.h" +#include "ppapi/shared_impl/ppb_char_set_shared.h" #include "ppapi/thunk/thunk.h" #include "ppapi/thunk/enter.h" @@ -34,8 +34,8 @@ char* UTF16ToCharSet(PP_Instance instance, if (enter.failed()) return NULL; - return CharSetImpl::UTF16ToCharSet(utf16, utf16_len, output_char_set, - on_error, output_length); + return PPB_CharSet_Shared::UTF16ToCharSet(utf16, utf16_len, output_char_set, + on_error, output_length); } uint16_t* CharSetToUTF16(PP_Instance instance, @@ -49,8 +49,8 @@ uint16_t* CharSetToUTF16(PP_Instance instance, if (enter.failed()) return NULL; - return CharSetImpl::CharSetToUTF16(input, input_len, input_char_set, - on_error, output_length); + return PPB_CharSet_Shared::CharSetToUTF16(input, input_len, input_char_set, + on_error, output_length); } PP_Var GetDefaultCharSet(PP_Instance instance) { diff --git a/ppapi/thunk/ppb_image_data_thunk.cc b/ppapi/thunk/ppb_image_data_thunk.cc index 7941ab6..00d9184 100644 --- a/ppapi/thunk/ppb_image_data_thunk.cc +++ b/ppapi/thunk/ppb_image_data_thunk.cc @@ -4,7 +4,7 @@ #include "ppapi/c/pp_errors.h" #include "ppapi/c/ppb_image_data.h" -#include "ppapi/shared_impl/image_data_impl.h" +#include "ppapi/shared_impl/ppb_image_data_shared.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_image_data_api.h" #include "ppapi/thunk/resource_creation_api.h" @@ -16,11 +16,11 @@ namespace thunk { namespace { PP_ImageDataFormat GetNativeImageDataFormat() { - return ppapi::ImageDataImpl::GetNativeImageDataFormat(); + return ppapi::PPB_ImageData_Shared::GetNativeImageDataFormat(); } PP_Bool IsImageDataFormatSupported(PP_ImageDataFormat format) { - return ppapi::ImageDataImpl::IsImageDataFormatSupported(format) + return ppapi::PPB_ImageData_Shared::IsImageDataFormatSupported(format) ? PP_TRUE : PP_FALSE; } diff --git a/ppapi/thunk/ppb_url_request_info_thunk.cc b/ppapi/thunk/ppb_url_request_info_thunk.cc index 4f41881..a5cca10 100644 --- a/ppapi/thunk/ppb_url_request_info_thunk.cc +++ b/ppapi/thunk/ppb_url_request_info_thunk.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ppapi/shared_impl/url_request_info_impl.h" +#include "ppapi/shared_impl/ppb_url_request_info_shared.h" #include "ppapi/thunk/thunk.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_url_request_info_api.h" diff --git a/ppapi/thunk/ppb_url_util_thunk.cc b/ppapi/thunk/ppb_url_util_thunk.cc index 1a6b4a8..f1dbc27 100644 --- a/ppapi/thunk/ppb_url_util_thunk.cc +++ b/ppapi/thunk/ppb_url_util_thunk.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. #include "ppapi/c/pp_errors.h" -#include "ppapi/shared_impl/url_util_impl.h" +#include "ppapi/shared_impl/ppb_url_util_shared.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_instance_api.h" #include "ppapi/thunk/thunk.h" @@ -54,10 +54,10 @@ PP_Var GetPluginInstanceURL(PP_Instance instance, } const PPB_URLUtil_Dev g_ppb_url_util = { - &URLUtilImpl::Canonicalize, - &URLUtilImpl::ResolveRelativeToURL, + &PPB_URLUtil_Shared::Canonicalize, + &PPB_URLUtil_Shared::ResolveRelativeToURL, &ResolveRelativeToDocument, - &URLUtilImpl::IsSameSecurityOrigin, + &PPB_URLUtil_Shared::IsSameSecurityOrigin, &DocumentCanRequest, &DocumentCanAccessDocument, &GetDocumentURL, diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi index 014acc4..571c7be 100644 --- a/webkit/glue/webkit_glue.gypi +++ b/webkit/glue/webkit_glue.gypi @@ -285,8 +285,6 @@ '../plugins/ppapi/ppb_image_data_impl.h', '../plugins/ppapi/ppb_layer_compositor_impl.cc', '../plugins/ppapi/ppb_layer_compositor_impl.h', - '../plugins/ppapi/ppb_opengles_impl.cc', - '../plugins/ppapi/ppb_opengles_impl.h', '../plugins/ppapi/ppb_proxy_impl.cc', '../plugins/ppapi/ppb_proxy_impl.h', '../plugins/ppapi/ppb_scrollbar_impl.cc', diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc index 87bc066..fc5b2a1 100644 --- a/webkit/plugins/ppapi/plugin_module.cc +++ b/webkit/plugins/ppapi/plugin_module.cc @@ -83,7 +83,8 @@ #include "ppapi/c/trusted/ppb_graphics_3d_trusted.h" #include "ppapi/c/trusted/ppb_image_data_trusted.h" #include "ppapi/c/trusted/ppb_url_loader_trusted.h" -#include "ppapi/shared_impl/input_event_impl.h" +#include "ppapi/shared_impl/ppb_input_event_shared.h" +#include "ppapi/shared_impl/ppb_opengles2_shared.h" #include "ppapi/shared_impl/time_conversion.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/thunk.h" @@ -105,7 +106,6 @@ #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" #include "webkit/plugins/ppapi/ppb_image_data_impl.h" #include "webkit/plugins/ppapi/ppb_layer_compositor_impl.h" -#include "webkit/plugins/ppapi/ppb_opengles_impl.h" #include "webkit/plugins/ppapi/ppb_proxy_impl.h" #include "webkit/plugins/ppapi/ppb_scrollbar_impl.h" #include "webkit/plugins/ppapi/ppb_uma_private_impl.h" @@ -314,7 +314,7 @@ const void* GetInterface(const char* name) { if (strcmp(name, PPB_INSTANCE_PRIVATE_INTERFACE) == 0) return ::ppapi::thunk::GetPPB_Instance_Private_Thunk(); if (strcmp(name, PPB_OPENGLES2_INTERFACE) == 0) - return PPB_OpenGLES_Impl::GetInterface(); + return ::ppapi::PPB_OpenGLES2_Shared::GetInterface(); if (strcmp(name, PPB_PROXY_PRIVATE_INTERFACE) == 0) return PPB_Proxy_Impl::GetInterface(); if (strcmp(name, PPB_UMA_PRIVATE_INTERFACE) == 0) diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc index f116d6c..92882f9 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc @@ -34,10 +34,10 @@ #include "ppapi/c/ppp_mouse_lock.h" #include "ppapi/c/private/ppb_instance_private.h" #include "ppapi/c/private/ppp_instance_private.h" -#include "ppapi/shared_impl/input_event_impl.h" +#include "ppapi/shared_impl/ppb_input_event_shared.h" +#include "ppapi/shared_impl/ppb_url_util_shared.h" #include "ppapi/shared_impl/resource.h" #include "ppapi/shared_impl/time_conversion.h" -#include "ppapi/shared_impl/url_util_impl.h" #include "ppapi/shared_impl/var.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_buffer_api.h" @@ -101,7 +101,7 @@ using base::StringPrintf; using ppapi::InputEventData; -using ppapi::InputEventImpl; +using ppapi::PPB_InputEvent_Shared; using ppapi::PpapiGlobals; using ppapi::StringVar; using ppapi::thunk::EnterResourceNoLock; @@ -588,9 +588,9 @@ bool PluginInstance::SendCompositionEventWithUnderlineInformationToPlugin( event.is_filtered = true; else handled = true; // Unfiltered events are assumed to be handled. - scoped_refptr event_resource( - new InputEventImpl(InputEventImpl::InitAsImpl(), - pp_instance(), event)); + scoped_refptr event_resource( + new PPB_InputEvent_Shared(PPB_InputEvent_Shared::InitAsImpl(), + pp_instance(), event)); handled |= PP_ToBool(plugin_input_event_interface_->HandleInputEvent( pp_instance(), event_resource->pp_resource())); return handled; @@ -687,9 +687,9 @@ bool PluginInstance::HandleInputEvent(const WebKit::WebInputEvent& event, events[i].is_filtered = true; else rv = true; // Unfiltered events are assumed to be handled. - scoped_refptr event_resource( - new InputEventImpl(InputEventImpl::InitAsImpl(), - pp_instance(), events[i])); + scoped_refptr event_resource( + new PPB_InputEvent_Shared(PPB_InputEvent_Shared::InitAsImpl(), + pp_instance(), events[i])); rv |= PP_ToBool(plugin_input_event_interface_->HandleInputEvent( pp_instance(), event_resource->pp_resource())); @@ -1895,7 +1895,7 @@ PP_Var PluginInstance::ResolveRelativeToDocument( WebElement plugin_element = container()->element(); GURL document_url = plugin_element.document().baseURL(); - return ::ppapi::URLUtilImpl::GenerateURLReturn( + return ::ppapi::PPB_URLUtil_Shared::GenerateURLReturn( module()->pp_module(), document_url.Resolve(relative_string->value()), components); @@ -1933,15 +1933,16 @@ PP_Bool PluginInstance::DocumentCanAccessDocument(PP_Instance instance, PP_Var PluginInstance::GetDocumentURL(PP_Instance instance, PP_URLComponents_Dev* components) { WebKit::WebDocument document = container()->element().document(); - return ::ppapi::URLUtilImpl::GenerateURLReturn(module()->pp_module(), - document.url(), components); + return ::ppapi::PPB_URLUtil_Shared::GenerateURLReturn( + module()->pp_module(), document.url(), components); } PP_Var PluginInstance::GetPluginInstanceURL( PP_Instance instance, PP_URLComponents_Dev* components) { - return ::ppapi::URLUtilImpl::GenerateURLReturn(module()->pp_module(), - plugin_url_, components); + return ::ppapi::PPB_URLUtil_Shared::GenerateURLReturn(module()->pp_module(), + plugin_url_, + components); } void PluginInstance::DoSetCursor(WebCursorInfo* cursor) { diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h index a2d429b..83dcf43 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.h +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h @@ -26,7 +26,7 @@ #include "ppapi/c/ppp_graphics_3d.h" #include "ppapi/c/ppp_instance.h" #include "ppapi/shared_impl/function_group_base.h" -#include "ppapi/shared_impl/instance_impl.h" +#include "ppapi/shared_impl/ppb_instance_shared.h" #include "ppapi/shared_impl/ppp_instance_combined.h" #include "ppapi/thunk/ppb_instance_api.h" #include "third_party/skia/include/core/SkBitmap.h" @@ -86,7 +86,7 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance : public base::RefCounted, public ::ppapi::FunctionGroupBase, NON_EXPORTED_BASE(public ::ppapi::thunk::PPB_Instance_FunctionAPI), - public ::ppapi::InstanceImpl { + public ::ppapi::PPB_Instance_Shared { public: // Create and return a PluginInstance object which supports the // PPP_Instance_1_0 interface. diff --git a/webkit/plugins/ppapi/ppb_audio_impl.h b/webkit/plugins/ppapi/ppb_audio_impl.h index 47c2e78..d131090 100644 --- a/webkit/plugins/ppapi/ppb_audio_impl.h +++ b/webkit/plugins/ppapi/ppb_audio_impl.h @@ -13,10 +13,10 @@ #include "ppapi/c/ppb_audio.h" #include "ppapi/c/ppb_audio_config.h" #include "ppapi/c/trusted/ppb_audio_trusted.h" -#include "ppapi/shared_impl/audio_config_impl.h" -#include "ppapi/shared_impl/audio_impl.h" -#include "ppapi/shared_impl/scoped_pp_resource.h" +#include "ppapi/shared_impl/ppb_audio_config_shared.h" +#include "ppapi/shared_impl/ppb_audio_shared.h" #include "ppapi/shared_impl/resource.h" +#include "ppapi/shared_impl/scoped_pp_resource.h" #include "webkit/plugins/ppapi/audio_helper.h" #include "webkit/plugins/ppapi/plugin_delegate.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" @@ -25,9 +25,9 @@ namespace webkit { namespace ppapi { // Some of the backend functionality of this class is implemented by the -// AudioImpl so it can be shared with the proxy. +// PPB_Audio_Shared so it can be shared with the proxy. class PPB_Audio_Impl : public ::ppapi::Resource, - public ::ppapi::AudioImpl, + public ::ppapi::PPB_Audio_Shared, public AudioHelper { public: // Trusted initialization. You must call Init after this. diff --git a/webkit/plugins/ppapi/ppb_audio_input_impl.h b/webkit/plugins/ppapi/ppb_audio_input_impl.h index 4435eb6..f18a7a0 100644 --- a/webkit/plugins/ppapi/ppb_audio_input_impl.h +++ b/webkit/plugins/ppapi/ppb_audio_input_impl.h @@ -12,8 +12,8 @@ #include "ppapi/c/dev/ppb_audio_input_dev.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/trusted/ppb_audio_input_trusted_dev.h" -#include "ppapi/shared_impl/audio_config_impl.h" -#include "ppapi/shared_impl/audio_input_impl.h" +#include "ppapi/shared_impl/ppb_audio_config_shared.h" +#include "ppapi/shared_impl/ppb_audio_input_shared.h" #include "ppapi/shared_impl/resource.h" #include "ppapi/shared_impl/scoped_pp_resource.h" #include "webkit/plugins/ppapi/audio_helper.h" @@ -26,7 +26,7 @@ namespace ppapi { // Some of the backend functionality of this class is implemented by the // AudioInputImpl so it can be shared with the proxy. class PPB_AudioInput_Impl : public ::ppapi::Resource, - public ::ppapi::AudioInputImpl, + public ::ppapi::PPB_AudioInput_Shared, public AudioHelper { public: // Trusted initialization. You must call Init after this. diff --git a/webkit/plugins/ppapi/ppb_file_ref_impl.cc b/webkit/plugins/ppapi/ppb_file_ref_impl.cc index 3b39ce6..bc0de22 100644 --- a/webkit/plugins/ppapi/ppb_file_ref_impl.cc +++ b/webkit/plugins/ppapi/ppb_file_ref_impl.cc @@ -80,14 +80,14 @@ std::string GetNameForVirtualFilePath(const std::string& path) { PPB_FileRef_Impl::PPB_FileRef_Impl(const PPB_FileRef_CreateInfo& info, PPB_FileSystem_Impl* file_system) - : FileRefImpl(FileRefImpl::InitAsImpl(), info), + : PPB_FileRef_Shared(PPB_FileRef_Shared::InitAsImpl(), info), file_system_(file_system), external_file_system_path_() { } PPB_FileRef_Impl::PPB_FileRef_Impl(const PPB_FileRef_CreateInfo& info, const FilePath& external_file_path) - : FileRefImpl(FileRefImpl::InitAsImpl(), info), + : PPB_FileRef_Shared(PPB_FileRef_Shared::InitAsImpl(), info), file_system_(), external_file_system_path_(external_file_path) { } diff --git a/webkit/plugins/ppapi/ppb_file_ref_impl.h b/webkit/plugins/ppapi/ppb_file_ref_impl.h index 39bc80b..c9b1dbf 100644 --- a/webkit/plugins/ppapi/ppb_file_ref_impl.h +++ b/webkit/plugins/ppapi/ppb_file_ref_impl.h @@ -10,7 +10,7 @@ #include "base/file_path.h" #include "googleurl/src/gurl.h" #include "ppapi/c/ppb_file_ref.h" -#include "ppapi/shared_impl/file_ref_impl.h" +#include "ppapi/shared_impl/ppb_file_ref_shared.h" #include "ppapi/shared_impl/var.h" namespace webkit { @@ -20,7 +20,7 @@ using ::ppapi::StringVar; class PPB_FileSystem_Impl; -class PPB_FileRef_Impl : public ::ppapi::FileRefImpl { +class PPB_FileRef_Impl : public ::ppapi::PPB_FileRef_Shared { public: PPB_FileRef_Impl(const ::ppapi::PPB_FileRef_CreateInfo& info, PPB_FileSystem_Impl* file_system); @@ -36,7 +36,7 @@ class PPB_FileRef_Impl : public ::ppapi::FileRefImpl { static PPB_FileRef_Impl* CreateExternal(PP_Instance instance, const FilePath& external_file_path); - // PPB_FileRef_API implementation (not provided by FileRefImpl). + // PPB_FileRef_API implementation (not provided by PPB_FileRef_Shared). virtual PP_Resource GetParent() OVERRIDE; virtual int32_t MakeDirectory(PP_Bool make_ancestors, PP_CompletionCallback callback) OVERRIDE; diff --git a/webkit/plugins/ppapi/ppb_font_impl.cc b/webkit/plugins/ppapi/ppb_font_impl.cc index a714e03..cac50b5 100644 --- a/webkit/plugins/ppapi/ppb_font_impl.cc +++ b/webkit/plugins/ppapi/ppb_font_impl.cc @@ -5,8 +5,8 @@ #include "webkit/plugins/ppapi/ppb_font_impl.h" #include "ppapi/c/dev/ppb_font_dev.h" -#include "ppapi/shared_impl/font_impl.h" #include "ppapi/shared_impl/ppapi_preferences.h" +#include "ppapi/shared_impl/ppb_font_shared.h" #include "ppapi/shared_impl/var.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/thunk.h" @@ -64,7 +64,7 @@ PPB_Font_Impl::~PPB_Font_Impl() { // static PP_Resource PPB_Font_Impl::Create(PP_Instance instance, const PP_FontDescription_Dev& description) { - if (!::ppapi::FontImpl::IsPPFontDescriptionValid(description)) + if (!::ppapi::PPB_Font_Shared::IsPPFontDescriptionValid(description)) return 0; return (new PPB_Font_Impl(instance, description))->GetReference(); } diff --git a/webkit/plugins/ppapi/ppb_graphics_3d_impl.h b/webkit/plugins/ppapi/ppb_graphics_3d_impl.h index 250911b..728f58a 100644 --- a/webkit/plugins/ppapi/ppb_graphics_3d_impl.h +++ b/webkit/plugins/ppapi/ppb_graphics_3d_impl.h @@ -6,7 +6,7 @@ #define WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_3D_IMPL_H_ #include "base/memory/weak_ptr.h" -#include "ppapi/shared_impl/graphics_3d_impl.h" +#include "ppapi/shared_impl/ppb_graphics_3d_shared.h" #include "ppapi/shared_impl/resource.h" #include "webkit/plugins/ppapi/plugin_delegate.h" @@ -14,7 +14,7 @@ namespace webkit { namespace ppapi { class PPB_Graphics3D_Impl : public ::ppapi::Resource, - public ::ppapi::Graphics3DImpl { + public ::ppapi::PPB_Graphics3D_Shared { public: virtual ~PPB_Graphics3D_Impl(); @@ -62,7 +62,7 @@ class PPB_Graphics3D_Impl : public ::ppapi::Resource, } protected: - // ppapi::Graphics3DImpl overrides. + // ppapi::PPB_Graphics3D_Shared overrides. virtual gpu::CommandBuffer* GetCommandBuffer() OVERRIDE; virtual int32 DoSwapBuffers() OVERRIDE; diff --git a/webkit/plugins/ppapi/ppb_image_data_impl.h b/webkit/plugins/ppapi/ppb_image_data_impl.h index 1c6b7ff..64685d0 100644 --- a/webkit/plugins/ppapi/ppb_image_data_impl.h +++ b/webkit/plugins/ppapi/ppb_image_data_impl.h @@ -8,7 +8,7 @@ #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "ppapi/c/ppb_image_data.h" -#include "ppapi/shared_impl/image_data_impl.h" +#include "ppapi/shared_impl/ppb_image_data_shared.h" #include "ppapi/shared_impl/resource.h" #include "ppapi/thunk/ppb_image_data_api.h" #include "webkit/plugins/ppapi/plugin_delegate.h" @@ -24,7 +24,7 @@ namespace webkit { namespace ppapi { class PPB_ImageData_Impl : public ::ppapi::Resource, - public ::ppapi::ImageDataImpl, + public ::ppapi::PPB_ImageData_Shared, public ::ppapi::thunk::PPB_ImageData_API { public: // If you call this constructor, you must also call Init before use. Normally diff --git a/webkit/plugins/ppapi/ppb_opengles_impl.cc b/webkit/plugins/ppapi/ppb_opengles_impl.cc deleted file mode 100644 index 1f95df5..0000000 --- a/webkit/plugins/ppapi/ppb_opengles_impl.cc +++ /dev/null @@ -1,18 +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 "webkit/plugins/ppapi/ppb_opengles_impl.h" - -#include "ppapi/shared_impl/opengles2_impl.h" - -namespace webkit { -namespace ppapi { - -const PPB_OpenGLES2* PPB_OpenGLES_Impl::GetInterface() { - return ::ppapi::OpenGLES2Impl::GetInterface(); -} - -} // namespace ppapi -} // namespace webkit - diff --git a/webkit/plugins/ppapi/ppb_opengles_impl.h b/webkit/plugins/ppapi/ppb_opengles_impl.h deleted file mode 100644 index e4a69d2..0000000 --- a/webkit/plugins/ppapi/ppb_opengles_impl.h +++ /dev/null @@ -1,22 +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 WEBKIT_PLUGINS_PPAPI_PPB_OPENGLES_IMPL_H_ -#define WEBKIT_PLUGINS_PPAPI_PPB_OPENGLES_IMPL_H_ - -struct PPB_OpenGLES2; - -namespace webkit { -namespace ppapi { - -class PPB_OpenGLES_Impl { - public: - static const PPB_OpenGLES2* GetInterface(); -}; - -} // namespace ppapi -} // namespace webkit - -#endif // WEBKIT_PLUGINS_PPAPI_PPB_OPENGLES_IMPL_H_ - diff --git a/webkit/plugins/ppapi/ppb_url_loader_impl.h b/webkit/plugins/ppapi/ppb_url_loader_impl.h index 61f4cde..326568e 100644 --- a/webkit/plugins/ppapi/ppb_url_loader_impl.h +++ b/webkit/plugins/ppapi/ppb_url_loader_impl.h @@ -11,8 +11,8 @@ #include "base/memory/scoped_ptr.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/trusted/ppb_url_loader_trusted.h" +#include "ppapi/shared_impl/ppb_url_request_info_shared.h" #include "ppapi/shared_impl/resource.h" -#include "ppapi/shared_impl/url_request_info_impl.h" #include "ppapi/thunk/ppb_url_loader_api.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoaderClient.h" #include "webkit/plugins/ppapi/callbacks.h" diff --git a/webkit/plugins/ppapi/ppb_url_request_info_impl.cc b/webkit/plugins/ppapi/ppb_url_request_info_impl.cc index eceedd7..dcea987 100644 --- a/webkit/plugins/ppapi/ppb_url_request_info_impl.cc +++ b/webkit/plugins/ppapi/ppb_url_request_info_impl.cc @@ -49,7 +49,7 @@ const int32_t kDefaultPrefetchBufferLowerThreshold = 50 * 1000 * 1000; PPB_URLRequestInfo_Impl::PPB_URLRequestInfo_Impl( PP_Instance instance, const PPB_URLRequestInfo_Data& data) - : URLRequestInfoImpl(instance, data) { + : PPB_URLRequestInfo_Shared(instance, data) { } PPB_URLRequestInfo_Impl::~PPB_URLRequestInfo_Impl() { diff --git a/webkit/plugins/ppapi/ppb_url_request_info_impl.h b/webkit/plugins/ppapi/ppb_url_request_info_impl.h index d9841f0..d2403b6 100644 --- a/webkit/plugins/ppapi/ppb_url_request_info_impl.h +++ b/webkit/plugins/ppapi/ppb_url_request_info_impl.h @@ -7,7 +7,7 @@ #include "base/memory/ref_counted.h" #include "ppapi/thunk/ppb_url_request_info_api.h" -#include "ppapi/shared_impl/url_request_info_impl.h" +#include "ppapi/shared_impl/ppb_url_request_info_shared.h" #include "webkit/plugins/webkit_plugins_export.h" namespace WebKit { @@ -20,7 +20,7 @@ namespace webkit { namespace ppapi { class WEBKIT_PLUGINS_EXPORT PPB_URLRequestInfo_Impl : - public ::ppapi::URLRequestInfoImpl { + public ::ppapi::PPB_URLRequestInfo_Shared { public: explicit PPB_URLRequestInfo_Impl( PP_Instance instance, diff --git a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc index f108ecf..a226a77 100644 --- a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc +++ b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc @@ -190,7 +190,7 @@ void PPB_VideoDecoder_Impl::Destroy() { FlushCommandBuffer(); platform_video_decoder_->Destroy(); - ::ppapi::VideoDecoderImpl::Destroy(); + ::ppapi::PPB_VideoDecoder_Shared::Destroy(); platform_video_decoder_ = NULL; ppp_videodecoder_ = NULL; } diff --git a/webkit/plugins/ppapi/ppb_video_decoder_impl.h b/webkit/plugins/ppapi/ppb_video_decoder_impl.h index a989ff8..47a9af4 100644 --- a/webkit/plugins/ppapi/ppb_video_decoder_impl.h +++ b/webkit/plugins/ppapi/ppb_video_decoder_impl.h @@ -13,8 +13,8 @@ #include "base/memory/scoped_ptr.h" #include "ppapi/c/dev/pp_video_dev.h" #include "ppapi/c/pp_var.h" +#include "ppapi/shared_impl/ppb_video_decoder_shared.h" #include "ppapi/shared_impl/resource.h" -#include "ppapi/shared_impl/video_decoder_impl.h" #include "ppapi/thunk/ppb_video_decoder_api.h" #include "webkit/plugins/ppapi/plugin_delegate.h" @@ -33,7 +33,7 @@ namespace webkit { namespace ppapi { class PPB_VideoDecoder_Impl : public ::ppapi::Resource, - public ::ppapi::VideoDecoderImpl, + public ::ppapi::PPB_VideoDecoder_Shared, public media::VideoDecodeAccelerator::Client { public: virtual ~PPB_VideoDecoder_Impl(); diff --git a/webkit/plugins/ppapi/resource_creation_impl.cc b/webkit/plugins/ppapi/resource_creation_impl.cc index d2b57f3..4b2e364 100644 --- a/webkit/plugins/ppapi/resource_creation_impl.cc +++ b/webkit/plugins/ppapi/resource_creation_impl.cc @@ -5,8 +5,8 @@ #include "webkit/plugins/ppapi/resource_creation_impl.h" #include "ppapi/c/pp_size.h" -#include "ppapi/shared_impl/audio_config_impl.h" -#include "ppapi/shared_impl/input_event_impl.h" +#include "ppapi/shared_impl/ppb_audio_config_shared.h" +#include "ppapi/shared_impl/ppb_input_event_shared.h" #include "ppapi/shared_impl/var.h" #include "webkit/plugins/ppapi/common.h" #include "webkit/plugins/ppapi/ppb_audio_impl.h" @@ -36,7 +36,7 @@ #include "webkit/plugins/ppapi/ppb_websocket_impl.h" using ppapi::InputEventData; -using ppapi::InputEventImpl; +using ppapi::PPB_InputEvent_Shared; using ppapi::StringVar; namespace webkit { @@ -66,8 +66,8 @@ PP_Resource ResourceCreationImpl::CreateAudioConfig( PP_Instance instance, PP_AudioSampleRate sample_rate, uint32_t sample_frame_count) { - return ::ppapi::AudioConfigImpl::CreateAsImpl(instance, sample_rate, - sample_frame_count); + return ::ppapi::PPB_AudioConfig_Shared::CreateAsImpl(instance, sample_rate, + sample_frame_count); } PP_Resource ResourceCreationImpl::CreateAudioTrusted( @@ -196,8 +196,8 @@ PP_Resource ResourceCreationImpl::CreateKeyboardInputEvent( data.character_text = string_var->value(); } - return (new InputEventImpl(InputEventImpl::InitAsImpl(), - instance, data))->GetReference(); + return (new PPB_InputEvent_Shared(PPB_InputEvent_Shared::InitAsImpl(), + instance, data))->GetReference(); } PP_Resource ResourceCreationImpl::CreateMouseInputEvent( @@ -225,8 +225,8 @@ PP_Resource ResourceCreationImpl::CreateMouseInputEvent( data.mouse_click_count = click_count; data.mouse_movement = *mouse_movement; - return (new InputEventImpl(InputEventImpl::InitAsImpl(), - instance, data))->GetReference(); + return (new PPB_InputEvent_Shared(PPB_InputEvent_Shared::InitAsImpl(), + instance, data))->GetReference(); } PP_Resource ResourceCreationImpl::CreateScrollbar(PP_Instance instance, @@ -299,8 +299,8 @@ PP_Resource ResourceCreationImpl::CreateWheelInputEvent( data.wheel_ticks = *wheel_ticks; data.wheel_scroll_by_page = PP_ToBool(scroll_by_page); - return (new InputEventImpl(InputEventImpl::InitAsImpl(), - instance, data))->GetReference(); + return (new PPB_InputEvent_Shared(PPB_InputEvent_Shared::InitAsImpl(), + instance, data))->GetReference(); } } // namespace ppapi diff --git a/webkit/plugins/ppapi/url_request_info_unittest.cc b/webkit/plugins/ppapi/url_request_info_unittest.cc index bdfe1c7..c7f1720 100644 --- a/webkit/plugins/ppapi/url_request_info_unittest.cc +++ b/webkit/plugins/ppapi/url_request_info_unittest.cc @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ppapi/shared_impl/url_request_info_impl.h" #include "ppapi/thunk/thunk.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" -- cgit v1.1