diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-06-18 14:10:49 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> | 2015-06-18 13:53:24 +0000 |
commit | 813fbf95af77a531c57a8c497345ad2c61d475b3 (patch) | |
tree | 821b2c8de8365f21b6c9ba17a236fb3006a1d506 /chromium/ppapi | |
parent | af6588f8d723931a298c995fa97259bb7f7deb55 (diff) | |
download | qtwebengine-chromium-813fbf95af77a531c57a8c497345ad2c61d475b3.tar.gz |
BASELINE: Update chromium to 44.0.2403.47
Change-Id: Ie056fedba95cf5e5c76b30c4b2c80fca4764aa2f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'chromium/ppapi')
449 files changed, 12599 insertions, 13851 deletions
diff --git a/chromium/ppapi/BUILD.gn b/chromium/ppapi/BUILD.gn index 62862eaa1e0..ae8b8b71904 100644 --- a/chromium/ppapi/BUILD.gn +++ b/chromium/ppapi/BUILD.gn @@ -2,817 +2,139 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -gypi_values = exec_script( - "//build/gypi_to_gn.py", - [ rebase_path("ppapi_sources.gypi") ], - "scope", - [ "ppapi_sources.gypi" ]) - -# TODO(GYP) support chrome_multiple_dll -#if (chrome_multiple_dll) { -# blink_target = "//third_party/WebKit/public:blink_minimal" -#} else { - blink_target = "//third_party/WebKit/public:blink" -#} - -# These are just headers. -source_set("ppapi_c") { - sources = gypi_values.c_source_files -} - -# Some targets need to depend on the PPAPI version only. This target exists so -# they can include this header without header check warnings. -source_set("ppapi_macros") { - sources = [ "c/pp_macros.h" ] -} - -source_set("ppapi_cpp_objects") { - sources = gypi_values.cpp_source_files - - if (is_win) { - cflags = [ - "/we4244", # Implicit conversion, possible loss of data. - ] - } else { - cflags = [ - "-Wextra", - "-pedantic", - ] - } -} - -source_set("ppapi_cpp") { +copy("copy_test_files") { + visibility = [ ":*" ] sources = [ - "cpp/module_embedder.h", - "cpp/ppp_entrypoints.cc", - ] - - if (is_posix) { - cflags = [ - "-Wextra", - "-pedantic", - ] - } - - deps = [ - ":ppapi_c", - ":ppapi_cpp_objects", + # Keep "test_case.html.mock-http-headers" with "test_case.html". + "tests/ppapi_nacl_tests_newlib.nmf", + "tests/test_case.html", + "tests/test_case.html.mock-http-headers", + "tests/test_page.css", + "tests/test_page.css.mock-http-headers", ] -} - -source_set("ppapi_internal_module") { - sources = [ - "cpp/private/internal_module.cc", - "cpp/private/internal_module.h", + outputs = [ + "$root_out_dir/{{source_file_part}}", ] } -source_set("ppapi_gles2") { +copy("copy_test_files2") { + visibility = [ ":*" ] sources = [ - "lib/gl/gles2/gl2ext_ppapi.c", - "lib/gl/gles2/gl2ext_ppapi.h", - "lib/gl/gles2/gles2.c", + "tests/test_url_loader_data/hello.txt", ] - - include_dirs = [ "lib/gl/include" ] - - deps = [ - ":ppapi_c", + outputs = [ + "$root_out_dir/test_url_loader_data/{{source_file_part}}", ] } -# TODO(brettw) argument list is too long. Need to add response files. -#shared_library("ppapi_tests") { -# sources = gypi_values.test_common_source_files + -# gypi_values.test_trusted_source_files -# -# defines = [ "GL_GLEXT_PROTOTYPES" ] -# include_dirs = [ "lib/gl/include" ] -# -# deps = [ -# ":ppapi_cpp", -# ":ppapi_shared", -# ] -#} - -component("ppapi_shared") { - sources = [ - "shared_impl/array_var.cc", - "shared_impl/array_var.h", - "shared_impl/array_writer.cc", - "shared_impl/array_writer.h", - "shared_impl/callback_tracker.cc", - "shared_impl/callback_tracker.h", - "shared_impl/compositor_layer_data.cc", - "shared_impl/compositor_layer_data.h", - "shared_impl/dictionary_var.cc", - "shared_impl/dictionary_var.h", - "shared_impl/file_io_state_manager.cc", - "shared_impl/file_io_state_manager.h", - "shared_impl/file_growth.cc", - "shared_impl/file_growth.h", - "shared_impl/file_path.cc", - "shared_impl/file_path.h", - "shared_impl/file_ref_create_info.cc", - "shared_impl/file_ref_create_info.h", - "shared_impl/file_ref_util.cc", - "shared_impl/file_ref_util.h", - "shared_impl/file_system_util.cc", - "shared_impl/file_system_util.h", - "shared_impl/file_type_conversion.cc", - "shared_impl/file_type_conversion.h", - "shared_impl/host_resource.cc", - "shared_impl/host_resource.h", - "shared_impl/id_assignment.cc", - "shared_impl/id_assignment.h", - "shared_impl/media_stream_buffer.h", - "shared_impl/media_stream_buffer_manager.cc", - "shared_impl/media_stream_buffer_manager.h", - "shared_impl/media_stream_audio_track_shared.cc", - "shared_impl/media_stream_audio_track_shared.h", - "shared_impl/media_stream_video_track_shared.h", - "shared_impl/media_stream_video_track_shared.cc", - "shared_impl/platform_file.cc", - "shared_impl/platform_file.h", - "shared_impl/ppapi_constants.h", - "shared_impl/ppapi_globals.cc", - "shared_impl/ppapi_globals.h", - "shared_impl/ppapi_nacl_plugin_args.cc", - "shared_impl/ppapi_nacl_plugin_args.h", - "shared_impl/ppapi_permissions.cc", - "shared_impl/ppapi_permissions.h", - "shared_impl/ppapi_preferences.cc", - "shared_impl/ppapi_preferences.h", - "shared_impl/ppapi_switches.cc", - "shared_impl/ppapi_switches.h", - "shared_impl/ppb_audio_config_shared.cc", - "shared_impl/ppb_audio_config_shared.h", - "shared_impl/ppb_audio_shared.cc", - "shared_impl/ppb_audio_shared.h", - "shared_impl/ppb_crypto_shared.cc", - "shared_impl/ppb_device_ref_shared.cc", - "shared_impl/ppb_device_ref_shared.h", - "shared_impl/ppb_gamepad_shared.cc", - "shared_impl/ppb_gamepad_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_message_loop_shared.cc", - "shared_impl/ppb_message_loop_shared.h", - "shared_impl/ppb_opengles2_shared.cc", - "shared_impl/ppb_opengles2_shared.h", - "shared_impl/ppb_tcp_socket_shared.cc", - "shared_impl/ppb_tcp_socket_shared.h", - "shared_impl/ppb_trace_event_impl.cc", - "shared_impl/ppb_trace_event_impl.h", - "shared_impl/ppb_var_shared.cc", - "shared_impl/ppb_var_shared.h", - "shared_impl/ppb_view_shared.cc", - "shared_impl/ppb_view_shared.h", - "shared_impl/ppp_flash_browser_operations_shared.h", - "shared_impl/ppp_instance_combined.cc", - "shared_impl/ppp_instance_combined.h", - "shared_impl/proxy_lock.cc", - "shared_impl/proxy_lock.h", - "shared_impl/resource.cc", - "shared_impl/resource.h", - "shared_impl/resource_tracker.cc", - "shared_impl/resource_tracker.h", - "shared_impl/resource_var.cc", - "shared_impl/resource_var.h", - "shared_impl/scoped_pp_resource.cc", - "shared_impl/scoped_pp_resource.h", - "shared_impl/scoped_pp_var.cc", - "shared_impl/scoped_pp_var.h", - "shared_impl/socket_option_data.cc", - "shared_impl/socket_option_data.h", - "shared_impl/thread_aware_callback.cc", - "shared_impl/thread_aware_callback.h", - "shared_impl/time_conversion.cc", - "shared_impl/time_conversion.h", - "shared_impl/tracked_callback.cc", - "shared_impl/tracked_callback.h", - "shared_impl/url_request_info_data.cc", - "shared_impl/url_request_info_data.h", - "shared_impl/url_response_info_data.cc", - "shared_impl/url_response_info_data.h", - "shared_impl/var.cc", - "shared_impl/var.h", - "shared_impl/var_tracker.cc", - "shared_impl/var_tracker.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_constants.cc", - "shared_impl/private/net_address_private_impl.h", - - "shared_impl/private/ppb_x509_certificate_private_shared.cc", - "shared_impl/private/ppb_x509_certificate_private_shared.h", - - "thunk/enter.cc", - "thunk/enter.h", - "thunk/ppb_audio_api.h", - "thunk/ppb_audio_config_api.h", - "thunk/ppb_audio_config_thunk.cc", - "thunk/ppb_audio_buffer_api.h", - "thunk/ppb_audio_buffer_thunk.cc", - "thunk/ppb_audio_input_api.h", - "thunk/ppb_audio_thunk.cc", - "thunk/ppb_broker_api.h", - "thunk/ppb_browser_font_trusted_api.h", - "thunk/ppb_buffer_api.h", - "thunk/ppb_compositor_api.h", - "thunk/ppb_compositor_layer_api.h", - "thunk/ppb_compositor_layer_thunk.cc", - "thunk/ppb_compositor_thunk.cc", - "thunk/ppb_console_thunk.cc", - "thunk/ppb_cursor_control_thunk.cc", - "thunk/ppb_device_ref_api.h", - "thunk/ppb_device_ref_dev_thunk.cc", - "thunk/ppb_ext_crx_file_system_private_thunk.cc", - "thunk/ppb_file_chooser_api.h", - "thunk/ppb_file_chooser_dev_thunk.cc", - "thunk/ppb_file_chooser_trusted_thunk.cc", - "thunk/ppb_file_io_api.h", - "thunk/ppb_file_io_private_thunk.cc", - "thunk/ppb_file_io_thunk.cc", - "thunk/ppb_file_mapping_thunk.cc", - "thunk/ppb_file_ref_api.h", - "thunk/ppb_file_ref_thunk.cc", - "thunk/ppb_file_system_api.h", - "thunk/ppb_file_system_thunk.cc", - "thunk/ppb_find_private_thunk.cc", - "thunk/ppb_flash_clipboard_api.h", - "thunk/ppb_flash_drm_api.h", - "thunk/ppb_flash_font_file_api.h", - "thunk/ppb_flash_fullscreen_api.h", - "thunk/ppb_flash_functions_api.h", - "thunk/ppb_flash_menu_api.h", - "thunk/ppb_flash_message_loop_api.h", - "thunk/ppb_flash_print_thunk.cc", - "thunk/ppb_fullscreen_thunk.cc", - "thunk/ppb_gamepad_api.h", - "thunk/ppb_gamepad_thunk.cc", - "thunk/ppb_graphics_2d_api.h", - "thunk/ppb_graphics_2d_thunk.cc", - "thunk/ppb_graphics_3d_api.h", - "thunk/ppb_graphics_3d_thunk.cc", - "thunk/ppb_host_resolver_api.h", - "thunk/ppb_host_resolver_thunk.cc", - "thunk/ppb_host_resolver_private_api.h", - "thunk/ppb_host_resolver_private_thunk.cc", - "thunk/ppb_image_data_api.h", - "thunk/ppb_image_data_thunk.cc", - "thunk/ppb_input_event_api.h", - "thunk/ppb_input_event_thunk.cc", - "thunk/ppb_input_event_private_thunk.cc", - "thunk/ppb_instance_api.h", - "thunk/ppb_instance_private_thunk.cc", - "thunk/ppb_instance_thunk.cc", - "thunk/ppb_isolated_file_system_private_api.h", - "thunk/ppb_isolated_file_system_private_thunk.cc", - "thunk/ppb_media_stream_audio_track_api.h", - "thunk/ppb_media_stream_audio_track_thunk.cc", - "thunk/ppb_media_stream_video_track_api.h", - "thunk/ppb_media_stream_video_track_thunk.cc", - "thunk/ppb_message_loop_api.h", - "thunk/ppb_messaging_thunk.cc", - "thunk/ppb_mouse_cursor_thunk.cc", - "thunk/ppb_mouse_lock_thunk.cc", - "thunk/ppb_net_address_api.h", - "thunk/ppb_net_address_thunk.cc", - "thunk/ppb_network_list_api.h", - "thunk/ppb_network_list_thunk.cc", - "thunk/ppb_network_monitor_api.h", - "thunk/ppb_network_monitor_thunk.cc", - "thunk/ppb_network_proxy_api.h", - "thunk/ppb_network_proxy_thunk.cc", - "thunk/ppb_output_protection_api.h", - "thunk/ppb_output_protection_private_thunk.cc", - "thunk/ppb_pdf_api.h", - "thunk/ppb_platform_verification_api.h", - "thunk/ppb_printing_api.h", - "thunk/ppb_printing_dev_thunk.cc", - "thunk/ppb_scrollbar_api.h", - "thunk/ppb_talk_private_api.h", - "thunk/ppb_tcp_server_socket_private_api.h", - "thunk/ppb_tcp_server_socket_private_thunk.cc", - "thunk/ppb_tcp_socket_api.h", - "thunk/ppb_tcp_socket_private_api.h", - "thunk/ppb_tcp_socket_private_thunk.cc", - "thunk/ppb_tcp_socket_thunk.cc", - "thunk/ppb_text_input_thunk.cc", - "thunk/ppb_truetype_font_api.h", - "thunk/ppb_truetype_font_singleton_api.h", - "thunk/ppb_truetype_font_dev_thunk.cc", - "thunk/ppb_udp_socket_api.h", - "thunk/ppb_udp_socket_thunk.cc", - "thunk/ppb_udp_socket_private_api.h", - "thunk/ppb_udp_socket_private_thunk.cc", - "thunk/ppb_uma_private_thunk.cc", - "thunk/ppb_uma_singleton_api.h", - "thunk/ppb_url_loader_api.h", - "thunk/ppb_url_loader_thunk.cc", - "thunk/ppb_url_loader_trusted_thunk.cc", - "thunk/ppb_url_request_info_api.h", - "thunk/ppb_url_request_info_thunk.cc", - "thunk/ppb_url_response_info_api.h", - "thunk/ppb_url_response_info_thunk.cc", - "thunk/ppb_var_array_thunk.cc", - "thunk/ppb_var_dictionary_thunk.cc", - "thunk/ppb_video_capture_api.h", - "thunk/ppb_video_capture_thunk.cc", - "thunk/ppb_video_decoder_api.h", - "thunk/ppb_video_decoder_dev_api.h", - "thunk/ppb_video_decoder_thunk.cc", - "thunk/ppb_video_destination_private_api.h", - "thunk/ppb_video_destination_private_thunk.cc", - "thunk/ppb_video_frame_api.h", - "thunk/ppb_video_frame_thunk.cc", - "thunk/ppb_video_source_private_api.h", - "thunk/ppb_video_source_private_thunk.cc", - "thunk/ppb_view_api.h", - "thunk/ppb_view_dev_thunk.cc", - "thunk/ppb_view_thunk.cc", - "thunk/ppb_websocket_api.h", - "thunk/ppb_websocket_thunk.cc", - "thunk/ppb_widget_api.h", - "thunk/ppb_widget_dev_thunk.cc", - "thunk/ppb_x509_certificate_private_api.h", - "thunk/ppb_x509_certificate_private_thunk.cc", - "thunk/ppb_zoom_dev_thunk.cc", - "thunk/thunk.h", - ] - - if (!is_nacl) { - sources += [ - "shared_impl/flash_clipboard_format_registry.cc", - "shared_impl/flash_clipboard_format_registry.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/private/ppb_char_set_shared.cc", - "shared_impl/private/ppb_char_set_shared.h", - "thunk/ppb_audio_input_dev_thunk.cc", - "thunk/ppb_broker_thunk.cc", - "thunk/ppb_browser_font_trusted_thunk.cc", - "thunk/ppb_buffer_thunk.cc", - "thunk/ppb_content_decryptor_private_thunk.cc", - "thunk/ppb_char_set_thunk.cc", - "thunk/ppb_flash_clipboard_thunk.cc", - "thunk/ppb_flash_device_id_thunk.cc", - "thunk/ppb_flash_drm_thunk.cc", - "thunk/ppb_flash_file_fileref_thunk.cc", - "thunk/ppb_flash_file_modulelocal_thunk.cc", - "thunk/ppb_flash_font_file_thunk.cc", - "thunk/ppb_flash_fullscreen_thunk.cc", - "thunk/ppb_flash_menu_thunk.cc", - "thunk/ppb_flash_thunk.cc", - "thunk/ppb_flash_message_loop_thunk.cc", - "thunk/ppb_gles_chromium_texture_mapping_thunk.cc", - "thunk/ppb_pdf_thunk.cc", - "thunk/ppb_platform_verification_private_thunk.cc", - "thunk/ppb_scrollbar_thunk.cc", - "thunk/ppb_talk_private_thunk.cc", - "thunk/ppb_url_util_thunk.cc", - "thunk/ppb_video_decoder_dev_thunk.cc", - ] - } +import("//ppapi/ppapi_sources.gni") +import("//testing/test.gni") - # We exclude a few more things for nacl_win64, to avoid pulling in more - # dependencies. - if (is_win && cpu_arch == "x64" && current_toolchain != default_toolchain) { - sources -= [ - "shared_impl/ppb_audio_shared.cc", - "shared_impl/ppb_graphics_3d_shared.cc", - "shared_impl/ppb_opengles2_shared.cc", - "shared_impl/private/ppb_host_resolver_shared.cc", - "shared_impl/private/net_address_private_impl.cc", - "thunk/ppb_graphics_3d_thunk.cc", - "thunk/ppb_host_resolver_private_thunk.cc", - "thunk/ppb_tcp_server_socket_private_thunk.cc", - "thunk/ppb_tcp_socket_private_thunk.cc", - "thunk/ppb_udp_socket_private_thunk.cc", - "thunk/ppb_x509_certificate_private_thunk.cc", - ] - } +shared_library("ppapi_tests") { + sources = ppapi_sources.test_common_source_files + + ppapi_sources.test_trusted_source_files - defines = [ - "PPAPI_SHARED_IMPLEMENTATION", - "PPAPI_THUNK_IMPLEMENTATION", - ] + defines = [ "GL_GLEXT_PROTOTYPES" ] + include_dirs = [ "lib/gl/include" ] - public_deps = [ - blink_target, - ] deps = [ - ":ppapi_c", - "//base", - "//base:i18n", - "//base/third_party/dynamic_annotations", - "//gpu/command_buffer/client", - "//gpu/command_buffer/client:gles2_cmd_helper", - "//gpu/command_buffer/client:gles2_implementation", - "//gpu/command_buffer/common", - "//ipc", - "//media:shared_memory_support", - "//skia", - "//third_party/icu:icuuc", - "//ui/events:events_base", - "//ui/surface", - "//url", + "//ppapi/cpp", + "//ppapi/shared_impl", + ":copy_test_files", + ":copy_test_files2", ] - - if (is_mac) { - libs = [ "QuartzCore.framework" ] - } else if (is_win) { - cflags = [ "/wd4267" ] # size_t to int truncation. - } } -source_set("ppapi_ipc") { +shared_library("power_saver_test_plugin") { sources = [ - "proxy/nacl_message_scanner.cc", - "proxy/nacl_message_scanner.h", - "proxy/ppapi_messages.cc", - "proxy/ppapi_messages.h", - "proxy/ppapi_param_traits.cc", - "proxy/ppapi_param_traits.h", - "proxy/raw_var_data.cc", - "proxy/raw_var_data.h", - "proxy/resource_message_params.cc", - "proxy/resource_message_params.h", - "proxy/serialized_flash_menu.cc", - "proxy/serialized_flash_menu.h", - "proxy/serialized_handle.cc", - "proxy/serialized_handle.h", - "proxy/serialized_structs.cc", - "proxy/serialized_structs.h", - "proxy/serialized_var.cc", - "proxy/serialized_var.h", - "proxy/var_serialization_rules.h", + "tests/power_saver_test_plugin.cc", + "tests/test_utils.cc", ] - defines = [ "PPAPI_PROXY_IMPLEMENTATION" ] - deps = [ - ":ppapi_c", - ":ppapi_shared", - "//base", - "//gpu/ipc", - "//ipc", - "//skia", - "//ui/events/ipc", + "//ppapi/cpp", + "//ppapi/shared_impl", ] - - if (is_nacl) { - sources -= [ "proxy/serialized_flash_menu.cc" ] - } } -component("ppapi_proxy") { +test("ppapi_unittests") { sources = [ - # Take some standalone files from the C++ wrapper allowing us to more - # easily make async callbacks in the proxy. We can"t depend on the - # full C++ wrappers at this layer since the C++ wrappers expect - # symbols defining the globals for "being a plugin" which we are not. - # These callback files are standalone. - "cpp/completion_callback.h", - "utility/completion_callback_factory.h", - - "proxy/audio_buffer_resource.cc", - "proxy/audio_buffer_resource.h", - "proxy/broker_resource.cc", - "proxy/broker_resource.h", - "proxy/compositor_layer_resource.cc", - "proxy/compositor_layer_resource.h", - "proxy/compositor_resource.cc", - "proxy/compositor_resource.h", - "proxy/connection.h", - "proxy/dispatcher.cc", - "proxy/dispatcher.h", - "proxy/enter_proxy.h", - "proxy/error_conversion.cc", - "proxy/error_conversion.h", - "proxy/file_chooser_resource.cc", - "proxy/file_chooser_resource.h", - "proxy/file_io_resource.cc", - "proxy/file_io_resource.h", - "proxy/file_mapping_resource.cc", - "proxy/file_mapping_resource.h", - "proxy/file_mapping_resource_posix.cc", - "proxy/file_mapping_resource_win.cc", - "proxy/file_ref_resource.cc", - "proxy/file_ref_resource.h", - "proxy/file_system_resource.cc", - "proxy/file_system_resource.h", - "proxy/gamepad_resource.cc", - "proxy/gamepad_resource.h", - "proxy/graphics_2d_resource.cc", - "proxy/graphics_2d_resource.h", - "proxy/host_resolver_private_resource.cc", - "proxy/host_resolver_private_resource.h", - "proxy/host_resolver_resource.cc", - "proxy/host_resolver_resource.h", - "proxy/host_resolver_resource_base.cc", - "proxy/host_resolver_resource_base.h", - "proxy/interface_list.cc", - "proxy/interface_list.h", - "proxy/interface_proxy.cc", - "proxy/interface_proxy.h", - "proxy/isolated_file_system_private_resource.cc", - "proxy/isolated_file_system_private_resource.h", - "proxy/locking_resource_releaser.h", - "proxy/media_stream_audio_track_resource.cc", - "proxy/media_stream_audio_track_resource.h", - "proxy/media_stream_track_resource_base.cc", - "proxy/media_stream_track_resource_base.h", - "proxy/media_stream_video_track_resource.cc", - "proxy/media_stream_video_track_resource.h", - "proxy/message_handler.cc", - "proxy/message_handler.h", - "proxy/net_address_resource.cc", - "proxy/net_address_resource.h", - "proxy/network_list_resource.cc", - "proxy/network_list_resource.h", - "proxy/network_monitor_resource.cc", - "proxy/network_monitor_resource.h", - "proxy/network_proxy_resource.cc", - "proxy/network_proxy_resource.h", - "proxy/output_protection_resource.cc", - "proxy/output_protection_resource.h", - "proxy/plugin_array_buffer_var.cc", - "proxy/plugin_array_buffer_var.h", - "proxy/plugin_dispatcher.cc", - "proxy/plugin_dispatcher.h", - "proxy/plugin_globals.cc", - "proxy/plugin_globals.h", - "proxy/plugin_message_filter.cc", - "proxy/plugin_message_filter.h", - "proxy/plugin_resource.cc", - "proxy/plugin_resource.h", - "proxy/plugin_resource_tracker.cc", - "proxy/plugin_resource_tracker.h", - "proxy/plugin_resource_var.cc", - "proxy/plugin_resource_var.h", - "proxy/plugin_var_serialization_rules.cc", - "proxy/plugin_var_serialization_rules.h", - "proxy/plugin_var_tracker.cc", - "proxy/plugin_var_tracker.h", - "proxy/ppapi_command_buffer_proxy.cc", - "proxy/ppapi_command_buffer_proxy.h", - "proxy/ppapi_messages.h", - "proxy/ppapi_message_utils.h", - "proxy/ppb_audio_proxy.cc", - "proxy/ppb_audio_proxy.h", - "proxy/ppb_core_proxy.cc", - "proxy/ppb_core_proxy.h", - "proxy/ppb_graphics_3d_proxy.cc", - "proxy/ppb_graphics_3d_proxy.h", - "proxy/ppb_image_data_proxy.cc", - "proxy/ppb_image_data_proxy.h", - "proxy/ppb_instance_proxy.cc", - "proxy/ppb_instance_proxy.h", - "proxy/ppb_message_loop_proxy.cc", - "proxy/ppb_message_loop_proxy.h", - "proxy/ppb_testing_proxy.cc", - "proxy/ppb_testing_proxy.h", - "proxy/ppb_var_deprecated_proxy.cc", - "proxy/ppb_var_deprecated_proxy.h", - "proxy/ppb_x509_certificate_private_proxy.cc", - "proxy/ppb_x509_certificate_private_proxy.h", - "proxy/ppp_class_proxy.cc", - "proxy/ppp_class_proxy.h", - "proxy/ppp_find_proxy.cc", - "proxy/ppp_find_proxy.h", - "proxy/ppp_graphics_3d_proxy.cc", - "proxy/ppp_graphics_3d_proxy.h", - "proxy/ppp_input_event_proxy.cc", - "proxy/ppp_input_event_proxy.h", - "proxy/ppp_instance_proxy.cc", - "proxy/ppp_instance_proxy.h", - "proxy/ppp_messaging_proxy.cc", - "proxy/ppp_messaging_proxy.h", - "proxy/ppp_mouse_lock_proxy.cc", - "proxy/ppp_mouse_lock_proxy.h", - "proxy/ppp_pdf_proxy.cc", - "proxy/ppp_pdf_proxy.h", - "proxy/ppp_printing_proxy.cc", - "proxy/ppp_printing_proxy.h", - "proxy/ppp_text_input_proxy.cc", - "proxy/ppp_text_input_proxy.h", - "proxy/printing_resource.cc", - "proxy/printing_resource.h", - "proxy/proxy_array_output.cc", - "proxy/proxy_array_output.h", - "proxy/proxy_channel.cc", - "proxy/proxy_channel.h", - "proxy/proxy_completion_callback_factory.h", - "proxy/proxy_module.cc", - "proxy/proxy_module.h", - "proxy/proxy_object_var.cc", - "proxy/proxy_object_var.h", - "proxy/resource_creation_proxy.cc", - "proxy/resource_creation_proxy.h", - "proxy/resource_reply_thread_registrar.cc", - "proxy/resource_reply_thread_registrar.h", - "proxy/tcp_server_socket_private_resource.cc", - "proxy/tcp_server_socket_private_resource.h", - "proxy/tcp_socket_private_resource.cc", - "proxy/tcp_socket_private_resource.h", - "proxy/tcp_socket_resource.cc", - "proxy/tcp_socket_resource.h", - "proxy/tcp_socket_resource_base.cc", - "proxy/tcp_socket_resource_base.h", - "proxy/truetype_font_resource.cc", - "proxy/truetype_font_resource.h", - "proxy/truetype_font_singleton_resource.cc", - "proxy/truetype_font_singleton_resource.h", - "proxy/udp_socket_private_resource.cc", - "proxy/udp_socket_private_resource.h", - "proxy/udp_socket_resource.cc", - "proxy/udp_socket_resource.h", - "proxy/udp_socket_resource_base.cc", - "proxy/udp_socket_resource_base.h", - "proxy/uma_private_resource.cc", - "proxy/uma_private_resource.h", - "proxy/url_loader_resource.cc", - "proxy/url_loader_resource.h", - "proxy/url_request_info_resource.cc", - "proxy/url_request_info_resource.h", - "proxy/url_response_info_resource.cc", - "proxy/url_response_info_resource.h", - "proxy/var_serialization_rules.h", - "proxy/video_destination_resource.cc", - "proxy/video_destination_resource.h", - "proxy/video_frame_resource.cc", - "proxy/video_frame_resource.h", - "proxy/video_source_resource.cc", - "proxy/video_source_resource.h", - "proxy/websocket_resource.cc", - "proxy/websocket_resource.h", + "host/resource_message_filter_unittest.cc", + "proxy/device_enumeration_resource_helper_unittest.cc", + "proxy/file_chooser_resource_unittest.cc", + "proxy/file_system_resource_unittest.cc", + "proxy/flash_resource_unittest.cc", + "proxy/interface_list_unittest.cc", + "proxy/mock_resource.cc", + "proxy/mock_resource.h", + "proxy/nacl_message_scanner_unittest.cc", + "proxy/pdf_resource_unittest.cc", + "proxy/plugin_dispatcher_unittest.cc", + "proxy/plugin_resource_tracker_unittest.cc", + "proxy/plugin_var_tracker_unittest.cc", + "proxy/ppb_var_unittest.cc", + "proxy/ppp_instance_private_proxy_unittest.cc", + "proxy/ppp_instance_proxy_unittest.cc", + "proxy/ppp_messaging_proxy_unittest.cc", + "proxy/printing_resource_unittest.cc", + "proxy/raw_var_data_unittest.cc", + "proxy/serialized_var_unittest.cc", + "proxy/tracked_callback_unittest.cc", + "proxy/video_decoder_resource_unittest.cc", + "proxy/video_encoder_resource_unittest.cc", + "proxy/websocket_resource_unittest.cc", + "shared_impl/media_stream_audio_track_shared_unittest.cc", + "shared_impl/media_stream_buffer_manager_unittest.cc", + "shared_impl/media_stream_video_track_shared_unittest.cc", + "shared_impl/proxy_lock_unittest.cc", + "shared_impl/resource_tracker_unittest.cc", + "shared_impl/thread_aware_callback_unittest.cc", + "shared_impl/time_conversion_unittest.cc", + "shared_impl/var_tracker_unittest.cc", ] - if (is_nacl) { - sources += [ - "nacl_irt/irt_ppapi.cc", - "nacl_irt/irt_ppapi.h", - "nacl_irt/irt_start.cc", - "nacl_irt/manifest_service.cc", - "nacl_irt/manifest_service.h", - "nacl_irt/plugin_main.cc", - "nacl_irt/plugin_main.h", - "nacl_irt/plugin_startup.cc", - "nacl_irt/plugin_startup.h", - "nacl_irt/ppapi_dispatcher.cc", - "nacl_irt/ppapi_dispatcher.h", - ] - } else { - sources += [ - "proxy/audio_input_resource.cc", - "proxy/audio_input_resource.h", - "proxy/broker_dispatcher.cc", - "proxy/broker_dispatcher.h", - "proxy/browser_font_singleton_resource.cc", - "proxy/browser_font_singleton_resource.h", - "proxy/device_enumeration_resource_helper.cc", - "proxy/device_enumeration_resource_helper.h", - "proxy/flash_clipboard_resource.cc", - "proxy/flash_clipboard_resource.h", - "proxy/flash_drm_resource.cc", - "proxy/flash_drm_resource.h", - "proxy/flash_file_resource.cc", - "proxy/flash_file_resource.h", - "proxy/flash_font_file_resource.cc", - "proxy/flash_font_file_resource.h", - "proxy/flash_fullscreen_resource.cc", - "proxy/flash_fullscreen_resource.h", - "proxy/flash_menu_resource.cc", - "proxy/flash_menu_resource.h", - "proxy/flash_resource.cc", - "proxy/flash_resource.h", - "proxy/host_dispatcher.cc", - "proxy/host_dispatcher.h", - "proxy/host_var_serialization_rules.cc", - "proxy/host_var_serialization_rules.h", - "proxy/pdf_resource.cc", - "proxy/pdf_resource.h", - "proxy/platform_verification_private_resource.cc", - "proxy/platform_verification_private_resource.h", - "proxy/ppb_broker_proxy.cc", - "proxy/ppb_broker_proxy.h", - "proxy/ppb_buffer_proxy.cc", - "proxy/ppb_buffer_proxy.h", - "proxy/ppb_flash_message_loop_proxy.cc", - "proxy/ppb_flash_message_loop_proxy.h", - "proxy/ppb_video_decoder_proxy.cc", - "proxy/ppb_video_decoder_proxy.h", - "proxy/ppp_content_decryptor_private_proxy.cc", - "proxy/ppp_content_decryptor_private_proxy.h", - "proxy/ppp_instance_private_proxy.cc", - "proxy/ppp_instance_private_proxy.h", - "proxy/ppp_video_decoder_proxy.cc", - "proxy/ppp_video_decoder_proxy.h", - "proxy/video_decoder_resource.cc", - "proxy/video_decoder_resource.h", - "proxy/talk_resource.cc", - "proxy/talk_resource.h", - "proxy/video_capture_resource.cc", - "proxy/video_capture_resource.h", - ] - } - - defines = [ "PPAPI_PROXY_IMPLEMENTATION" ] - deps = [ - ":ppapi_c", - ":ppapi_shared", - ":ppapi_ipc", - "//base", - "//base/third_party/dynamic_annotations", - "//gpu/command_buffer/client:gles2_implementation", + "//base/allocator", + "//base/test:run_all_unittests", + "//base/test:test_support", "//gpu/ipc", - "//media:shared_memory_support", "//ipc", - "//skia", - "//third_party/icu", - "//ui/events:events_base", + "//ipc:test_support", + "//media:shared_memory_support", + "//ppapi/host", + "//ppapi/proxy", + "//ppapi/proxy:test_support", + "//ppapi/shared_impl", + "//ppapi/shared_impl:test_support", + "//testing/gmock", + "//testing/gtest", "//ui/surface", - blink_target, ] - - if (is_win) { - cflags = [ "/wd4267" ] # size_t to int truncation. - } } -component("ppapi_host") { +test("ppapi_perftests") { sources = [ - "host/dispatch_host_message.h", - "host/error_conversion.cc", - "host/error_conversion.h", - "host/host_factory.h", - "host/host_message_context.cc", - "host/host_message_context.h", - "host/instance_message_filter.cc", - "host/instance_message_filter.h", - "host/message_filter_host.cc", - "host/message_filter_host.h", - "host/ppapi_host.cc", - "host/ppapi_host.h", - "host/ppapi_host_export.h", - "host/resource_host.cc", - "host/resource_host.h", - "host/resource_message_filter.cc", - "host/resource_message_filter.h", - "host/resource_message_handler.cc", - "host/resource_message_handler.h", + "proxy/ppapi_perftests.cc", + "proxy/ppp_messaging_proxy_perftest.cc", ] - defines = [ "PPAPI_HOST_IMPLEMENTATION" ] - deps = [ - ":ppapi_c", - ":ppapi_ipc", - ":ppapi_proxy", - ":ppapi_shared", - "//base", - "//ipc", - "//media:shared_memory_support", - "//ui/events:events_base", - "//ui/surface", - "//url", + "//base/allocator", + "//base/test:test_support", + "//ppapi/proxy", + "//ppapi/proxy:test_support", + "//ppapi/shared_impl", + "//ppapi/shared_impl:test_support", + "//testing/gtest", ] } -static_library("ppapi_unittest_shared") { - testonly = true +executable("pepper_hash_for_uma") { sources = [ - "proxy/ppapi_proxy_test.cc", - "proxy/ppapi_proxy_test.h", - "proxy/resource_message_test_sink.cc", - "proxy/resource_message_test_sink.h", - "shared_impl/test_globals.cc", - "shared_impl/test_globals.h", - "shared_impl/unittest_utils.cc", - "shared_impl/unittest_utils.h", + "tools/pepper_hash_for_uma.cc", ] deps = [ - ":ppapi_proxy", - ":ppapi_shared", - "//base/test:test_support", - "//ipc", - "//ipc:test_support", - "//testing/gmock", - "//testing/gtest", + "//base", ] } - -# TODO(GYP) other targets from ppapi_tests.gyp diff --git a/chromium/ppapi/api/dev/ppp_zoom_dev.idl b/chromium/ppapi/api/dev/ppp_zoom_dev.idl index e8254da4506..2398f752ab6 100644 --- a/chromium/ppapi/api/dev/ppp_zoom_dev.idl +++ b/chromium/ppapi/api/dev/ppp_zoom_dev.idl @@ -16,7 +16,7 @@ label Chrome { */ interface PPP_Zoom_Dev { /** - * Instruct plug-in to zoom according to the given factor and whether the zoom + * Instruct plugin to zoom according to the given factor and whether the zoom * only applies to text only. The scale factor is the percentage divided by * 100, i.e. 150% zoom is 1.5. */ diff --git a/chromium/ppapi/api/pp_codecs.idl b/chromium/ppapi/api/pp_codecs.idl index 5a93ff1063f..89642a9adce 100644 --- a/chromium/ppapi/api/pp_codecs.idl +++ b/chromium/ppapi/api/pp_codecs.idl @@ -115,3 +115,86 @@ struct PP_VideoPicture_0_1 { */ PP_Size texture_size; }; + +/** + * Supported video profile information. See the PPB_VideoEncoder function + * GetSupportedProfiles() for more details. + */ +struct PP_VideoProfileDescription { + /** + * The codec profile. + */ + PP_VideoProfile profile; + + /** + * Dimensions of the maximum resolution of video frames, in pixels. + */ + PP_Size max_resolution; + + /** + * The numerator of the maximum frame rate. + */ + uint32_t max_framerate_numerator; + + /** + * The denominator of the maximum frame rate. + */ + uint32_t max_framerate_denominator; + + /** + * Whether the profile is hardware accelerated. + */ + PP_Bool hardware_accelerated; +}; + +/** + * Supported video profile information. See the PPB_VideoEncoder function + * GetSupportedProfiles() for more details. + */ +struct PP_VideoProfileDescription_0_1 { + /** + * The codec profile. + */ + PP_VideoProfile profile; + + /** + * Dimensions of the maximum resolution of video frames, in pixels. + */ + PP_Size max_resolution; + + /** + * The numerator of the maximum frame rate. + */ + uint32_t max_framerate_numerator; + + /** + * The denominator of the maximum frame rate. + */ + uint32_t max_framerate_denominator; + + /** + * A value indicating if the profile is available in hardware, software, or + * both. + */ + PP_HardwareAcceleration acceleration; +}; + +/** + * Struct describing a bitstream buffer. + */ +struct PP_BitstreamBuffer { + /** + * The size, in bytes, of the bitstream data. + */ + uint32_t size; + + /** + * The base address of the bitstream data. + */ + mem_t buffer; + + /** + * Whether the buffer represents a key frame. + */ + PP_Bool key_frame; +}; diff --git a/chromium/ppapi/api/ppb_file_mapping.idl b/chromium/ppapi/api/ppb_file_mapping.idl deleted file mode 100644 index 7037955d343..00000000000 --- a/chromium/ppapi/api/ppb_file_mapping.idl +++ /dev/null @@ -1,131 +0,0 @@ -/* Copyright 2014 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - - -/** - * This file defines methods for mapping and unmapping files into and out of - * memory. - */ - -[generate_thunk] - -label Chrome { - [channel=dev] M34 = 0.1 -}; - -/** - * The PP_FileMapProtection values indicate the permissions requested for the - * file mapping. These should be used in a uint32_t bitfield. - */ -[assert_size(4)] -enum PP_FileMapProtection { - /** Requests read access to the mapped address. */ - PP_FILEMAPPROTECTION_READ = 1u << 0, - - /** Requests write access to the mapped address. */ - PP_FILEMAPPROTECTION_WRITE = 1u << 1 -}; - -/** - * The PP_FileMapFlags contain flag values for use with Map(). - */ -[assert_size(4)] -enum PP_FileMapFlags { - /** - * Requests a shared mapping. If this flag is set, changes written to the - * memory region will be reflected in the underlying file and will thus - * eventually be visible to other processes which have opened the file. The - * file may not actually be updated until Unmap() is called. This is only - * valid if the PPB_FileIO resource was opened with write permission. - */ - PP_FILEMAPFLAG_SHARED = 1u << 0, - - /** - * Requests a copy-on-write mapping. If this flag is set, changes are not - * written to the underlying file, but only in the memory of the process - * (copy-on-write). - */ - PP_FILEMAPFLAG_PRIVATE = 1u << 1, - - /** - * Forces Map() to map the file contents at the provided |address|. If Map() - * can not comply, Map() will fail. - */ - PP_FILEMAPFLAG_FIXED = 1u << 2 -}; - -/** - * PPB_FileMapping contains functions for mapping and unmapping files into and - * out of memory. - */ -[singleton] -interface PPB_FileMapping { - /** - * Map() maps the contents from an offset of the file into memory. - * - * @param[in] instance A <code>PP_Instance</code> identifying one instance of - * a module. - * @param[in] file_io A <code>PPB_FileIO</code> <code>PP_Resource</code> - * corresponding to the file that should be mapped in to memory. - * @param[in] length The number of bytes to map. - * @param[in] map_protection A bitfield containing values from - * <code>PP_FileMapProtection</code>, indicating what memory operations - * should be permitted on the mapped region. - * @param[in] map_flags A bitfield containing values from - * <code>PP_FileMapFlags</code>, providing options for the behavior of Map. - * If the region is to be writeable, then exactly one of - * <code>PP_FILEMAPFLAG_SHARED</code> or <code>PP_FILEMAPFLAG_PRIVATE</code> - * must be set. - * @param[in] offset The offset into the file. Must be a multiple of the - * Map page size as returned by GetMapPageSize(). - * @param[inout] address The value of <code>*address</code>, if non-NULL, - * will be used as a hint to determine where in memory the file should be - * mapped. If the value is NULL, the host operating system will choose - * <code>address</code>. Upon Map() completing, <code>*address</code> will - * contain the actual memory location at which the file was mapped. If the - * plugin provides a non-NULL <code>*address</code>, it must be a multiple of - * the map page size as returned by GetMapPageSize(). - * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon - * completion of Map(). - * - * @return An int32_t containing an error code from <code>pp_errors.h</code>. - */ - int32_t Map([in] PP_Instance instance, - [in] PP_Resource file_io, - [in] int64_t length, - [in] uint32_t map_protection, - [in] uint32_t map_flags, - [in] int64_t offset, - [inout] mem_ptr_t address, - [in] PP_CompletionCallback callback); - - /** - * Unmap() deletes the mapping of the specified address. The specified - * address must have been retrieved with Map(). - * @param[in] instance A <code>PP_Instance</code> identifying the instance. - * @param[in] address The starting address of the address in memory to - * be unmapped. - * @param[in] length The length of the region to unmap. - * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon - * completion of Unmap(). - * - * @return An int32_t containing an error code from <code>pp_errors.h</code>. - */ - int32_t Unmap([in] PP_Instance instance, - [in] mem_t address, - [in] int64_t length, - [in] PP_CompletionCallback callback); - - /** - * GetMapPageSize() retrieves the size of pages that Map() uses. - * - * @param[in] instance A <code>PP_Instance</code> identifying the instance. - * - * @return The size of pages that Map() uses. Returns 0 on failure. - */ - [on_failure=0] - int64_t GetMapPageSize(PP_Instance instance); -}; - diff --git a/chromium/ppapi/api/ppb_messaging.idl b/chromium/ppapi/api/ppb_messaging.idl index 120367f21d8..aa5c6d769bc 100644 --- a/chromium/ppapi/api/ppb_messaging.idl +++ b/chromium/ppapi/api/ppb_messaging.idl @@ -9,6 +9,8 @@ * specific module instance. */ +[generate_thunk] + label Chrome { M14 = 1.0, M39 = 1.2 diff --git a/chromium/ppapi/api/ppb_tcp_socket.idl b/chromium/ppapi/api/ppb_tcp_socket.idl index 543cd305191..5851f1d3e34 100644 --- a/chromium/ppapi/api/ppb_tcp_socket.idl +++ b/chromium/ppapi/api/ppb_tcp_socket.idl @@ -9,7 +9,8 @@ label Chrome { M29 = 1.0, - M31 = 1.1 + M31 = 1.1, + M41 = 1.2 }; /** @@ -20,14 +21,18 @@ enum PP_TCPSocket_Option { /** * Disables coalescing of small writes to make TCP segments, and instead * delivers data immediately. Value's type is <code>PP_VARTYPE_BOOL</code>. - * This option can only be set after a successful <code>Connect()</code> call. + * On version 1.1 or earlier, this option can only be set after a successful + * <code>Connect()</code> call. On version 1.2 or later, there is no such + * limitation. */ PP_TCPSOCKET_OPTION_NO_DELAY = 0, /** * Specifies the total per-socket buffer space reserved for sends. Value's * type should be <code>PP_VARTYPE_INT32</code>. - * This option can only be set after a successful <code>Connect()</code> call. + * On version 1.1 or earlier, this option can only be set after a successful + * <code>Connect()</code> call. On version 1.2 or later, there is no such + * limitation. * * Note: This is only treated as a hint for the browser to set the buffer * size. Even if <code>SetOption()</code> succeeds, the browser doesn't @@ -38,7 +43,9 @@ enum PP_TCPSocket_Option { /** * Specifies the total per-socket buffer space reserved for receives. Value's * type should be <code>PP_VARTYPE_INT32</code>. - * This option can only be set after a successful <code>Connect()</code> call. + * On version 1.1 or earlier, this option can only be set after a successful + * <code>Connect()</code> call. On version 1.2 or later, there is no such + * limitation. * * Note: This is only treated as a hint for the browser to set the buffer * size. Even if <code>SetOption()</code> succeeds, the browser doesn't @@ -261,4 +268,24 @@ interface PPB_TCPSocket { [in] PP_TCPSocket_Option name, [in] PP_Var value, [in] PP_CompletionCallback callback); + + /** + * Sets a socket option on the TCP socket. + * Please see the <code>PP_TCPSocket_Option</code> description for option + * names, value types and allowed values. + * + * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP + * socket. + * @param[in] name The option to set. + * @param[in] value The option value to set. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + */ + [version=1.2] + int32_t SetOption([in] PP_Resource tcp_socket, + [in] PP_TCPSocket_Option name, + [in] PP_Var value, + [in] PP_CompletionCallback callback); }; diff --git a/chromium/ppapi/api/ppb_udp_socket.idl b/chromium/ppapi/api/ppb_udp_socket.idl index e4c87b2a1cd..d4ceb1121a9 100644 --- a/chromium/ppapi/api/ppb_udp_socket.idl +++ b/chromium/ppapi/api/ppb_udp_socket.idl @@ -10,7 +10,9 @@ [generate_thunk] label Chrome { - M29 = 1.0 + M29 = 1.0, + M41 = 1.1, + [channel=dev] M43 = 1.2 }; /** @@ -28,14 +30,17 @@ enum PP_UDPSocket_Option { /** * Allows sending and receiving packets to and from broadcast addresses. * Value's type should be <code>PP_VARTYPE_BOOL</code>. - * This option can only be set before calling <code>Bind()</code>. + * On version 1.0, this option can only be set before calling + * <code>Bind()</code>. On version 1.1 or later, there is no such limitation. */ PP_UDPSOCKET_OPTION_BROADCAST = 1, /** * Specifies the total per-socket buffer space reserved for sends. Value's * type should be <code>PP_VARTYPE_INT32</code>. - * This option can only be set after a successful <code>Bind()</code> call. + * On version 1.0, this option can only be set after a successful + * <code>Bind()</code> call. On version 1.1 or later, there is no such + * limitation. * * Note: This is only treated as a hint for the browser to set the buffer * size. Even if <code>SetOption()</code> succeeds, the browser doesn't @@ -46,13 +51,36 @@ enum PP_UDPSocket_Option { /** * Specifies the total per-socket buffer space reserved for receives. Value's * type should be <code>PP_VARTYPE_INT32</code>. - * This option can only be set after a successful <code>Bind()</code> call. + * On version 1.0, this option can only be set after a successful + * <code>Bind()</code> call. On version 1.1 or later, there is no such + * limitation. * * Note: This is only treated as a hint for the browser to set the buffer * size. Even if <code>SetOption()</code> succeeds, the browser doesn't * guarantee it will conform to the size. */ - PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE = 3 + PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE = 3, + + /** + * Specifies whether the packets sent from the host to the multicast group + * should be looped back to the host or not. Value's type should be + * <code>PP_VARTYPE_BOOL</code>. + * This option can only be set before calling <code>Bind()</code>. + * + * This is only supported in version 1.2 of the API (Chrome 43) and later. + */ + PP_UDPSOCKET_OPTION_MULTICAST_LOOP = 4, + + /** + * Specifies the time-to-live for packets sent to the multicast group. The + * value should be within 0 to 255 range. The default value is 1 and means + * that packets will not be routed beyond the local network. Value's type + * should be <code>PP_VARTYPE_INT32</code>. + * This option can only be set before calling <code>Bind()</code>. + * + * This is only supported in version 1.2 of the API (Chrome 43) and later. + */ + PP_UDPSOCKET_OPTION_MULTICAST_TTL = 5 }; /** @@ -153,6 +181,9 @@ interface PPB_UDPSocket { * been sent; otherwise, an error code from <code>pp_errors.h</code>. * <code>PP_ERROR_NOACCESS</code> will be returned if the caller doesn't have * required permissions. + * <code>PP_ERROR_INPROGRESS</code> will be returned if the socket is busy + * sending. The caller should wait until a pending send completes before + * retrying. */ int32_t SendTo([in] PP_Resource udp_socket, [in] str_t buffer, @@ -193,4 +224,80 @@ interface PPB_UDPSocket { [in] PP_UDPSocket_Option name, [in] PP_Var value, [in] PP_CompletionCallback callback); + + /** + * Sets a socket option on the UDP socket. + * Please see the <code>PP_UDPSocket_Option</code> description for option + * names, value types and allowed values. + * + * @param[in] udp_socket A <code>PP_Resource</code> corresponding to a UDP + * socket. + * @param[in] name The option to set. + * @param[in] value The option value to set. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + */ + [version=1.1] + int32_t SetOption([in] PP_Resource udp_socket, + [in] PP_UDPSocket_Option name, + [in] PP_Var value, + [in] PP_CompletionCallback callback); + + /** + * Sets a socket option on the UDP socket. + * Please see the <code>PP_UDPSocket_Option</code> description for option + * names, value types and allowed values. + * + * @param[in] udp_socket A <code>PP_Resource</code> corresponding to a UDP + * socket. + * @param[in] name The option to set. + * @param[in] value The option value to set. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + */ + [version=1.2] + int32_t SetOption([in] PP_Resource udp_socket, + [in] PP_UDPSocket_Option name, + [in] PP_Var value, + [in] PP_CompletionCallback callback); + + /** + * Joins the multicast group with address specified by <code>group</code> + * parameter, which is expected to be a <code>PPB_NetAddress</code> object. + * + * @param[in] udp_socket A <code>PP_Resource</code> corresponding to a UDP + * socket. + * @param[in] group A <code>PP_Resource</code> corresponding to the network + * address of the multicast group. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + */ + [version=1.2] + int32_t JoinGroup([in] PP_Resource udp_socket, + [in] PP_Resource group, + [in] PP_CompletionCallback callback); + + /** + * Leaves the multicast group with address specified by <code>group</code> + * parameter, which is expected to be a <code>PPB_NetAddress</code> object. + * + * @param[in] udp_socket A <code>PP_Resource</code> corresponding to a UDP + * socket. + * @param[in] group A <code>PP_Resource</code> corresponding to the network + * address of the multicast group. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + */ + [version=1.2] + int32_t LeaveGroup([in] PP_Resource udp_socket, + [in] PP_Resource group, + [in] PP_CompletionCallback callback); }; diff --git a/chromium/ppapi/api/ppb_video_encoder.idl b/chromium/ppapi/api/ppb_video_encoder.idl new file mode 100644 index 00000000000..68a7f6dd82d --- /dev/null +++ b/chromium/ppapi/api/ppb_video_encoder.idl @@ -0,0 +1,249 @@ +/* Copyright 2015 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/** + * This file defines the <code>PPB_VideoEncoder</code> interface. + */ + +[generate_thunk] + +label Chrome { + [channel=dev] M42 = 0.1, + [channel=dev] M44 = 0.2 +}; + +/** + * Video encoder interface. + * + * Typical usage: + * - Call Create() to create a new video encoder resource. + * - Call GetSupportedFormats() to determine which codecs and profiles are + * available. + * - Call Initialize() to initialize the encoder for a supported profile. + * - Call GetVideoFrame() to get a blank frame and fill it in, or get a video + * frame from another resource, e.g. <code>PPB_MediaStreamVideoTrack</code>. + * - Call Encode() to push the video frame to the encoder. If an external frame + * is pushed, wait for completion to recycle the frame. + * - Call GetBitstreamBuffer() continuously (waiting for each previous call to + * complete) to pull encoded pictures from the encoder. + * - Call RecycleBitstreamBuffer() after consuming the data in the bitstream + * buffer. + * - To destroy the encoder, the plugin should release all of its references to + * it. Any pending callbacks will abort before the encoder is destroyed. + * + * Available video codecs vary by platform. + * All: vp8 (software). + * ChromeOS, depending on your device: h264 (hardware), vp8 (hardware) + */ +interface PPB_VideoEncoder { + /** + * Creates a new video encoder resource. + * + * @param[in] instance A <code>PP_Instance</code> identifying the instance + * with the video encoder. + * + * @return A <code>PP_Resource</code> corresponding to a video encoder if + * successful or 0 otherwise. + */ + PP_Resource Create([in] PP_Instance instance); + + /** + * Determines if the given resource is a video encoder. + * + * @param[in] resource A <code>PP_Resource</code> identifying a resource. + * + * @return <code>PP_TRUE</code> if the resource is a + * <code>PPB_VideoEncoder</code>, <code>PP_FALSE</code> if the resource is + * invalid or some other type. + */ + PP_Bool IsVideoEncoder([in] PP_Resource resource); + + /** + * Gets an array of supported video encoder profiles. + * These can be used to choose a profile before calling Initialize(). + * + * @param[in] video_encoder A <code>PP_Resource</code> identifying the video + * encoder. + * @param[in] output A <code>PP_ArrayOutput</code> to receive the supported + * <code>PP_VideoProfileDescription_0_1</code> structs. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. + * + * @return If >= 0, the number of supported profiles returned, otherwise an + * error code from <code>pp_errors.h</code>. + */ + int32_t GetSupportedProfiles([in] PP_Resource video_encoder, + [in] PP_ArrayOutput output, + [in] PP_CompletionCallback callback); + + /** + * Gets an array of supported video encoder profiles. + * These can be used to choose a profile before calling Initialize(). + * + * @param[in] video_encoder A <code>PP_Resource</code> identifying the video + * encoder. + * @param[in] output A <code>PP_ArrayOutput</code> to receive the supported + * <code>PP_VideoProfileDescription</code> structs. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. + * + * @return If >= 0, the number of supported profiles returned, otherwise an + * error code from <code>pp_errors.h</code>. + */ + [version = 0.2] + int32_t GetSupportedProfiles([in] PP_Resource video_encoder, + [in] PP_ArrayOutput output, + [in] PP_CompletionCallback callback); + + /** + * Initializes a video encoder resource. The plugin should call Initialize() + * successfully before calling any of the functions below. + * + * @param[in] video_encoder A <code>PP_Resource</code> identifying the video + * encoder. + * @param[in] input_format The <code>PP_VideoFrame_Format</code> of the + * frames which will be encoded. + * @param[in] input_visible_size A <code>PP_Size</code> specifying the + * dimensions of the visible part of the input frames. + * @param[in] output_profile A <code>PP_VideoProfile</code> specifying the + * codec profile of the encoded output stream. + * @param[in] acceleration A <code>PP_HardwareAcceleration</code> specifying + * whether to use a hardware accelerated or a software implementation. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + * Returns PP_ERROR_NOTSUPPORTED if video encoding is not available, or the + * requested codec profile is not supported. + */ + int32_t Initialize([in] PP_Resource video_encoder, + [in] PP_VideoFrame_Format input_format, + [in] PP_Size input_visible_size, + [in] PP_VideoProfile output_profile, + [in] uint32_t initial_bitrate, + [in] PP_HardwareAcceleration acceleration, + [in] PP_CompletionCallback callback); + + /** + * Gets the number of input video frames that the encoder may hold while + * encoding. If the plugin is providing the video frames, it should have at + * least this many available. + * + * @param[in] video_encoder A <code>PP_Resource</code> identifying the video + * encoder. + * @return An int32_t containing the number of frames required, or an error + * code from <code>pp_errors.h</code>. + * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. + */ + int32_t GetFramesRequired([in] PP_Resource video_encoder); + + /** + * Gets the coded size of the video frames required by the encoder. Coded + * size is the logical size of the input frames, in pixels. The encoder may + * have hardware alignment requirements that make this different from + * |input_visible_size|, as requested in the call to Initialize(). + * + * @param[in] video_encoder A <code>PP_Resource</code> identifying the video + * encoder. + * @param[in] coded_size A <code>PP_Size</code> to hold the coded size. + * @return An int32_t containing a result code from <code>pp_errors.h</code>. + * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. + */ + int32_t GetFrameCodedSize([in] PP_Resource video_encoder, + [out] PP_Size coded_size); + + /** + * Gets a blank video frame which can be filled with video data and passed + * to the encoder. + * + * @param[in] video_encoder A <code>PP_Resource</code> identifying the video + * encoder. + * @param[out] video_frame A blank <code>PPB_VideoFrame</code> resource. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. + */ + int32_t GetVideoFrame([in] PP_Resource video_encoder, + [out] PP_Resource video_frame, + [in] PP_CompletionCallback callback); + + /** + * Encodes a video frame. + * + * @param[in] video_encoder A <code>PP_Resource</code> identifying the video + * encoder. + * @param[in] video_frame The <code>PPB_VideoFrame</code> to be encoded. + * @param[in] force_keyframe A <code>PP_Bool> specifying whether the encoder + * should emit a key frame for this video frame. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. Plugins that pass <code>PPB_VideoFrame</code> resources owned + * by other resources should wait for completion before reusing them. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. + */ + int32_t Encode([in] PP_Resource video_encoder, + [in] PP_Resource video_frame, + [in] PP_Bool force_keyframe, + [in] PP_CompletionCallback callback); + + /** + * Gets the next encoded bitstream buffer from the encoder. + * + * @param[in] video_encoder A <code>PP_Resource</code> identifying the video + * encoder. + * @param[out] bitstream_buffer A <code>PP_BitstreamBuffer</code> containing + * encoded video data. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. The plugin can call GetBitstreamBuffer from the callback in + * order to continuously "pull" bitstream buffers from the encoder. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. + * Returns PP_ERROR_INPROGRESS if a prior call to GetBitstreamBuffer() has + * not completed. + */ + int32_t GetBitstreamBuffer([in] PP_Resource video_encoder, + [out] PP_BitstreamBuffer bitstream_buffer, + [in] PP_CompletionCallback callback); + + /** + * Recycles a bitstream buffer back to the encoder. + * + * @param[in] video_encoder A <code>PP_Resource</code> identifying the video + * encoder. + * @param[in] bitstream_buffer A <code>PP_BitstreamBuffer</code> that is no + * longer needed by the plugin. + */ + void RecycleBitstreamBuffer([in] PP_Resource video_encoder, + [in] PP_BitstreamBuffer bitstream_buffer); + + /** + * Requests a change to encoding parameters. This is only a request, + * fulfilled on a best-effort basis. + * + * @param[in] video_encoder A <code>PP_Resource</code> identifying the video + * encoder. + * @param[in] bitrate The requested new bitrate, in bits per second. + * @param[in] framerate The requested new framerate, in frames per second. + */ + void RequestEncodingParametersChange([in] PP_Resource video_encoder, + [in] uint32_t bitrate, + [in] uint32_t framerate); + + /** + * Closes the video encoder, and cancels any pending encodes. Any pending + * callbacks will still run, reporting <code>PP_ERROR_ABORTED</code> . It is + * not valid to call any encoder functions after a call to this method. + * <strong>Note:</strong> Destroying the video encoder closes it implicitly, + * so you are not required to call Close(). + * + * @param[in] video_encoder A <code>PP_Resource</code> identifying the video + * encoder. + */ + void Close([in] PP_Resource video_encoder); +}; diff --git a/chromium/ppapi/api/private/pp_content_decryptor.idl b/chromium/ppapi/api/private/pp_content_decryptor.idl index 4493c3eab7a..e5f92da10dc 100644 --- a/chromium/ppapi/api/private/pp_content_decryptor.idl +++ b/chromium/ppapi/api/private/pp_content_decryptor.idl @@ -406,7 +406,18 @@ enum PP_DecryptorStreamType { [assert_size(4)] enum PP_SessionType { PP_SESSIONTYPE_TEMPORARY = 0, - PP_SESSIONTYPE_PERSISTENT = 1 + PP_SESSIONTYPE_PERSISTENT_LICENSE = 1, + PP_SESSIONTYPE_PERSISTENT_RELEASE = 2 +}; + +/** + * <code>PP_InitDataType</code> contains Initialization Data Type constants. + */ +[assert_size(4)] +enum PP_InitDataType { + PP_INITDATATYPE_CENC = 0, + PP_INITDATATYPE_KEYIDS = 1, + PP_INITDATATYPE_WEBM = 2 }; /** @@ -422,3 +433,49 @@ enum PP_CdmExceptionCode { PP_CDMEXCEPTIONCODE_CLIENTERROR = 6, PP_CDMEXCEPTIONCODE_OUTPUTERROR = 7 }; + +/** + * <code>PP_CdmMessageType</code> contains message type constants. + */ +[assert_size(4)] +enum PP_CdmMessageType { + PP_CDMMESSAGETYPE_LICENSE_REQUEST = 0, + PP_CDMMESSAGETYPE_LICENSE_RENEWAL = 1, + PP_CDMMESSAGETYPE_LICENSE_RELEASE = 2 +}; + +/** + * <code>PP_CdmKeyStatus</code> contains key status constants. + */ +[assert_size(4)] +enum PP_CdmKeyStatus { + PP_CDMKEYSTATUS_USABLE = 0, + PP_CDMKEYSTATUS_INVALID = 1, + PP_CDMKEYSTATUS_EXPIRED = 2, + PP_CDMKEYSTATUS_OUTPUTNOTALLOWED = 3, + PP_CDMKEYSTATUS_OUTPUTDOWNSCALED = 4, + PP_CDMKEYSTATUS_STATUSPENDING = 5 +}; + +/** + * The <code>PP_KeyInformation</code> struct contains information about a + * key used for decryption. + */ +[assert_size(524)] +struct PP_KeyInformation { + /** + * Key ID. + */ + uint8_t[512] key_id; + uint32_t key_id_size; + + /** + * Status of this key. + */ + PP_CdmKeyStatus key_status; + + /** + * Optional error code for keys that are not usable. + */ + uint32_t system_code; +}; diff --git a/chromium/ppapi/api/private/pp_video_capture_format.idl b/chromium/ppapi/api/private/pp_video_capture_format.idl new file mode 100644 index 00000000000..e9345665ada --- /dev/null +++ b/chromium/ppapi/api/private/pp_video_capture_format.idl @@ -0,0 +1,29 @@ +/* Copyright 2015 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/** + * This file defines the struct used to hold a video capture format. + */ + +label Chrome { + M42 = 0.1 +}; + +/** + * The <code>PP_VideoCaptureFormat</code> struct represents a video capture + * format. + */ +[assert_size(12)] +struct PP_VideoCaptureFormat { + /** + * Frame size in pixels. + */ + PP_Size frame_size; + + /** + * Frame rate in frames per second. + */ + float_t frame_rate; +}; diff --git a/chromium/ppapi/api/private/ppb_camera_capabilities_private.idl b/chromium/ppapi/api/private/ppb_camera_capabilities_private.idl index 57c7421997f..fb480bfd5e8 100644 --- a/chromium/ppapi/api/private/ppb_camera_capabilities_private.idl +++ b/chromium/ppapi/api/private/ppb_camera_capabilities_private.idl @@ -11,7 +11,7 @@ [generate_thunk] label Chrome { - M39 = 0.1 + M42 = 0.1 }; /** @@ -22,17 +22,6 @@ label Chrome { [version=0.1] interface PPB_CameraCapabilities_Private { /** - * Creates a PPB_CameraCapabilities_Private resource. - * - * @param[in] instance A <code>PP_Instance</code> identifying one instance of - * a module. - * - * @return A <code>PP_Resource</code> corresponding to a - * PPB_CameraCapabilities_Private resource if successful, 0 if failed. - */ - PP_Resource Create([in] PP_Instance instance); - - /** * IsCameraCapabilities() determines if the given resource is a * <code>PPB_CameraCapabilities_Private</code>. * @@ -47,39 +36,20 @@ interface PPB_CameraCapabilities_Private { [in] PP_Resource resource); /** - * GetSupportedPreviewSizes() returns the supported preview sizes for the - * given <code>PPB_CameraCapabilities_Private</code>. + * GetSupportedVideoCaptureFormats() returns the supported video capture + * formats for the given <code>PPB_CameraCapabilities_Private</code>. * * @param[in] capabilities A <code>PP_Resource</code> corresponding to an * image capture capabilities resource. * @param[out] array_size The size of preview size array. - * @param[out] preview_sizes An array of <code>PP_Size</code> corresponding - * to the supported preview sizes in pixels. The ownership of the array - * belongs to <code>PPB_CameraCapabilities_Private</code> and the caller - * should not free it. When a PPB_CameraCapabilities_Private is deleted, - * the array returning from this is no longer valid. - */ - void GetSupportedPreviewSizes( - [in] PP_Resource capabilities, - [out] int32_t array_size, - [out, size_is(array_size)] PP_Size[] preview_sizes); - - /** - * GetSupportedJpegSize() returns the supported JPEG sizes for the given - * <code>PPB_CameraCapabilities_Private</code>. - * - * @param[in] capabilities A <code>PP_Resource</code> corresponding to an - * image capture capabilities resource. - * @param[out] array_size The size of JPEG size array. If the output of this - * is 0, the camera has no support for generating JPEG images. - * @param[out] jpeg_sizes An array of <code>PP_Size</code> corresponding to - * the supported JPEG image sizes in pixels. The ownership of the array - * belongs to <code>PPB_CameraCapabilities_Private</code> and the caller + * @param[out] formats An array of <code>PP_VideoCaptureFormat</code> + * corresponding to the supported video capture formats. The ownership of the + * array belongs to <code>PPB_CameraCapabilities_Private</code> and the caller * should not free it. When a PPB_CameraCapabilities_Private is deleted, the * array returning from this is no longer valid. */ - void GetSupportedJpegSizes( + void GetSupportedVideoCaptureFormats( [in] PP_Resource capabilities, - [out] int32_t array_size, - [out, size_is(array_size)] PP_Size[] jpeg_sizes); + [out] uint32_t array_size, + [out, size_is(array_size)] PP_VideoCaptureFormat[] formats); }; diff --git a/chromium/ppapi/api/private/ppb_camera_device_private.idl b/chromium/ppapi/api/private/ppb_camera_device_private.idl new file mode 100644 index 00000000000..d87ac2059a8 --- /dev/null +++ b/chromium/ppapi/api/private/ppb_camera_device_private.idl @@ -0,0 +1,96 @@ +/* Copyright 2014 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. + */ + +/** + * Defines the <code>PPB_CameraDevice_Private</code> interface. Used for + * manipulating a camera device. + */ + +[generate_thunk] + +label Chrome { + M42 = 0.1 +}; + +/** + * To query camera capabilities: + * 1. Get a PPB_CameraDevice_Private object by Create(). + * 2. Open() camera device with track id of MediaStream video track. + * 3. Call GetCameraCapabilities() to get a + * <code>PPB_CameraCapabilities_Private</code> object, which can be used to + * query camera capabilities. + */ +interface PPB_CameraDevice_Private { + /** + * Creates a PPB_CameraDevice_Private resource. + * + * @param[in] instance A <code>PP_Instance</code> identifying one instance + * of a module. + * + * @return A <code>PP_Resource</code> corresponding to a + * PPB_CameraDevice_Private resource if successful, 0 if failed. + */ + PP_Resource Create([in] PP_Instance instance); + + /** + * Determines if a resource is a camera device resource. + * + * @param[in] resource The <code>PP_Resource</code> to test. + * + * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given + * resource is a camera device resource or <code>PP_FALSE</code> + * otherwise. + */ + PP_Bool IsCameraDevice([in] PP_Resource resource); + + /** + * Opens a camera device. + * + * @param[in] camera_device A <code>PP_Resource</code> corresponding to a + * camera device resource. + * @param[in] device_id A <code>PP_Var</code> identifying a camera device. The + * type is string. The ID can be obtained from MediaStreamTrack.getSources() + * or MediaStreamVideoTrack.id. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion of <code>Open()</code>. + * + * @return An error code from <code>pp_errors.h</code>. + */ + int32_t Open( + [in] PP_Resource camera_device, + [in] PP_Var device_id, + [in] PP_CompletionCallback callback); + + /** + * Disconnects from the camera and cancels all pending requests. + * After this returns, no callbacks will be called. If <code> + * PPB_CameraDevice_Private</code> is destroyed and is not closed yet, this + * function will be automatically called. Calling this more than once has no + * effect. + * + * @param[in] camera_device A <code>PP_Resource</code> corresponding to a + * camera device resource. + */ + void Close([in] PP_Resource camera_device); + + /** + * Gets the camera capabilities. + * + * The camera capabilities do not change for a given camera source. + * + * @param[in] camera_device A <code>PP_Resource</code> corresponding to a + * camera device resource. + * @param[out] capabilities A <code>PPB_CameraCapabilities_Private</code> for + * storing the camera capabilities on success. Otherwise, the value will not + * be changed. + * @param[in] callback <code>PP_CompletionCallback</code> to be called upon + * completion of <code>GetCameraCapabilities()</code>. + * + * @return An int32_t containing a result code from <code>pp_errors.h</code>. + */ + int32_t GetCameraCapabilities([in] PP_Resource camera_device, + [out] PP_Resource capabilities, + [in] PP_CompletionCallback callback); +}; diff --git a/chromium/ppapi/api/private/ppb_content_decryptor_private.idl b/chromium/ppapi/api/private/ppb_content_decryptor_private.idl index ad59210e59a..602bf125e4c 100644 --- a/chromium/ppapi/api/private/ppb_content_decryptor_private.idl +++ b/chromium/ppapi/api/private/ppb_content_decryptor_private.idl @@ -12,7 +12,7 @@ [generate_thunk] label Chrome { - M36 = 0.12 + M44 = 0.14 }; /** @@ -37,27 +37,14 @@ interface PPB_ContentDecryptor_Private { * * @param[in] promise_id Identifies the promise that the CDM resolved. * - * @param[in] web_session_id A <code>PP_Var</code> of type + * @param[in] session_id A <code>PP_Var</code> of type * <code>PP_VARTYPE_STRING</code> containing the session's ID attribute. */ void PromiseResolvedWithSession( [in] PP_Instance instance, [in] uint32_t promise_id, - [in] PP_Var web_session_id); + [in] PP_Var session_id); - /** - * A promise that returns a set of key IDs has been resolved by the CDM. - * - * @param[in] promise_id Identifies the promise that the CDM resolved. - * - * @param[in] key_ids A <code>PP_Var</code> of type - * <code>PP_VARTYPE_ARRAY</code> containing elements of type - * <code>PP_VARTYPE_ARRAYBUFFER</code> that are the session's usable key IDs. - */ - void PromiseResolvedWithKeyIds( - [in] PP_Instance instance, - [in] uint32_t promise_id, - [in] PP_Var key_ids_array); /** * A promise has been rejected by the CDM due to an error. @@ -93,42 +80,54 @@ interface PPB_ContentDecryptor_Private { * of <code>UpdateSession()</code> and <code>SessionMessage()</code> calls * required to prepare for decryption. * - * @param[in] web_session_id A <code>PP_Var</code> of type + * @param[in] session_id A <code>PP_Var</code> of type * <code>PP_VARTYPE_STRING</code> containing the ID of a session for * which this message is intended. * + * @param[in] message_type A <code>PP_CdmMessageType</code> containing the + * message type. + * * @param[in] message A <code>PP_Var</code> of type * <code>PP_VARTYPE_ARRAY_BUFFER</code> that contains the message. * - * @param[in] destination_url A <code>PP_Var</code> of type + * @param[in] legacy_destination_url A <code>PP_Var</code> of type * <code>PP_VARTYPE_STRING</code> containing the destination URL for the * message. */ void SessionMessage( [in] PP_Instance instance, - [in] PP_Var web_session_id, + [in] PP_Var session_id, + [in] PP_CdmMessageType message_type, [in] PP_Var message, - [in] PP_Var destination_url); + [in] PP_Var legacy_destination_url); /** * The keys for a session have changed. * - * @param[in] web_session_id A <code>PP_Var</code> of type + * @param[in] session_id A <code>PP_Var</code> of type * <code>PP_VARTYPE_STRING</code> containing the ID of the session that has * a change in keys. * * @param[in] has_additional_usable_key A <code>PP_Bool</code> indicating if * a new usable key has been added. + * + * @param[in] key_count The number of arguments contained in + * <code>key_information</code> + * + * @param[in] key_information An array of type <code>PP_KeyInformation</code> + * that are the session's key IDs and their status. */ void SessionKeysChange( [in] PP_Instance instance, - [in] PP_Var web_session_id, - [in] PP_Bool has_additional_usable_key); + [in] PP_Var session_id, + [in] PP_Bool has_additional_usable_key, + [in] uint32_t key_count, + [in, size_as=key_count] PP_KeyInformation[] key_information); /** * The expiration time for a session has changed. * - * @param[in] web_session_id A <code>PP_Var</code> of type + * @param[in] session_id A <code>PP_Var</code> of type * <code>PP_VARTYPE_STRING</code> containing the ID of the session that has * a new expiration time. * @@ -138,48 +137,28 @@ interface PPB_ContentDecryptor_Private { */ void SessionExpirationChange( [in] PP_Instance instance, - [in] PP_Var web_session_id, + [in] PP_Var session_id, [in] PP_Time new_expiry_time); /** - * The session is now ready to decrypt the media stream. - * - * Note: The above describes the most simple case. Depending on the key - * system, a series of <code>SessionMessage()</code> calls from the CDM will - * be sent to the browser, and then on to the web application. The web - * application must then provide more data to the CDM by directing the browser - * to pass the data to the CDM via calls to <code>UpdateSession()</code> on - * the <code>PPP_ContentDecryptor_Private</code> interface. - * The CDM must call <code>SessionReady()</code> when the sequence is - * completed, and, in response, the browser must notify the web application. - * - * @param[in] web_session_id A <code>PP_Var</code> of type - * <code>PP_VARTYPE_STRING</code> containing the session's ID attribute of - * the session that is now ready. - */ - void SessionReady( - [in] PP_Instance instance, - [in] PP_Var web_session_id); - - /** * The session has been closed as the result of a call to the * <code>ReleaseSession()</code> method on the * <code>PPP_ContentDecryptor_Private</code> interface, or due to other * factors as determined by the CDM. * - * @param[in] web_session_id A <code>PP_Var</code> of type + * @param[in] session_id A <code>PP_Var</code> of type * <code>PP_VARTYPE_STRING</code> containing the session's ID attribute of * the session that is now closed. */ void SessionClosed( [in] PP_Instance instance, - [in] PP_Var web_session_id); + [in] PP_Var session_id); /** * An error occurred in a <code>PPP_ContentDecryptor_Private</code> method, * or within the plugin implementing the interface. * - * @param[in] web_session_id A <code>PP_Var</code> of type + * @param[in] session_id A <code>PP_Var</code> of type * <code>PP_VARTYPE_STRING</code> containing the session's ID attribute of * the session that caused the error. * @@ -191,9 +170,9 @@ interface PPB_ContentDecryptor_Private { * @param[in] error_description A <code>PP_Var</code> of type * <code>PP_VARTYPE_STRING</code> containing the error description. */ - void SessionError( + void LegacySessionError( [in] PP_Instance instance, - [in] PP_Var web_session_id, + [in] PP_Var session_id, [in] PP_CdmExceptionCode exception_code, [in] uint32_t system_code, [in] PP_Var error_description); diff --git a/chromium/ppapi/api/private/ppb_image_capture_config_private.idl b/chromium/ppapi/api/private/ppb_image_capture_config_private.idl deleted file mode 100644 index 95bded3cf0d..00000000000 --- a/chromium/ppapi/api/private/ppb_image_capture_config_private.idl +++ /dev/null @@ -1,101 +0,0 @@ -/* Copyright 2014 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * This file defines the PPB_ImageCaptureConfig_Private interface for - * establishing an image capture configuration resource within the browser. - */ - -[generate_thunk] - -label Chrome { - M39 = 0.1 -}; - -/** - * The <code>PPB_ImageCaptureConfig_Private</code> interface contains pointers - * to several functions for establishing image capture configuration within the - * browser. The new configuration will take effect after <code> - * PPB_ImageCapture_Private.SetConfig</code> is called. - */ -[version=0.1] -interface PPB_ImageCaptureConfig_Private { - /** - * Creates a PPB_ImageCaptureConfig_Private resource. - * - * @param[in] instance A <code>PP_Instance</code> identifying one instance of - * a module. - * - * @return A <code>PP_Resource</code> corresponding to a - * PPB_ImageCaptureConfig_Private resource if successful, 0 if failed. - */ - PP_Resource Create([in] PP_Instance instance); - - /** - * IsImageCaptureConfig() determines if the given resource is a - * <code>PPB_ImageCaptureConfig_Private</code>. - * - * @param[in] resource A <code>PP_Resource</code> corresponding to an image - * capture config resource. - * - * @return A <code>PP_Bool</code> containing <code>PP_TRUE</code> if the given - * resource is an <code>ImageCaptureConfig_Private</code> resource, otherwise - * <code>PP_FALSE</code>. - */ - PP_Bool IsImageCaptureConfig( - [in] PP_Resource resource); - - /** - * GetPreviewSize() returns the preview image size in pixels for the given - * <code>PPB_ImageCaptureConfig_Private</code>. - * - * @param[in] config A <code>PP_Resource</code> corresponding to an image - * capture config resource. - * @param[out] preview_size A <code>PP_Size</code> that indicates the - * requested preview image size. - */ - void GetPreviewSize( - [in] PP_Resource config, - [out] PP_Size preview_size); - - /** - * SetPreviewSize() sets the preview image size for the given <code> - * PPB_ImageCaptureConfig_Private</code>. - * - * @param[in] config A <code>PP_Resource</code> corresponding to a - * <code>PPB_ImageCaptureConfig_Private</code>. - * @param[in] preview_size A <code>PP_Size</code> that indicates the requested - * preview image size. - */ - void SetPreviewSize( - [in] PP_Resource config, - [in] PP_Size preview_size); - - /** - * GetJpegSize() returns the JPEG image size in pixels for the given - * <code>PPB_ImageCaptureConfig_Private</code>. - * - * @param[in] config A <code>PP_Resource</code> corresponding to an image - * capture config resource. - * @param[out] jpeg_size A <code>PP_Size</code> that indicates the current - * JPEG image size. - */ - void GetJpegSize( - [in] PP_Resource config, - [out] PP_Size jpeg_size); - - /** - * SetJpegSize() sets the JPEG image size for the given - * <code>PPB_ImageCaptureConfig_Private</code>. - * - * @param[in] config A <code>PP_Resource</code> corresponding to a - * <code>PPB_ImageCaptureConfig_Private</code>. - * @param[in] jpeg_size A <code>PP_Size</code> that indicates the requested - * JPEG image size. - */ - void SetJpegSize( - [in] PP_Resource config, - [in] PP_Size jpeg_size); -}; diff --git a/chromium/ppapi/api/private/ppb_image_capture_private.idl b/chromium/ppapi/api/private/ppb_image_capture_private.idl deleted file mode 100644 index 28432af5dde..00000000000 --- a/chromium/ppapi/api/private/ppb_image_capture_private.idl +++ /dev/null @@ -1,259 +0,0 @@ -/* Copyright 2014 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. - */ - -/** - * Defines the <code>PPB_ImageCapture_Private</code> interface. Used for - * acquiring a single still image from a camera source. - */ - -[generate_thunk] - -label Chrome { - M39 = 0.1 -}; - -/** - * Callback function for <code>PPB_ImageCapture_Private.CaptureStillImage - * </code> to indicate the image has been captured from the sensor. This is a - * good opportunity to play a shutter sound or give other feedback of camera - * operation. This will occur after the image was captured, but before the - * actual data is available. - * - * Parameters: - * |user_data| The same pointer that was passed into <code> - * PPB_ImageCapture_Private.Create()</code>. - * |sequence_id| The sequence ID of the image capture, same as the one from - * CaptureStillImage. - */ -typedef void PPB_ImageCapture_Private_ShutterCallback( - [inout] mem_t user_data, - [in] int64_t sequence_id); - -/** - * Callback function for <code>PPB_ImageCapture_Private.CaptureStillImage - * </code> to deliver a preview image. The client can use this to show the - * captured image. See <code>PPB_ImageCapture_Private.CaptureStillImage - * </code> for more information. - * - * Parameters: - * |user_data| The same pointer that was passed into <code> - * PPB_ImageCapture_Private.Create()</code>. - * |sequence_id| The sequence ID of the image capture, same as the one from - * CaptureStillImage. - * |preview| A <code>PP_Resource</code> corresponding to a VideoFrame - * resource used to store the preview image. - */ -typedef void PPB_ImageCapture_Private_PreviewCallback( - [inout] mem_t user_data, - [in] int64_t sequence_id, - [in] PP_Resource preview); - -/** - * Callback function for <code>PPB_ImageCapture_Private.CaptureStillImage - * </code> to deliver a still JPEG image. See <code> - * PPB_ImageCapture_Private.CaptureStillImage</code> for more information. - * - * Parameters: - * |user_data| The same pointer that was passed into <code> - * PPB_ImageCapture_Private.Create()</code>. - * |sequence_id| The sequence ID of the image capture, same as the one from - * CaptureStillImage. - * |jpeg| A <code>PP_Resource</code> corresponding to a VideoFrame - * resource used to store the JPEG image. - */ -typedef void PPB_ImageCapture_Private_JpegCallback( - [inout] mem_t user_data, - [in] int64_t sequence_id, - [in] PP_Resource jpeg); - -/** - * Callback function for <code>PPB_ImageCapture_Private.CaptureStillImage - * </code> to indicate the image capture has failed. - * - * Parameters: - * |user_data| The same pointer that was passed into <code> - * PPB_ImageCapture_Private.Create()</code>. - * |sequence_id| The sequence ID of the image capture, same as the one from - * CaptureStillImage. - * |int32_t| An error code from <code>pp_errors.h</code>. - */ -typedef void PPB_ImageCapture_Private_ErrorCallback( - [inout] mem_t user_data, - [in] int64_t sequence_id, - [in] int32_t pp_error); - -/** - * To capture a still image with this class, use the following steps. - * 1. Get a PPB_ImageCapture_Private object by Create(). - * 2. Call GetCameraCapabilities to get the supported preview sizes. - * 3. For optimal performance, set one of the supported preview size as the - * constraints of getUserMedia. Use the created MediaStreamVideoTrack for - * camera previews. - * 4. Set the same preview size and other settings by SetConfig. - * 5. Call CaptureStillImage to capture a still image. Play the shutter sound in - * the shutter callback. The image from the preview callback can be used for - * display. JPEG image will be returned to the JPEG callback. - */ -interface PPB_ImageCapture_Private { - /** - * Creates a PPB_ImageCapture_Private resource. - * - * @param[in] instance A <code>PP_Instance</code> identifying one instance - * of a module. - * @param[in] camera_source_id A <code>PP_Var</code> identifying a camera - * source. The type is string. The ID can be obtained from - * MediaStreamTrack.getSources() or MediaStreamVideoTrack.id. If a - * MediaStreamVideoTrack is associated with the same source and the track - * is closed, this PPB_ImageCapture_Private object can still do image capture. - * @param[in] error_callback A <code>PPB_ImageCapture_Private_ErrorCallback - * </code> callback to indicate the image capture has failed. - * @param[inout] user_data An opaque pointer that will be passed to the - * callbacks of PPB_ImageCapture_Private. - * - * @return A <code>PP_Resource</code> corresponding to a - * PPB_ImageCapture_Private resource if successful, 0 if failed. - */ - PP_Resource Create([in] PP_Instance instance, - [in] PP_Var camera_source_id, - [in] PPB_ImageCapture_Private_ErrorCallback error_callback, - [inout] mem_t user_data); - - /** - * Determines if a resource is an image capture resource. - * - * @param[in] resource The <code>PP_Resource</code> to test. - * - * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given - * resource is an image capture resource or <code>PP_FALSE</code> - * otherwise. - */ - PP_Bool IsImageCapture([in] PP_Resource resource); - - /** - * Disconnects from the camera and cancels all pending capture requests. - * After this returns, no callbacks will be called. If <code> - * PPB_ImageCapture_Private</code> is destroyed and is not closed yet, this - * function will be automatically called. Calling this more than once has no - * effect. - * - * @param[in] image_capture A <code>PP_Resource</code> corresponding to an - * image capture resource. - * @param[in] callback <code>PP_CompletionCallback</code> to be called upon - * completion of <code>Close()</code>. - * - * @return An int32_t containing a result code from <code>pp_errors.h</code>. - */ - int32_t Close([in] PP_Resource resource, - [in] PP_CompletionCallback callback); - - /** - * Sets the configuration of the image capture. - * If <code>SetConfig()</code> is not called, default settings will be used. - * - * @param[in] image_capture A <code>PP_Resource</code> corresponding to an - * image capture resource. - * @param[in] config A <code>PP_ImageCaptureConfig_Private</code> object. - * @param[in] callback <code>PP_CompletionCallback</code> to be called upon - * completion of <code>SetConfig()</code>. - * - * @return An int32_t containing a result code from <code>pp_errors.h</code>. - * Returns <code>PP_ERROR_INPROGRESS</code> if there is a pending call of - * <code>SetConfig()</code> or <code>CaptureStillImage()</code>. - * If an error is returned, the configuration will not be changed. - */ - int32_t SetConfig([in] PP_Resource image_capture, - [in] PP_Resource config, - [in] PP_CompletionCallback callback); - - /** - * Gets the configuration of the image capture. - * - * @param[in] image_capture A <code>PP_Resource</code> corresponding to an - * image capture resource. - * @param[out] config A <code>PP_ImageCaptureConfig_Private</code> for storing - * the current image capture config on success. Otherwise, the values will not - * be changed. - * @param[in] callback <code>PP_CompletionCallback</code> to be called upon - * completion of <code>GetConfig()</code>. - * - * @return An int32_t containing a result code from <code>pp_errors.h</code>. - */ - int32_t GetConfig([in] PP_Resource image_capture, - [out] PP_Resource config, - [in] PP_CompletionCallback callback); - - /** - * Gets the camera capabilities. - * - * The camera capabilities do not change for a given camera source. - * - * @param[in] image_capture A <code>PP_Resource</code> corresponding to an - * image capture resource. - * @param[out] capabilities A <code>PPB_CameraCapabilities_Private</code> for - * storing the image capture capabilities on success. Otherwise, the value - * will not be changed. - * @param[in] callback <code>PP_CompletionCallback</code> to be called upon - * completion of <code>GetCameraCapabilities()</code>. - * - * @return An int32_t containing a result code from <code>pp_errors.h</code>. - */ - int32_t GetCameraCapabilities([in] PP_Resource image_capture, - [out] PP_Resource capabilities, - [in] PP_CompletionCallback callback); - - /** - * Captures a still JPEG image from the camera. - * - * Triggers an asynchronous image capture. The camera will initiate a series - * of callbacks to the application as the image capture progresses. The - * callbacks will be invoked in the order of shutter callback, preview - * callback, and JPEG callback. The shutter callback occurs after the image is - * captured. This can be used to trigger a sound to let the user know that - * image has been captured. The preview callback occurs when a scaled, fully - * processed preview image is available. The JPEG callback occurs when the - * compressed image is available. If there is an error after the capture is in - * progress, the error callback passed to <code> - * PPB_ImageCapture_Private.Create()</code> will be invoked. All the callbacks - * are invoked by the thread that calls this function. - * - * The size of the preview image in preview callback is determined by - * <code>PPB_ImageCaptureConfig_Private.SetPreviewSize</code>. The format is - * decided by the camera and can be got from <code>PPB_VideoFrame.GetFormat - * </code>. The size of the JPEG image is determined by <code> - * PPB_ImageCaptureConfig_Private.SetJpegSize</code>. - * - * The camera may need to stop and re-start streaming during image capture. If - * some MediaStreamVideoTrack are associated with the camera source, they will - * receive mute and unmute events. The mute event will be received before all - * the callbacks. The unmute event will be received after all the callbacks. - * The preview image will not be sent to the video tracks associated with the - * camera. - * - * @param[in] image_capture A <code>PP_Resource</code> corresponding to an - * image capture resource. - * @param[in] shutter_callback A <code> - * PPB_ImageCapture_Private_ShutterCallback</code> callback to indicate the - * image has been taken. - * @param[in] preview_callback A <code> - * PPB_ImageCapture_Private_PreviewCallback</code> callback to return a - * preview of the captured image. - * @param[in] jpeg_callback A <code> - * PPB_ImageCapture_Private_JpegCallback</code> callback to return captured - * JPEG image. - * @param[out] sequence_id The sequence ID is a unique monotonically - * increasing value starting from 0, incremented every time a new request like - * image capture is submitted. - * - * @return An int32_t containing a result code from <code>pp_errors.h</code>. - * PP_OK means the callbacks will be triggered. Other values mean the - * callbacks will not be triggered. - */ - int32_t CaptureStillImage( - [in] PP_Resource image_capture, - [in] PPB_ImageCapture_Private_ShutterCallback shutter_callback, - [in] PPB_ImageCapture_Private_PreviewCallback preview_callback, - [in] PPB_ImageCapture_Private_JpegCallback jpeg_callback, - [out] int64_t sequence_id); -}; diff --git a/chromium/ppapi/api/private/ppb_nacl_private.idl b/chromium/ppapi/api/private/ppb_nacl_private.idl deleted file mode 100644 index ba2b693a857..00000000000 --- a/chromium/ppapi/api/private/ppb_nacl_private.idl +++ /dev/null @@ -1,392 +0,0 @@ -/* Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* This file contains NaCl private interfaces. This interface is not versioned - * and is for internal Chrome use. It may change without notice. */ - -label Chrome { - M25 = 1.0 -}; - -#inline c -#include "ppapi/c/private/pp_file_handle.h" -#include "ppapi/c/private/ppb_instance_private.h" -#endinl - -/** NaCl-specific errors that should be reported to the user. - * These error codes are reported via UMA so, if you edit them: - * 1) make sure you understand UMA first. - * 2) update src/tools/metrics/histograms/histograms.xml - * Values are explicitly specified to make sure they don't shift around when - * edited, and also to make reading about:histograms easier. - */ -enum PP_NaClError { - PP_NACL_ERROR_LOAD_SUCCESS = 0, - PP_NACL_ERROR_LOAD_ABORTED = 1, - PP_NACL_ERROR_UNKNOWN = 2, - PP_NACL_ERROR_MANIFEST_RESOLVE_URL = 3, - PP_NACL_ERROR_MANIFEST_LOAD_URL = 4, - PP_NACL_ERROR_MANIFEST_STAT = 5, - PP_NACL_ERROR_MANIFEST_TOO_LARGE = 6, - PP_NACL_ERROR_MANIFEST_OPEN = 7, - PP_NACL_ERROR_MANIFEST_MEMORY_ALLOC = 8, - PP_NACL_ERROR_MANIFEST_READ = 9, - PP_NACL_ERROR_MANIFEST_PARSING = 10, - PP_NACL_ERROR_MANIFEST_SCHEMA_VALIDATE = 11, - PP_NACL_ERROR_MANIFEST_GET_NEXE_URL = 12, - PP_NACL_ERROR_NEXE_LOAD_URL = 13, - PP_NACL_ERROR_NEXE_ORIGIN_PROTOCOL = 14, - PP_NACL_ERROR_NEXE_FH_DUP = 15, - PP_NACL_ERROR_NEXE_STAT = 16, - PP_NACL_ERROR_ELF_CHECK_IO = 17, - PP_NACL_ERROR_ELF_CHECK_FAIL = 18, - PP_NACL_ERROR_SEL_LDR_INIT = 19, - PP_NACL_ERROR_SEL_LDR_CREATE_LAUNCHER = 20, - PP_NACL_ERROR_SEL_LDR_FD = 21, - PP_NACL_ERROR_SEL_LDR_LAUNCH = 22, - /* Deprecated, safe to reuse the value because it's never logged in UMA. - PP_NACL_ERROR_SEL_LDR_COMMUNICATION = 23, */ - PP_NACL_ERROR_SEL_LDR_SEND_NEXE = 24, - PP_NACL_ERROR_SEL_LDR_HANDLE_PASSING = 25, - PP_NACL_ERROR_SEL_LDR_START_MODULE = 26, - PP_NACL_ERROR_SEL_LDR_START_STATUS = 27, - PP_NACL_ERROR_SRPC_CONNECTION_FAIL = 28, - PP_NACL_ERROR_START_PROXY_CHECK_PPP = 29, - PP_NACL_ERROR_START_PROXY_ALLOC = 30, - PP_NACL_ERROR_START_PROXY_MODULE = 31, - PP_NACL_ERROR_START_PROXY_INSTANCE = 32, - PP_NACL_ERROR_SEL_LDR_COMMUNICATION_CMD_CHANNEL = 33, - PP_NACL_ERROR_SEL_LDR_COMMUNICATION_REV_SETUP = 34, - PP_NACL_ERROR_SEL_LDR_COMMUNICATION_WRAPPER = 35, - PP_NACL_ERROR_SEL_LDR_COMMUNICATION_REV_SERVICE = 36, - PP_NACL_ERROR_START_PROXY_CRASH = 37, - PP_NACL_ERROR_MANIFEST_PROGRAM_MISSING_ARCH = 38, - PP_NACL_ERROR_PNACL_CACHE_OPEN_INPROGRESS = 39, - PP_NACL_ERROR_PNACL_CACHE_OPEN_NOACCESS = 40, - PP_NACL_ERROR_PNACL_CACHE_OPEN_NOQUOTA = 41, - PP_NACL_ERROR_PNACL_CACHE_OPEN_NOSPACE = 42, - PP_NACL_ERROR_PNACL_CACHE_OPEN_OTHER = 43, - PP_NACL_ERROR_PNACL_CACHE_DIRECTORY_CREATE = 44, - PP_NACL_ERROR_PNACL_CACHE_FILEOPEN_NOACCESS = 45, - PP_NACL_ERROR_PNACL_CACHE_FILEOPEN_NOQUOTA = 46, - PP_NACL_ERROR_PNACL_CACHE_FILEOPEN_NOSPACE = 47, - PP_NACL_ERROR_PNACL_CACHE_FILEOPEN_NOTAFILE = 48, - PP_NACL_ERROR_PNACL_CACHE_FILEOPEN_OTHER = 49, - PP_NACL_ERROR_PNACL_CACHE_FETCH_NOACCESS = 50, - PP_NACL_ERROR_PNACL_CACHE_FETCH_NOTFOUND = 51, - PP_NACL_ERROR_PNACL_CACHE_FETCH_OTHER = 52, - PP_NACL_ERROR_PNACL_CACHE_FINALIZE_COPY_NOQUOTA = 53, - PP_NACL_ERROR_PNACL_CACHE_FINALIZE_COPY_NOSPACE = 54, - PP_NACL_ERROR_PNACL_CACHE_FINALIZE_COPY_OTHER = 55, - PP_NACL_ERROR_PNACL_CACHE_FINALIZE_RENAME_NOACCESS = 56, - PP_NACL_ERROR_PNACL_CACHE_FINALIZE_RENAME_OTHER = 57, - PP_NACL_ERROR_PNACL_RESOURCE_FETCH = 58, - PP_NACL_ERROR_PNACL_PEXE_FETCH_ABORTED = 59, - PP_NACL_ERROR_PNACL_PEXE_FETCH_NOACCESS = 60, - PP_NACL_ERROR_PNACL_PEXE_FETCH_OTHER = 61, - PP_NACL_ERROR_PNACL_THREAD_CREATE = 62, - PP_NACL_ERROR_PNACL_LLC_SETUP = 63, - PP_NACL_ERROR_PNACL_LD_SETUP = 64, - PP_NACL_ERROR_PNACL_LLC_INTERNAL = 65, - PP_NACL_ERROR_PNACL_LD_INTERNAL = 66, - PP_NACL_ERROR_PNACL_CREATE_TEMP = 67, - /* This entry is no longer used, but should not be removed, because UMA - numbers need to be kept consistent. */ - PP_NACL_ERROR_PNACL_NOT_ENABLED = 68, - PP_NACL_ERROR_MANIFEST_NOACCESS_URL = 69, - PP_NACL_ERROR_NEXE_NOACCESS_URL = 70, - PP_NACL_ERROR_PNACL_CRASH_THROTTLED = 71, - - /* If you add a code, read the enum comment above on how to update - histograms. */ - PP_NACL_ERROR_MAX -}; - -/** Event types that NaCl may use when reporting load progress or errors. */ -enum PP_NaClEventType { - PP_NACL_EVENT_LOADSTART, - PP_NACL_EVENT_PROGRESS, - PP_NACL_EVENT_ERROR, - PP_NACL_EVENT_ABORT, - PP_NACL_EVENT_LOAD, - PP_NACL_EVENT_LOADEND, - PP_NACL_EVENT_CRASH -}; - -enum PP_UrlSchemeType { - PP_SCHEME_CHROME_EXTENSION, - PP_SCHEME_DATA, - PP_SCHEME_OTHER -}; - -enum PP_NaClReadyState { - /* The trusted plugin begins in this ready state. */ - PP_NACL_READY_STATE_UNSENT = 0, - /* The manifest file has been requested, but not yet received. */ - PP_NACL_READY_STATE_OPENED = 1, - /* The manifest file has been received and the nexe successfully requested. */ - PP_NACL_READY_STATE_LOADING = 3, - /* The nexe has been loaded and the proxy started, so it is ready for - interaction with the page. */ - PP_NACL_READY_STATE_DONE = 4 -}; - -/** Types of untrusted NaCl processes. Mirrors NaClAppProcessType from - * components/nacl/common/nacl_types.h. - */ -enum PP_NaClAppProcessType { - PP_UNKNOWN_NACL_PROCESS_TYPE, - PP_NATIVE_NACL_PROCESS_TYPE, - PP_PNACL_PROCESS_TYPE, - PP_PNACL_TRANSLATOR_PROCESS_TYPE, - PP_NUM_NACL_PROCESS_TYPES -}; - -struct PP_PNaClOptions { - PP_Bool translate; - PP_Bool is_debug; - int32_t opt_level; -}; - -/* Callback invoked upon completion of PPP_ManifestService::OpenResource(). */ -typedef void PP_OpenResourceCompletionCallback([inout] mem_t user_data, - [in] PP_FileHandle file_handle); - -/* Corresponds to NaClFileInfo in - * native_client/src/trusted/validator/nacl_file_info.h */ -struct PP_NaClFileInfo { - PP_FileHandle handle; - - /* See NaClFileToken comment in nacl_file_info.h */ - uint64_t token_lo; - uint64_t token_hi; -}; - -/* PPB_NaCl_Private */ -interface PPB_NaCl_Private { - /* Launches NaCl's sel_ldr process. Returns PP_EXTERNAL_PLUGIN_OK on success - * and writes a NaClHandle to imc_handle. Returns PP_EXTERNAL_PLUGIN_FAILED on - * failure. The |enable_ppapi_dev| parameter controls whether GetInterface - * returns 'Dev' interfaces to the NaCl plugin. - * The |nexe_file_info| is currently used only in non-SFI mode. It is the - * file handle for the main nexe file, which should be initially loaded. - * LaunchSelLdr takes the ownership of the file handle. - * The |uses_nonsfi_mode| flag indicates whether or not nonsfi-mode should - * be used with the binary pointed by the url. - */ - void LaunchSelLdr([in] PP_Instance instance, - [in] PP_Bool main_service_runtime, - [in] str_t alleged_url, - [in] PP_NaClFileInfo nexe_file_info, - [in] PP_Bool uses_nonsfi_mode, - [in] PP_Bool enable_ppapi_dev, - [in] PP_NaClAppProcessType process_type, - [out] mem_t imc_handle, - [in] PP_CompletionCallback callback); - - /* This function starts the IPC proxy so the nexe can communicate with the - * browser. - */ - PP_Bool StartPpapiProxy(PP_Instance instance); - - /* On POSIX systems, this function returns the file descriptor of - * /dev/urandom. On non-POSIX systems, this function returns 0. - */ - int32_t UrandomFD(); - - /* Whether the Pepper 3D interfaces should be disabled in the NaCl PPAPI - * proxy. This is so paranoid admins can effectively prevent untrusted shader - * code to be processed by the graphics stack. - */ - PP_Bool Are3DInterfacesDisabled(); - - /* This is Windows-specific. This is a replacement for DuplicateHandle() for - * use inside the Windows sandbox. Note that we provide this via dependency - * injection only to avoid the linkage problems that occur because the NaCl - * plugin is built as a separate DLL/DSO - * (see http://code.google.com/p/chromium/issues/detail?id=114439#c8). - */ - int32_t BrokerDuplicateHandle([in] PP_FileHandle source_handle, - [in] uint32_t process_id, - [out] PP_FileHandle target_handle, - [in] uint32_t desired_access, - [in] uint32_t options); - - /* Returns a read-only (but executable) file descriptor / file info for - * a url for pnacl translator tools. Returns an invalid handle on failure. - */ - void GetReadExecPnaclFd([in] str_t url, - [out] PP_NaClFileInfo out_file_info); - - /* This creates a temporary file that will be deleted by the time - * the last handle is closed (or earlier on POSIX systems), and - * returns a posix handle to that temporary file. - */ - PP_FileHandle CreateTemporaryFile([in] PP_Instance instance); - - /* Return the number of processors in the system as reported by the OS */ - int32_t GetNumberOfProcessors(); - - /* Return whether the non-SFI mode is enabled. */ - PP_Bool IsNonSFIModeEnabled(); - - /* Report to the browser that translation of the pexe for |instance| - * has finished, or aborted with an error. If |success| is true, the - * browser may then store the translation in the cache. The renderer - * must first have called GetNexeFd for the same instance. (The browser is - * not guaranteed to store the nexe even if |success| is true; if there is - * an error on the browser side, or the file is too big for the cache, or - * the browser is in incognito mode, no notification will be delivered to - * the plugin.) - */ - void ReportTranslationFinished([in] PP_Instance instance, - [in] PP_Bool success, - [in] int32_t opt_level, - [in] int64_t pexe_size, - [in] int64_t compile_time_us); - - /* Dispatch a progress event on the DOM element where the given instance is - * embedded. - */ - void DispatchEvent([in] PP_Instance instance, - [in] PP_NaClEventType event_type, - [in] str_t resource_url, - [in] PP_Bool length_is_computable, - [in] uint64_t loaded_bytes, - [in] uint64_t total_bytes); - - /* Report that the nexe loaded successfully. */ - void ReportLoadSuccess([in] PP_Instance instance, - [in] uint64_t loaded_bytes, - [in] uint64_t total_bytes); - - /* Report an error that occured while attempting to load a nexe. */ - void ReportLoadError([in] PP_Instance instance, - [in] PP_NaClError error, - [in] str_t error_message); - - /* Reports that loading a nexe was aborted. */ - void ReportLoadAbort([in] PP_Instance instance); - - /* Performs internal setup when an instance is created. */ - void InstanceCreated([in] PP_Instance instance); - - /* Performs internal cleanup when an instance is destroyed. */ - void InstanceDestroyed([in] PP_Instance instance); - - /* Return true if the NaCl debug stub is enabled and the app loaded from - * alleged_nmf_url will be attached to a debugger. - */ - PP_Bool NaClDebugEnabledForURL([in] str_t alleged_nmf_url); - - /* Returns the kind of SFI sandbox implemented by NaCl on this - * platform. - */ - str_t GetSandboxArch(); - - /* Logs the message to the console. */ - void LogToConsole([in] PP_Instance instance, - [in] str_t message); - - /* Returns the NaCl readiness status for this instance. */ - PP_NaClReadyState GetNaClReadyState([in] PP_Instance instance); - - /* Logs the message via VLOG. */ - void Vlog([in] str_t message); - - /* Initializes internal state for a NaCl plugin. */ - void InitializePlugin([in] PP_Instance instance, - [in] uint32_t argc, - [in, size_as=argc] str_t[] argn, - [in, size_as=argv] str_t[] argv); - - /* Returns the size of the nexe. */ - int64_t GetNexeSize([in] PP_Instance instance); - - /* Requests the NaCl manifest specified in the plugin arguments. */ - void RequestNaClManifest([in] PP_Instance instance, - [in] PP_CompletionCallback callback); - - PP_Var GetManifestBaseURL([in] PP_Instance instance); - - /* Processes the NaCl manifest once it's been retrieved. - * TODO(teravest): Move the rest of the supporting logic out of the trusted - * plugin. - */ - void ProcessNaClManifest([in] PP_Instance instance, - [in] str_t program_url); - - PP_Bool DevInterfacesEnabled([in] PP_Instance instance); - - PP_Bool GetManifestProgramURL([in] PP_Instance instance, - [out] PP_Var full_url, - [out] PP_PNaClOptions pnacl_options, - [out] PP_Bool uses_nonsfi_mode); - - /* Returns the filenames for the llc and ld tools. */ - PP_Bool GetPnaclResourceInfo([in] PP_Instance instance, - [out] PP_Var llc_tool_name, - [out] PP_Var ld_tool_name); - - // PP_Var string of attributes describing the CPU features supported - // by the current architecture. The string is a comma-delimited list - // of attributes supported by LLVM in its -mattr= option: - // http://llvm.org/docs/CommandGuide/llc.html#cmdoption-mattr - PP_Var GetCpuFeatureAttrs(); - - /* Downloads the .nexe file at the given URL to a file, and sets |file_info| - * to information for a handle to a file containing its contents. - * If metadata for identity-based validation caching is available - * then it sets token information in |file_info| (otherwise left untouched). - */ - void DownloadNexe([in] PP_Instance instance, - [in] str_t url, - [out] PP_NaClFileInfo file_info, - [in] PP_CompletionCallback callback); - - /* Reports the status of sel_ldr for UMA reporting. - * |max_status| has to be provided because the implementation of this - * interface can't access the NaClErrorCode enum. - */ - void ReportSelLdrStatus([in] PP_Instance instance, - [in] int32_t load_status, - [in] int32_t max_status); - - /* Logs time taken by an operation to UMA histograms. - * This function is safe to call on any thread. - */ - void LogTranslateTime([in] str_t histogram_name, - [in] int64_t time_us); - - /* Opens a manifest entry for the given instance. If this is for a helper - * process, we consult our internal pnacl.json instead of the user-supplied - * NMF. - * Fails for files which require PNaCl translation. - */ - void OpenManifestEntry([in] PP_Instance instance, - [in] PP_Bool is_helper_process, - [in] str_t key, - [out] PP_NaClFileInfo file_info, - [in] PP_CompletionCallback callback); - - /* Sets the start time for PNaCl downloading and translation to the current - * time. - */ - void SetPNaClStartTime([in] PP_Instance instance); - - /* Downloads and streams a pexe file for PNaCl translation. - * Fetches the content at |pexe_url| for the given instance and opt_level. - * If a translated cached nexe is already available, |cache_hit_handle| - * is set and |cache_hit_callback| is called. - * Otherwise, |stream_callback| is called repeatedly with blocks of data - * as they are received. |stream_finished_callback| is called after all - * data has been received and dispatched to |stream_callback|. - */ - void StreamPexe([in] PP_Instance instance, - [in] str_t pexe_url, - [in] int32_t opt_level, - [in] PPP_PexeStreamHandler stream_handler, - [inout] mem_t stream_handler_user_data); -}; diff --git a/chromium/ppapi/api/private/ppb_talk_private.idl b/chromium/ppapi/api/private/ppb_talk_private.idl deleted file mode 100644 index 548ac1eeba8..00000000000 --- a/chromium/ppapi/api/private/ppb_talk_private.idl +++ /dev/null @@ -1,142 +0,0 @@ -/* Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * This file contains the <code>PPB_Talk_Private</code> interface. - */ -label Chrome { - M19 = 1.0, - M29 = 2.0 -}; - -/** - * The type of permissions that can be requested from the user. - */ -[assert_size(4)] -enum PP_TalkPermission { - /** - * Request permission for screencast. - */ - PP_TALKPERMISSION_SCREENCAST, - /** - * Request permission for Remote Desktop. - */ - PP_TALKPERMISSION_REMOTING, - /** - * Request permission for continuing Remote Desktop. - */ - PP_TALKPERMISSION_REMOTING_CONTINUE, - /** - * Number of permissions. - */ - PP_TALKPERMISSION_NUM_PERMISSIONS -}; - -/** - * Talk event types reported by the browser. - */ -[assert_size(4)] -enum PP_TalkEvent { - /** - * Indicates that the user took action to terminate the remoting session. - */ - PP_TALKEVENT_TERMINATE, - /** - * Indicates that an error occurred (e.g. failed to show the UI). - */ - PP_TALKEVENT_ERROR, - /** - * Number of events - */ - PP_TALKEVENT_NUM_EVENTS -}; - -/** - * Callback for Talk events. - */ -typedef void PP_TalkEventCallback([inout] mem_t user_data, - [in] PP_TalkEvent event); - -/** - * Extra interface for Talk. - */ -interface PPB_Talk_Private { - /** - * Creates a Talk_Private resource. - */ - [version=1.0] - PP_Resource Create(PP_Instance instance); - - /** - * Displays confirmation dialog for screencasting. - * - * The callback will be issued with 1 as the result if the user gave - * permission, or 0 if the user denied. - * - * You can only have one call pending. It will return PP_OK_COMPLETIONPENDING - * if the request is queued, or PP_ERROR_INPROGRESS if there is already a - * request in progress. - * - * (Deprecated in 2.0. Please us RequestPermission instead.) - */ - [version=1.0, deprecate=2.0] - int32_t GetPermission( - [in] PP_Resource talk_resource, - [in] PP_CompletionCallback callback); - - /** - * Requests permission from the user using a system modal dialog. - * - * <code>permission</code> specifies the type of permission to request from - * the user. - * - * <code>callback</code> is the completion callback. It will be issued with 1 - * as the result if the user gave permission, or 0 if the user denied. - * - * You can only have one call pending. It will return PP_OK_COMPLETIONPENDING - * if the request is queued, or PP_ERROR_INPROGRESS if there is already a - * request in progress. - */ - [version=2.0] - int32_t RequestPermission( - [in] PP_Resource talk_resource, - [in] PP_TalkPermission permission, - [in] PP_CompletionCallback callback); - - /** - * Shows the remoting-in-progress UI and registers a callback for events. - * - * <code>event_callback</code> is the callback for session releated events. - * It will only start receiving events after the completion callback has been - * issued. This callback will be called on the pepper main thread. - * - * <code>user_data</code> is an opaque value used when - * <code>event_callback</code> is invoked. - * - * <code>callback</code> is the completion callback. - * - * You can only have one call pending. It will return PP_OK_COMPLETIONPENDING - * if the request is queued, or PP_ERROR_INPROGRESS if there is already a - * request in progress. PP_ERROR_INPROGRESS will also be returned if a - * previous call to StartRemoting succeeded without a corresponding - * StopRemoting call. - */ - [version=2.0] - int32_t StartRemoting( - [in] PP_Resource talk_resource, - [in] PP_TalkEventCallback event_callback, - [inout] mem_t user_data, - [in] PP_CompletionCallback callback); - - /** - * Hides the remoting-in-progress UI and unregisters the event callback. - * - * <code>callback</code> is the completion callback. - */ - [version=2.0] - int32_t StopRemoting( - [in] PP_Resource talk_resource, - [in] PP_CompletionCallback callback); -}; diff --git a/chromium/ppapi/api/private/ppb_testing_private.idl b/chromium/ppapi/api/private/ppb_testing_private.idl index 0ede2de2ea0..c2aed417615 100644 --- a/chromium/ppapi/api/private/ppb_testing_private.idl +++ b/chromium/ppapi/api/private/ppb_testing_private.idl @@ -79,6 +79,20 @@ interface PPB_Testing_Private { PP_Bool IsOutOfProcess(); /** + * Posts the plugin's current Power Saver status to JavaScript. The plugin + * itself does not recieve anything. This is not idiomatic for Pepper, + * but convenient for testing. + */ + void PostPowerSaverStatus([in] PP_Instance instance); + + /** + * Subscribes to changes to the plugin's Power Saver status. The status + * changes are not forwarded to the plugin itself, but posted to JavaScript. + * This is not idiomatic for Pepper, but conveienent for testing. + */ + void SubscribeToPowerSaverNotifications([in] PP_Instance instance); + + /** * Passes the input event to the browser, which sends it back to the * plugin. The plugin should implement PPP_InputEvent and register for * the input event type. diff --git a/chromium/ppapi/api/private/ppp_content_decryptor_private.idl b/chromium/ppapi/api/private/ppp_content_decryptor_private.idl index 46fc7016164..20a56a7b01a 100644 --- a/chromium/ppapi/api/private/ppp_content_decryptor_private.idl +++ b/chromium/ppapi/api/private/ppp_content_decryptor_private.idl @@ -9,7 +9,7 @@ * Decryption Modules, not normal plugins. */ label Chrome { - M36 = 0.12 + M44 = 0.15 }; /** @@ -23,12 +23,22 @@ interface PPP_ContentDecryptor_Private { /** * Initialize for the specified key system. * + * @param[in] promise_id A reference for the promise that gets resolved or + * rejected depending upon the success or failure of initialization. + * * @param[in] key_system A <code>PP_Var</code> of type * <code>PP_VARTYPE_STRING</code> containing the name of the key system. + * @param[in] allow_distinctive_identifier Inform the CDM that it may use a + * distinctive identifier. + * @param[in] allow_persistent_state Inform the CDM that it may use persistent + * state. */ void Initialize( [in] PP_Instance instance, - [in] PP_Var key_system); + [in] uint32_t promise_id, + [in] PP_Var key_system, + [in] PP_Bool allow_distinctive_identifier, + [in] PP_Bool allow_persistent_state); /** * Provides a server certificate to be used to encrypt messages to the @@ -46,52 +56,57 @@ interface PPP_ContentDecryptor_Private { [in] PP_Var server_certificate); /** - * Creates a session. <code>init_data_type</code> contains the MIME type of + * Creates a session and subsequently generates a request for a license. + * <code>init_data_type</code> contains the MIME type of * <code>init_data</code>. <code>init_data</code> is a data buffer * containing data for use in generating the request. * - * Note: <code>CreateSession()</code> must create a web session ID and provide - * it to the browser via <code>SessionCreated()</code> on the - * <code>PPB_ContentDecryptor_Private</code> interface. + * Note: <code>CreateSessionAndGenerateRequest()</code> must create a + * session ID and provide it to the browser via <code>SessionCreated()</code> + * on the <code>PPB_ContentDecryptor_Private</code> interface. * * @param[in] promise_id A reference for the promise that gets resolved or * rejected depending upon the success or failure when creating the session. * - * @param[in] init_data_type A <code>PP_Var</code> of type - * <code>PP_VARTYPE_STRING</code> containing the MIME type for init_data. + * @param[in] session_type A <code>PP_SessionType</code> that indicates the + * type of session to be created. + * + * @param[in] init_data_type A <code>PP_InitDataType</code> that indicates + * the Initialization Data Type for init_data. * * @param[in] init_data A <code>PP_Var</code> of type * <code>PP_VARTYPE_ARRAYBUFFER</code> containing container specific * initialization data. - * - * @param[in] session_type A <code>PP_SessionType</code> that indicates the - * type of session to be created. */ - void CreateSession( + void CreateSessionAndGenerateRequest( [in] PP_Instance instance, [in] uint32_t promise_id, - [in] PP_Var init_data_type, - [in] PP_Var init_data, - [in] PP_SessionType session_type); + [in] PP_SessionType session_type, + [in] PP_InitDataType init_data_type, + [in] PP_Var init_data); /** - * Loads a session whose web session ID is <code>web_session_id</code>. + * Loads a session whose session ID is <code>session_id</code>. * * Note: After the session is successfully loaded, the CDM must call - * <code>SessionCreated()</code> with <code>web_session_id</code> on the + * <code>SessionCreated()</code> with <code>session_id</code> on the * <code>PPB_ContentDecryptor_Private</code> interface. * * @param[in] promise_id A reference for the promise that gets resolved or * rejected depending upon the success or failure of loading the session. * - * @param[in] web_session_id A <code>PP_Var</code> of type - * <code>PP_VARTYPE_STRING</code> containing the web session ID of the session + * @param[in] session_type A <code>PP_SessionType</code> that indicates the + * type of session to be loaded. + * + * @param[in] session_id A <code>PP_Var</code> of type + * <code>PP_VARTYPE_STRING</code> containing the session ID of the session * to load. */ void LoadSession( [in] PP_Instance instance, [in] uint32_t promise_id, - [in] PP_Var web_session_id); + [in] PP_SessionType session_type, + [in] PP_Var session_id); /** * Provides a license or other message to the decryptor. @@ -108,8 +123,8 @@ interface PPP_ContentDecryptor_Private { * @param[in] promise_id A reference for the promise that gets resolved or * rejected depending upon the success or failure of updating the session. * - * @param[in] web_session_id A <code>PP_Var</code> of type - * <code>PP_VARTYPE_STRING</code> containing the web session ID of the session + * @param[in] session_id A <code>PP_Var</code> of type + * <code>PP_VARTYPE_STRING</code> containing the session ID of the session * to be updated. * * @param[in] response A <code>PP_Var</code> of type @@ -119,7 +134,7 @@ interface PPP_ContentDecryptor_Private { void UpdateSession( [in] PP_Instance instance, [in] uint32_t promise_id, - [in] PP_Var web_session_id, + [in] PP_Var session_id, [in] PP_Var response); /** @@ -128,15 +143,15 @@ interface PPP_ContentDecryptor_Private { * @param[in] promise_id A reference for the promise that gets resolved or * rejected depending upon the success or failure of closing the session. * - * @param[in] web_session_id A <code>PP_Var</code> of type - * <code>PP_VARTYPE_STRING</code> containing the web session ID of the session + * @param[in] session_id A <code>PP_Var</code> of type + * <code>PP_VARTYPE_STRING</code> containing the session ID of the session * to be closed. * */ void CloseSession( [in] PP_Instance instance, [in] uint32_t promise_id, - [in] PP_Var web_session_id); + [in] PP_Var session_id); /** * Remove stored data associated with this session. @@ -145,32 +160,15 @@ interface PPP_ContentDecryptor_Private { * rejected depending upon the success or failure of removing the session * data. * - * @param[in] web_session_id A <code>PP_Var</code> of type - * <code>PP_VARTYPE_STRING</code> containing the web session ID of the session + * @param[in] session_id A <code>PP_Var</code> of type + * <code>PP_VARTYPE_STRING</code> containing the session ID of the session * to be removed. * */ void RemoveSession( [in] PP_Instance instance, [in] uint32_t promise_id, - [in] PP_Var web_session_id); - - /** - * Get the key IDs for keys in the session that the CDM knows are currently - * usable to decrypt media data. - * - * @param[in] promise_id A reference for the promise that gets resolved or - * rejected depending upon the success or failure of obtaining the key IDs. - * - * @param[in] web_session_id A <code>PP_Var</code> of type - * <code>PP_VARTYPE_STRING</code> containing the web session ID of the session - * to be queried. - * - */ - void GetUsableKeyIds( - [in] PP_Instance instance, - [in] uint32_t promise_id, - [in] PP_Var web_session_id); + [in] PP_Var session_id); /** * Decrypts the block and returns the unencrypted block via diff --git a/chromium/ppapi/c/BUILD.gn b/chromium/ppapi/c/BUILD.gn new file mode 100644 index 00000000000..7ec7674d612 --- /dev/null +++ b/chromium/ppapi/c/BUILD.gn @@ -0,0 +1,10 @@ +# Copyright 2015 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. + +import("//ppapi/ppapi_sources.gni") + +# These are just headers. +source_set("c") { + sources = rebase_path(ppapi_sources.c_source_files, ".", "..") +} diff --git a/chromium/ppapi/c/dev/pp_print_settings_dev.h b/chromium/ppapi/c/dev/pp_print_settings_dev.h index 93e21d4300f..12531902b9d 100644 --- a/chromium/ppapi/c/dev/pp_print_settings_dev.h +++ b/chromium/ppapi/c/dev/pp_print_settings_dev.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From dev/pp_print_settings_dev.idl modified Wed Jun 13 09:14:31 2012. */ +/* From dev/pp_print_settings_dev.idl modified Fri Jan 16 13:30:14 2015. */ #ifndef PPAPI_C_DEV_PP_PRINT_SETTINGS_DEV_H_ #define PPAPI_C_DEV_PP_PRINT_SETTINGS_DEV_H_ diff --git a/chromium/ppapi/c/dev/ppb_messaging_deprecated.h b/chromium/ppapi/c/dev/ppb_messaging_deprecated.h deleted file mode 100644 index 045c9d9ba7d..00000000000 --- a/chromium/ppapi/c/dev/ppb_messaging_deprecated.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright 2014 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_C_DEV_IMPL_PPB_MESSAGING_DEPRECATED_H_ -#define PPAPI_C_DEV_IMPL_PPB_MESSAGING_DEPRECATED_H_ - -#include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_resource.h" -#include "ppapi/c/pp_stdint.h" -#include "ppapi/c/pp_var.h" - -/* dev, deprecated */ -#define PPB_MESSAGING_INTERFACE_1_1_DEPRECATED "PPB_Messaging;1.1" - -/** - * This file defines a dev-channel-only API, PPB_Messaging;1.1 that is - * deprecated, but which still should provide ABI compatibility for a little - * bit longer to give time to transition off of it. The header is *not* provided - * in ppapi/c/ppb_messaging.h, in order to push clients to the new API, - * version 1.2. - * TODO(dmichael): Delete this API altogether when all uses are gone. - * crbug.com/414398 - */ -struct PPP_MessageHandler_0_1_Deprecated { /* dev */ - void (*HandleMessage)(PP_Instance instance, - void* user_data, - struct PP_Var message); - struct PP_Var (*HandleBlockingMessage)(PP_Instance instance, - void* user_data, - struct PP_Var message); - void (*Destroy)(PP_Instance instance, void* user_data); -}; - -struct PPB_Messaging_1_1_Deprecated { /* dev */ - void (*PostMessage)(PP_Instance instance, struct PP_Var message); - int32_t (*RegisterMessageHandler)( - PP_Instance instance, - void* user_data, - const struct PPP_MessageHandler_0_1_Deprecated* handler, - PP_Resource message_loop); - void (*UnregisterMessageHandler)(PP_Instance instance); -}; - -#endif /* PPAPI_C_DEV_IMPL_PPB_MESSAGING_DEPRECATED_H_ */ - diff --git a/chromium/ppapi/c/dev/ppp_zoom_dev.h b/chromium/ppapi/c/dev/ppp_zoom_dev.h index d70fcddf4b6..0cc39ea3d5c 100644 --- a/chromium/ppapi/c/dev/ppp_zoom_dev.h +++ b/chromium/ppapi/c/dev/ppp_zoom_dev.h @@ -31,7 +31,7 @@ */ struct PPP_Zoom_Dev_0_3 { /** - * Instruct plug-in to zoom according to the given factor and whether the zoom + * Instruct plugin to zoom according to the given factor and whether the zoom * only applies to text only. The scale factor is the percentage divided by * 100, i.e. 150% zoom is 1.5. */ diff --git a/chromium/ppapi/c/pp_codecs.h b/chromium/ppapi/c/pp_codecs.h index 86d8fb5ea3d..173f9f4325e 100644 --- a/chromium/ppapi/c/pp_codecs.h +++ b/chromium/ppapi/c/pp_codecs.h @@ -3,11 +3,12 @@ * found in the LICENSE file. */ -/* From pp_codecs.idl modified Wed Nov 5 13:38:52 2014. */ +/* From pp_codecs.idl modified Fri Apr 17 10:55:27 2015. */ #ifndef PPAPI_C_PP_CODECS_H_ #define PPAPI_C_PP_CODECS_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_rect.h" @@ -130,6 +131,79 @@ struct PP_VideoPicture_0_1 { */ struct PP_Size texture_size; }; + +/** + * Supported video profile information. See the PPB_VideoEncoder function + * GetSupportedProfiles() for more details. + */ +struct PP_VideoProfileDescription { + /** + * The codec profile. + */ + PP_VideoProfile profile; + /** + * Dimensions of the maximum resolution of video frames, in pixels. + */ + struct PP_Size max_resolution; + /** + * The numerator of the maximum frame rate. + */ + uint32_t max_framerate_numerator; + /** + * The denominator of the maximum frame rate. + */ + uint32_t max_framerate_denominator; + /** + * Whether the profile is hardware accelerated. + */ + PP_Bool hardware_accelerated; +}; + +/** + * Supported video profile information. See the PPB_VideoEncoder function + * GetSupportedProfiles() for more details. + */ +struct PP_VideoProfileDescription_0_1 { + /** + * The codec profile. + */ + PP_VideoProfile profile; + /** + * Dimensions of the maximum resolution of video frames, in pixels. + */ + struct PP_Size max_resolution; + /** + * The numerator of the maximum frame rate. + */ + uint32_t max_framerate_numerator; + /** + * The denominator of the maximum frame rate. + */ + uint32_t max_framerate_denominator; + /** + * A value indicating if the profile is available in hardware, software, or + * both. + */ + PP_HardwareAcceleration acceleration; +}; + +/** + * Struct describing a bitstream buffer. + */ +struct PP_BitstreamBuffer { + /** + * The size, in bytes, of the bitstream data. + */ + uint32_t size; + /** + * The base address of the bitstream data. + */ + void* buffer; + /** + * Whether the buffer represents a key frame. + */ + PP_Bool key_frame; +}; /** * @} */ diff --git a/chromium/ppapi/c/pp_macros.h b/chromium/ppapi/c/pp_macros.h index 7d75ebada11..28b6c3a7b16 100644 --- a/chromium/ppapi/c/pp_macros.h +++ b/chromium/ppapi/c/pp_macros.h @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -/* From pp_macros.idl modified Thu Sep 18 11:36:39 2014. */ +/* From pp_macros.idl modified Tue Dec 9 11:24:44 2014. */ #ifndef PPAPI_C_PP_MACROS_H_ #define PPAPI_C_PP_MACROS_H_ -#define PPAPI_RELEASE 40 +#define PPAPI_RELEASE 44 /** * @file diff --git a/chromium/ppapi/c/ppb_file_mapping.h b/chromium/ppapi/c/ppb_file_mapping.h deleted file mode 100644 index 3c1f87bf928..00000000000 --- a/chromium/ppapi/c/ppb_file_mapping.h +++ /dev/null @@ -1,147 +0,0 @@ -/* Copyright 2014 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* From ppb_file_mapping.idl modified Mon Jan 27 11:00:43 2014. */ - -#ifndef PPAPI_C_PPB_FILE_MAPPING_H_ -#define PPAPI_C_PPB_FILE_MAPPING_H_ - -#include "ppapi/c/pp_completion_callback.h" -#include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_macros.h" -#include "ppapi/c/pp_resource.h" -#include "ppapi/c/pp_stdint.h" - -#define PPB_FILEMAPPING_INTERFACE_0_1 "PPB_FileMapping;0.1" /* dev */ -/** - * @file - * This file defines methods for mapping and unmapping files into and out of - * memory. - */ - - -/** - * @addtogroup Enums - * @{ - */ -/** - * The PP_FileMapProtection values indicate the permissions requested for the - * file mapping. These should be used in a uint32_t bitfield. - */ -typedef enum { - /** Requests read access to the mapped address. */ - PP_FILEMAPPROTECTION_READ = 1u << 0, - /** Requests write access to the mapped address. */ - PP_FILEMAPPROTECTION_WRITE = 1u << 1 -} PP_FileMapProtection; -PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FileMapProtection, 4); - -/** - * The PP_FileMapFlags contain flag values for use with Map(). - */ -typedef enum { - /** - * Requests a shared mapping. If this flag is set, changes written to the - * memory region will be reflected in the underlying file and will thus - * eventually be visible to other processes which have opened the file. The - * file may not actually be updated until Unmap() is called. This is only - * valid if the PPB_FileIO resource was opened with write permission. - */ - PP_FILEMAPFLAG_SHARED = 1u << 0, - /** - * Requests a copy-on-write mapping. If this flag is set, changes are not - * written to the underlying file, but only in the memory of the process - * (copy-on-write). - */ - PP_FILEMAPFLAG_PRIVATE = 1u << 1, - /** - * Forces Map() to map the file contents at the provided |address|. If Map() - * can not comply, Map() will fail. - */ - PP_FILEMAPFLAG_FIXED = 1u << 2 -} PP_FileMapFlags; -PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FileMapFlags, 4); -/** - * @} - */ - -/** - * @addtogroup Interfaces - * @{ - */ -/** - * PPB_FileMapping contains functions for mapping and unmapping files into and - * out of memory. - */ -struct PPB_FileMapping_0_1 { /* dev */ - /** - * Map() maps the contents from an offset of the file into memory. - * - * @param[in] instance A <code>PP_Instance</code> identifying one instance of - * a module. - * @param[in] file_io A <code>PPB_FileIO</code> <code>PP_Resource</code> - * corresponding to the file that should be mapped in to memory. - * @param[in] length The number of bytes to map. - * @param[in] map_protection A bitfield containing values from - * <code>PP_FileMapProtection</code>, indicating what memory operations - * should be permitted on the mapped region. - * @param[in] map_flags A bitfield containing values from - * <code>PP_FileMapFlags</code>, providing options for the behavior of Map. - * If the region is to be writeable, then exactly one of - * <code>PP_FILEMAPFLAG_SHARED</code> or <code>PP_FILEMAPFLAG_PRIVATE</code> - * must be set. - * @param[in] offset The offset into the file. Must be a multiple of the - * Map page size as returned by GetMapPageSize(). - * @param[inout] address The value of <code>*address</code>, if non-NULL, - * will be used as a hint to determine where in memory the file should be - * mapped. If the value is NULL, the host operating system will choose - * <code>address</code>. Upon Map() completing, <code>*address</code> will - * contain the actual memory location at which the file was mapped. If the - * plugin provides a non-NULL <code>*address</code>, it must be a multiple of - * the map page size as returned by GetMapPageSize(). - * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon - * completion of Map(). - * - * @return An int32_t containing an error code from <code>pp_errors.h</code>. - */ - int32_t (*Map)(PP_Instance instance, - PP_Resource file_io, - int64_t length, - uint32_t map_protection, - uint32_t map_flags, - int64_t offset, - void** address, - struct PP_CompletionCallback callback); - /** - * Unmap() deletes the mapping of the specified address. The specified - * address must have been retrieved with Map(). - * @param[in] instance A <code>PP_Instance</code> identifying the instance. - * @param[in] address The starting address of the address in memory to - * be unmapped. - * @param[in] length The length of the region to unmap. - * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon - * completion of Unmap(). - * - * @return An int32_t containing an error code from <code>pp_errors.h</code>. - */ - int32_t (*Unmap)(PP_Instance instance, - const void* address, - int64_t length, - struct PP_CompletionCallback callback); - /** - * GetMapPageSize() retrieves the size of pages that Map() uses. - * - * @param[in] instance A <code>PP_Instance</code> identifying the instance. - * - * @return The size of pages that Map() uses. Returns 0 on failure. - */ - int64_t (*GetMapPageSize)(PP_Instance instance); -}; -/** - * @} - */ - -#endif /* PPAPI_C_PPB_FILE_MAPPING_H_ */ - diff --git a/chromium/ppapi/c/ppb_tcp_socket.h b/chromium/ppapi/c/ppb_tcp_socket.h index a6fe111f71e..64faa362be1 100644 --- a/chromium/ppapi/c/ppb_tcp_socket.h +++ b/chromium/ppapi/c/ppb_tcp_socket.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From ppb_tcp_socket.idl modified Fri Sep 20 09:58:19 2013. */ +/* From ppb_tcp_socket.idl modified Mon Dec 8 16:50:44 2014. */ #ifndef PPAPI_C_PPB_TCP_SOCKET_H_ #define PPAPI_C_PPB_TCP_SOCKET_H_ @@ -18,7 +18,8 @@ #define PPB_TCPSOCKET_INTERFACE_1_0 "PPB_TCPSocket;1.0" #define PPB_TCPSOCKET_INTERFACE_1_1 "PPB_TCPSocket;1.1" -#define PPB_TCPSOCKET_INTERFACE PPB_TCPSOCKET_INTERFACE_1_1 +#define PPB_TCPSOCKET_INTERFACE_1_2 "PPB_TCPSocket;1.2" +#define PPB_TCPSOCKET_INTERFACE PPB_TCPSOCKET_INTERFACE_1_2 /** * @file @@ -37,13 +38,17 @@ typedef enum { /** * Disables coalescing of small writes to make TCP segments, and instead * delivers data immediately. Value's type is <code>PP_VARTYPE_BOOL</code>. - * This option can only be set after a successful <code>Connect()</code> call. + * On version 1.1 or earlier, this option can only be set after a successful + * <code>Connect()</code> call. On version 1.2 or later, there is no such + * limitation. */ PP_TCPSOCKET_OPTION_NO_DELAY = 0, /** * Specifies the total per-socket buffer space reserved for sends. Value's * type should be <code>PP_VARTYPE_INT32</code>. - * This option can only be set after a successful <code>Connect()</code> call. + * On version 1.1 or earlier, this option can only be set after a successful + * <code>Connect()</code> call. On version 1.2 or later, there is no such + * limitation. * * Note: This is only treated as a hint for the browser to set the buffer * size. Even if <code>SetOption()</code> succeeds, the browser doesn't @@ -53,7 +58,9 @@ typedef enum { /** * Specifies the total per-socket buffer space reserved for receives. Value's * type should be <code>PP_VARTYPE_INT32</code>. - * This option can only be set after a successful <code>Connect()</code> call. + * On version 1.1 or earlier, this option can only be set after a successful + * <code>Connect()</code> call. On version 1.2 or later, there is no such + * limitation. * * Note: This is only treated as a hint for the browser to set the buffer * size. Even if <code>SetOption()</code> succeeds, the browser doesn't @@ -79,7 +86,7 @@ PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TCPSocket_Option, 4); * For more details about network communication permissions, please see: * http://developer.chrome.com/apps/app_network.html */ -struct PPB_TCPSocket_1_1 { +struct PPB_TCPSocket_1_2 { /** * Creates a TCP socket resource. * @@ -273,7 +280,7 @@ struct PPB_TCPSocket_1_1 { struct PP_CompletionCallback callback); }; -typedef struct PPB_TCPSocket_1_1 PPB_TCPSocket; +typedef struct PPB_TCPSocket_1_2 PPB_TCPSocket; struct PPB_TCPSocket_1_0 { PP_Resource (*Create)(PP_Instance instance); @@ -297,6 +304,38 @@ struct PPB_TCPSocket_1_0 { struct PP_Var value, struct PP_CompletionCallback callback); }; + +struct PPB_TCPSocket_1_1 { + PP_Resource (*Create)(PP_Instance instance); + PP_Bool (*IsTCPSocket)(PP_Resource resource); + int32_t (*Bind)(PP_Resource tcp_socket, + PP_Resource addr, + struct PP_CompletionCallback callback); + int32_t (*Connect)(PP_Resource tcp_socket, + PP_Resource addr, + struct PP_CompletionCallback callback); + PP_Resource (*GetLocalAddress)(PP_Resource tcp_socket); + PP_Resource (*GetRemoteAddress)(PP_Resource tcp_socket); + int32_t (*Read)(PP_Resource tcp_socket, + char* buffer, + int32_t bytes_to_read, + struct PP_CompletionCallback callback); + int32_t (*Write)(PP_Resource tcp_socket, + const char* buffer, + int32_t bytes_to_write, + struct PP_CompletionCallback callback); + int32_t (*Listen)(PP_Resource tcp_socket, + int32_t backlog, + struct PP_CompletionCallback callback); + int32_t (*Accept)(PP_Resource tcp_socket, + PP_Resource* accepted_tcp_socket, + struct PP_CompletionCallback callback); + void (*Close)(PP_Resource tcp_socket); + int32_t (*SetOption)(PP_Resource tcp_socket, + PP_TCPSocket_Option name, + struct PP_Var value, + struct PP_CompletionCallback callback); +}; /** * @} */ diff --git a/chromium/ppapi/c/ppb_udp_socket.h b/chromium/ppapi/c/ppb_udp_socket.h index 5551c3388f4..d25de17b272 100644 --- a/chromium/ppapi/c/ppb_udp_socket.h +++ b/chromium/ppapi/c/ppb_udp_socket.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From ppb_udp_socket.idl modified Sat Jun 22 10:56:26 2013. */ +/* From ppb_udp_socket.idl modified Mon Mar 2 16:50:15 2015. */ #ifndef PPAPI_C_PPB_UDP_SOCKET_H_ #define PPAPI_C_PPB_UDP_SOCKET_H_ @@ -17,7 +17,9 @@ #include "ppapi/c/pp_var.h" #define PPB_UDPSOCKET_INTERFACE_1_0 "PPB_UDPSocket;1.0" -#define PPB_UDPSOCKET_INTERFACE PPB_UDPSOCKET_INTERFACE_1_0 +#define PPB_UDPSOCKET_INTERFACE_1_1 "PPB_UDPSocket;1.1" +#define PPB_UDPSOCKET_INTERFACE_1_2 "PPB_UDPSocket;1.2" /* dev */ +#define PPB_UDPSOCKET_INTERFACE PPB_UDPSOCKET_INTERFACE_1_1 /** * @file @@ -42,13 +44,16 @@ typedef enum { /** * Allows sending and receiving packets to and from broadcast addresses. * Value's type should be <code>PP_VARTYPE_BOOL</code>. - * This option can only be set before calling <code>Bind()</code>. + * On version 1.0, this option can only be set before calling + * <code>Bind()</code>. On version 1.1 or later, there is no such limitation. */ PP_UDPSOCKET_OPTION_BROADCAST = 1, /** * Specifies the total per-socket buffer space reserved for sends. Value's * type should be <code>PP_VARTYPE_INT32</code>. - * This option can only be set after a successful <code>Bind()</code> call. + * On version 1.0, this option can only be set after a successful + * <code>Bind()</code> call. On version 1.1 or later, there is no such + * limitation. * * Note: This is only treated as a hint for the browser to set the buffer * size. Even if <code>SetOption()</code> succeeds, the browser doesn't @@ -58,13 +63,34 @@ typedef enum { /** * Specifies the total per-socket buffer space reserved for receives. Value's * type should be <code>PP_VARTYPE_INT32</code>. - * This option can only be set after a successful <code>Bind()</code> call. + * On version 1.0, this option can only be set after a successful + * <code>Bind()</code> call. On version 1.1 or later, there is no such + * limitation. * * Note: This is only treated as a hint for the browser to set the buffer * size. Even if <code>SetOption()</code> succeeds, the browser doesn't * guarantee it will conform to the size. */ - PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE = 3 + PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE = 3, + /** + * Specifies whether the packets sent from the host to the multicast group + * should be looped back to the host or not. Value's type should be + * <code>PP_VARTYPE_BOOL</code>. + * This option can only be set before calling <code>Bind()</code>. + * + * This is only supported in version 1.2 of the API (Chrome 43) and later. + */ + PP_UDPSOCKET_OPTION_MULTICAST_LOOP = 4, + /** + * Specifies the time-to-live for packets sent to the multicast group. The + * value should be within 0 to 255 range. The default value is 1 and means + * that packets will not be routed beyond the local network. Value's type + * should be <code>PP_VARTYPE_INT32</code>. + * This option can only be set before calling <code>Bind()</code>. + * + * This is only supported in version 1.2 of the API (Chrome 43) and later. + */ + PP_UDPSOCKET_OPTION_MULTICAST_TTL = 5 } PP_UDPSocket_Option; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_UDPSocket_Option, 4); /** @@ -84,7 +110,7 @@ PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_UDPSocket_Option, 4); * For more details about network communication permissions, please see: * http://developer.chrome.com/apps/app_network.html */ -struct PPB_UDPSocket_1_0 { +struct PPB_UDPSocket_1_2 { /* dev */ /** * Creates a UDP socket resource. * @@ -168,6 +194,9 @@ struct PPB_UDPSocket_1_0 { * been sent; otherwise, an error code from <code>pp_errors.h</code>. * <code>PP_ERROR_NOACCESS</code> will be returned if the caller doesn't have * required permissions. + * <code>PP_ERROR_INPROGRESS</code> will be returned if the socket is busy + * sending. The caller should wait until a pending send completes before + * retrying. */ int32_t (*SendTo)(PP_Resource udp_socket, const char* buffer, @@ -206,9 +235,89 @@ struct PPB_UDPSocket_1_0 { PP_UDPSocket_Option name, struct PP_Var value, struct PP_CompletionCallback callback); + /** + * Joins the multicast group with address specified by <code>group</code> + * parameter, which is expected to be a <code>PPB_NetAddress</code> object. + * + * @param[in] udp_socket A <code>PP_Resource</code> corresponding to a UDP + * socket. + * @param[in] group A <code>PP_Resource</code> corresponding to the network + * address of the multicast group. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + */ + int32_t (*JoinGroup)(PP_Resource udp_socket, + PP_Resource group, + struct PP_CompletionCallback callback); + /** + * Leaves the multicast group with address specified by <code>group</code> + * parameter, which is expected to be a <code>PPB_NetAddress</code> object. + * + * @param[in] udp_socket A <code>PP_Resource</code> corresponding to a UDP + * socket. + * @param[in] group A <code>PP_Resource</code> corresponding to the network + * address of the multicast group. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + */ + int32_t (*LeaveGroup)(PP_Resource udp_socket, + PP_Resource group, + struct PP_CompletionCallback callback); +}; + +struct PPB_UDPSocket_1_0 { + PP_Resource (*Create)(PP_Instance instance); + PP_Bool (*IsUDPSocket)(PP_Resource resource); + int32_t (*Bind)(PP_Resource udp_socket, + PP_Resource addr, + struct PP_CompletionCallback callback); + PP_Resource (*GetBoundAddress)(PP_Resource udp_socket); + int32_t (*RecvFrom)(PP_Resource udp_socket, + char* buffer, + int32_t num_bytes, + PP_Resource* addr, + struct PP_CompletionCallback callback); + int32_t (*SendTo)(PP_Resource udp_socket, + const char* buffer, + int32_t num_bytes, + PP_Resource addr, + struct PP_CompletionCallback callback); + void (*Close)(PP_Resource udp_socket); + int32_t (*SetOption)(PP_Resource udp_socket, + PP_UDPSocket_Option name, + struct PP_Var value, + struct PP_CompletionCallback callback); +}; + +struct PPB_UDPSocket_1_1 { + PP_Resource (*Create)(PP_Instance instance); + PP_Bool (*IsUDPSocket)(PP_Resource resource); + int32_t (*Bind)(PP_Resource udp_socket, + PP_Resource addr, + struct PP_CompletionCallback callback); + PP_Resource (*GetBoundAddress)(PP_Resource udp_socket); + int32_t (*RecvFrom)(PP_Resource udp_socket, + char* buffer, + int32_t num_bytes, + PP_Resource* addr, + struct PP_CompletionCallback callback); + int32_t (*SendTo)(PP_Resource udp_socket, + const char* buffer, + int32_t num_bytes, + PP_Resource addr, + struct PP_CompletionCallback callback); + void (*Close)(PP_Resource udp_socket); + int32_t (*SetOption)(PP_Resource udp_socket, + PP_UDPSocket_Option name, + struct PP_Var value, + struct PP_CompletionCallback callback); }; -typedef struct PPB_UDPSocket_1_0 PPB_UDPSocket; +typedef struct PPB_UDPSocket_1_1 PPB_UDPSocket; /** * @} */ diff --git a/chromium/ppapi/c/ppb_video_encoder.h b/chromium/ppapi/c/ppb_video_encoder.h new file mode 100644 index 00000000000..0b3ceb01838 --- /dev/null +++ b/chromium/ppapi/c/ppb_video_encoder.h @@ -0,0 +1,278 @@ +/* Copyright 2015 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* From ppb_video_encoder.idl modified Tue May 5 23:37:20 2015. */ + +#ifndef PPAPI_C_PPB_VIDEO_ENCODER_H_ +#define PPAPI_C_PPB_VIDEO_ENCODER_H_ + +#include "ppapi/c/pp_array_output.h" +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_codecs.h" +#include "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_macros.h" +#include "ppapi/c/pp_resource.h" +#include "ppapi/c/pp_size.h" +#include "ppapi/c/pp_stdint.h" +#include "ppapi/c/ppb_video_frame.h" + +#define PPB_VIDEOENCODER_INTERFACE_0_1 "PPB_VideoEncoder;0.1" /* dev */ +#define PPB_VIDEOENCODER_INTERFACE_0_2 "PPB_VideoEncoder;0.2" /* dev */ +/** + * @file + * This file defines the <code>PPB_VideoEncoder</code> interface. + */ + + +/** + * @addtogroup Interfaces + * @{ + */ +/** + * Video encoder interface. + * + * Typical usage: + * - Call Create() to create a new video encoder resource. + * - Call GetSupportedFormats() to determine which codecs and profiles are + * available. + * - Call Initialize() to initialize the encoder for a supported profile. + * - Call GetVideoFrame() to get a blank frame and fill it in, or get a video + * frame from another resource, e.g. <code>PPB_MediaStreamVideoTrack</code>. + * - Call Encode() to push the video frame to the encoder. If an external frame + * is pushed, wait for completion to recycle the frame. + * - Call GetBitstreamBuffer() continuously (waiting for each previous call to + * complete) to pull encoded pictures from the encoder. + * - Call RecycleBitstreamBuffer() after consuming the data in the bitstream + * buffer. + * - To destroy the encoder, the plugin should release all of its references to + * it. Any pending callbacks will abort before the encoder is destroyed. + * + * Available video codecs vary by platform. + * All: vp8 (software). + * ChromeOS, depending on your device: h264 (hardware), vp8 (hardware) + */ +struct PPB_VideoEncoder_0_2 { /* dev */ + /** + * Creates a new video encoder resource. + * + * @param[in] instance A <code>PP_Instance</code> identifying the instance + * with the video encoder. + * + * @return A <code>PP_Resource</code> corresponding to a video encoder if + * successful or 0 otherwise. + */ + PP_Resource (*Create)(PP_Instance instance); + /** + * Determines if the given resource is a video encoder. + * + * @param[in] resource A <code>PP_Resource</code> identifying a resource. + * + * @return <code>PP_TRUE</code> if the resource is a + * <code>PPB_VideoEncoder</code>, <code>PP_FALSE</code> if the resource is + * invalid or some other type. + */ + PP_Bool (*IsVideoEncoder)(PP_Resource resource); + /** + * Gets an array of supported video encoder profiles. + * These can be used to choose a profile before calling Initialize(). + * + * @param[in] video_encoder A <code>PP_Resource</code> identifying the video + * encoder. + * @param[in] output A <code>PP_ArrayOutput</code> to receive the supported + * <code>PP_VideoProfileDescription</code> structs. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. + * + * @return If >= 0, the number of supported profiles returned, otherwise an + * error code from <code>pp_errors.h</code>. + */ + int32_t (*GetSupportedProfiles)(PP_Resource video_encoder, + struct PP_ArrayOutput output, + struct PP_CompletionCallback callback); + /** + * Initializes a video encoder resource. The plugin should call Initialize() + * successfully before calling any of the functions below. + * + * @param[in] video_encoder A <code>PP_Resource</code> identifying the video + * encoder. + * @param[in] input_format The <code>PP_VideoFrame_Format</code> of the + * frames which will be encoded. + * @param[in] input_visible_size A <code>PP_Size</code> specifying the + * dimensions of the visible part of the input frames. + * @param[in] output_profile A <code>PP_VideoProfile</code> specifying the + * codec profile of the encoded output stream. + * @param[in] acceleration A <code>PP_HardwareAcceleration</code> specifying + * whether to use a hardware accelerated or a software implementation. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + * Returns PP_ERROR_NOTSUPPORTED if video encoding is not available, or the + * requested codec profile is not supported. + */ + int32_t (*Initialize)(PP_Resource video_encoder, + PP_VideoFrame_Format input_format, + const struct PP_Size* input_visible_size, + PP_VideoProfile output_profile, + uint32_t initial_bitrate, + PP_HardwareAcceleration acceleration, + struct PP_CompletionCallback callback); + /** + * Gets the number of input video frames that the encoder may hold while + * encoding. If the plugin is providing the video frames, it should have at + * least this many available. + * + * @param[in] video_encoder A <code>PP_Resource</code> identifying the video + * encoder. + * @return An int32_t containing the number of frames required, or an error + * code from <code>pp_errors.h</code>. + * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. + */ + int32_t (*GetFramesRequired)(PP_Resource video_encoder); + /** + * Gets the coded size of the video frames required by the encoder. Coded + * size is the logical size of the input frames, in pixels. The encoder may + * have hardware alignment requirements that make this different from + * |input_visible_size|, as requested in the call to Initialize(). + * + * @param[in] video_encoder A <code>PP_Resource</code> identifying the video + * encoder. + * @param[in] coded_size A <code>PP_Size</code> to hold the coded size. + * @return An int32_t containing a result code from <code>pp_errors.h</code>. + * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. + */ + int32_t (*GetFrameCodedSize)(PP_Resource video_encoder, + struct PP_Size* coded_size); + /** + * Gets a blank video frame which can be filled with video data and passed + * to the encoder. + * + * @param[in] video_encoder A <code>PP_Resource</code> identifying the video + * encoder. + * @param[out] video_frame A blank <code>PPB_VideoFrame</code> resource. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. + */ + int32_t (*GetVideoFrame)(PP_Resource video_encoder, + PP_Resource* video_frame, + struct PP_CompletionCallback callback); + /** + * Encodes a video frame. + * + * @param[in] video_encoder A <code>PP_Resource</code> identifying the video + * encoder. + * @param[in] video_frame The <code>PPB_VideoFrame</code> to be encoded. + * @param[in] force_keyframe A <code>PP_Bool> specifying whether the encoder + * should emit a key frame for this video frame. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. Plugins that pass <code>PPB_VideoFrame</code> resources owned + * by other resources should wait for completion before reusing them. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. + */ + int32_t (*Encode)(PP_Resource video_encoder, + PP_Resource video_frame, + PP_Bool force_keyframe, + struct PP_CompletionCallback callback); + /** + * Gets the next encoded bitstream buffer from the encoder. + * + * @param[in] video_encoder A <code>PP_Resource</code> identifying the video + * encoder. + * @param[out] bitstream_buffer A <code>PP_BitstreamBuffer</code> containing + * encoded video data. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. The plugin can call GetBitstreamBuffer from the callback in + * order to continuously "pull" bitstream buffers from the encoder. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. + * Returns PP_ERROR_INPROGRESS if a prior call to GetBitstreamBuffer() has + * not completed. + */ + int32_t (*GetBitstreamBuffer)(PP_Resource video_encoder, + struct PP_BitstreamBuffer* bitstream_buffer, + struct PP_CompletionCallback callback); + /** + * Recycles a bitstream buffer back to the encoder. + * + * @param[in] video_encoder A <code>PP_Resource</code> identifying the video + * encoder. + * @param[in] bitstream_buffer A <code>PP_BitstreamBuffer</code> that is no + * longer needed by the plugin. + */ + void (*RecycleBitstreamBuffer)( + PP_Resource video_encoder, + const struct PP_BitstreamBuffer* bitstream_buffer); + /** + * Requests a change to encoding parameters. This is only a request, + * fulfilled on a best-effort basis. + * + * @param[in] video_encoder A <code>PP_Resource</code> identifying the video + * encoder. + * @param[in] bitrate The requested new bitrate, in bits per second. + * @param[in] framerate The requested new framerate, in frames per second. + */ + void (*RequestEncodingParametersChange)(PP_Resource video_encoder, + uint32_t bitrate, + uint32_t framerate); + /** + * Closes the video encoder, and cancels any pending encodes. Any pending + * callbacks will still run, reporting <code>PP_ERROR_ABORTED</code> . It is + * not valid to call any encoder functions after a call to this method. + * <strong>Note:</strong> Destroying the video encoder closes it implicitly, + * so you are not required to call Close(). + * + * @param[in] video_encoder A <code>PP_Resource</code> identifying the video + * encoder. + */ + void (*Close)(PP_Resource video_encoder); +}; + +struct PPB_VideoEncoder_0_1 { /* dev */ + PP_Resource (*Create)(PP_Instance instance); + PP_Bool (*IsVideoEncoder)(PP_Resource resource); + int32_t (*GetSupportedProfiles)(PP_Resource video_encoder, + struct PP_ArrayOutput output, + struct PP_CompletionCallback callback); + int32_t (*Initialize)(PP_Resource video_encoder, + PP_VideoFrame_Format input_format, + const struct PP_Size* input_visible_size, + PP_VideoProfile output_profile, + uint32_t initial_bitrate, + PP_HardwareAcceleration acceleration, + struct PP_CompletionCallback callback); + int32_t (*GetFramesRequired)(PP_Resource video_encoder); + int32_t (*GetFrameCodedSize)(PP_Resource video_encoder, + struct PP_Size* coded_size); + int32_t (*GetVideoFrame)(PP_Resource video_encoder, + PP_Resource* video_frame, + struct PP_CompletionCallback callback); + int32_t (*Encode)(PP_Resource video_encoder, + PP_Resource video_frame, + PP_Bool force_keyframe, + struct PP_CompletionCallback callback); + int32_t (*GetBitstreamBuffer)(PP_Resource video_encoder, + struct PP_BitstreamBuffer* bitstream_buffer, + struct PP_CompletionCallback callback); + void (*RecycleBitstreamBuffer)( + PP_Resource video_encoder, + const struct PP_BitstreamBuffer* bitstream_buffer); + void (*RequestEncodingParametersChange)(PP_Resource video_encoder, + uint32_t bitrate, + uint32_t framerate); + void (*Close)(PP_Resource video_encoder); +}; +/** + * @} + */ + +#endif /* PPAPI_C_PPB_VIDEO_ENCODER_H_ */ + diff --git a/chromium/ppapi/c/private/pp_content_decryptor.h b/chromium/ppapi/c/private/pp_content_decryptor.h index 971d2a0b619..3151fc31e24 100644 --- a/chromium/ppapi/c/private/pp_content_decryptor.h +++ b/chromium/ppapi/c/private/pp_content_decryptor.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From private/pp_content_decryptor.idl modified Thu Jun 5 13:39:15 2014. */ +/* From private/pp_content_decryptor.idl modified Thu Mar 19 16:04:42 2015. */ #ifndef PPAPI_C_PRIVATE_PP_CONTENT_DECRYPTOR_H_ #define PPAPI_C_PRIVATE_PP_CONTENT_DECRYPTOR_H_ @@ -455,11 +455,22 @@ PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_DecryptorStreamType, 4); */ typedef enum { PP_SESSIONTYPE_TEMPORARY = 0, - PP_SESSIONTYPE_PERSISTENT = 1 + PP_SESSIONTYPE_PERSISTENT_LICENSE = 1, + PP_SESSIONTYPE_PERSISTENT_RELEASE = 2 } PP_SessionType; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_SessionType, 4); /** + * <code>PP_InitDataType</code> contains Initialization Data Type constants. + */ +typedef enum { + PP_INITDATATYPE_CENC = 0, + PP_INITDATATYPE_KEYIDS = 1, + PP_INITDATATYPE_WEBM = 2 +} PP_InitDataType; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InitDataType, 4); + +/** * <code>PP_CdmExceptionCode</code> contains exception code constants. */ typedef enum { @@ -472,6 +483,57 @@ typedef enum { PP_CDMEXCEPTIONCODE_OUTPUTERROR = 7 } PP_CdmExceptionCode; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_CdmExceptionCode, 4); + +/** + * <code>PP_CdmMessageType</code> contains message type constants. + */ +typedef enum { + PP_CDMMESSAGETYPE_LICENSE_REQUEST = 0, + PP_CDMMESSAGETYPE_LICENSE_RENEWAL = 1, + PP_CDMMESSAGETYPE_LICENSE_RELEASE = 2 +} PP_CdmMessageType; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_CdmMessageType, 4); + +/** + * <code>PP_CdmKeyStatus</code> contains key status constants. + */ +typedef enum { + PP_CDMKEYSTATUS_USABLE = 0, + PP_CDMKEYSTATUS_INVALID = 1, + PP_CDMKEYSTATUS_EXPIRED = 2, + PP_CDMKEYSTATUS_OUTPUTNOTALLOWED = 3, + PP_CDMKEYSTATUS_OUTPUTDOWNSCALED = 4, + PP_CDMKEYSTATUS_STATUSPENDING = 5 +} PP_CdmKeyStatus; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_CdmKeyStatus, 4); +/** + * @} + */ + +/** + * @addtogroup Structs + * @{ + */ +/** + * The <code>PP_KeyInformation</code> struct contains information about a + * key used for decryption. + */ +struct PP_KeyInformation { + /** + * Key ID. + */ + uint8_t key_id[512]; + uint32_t key_id_size; + /** + * Status of this key. + */ + PP_CdmKeyStatus key_status; + /** + * Optional error code for keys that are not usable. + */ + uint32_t system_code; +}; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_KeyInformation, 524); /** * @} */ diff --git a/chromium/ppapi/c/private/pp_video_capture_format.h b/chromium/ppapi/c/private/pp_video_capture_format.h new file mode 100644 index 00000000000..4df9cba4e06 --- /dev/null +++ b/chromium/ppapi/c/private/pp_video_capture_format.h @@ -0,0 +1,47 @@ +/* Copyright 2015 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* From private/pp_video_capture_format.idl, + * modified Wed Feb 18 01:41:26 2015. + */ + +#ifndef PPAPI_C_PRIVATE_PP_VIDEO_CAPTURE_FORMAT_H_ +#define PPAPI_C_PRIVATE_PP_VIDEO_CAPTURE_FORMAT_H_ + +#include "ppapi/c/pp_macros.h" +#include "ppapi/c/pp_size.h" +#include "ppapi/c/pp_stdint.h" + +/** + * @file + * This file defines the struct used to hold a video capture format. + */ + + +/** + * @addtogroup Structs + * @{ + */ +/** + * The <code>PP_VideoCaptureFormat</code> struct represents a video capture + * format. + */ +struct PP_VideoCaptureFormat { + /** + * Frame size in pixels. + */ + struct PP_Size frame_size; + /** + * Frame rate in frames per second. + */ + float frame_rate; +}; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoCaptureFormat, 12); +/** + * @} + */ + +#endif /* PPAPI_C_PRIVATE_PP_VIDEO_CAPTURE_FORMAT_H_ */ + diff --git a/chromium/ppapi/c/private/ppb_camera_capabilities_private.h b/chromium/ppapi/c/private/ppb_camera_capabilities_private.h index c5c17d6ebba..269cd7a5c29 100644 --- a/chromium/ppapi/c/private/ppb_camera_capabilities_private.h +++ b/chromium/ppapi/c/private/ppb_camera_capabilities_private.h @@ -4,18 +4,18 @@ */ /* From private/ppb_camera_capabilities_private.idl, - * modified Fri Aug 22 11:08:14 2014. + * modified Thu Feb 19 09:06:18 2015. */ #ifndef PPAPI_C_PRIVATE_PPB_CAMERA_CAPABILITIES_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_CAMERA_CAPABILITIES_PRIVATE_H_ #include "ppapi/c/pp_bool.h" -#include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" +#include "ppapi/c/private/pp_video_capture_format.h" #define PPB_CAMERACAPABILITIES_PRIVATE_INTERFACE_0_1 \ "PPB_CameraCapabilities_Private;0.1" @@ -40,16 +40,6 @@ */ struct PPB_CameraCapabilities_Private_0_1 { /** - * Creates a PPB_CameraCapabilities_Private resource. - * - * @param[in] instance A <code>PP_Instance</code> identifying one instance of - * a module. - * - * @return A <code>PP_Resource</code> corresponding to a - * PPB_CameraCapabilities_Private resource if successful, 0 if failed. - */ - PP_Resource (*Create)(PP_Instance instance); - /** * IsCameraCapabilities() determines if the given resource is a * <code>PPB_CameraCapabilities_Private</code>. * @@ -62,38 +52,22 @@ struct PPB_CameraCapabilities_Private_0_1 { */ PP_Bool (*IsCameraCapabilities)(PP_Resource resource); /** - * GetSupportedPreviewSizes() returns the supported preview sizes for the - * given <code>PPB_CameraCapabilities_Private</code>. + * GetSupportedVideoCaptureFormats() returns the supported video capture + * formats for the given <code>PPB_CameraCapabilities_Private</code>. * * @param[in] capabilities A <code>PP_Resource</code> corresponding to an * image capture capabilities resource. * @param[out] array_size The size of preview size array. - * @param[out] preview_sizes An array of <code>PP_Size</code> corresponding - * to the supported preview sizes in pixels. The ownership of the array - * belongs to <code>PPB_CameraCapabilities_Private</code> and the caller - * should not free it. When a PPB_CameraCapabilities_Private is deleted, - * the array returning from this is no longer valid. - */ - void (*GetSupportedPreviewSizes)(PP_Resource capabilities, - int32_t* array_size, - struct PP_Size** preview_sizes); - /** - * GetSupportedJpegSize() returns the supported JPEG sizes for the given - * <code>PPB_CameraCapabilities_Private</code>. - * - * @param[in] capabilities A <code>PP_Resource</code> corresponding to an - * image capture capabilities resource. - * @param[out] array_size The size of JPEG size array. If the output of this - * is 0, the camera has no support for generating JPEG images. - * @param[out] jpeg_sizes An array of <code>PP_Size</code> corresponding to - * the supported JPEG image sizes in pixels. The ownership of the array - * belongs to <code>PPB_CameraCapabilities_Private</code> and the caller + * @param[out] formats An array of <code>PP_VideoCaptureFormat</code> + * corresponding to the supported video capture formats. The ownership of the + * array belongs to <code>PPB_CameraCapabilities_Private</code> and the caller * should not free it. When a PPB_CameraCapabilities_Private is deleted, the * array returning from this is no longer valid. */ - void (*GetSupportedJpegSizes)(PP_Resource capabilities, - int32_t* array_size, - struct PP_Size** jpeg_sizes); + void (*GetSupportedVideoCaptureFormats)( + PP_Resource capabilities, + uint32_t* array_size, + struct PP_VideoCaptureFormat** formats); }; typedef struct PPB_CameraCapabilities_Private_0_1 diff --git a/chromium/ppapi/c/private/ppb_camera_device_private.h b/chromium/ppapi/c/private/ppb_camera_device_private.h new file mode 100644 index 00000000000..821ad299db9 --- /dev/null +++ b/chromium/ppapi/c/private/ppb_camera_device_private.h @@ -0,0 +1,118 @@ +/* Copyright 2014 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* From private/ppb_camera_device_private.idl, + * modified Fri Feb 20 13:48:52 2015. + */ + +#ifndef PPAPI_C_PRIVATE_PPB_CAMERA_DEVICE_PRIVATE_H_ +#define PPAPI_C_PRIVATE_PPB_CAMERA_DEVICE_PRIVATE_H_ + +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_macros.h" +#include "ppapi/c/pp_resource.h" +#include "ppapi/c/pp_stdint.h" +#include "ppapi/c/pp_var.h" + +#define PPB_CAMERADEVICE_PRIVATE_INTERFACE_0_1 "PPB_CameraDevice_Private;0.1" +#define PPB_CAMERADEVICE_PRIVATE_INTERFACE \ + PPB_CAMERADEVICE_PRIVATE_INTERFACE_0_1 + +/** + * @file + * Defines the <code>PPB_CameraDevice_Private</code> interface. Used for + * manipulating a camera device. + */ + + +/** + * @addtogroup Interfaces + * @{ + */ +/** + * To query camera capabilities: + * 1. Get a PPB_CameraDevice_Private object by Create(). + * 2. Open() camera device with track id of MediaStream video track. + * 3. Call GetCameraCapabilities() to get a + * <code>PPB_CameraCapabilities_Private</code> object, which can be used to + * query camera capabilities. + */ +struct PPB_CameraDevice_Private_0_1 { + /** + * Creates a PPB_CameraDevice_Private resource. + * + * @param[in] instance A <code>PP_Instance</code> identifying one instance + * of a module. + * + * @return A <code>PP_Resource</code> corresponding to a + * PPB_CameraDevice_Private resource if successful, 0 if failed. + */ + PP_Resource (*Create)(PP_Instance instance); + /** + * Determines if a resource is a camera device resource. + * + * @param[in] resource The <code>PP_Resource</code> to test. + * + * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given + * resource is a camera device resource or <code>PP_FALSE</code> + * otherwise. + */ + PP_Bool (*IsCameraDevice)(PP_Resource resource); + /** + * Opens a camera device. + * + * @param[in] camera_device A <code>PP_Resource</code> corresponding to a + * camera device resource. + * @param[in] device_id A <code>PP_Var</code> identifying a camera device. The + * type is string. The ID can be obtained from MediaStreamTrack.getSources() + * or MediaStreamVideoTrack.id. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion of <code>Open()</code>. + * + * @return An error code from <code>pp_errors.h</code>. + */ + int32_t (*Open)(PP_Resource camera_device, + struct PP_Var device_id, + struct PP_CompletionCallback callback); + /** + * Disconnects from the camera and cancels all pending requests. + * After this returns, no callbacks will be called. If <code> + * PPB_CameraDevice_Private</code> is destroyed and is not closed yet, this + * function will be automatically called. Calling this more than once has no + * effect. + * + * @param[in] camera_device A <code>PP_Resource</code> corresponding to a + * camera device resource. + */ + void (*Close)(PP_Resource camera_device); + /** + * Gets the camera capabilities. + * + * The camera capabilities do not change for a given camera source. + * + * @param[in] camera_device A <code>PP_Resource</code> corresponding to a + * camera device resource. + * @param[out] capabilities A <code>PPB_CameraCapabilities_Private</code> for + * storing the camera capabilities on success. Otherwise, the value will not + * be changed. + * @param[in] callback <code>PP_CompletionCallback</code> to be called upon + * completion of <code>GetCameraCapabilities()</code>. + * + * @return An int32_t containing a result code from <code>pp_errors.h</code>. + */ + int32_t (*GetCameraCapabilities)(PP_Resource camera_device, + PP_Resource* capabilities, + struct PP_CompletionCallback callback); +}; + +typedef struct PPB_CameraDevice_Private_0_1 PPB_CameraDevice_Private; +/** + * @} + */ + +#endif /* PPAPI_C_PRIVATE_PPB_CAMERA_DEVICE_PRIVATE_H_ */ + diff --git a/chromium/ppapi/c/private/ppb_content_decryptor_private.h b/chromium/ppapi/c/private/ppb_content_decryptor_private.h index 566580606c9..e5493fa57a0 100644 --- a/chromium/ppapi/c/private/ppb_content_decryptor_private.h +++ b/chromium/ppapi/c/private/ppb_content_decryptor_private.h @@ -4,7 +4,7 @@ */ /* From private/ppb_content_decryptor_private.idl, - * modified Mon Aug 25 13:52:39 2014. + * modified Mon Mar 30 22:35:33 2015. */ #ifndef PPAPI_C_PRIVATE_PPB_CONTENT_DECRYPTOR_PRIVATE_H_ @@ -19,10 +19,10 @@ #include "ppapi/c/pp_var.h" #include "ppapi/c/private/pp_content_decryptor.h" -#define PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_12 \ - "PPB_ContentDecryptor_Private;0.12" +#define PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_14 \ + "PPB_ContentDecryptor_Private;0.14" #define PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE \ - PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_12 + PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_14 /** * @file @@ -43,7 +43,7 @@ * browser side support for the Content Decryption Module (CDM) for Encrypted * Media Extensions: http://www.w3.org/TR/encrypted-media/ */ -struct PPB_ContentDecryptor_Private_0_12 { +struct PPB_ContentDecryptor_Private_0_14 { /** * A promise has been resolved by the CDM. * @@ -55,24 +55,12 @@ struct PPB_ContentDecryptor_Private_0_12 { * * @param[in] promise_id Identifies the promise that the CDM resolved. * - * @param[in] web_session_id A <code>PP_Var</code> of type + * @param[in] session_id A <code>PP_Var</code> of type * <code>PP_VARTYPE_STRING</code> containing the session's ID attribute. */ void (*PromiseResolvedWithSession)(PP_Instance instance, uint32_t promise_id, - struct PP_Var web_session_id); - /** - * A promise that returns a set of key IDs has been resolved by the CDM. - * - * @param[in] promise_id Identifies the promise that the CDM resolved. - * - * @param[in] key_ids A <code>PP_Var</code> of type - * <code>PP_VARTYPE_ARRAY</code> containing elements of type - * <code>PP_VARTYPE_ARRAYBUFFER</code> that are the session's usable key IDs. - */ - void (*PromiseResolvedWithKeyIds)(PP_Instance instance, - uint32_t promise_id, - struct PP_Var key_ids_array); + struct PP_Var session_id); /** * A promise has been rejected by the CDM due to an error. * @@ -105,38 +93,50 @@ struct PPB_ContentDecryptor_Private_0_12 { * of <code>UpdateSession()</code> and <code>SessionMessage()</code> calls * required to prepare for decryption. * - * @param[in] web_session_id A <code>PP_Var</code> of type + * @param[in] session_id A <code>PP_Var</code> of type * <code>PP_VARTYPE_STRING</code> containing the ID of a session for * which this message is intended. * + * @param[in] message_type A <code>PP_CdmMessageType</code> containing the + * message type. + * * @param[in] message A <code>PP_Var</code> of type * <code>PP_VARTYPE_ARRAY_BUFFER</code> that contains the message. * - * @param[in] destination_url A <code>PP_Var</code> of type + * @param[in] legacy_destination_url A <code>PP_Var</code> of type * <code>PP_VARTYPE_STRING</code> containing the destination URL for the * message. */ void (*SessionMessage)(PP_Instance instance, - struct PP_Var web_session_id, + struct PP_Var session_id, + PP_CdmMessageType message_type, struct PP_Var message, - struct PP_Var destination_url); + struct PP_Var legacy_destination_url); /** * The keys for a session have changed. * - * @param[in] web_session_id A <code>PP_Var</code> of type + * @param[in] session_id A <code>PP_Var</code> of type * <code>PP_VARTYPE_STRING</code> containing the ID of the session that has * a change in keys. * * @param[in] has_additional_usable_key A <code>PP_Bool</code> indicating if * a new usable key has been added. + * + * @param[in] key_count The number of arguments contained in + * <code>key_information</code> + * + * @param[in] key_information An array of type <code>PP_KeyInformation</code> + * that are the session's key IDs and their status. */ void (*SessionKeysChange)(PP_Instance instance, - struct PP_Var web_session_id, - PP_Bool has_additional_usable_key); + struct PP_Var session_id, + PP_Bool has_additional_usable_key, + uint32_t key_count, + const struct PP_KeyInformation key_information[]); /** * The expiration time for a session has changed. * - * @param[in] web_session_id A <code>PP_Var</code> of type + * @param[in] session_id A <code>PP_Var</code> of type * <code>PP_VARTYPE_STRING</code> containing the ID of the session that has * a new expiration time. * @@ -145,41 +145,24 @@ struct PPB_ContentDecryptor_Private_0_12 { * since the Epoch (00:00:00 UTC, January 1, 1970). */ void (*SessionExpirationChange)(PP_Instance instance, - struct PP_Var web_session_id, + struct PP_Var session_id, PP_Time new_expiry_time); /** - * The session is now ready to decrypt the media stream. - * - * Note: The above describes the most simple case. Depending on the key - * system, a series of <code>SessionMessage()</code> calls from the CDM will - * be sent to the browser, and then on to the web application. The web - * application must then provide more data to the CDM by directing the browser - * to pass the data to the CDM via calls to <code>UpdateSession()</code> on - * the <code>PPP_ContentDecryptor_Private</code> interface. - * The CDM must call <code>SessionReady()</code> when the sequence is - * completed, and, in response, the browser must notify the web application. - * - * @param[in] web_session_id A <code>PP_Var</code> of type - * <code>PP_VARTYPE_STRING</code> containing the session's ID attribute of - * the session that is now ready. - */ - void (*SessionReady)(PP_Instance instance, struct PP_Var web_session_id); - /** * The session has been closed as the result of a call to the * <code>ReleaseSession()</code> method on the * <code>PPP_ContentDecryptor_Private</code> interface, or due to other * factors as determined by the CDM. * - * @param[in] web_session_id A <code>PP_Var</code> of type + * @param[in] session_id A <code>PP_Var</code> of type * <code>PP_VARTYPE_STRING</code> containing the session's ID attribute of * the session that is now closed. */ - void (*SessionClosed)(PP_Instance instance, struct PP_Var web_session_id); + void (*SessionClosed)(PP_Instance instance, struct PP_Var session_id); /** * An error occurred in a <code>PPP_ContentDecryptor_Private</code> method, * or within the plugin implementing the interface. * - * @param[in] web_session_id A <code>PP_Var</code> of type + * @param[in] session_id A <code>PP_Var</code> of type * <code>PP_VARTYPE_STRING</code> containing the session's ID attribute of * the session that caused the error. * @@ -191,11 +174,11 @@ struct PPB_ContentDecryptor_Private_0_12 { * @param[in] error_description A <code>PP_Var</code> of type * <code>PP_VARTYPE_STRING</code> containing the error description. */ - void (*SessionError)(PP_Instance instance, - struct PP_Var web_session_id, - PP_CdmExceptionCode exception_code, - uint32_t system_code, - struct PP_Var error_description); + void (*LegacySessionError)(PP_Instance instance, + struct PP_Var session_id, + PP_CdmExceptionCode exception_code, + uint32_t system_code, + struct PP_Var error_description); /** * Called after the <code>Decrypt()</code> method on the * <code>PPP_ContentDecryptor_Private</code> interface completes to @@ -325,7 +308,7 @@ struct PPB_ContentDecryptor_Private_0_12 { const struct PP_DecryptedSampleInfo* decrypted_sample_info); }; -typedef struct PPB_ContentDecryptor_Private_0_12 PPB_ContentDecryptor_Private; +typedef struct PPB_ContentDecryptor_Private_0_14 PPB_ContentDecryptor_Private; /** * @} */ diff --git a/chromium/ppapi/c/private/ppb_image_capture_config_private.h b/chromium/ppapi/c/private/ppb_image_capture_config_private.h deleted file mode 100644 index 3788b67efc3..00000000000 --- a/chromium/ppapi/c/private/ppb_image_capture_config_private.h +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright 2014 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* From private/ppb_image_capture_config_private.idl, - * modified Wed Aug 13 17:43:55 2014. - */ - -#ifndef PPAPI_C_PRIVATE_PPB_IMAGE_CAPTURE_CONFIG_PRIVATE_H_ -#define PPAPI_C_PRIVATE_PPB_IMAGE_CAPTURE_CONFIG_PRIVATE_H_ - -#include "ppapi/c/pp_bool.h" -#include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_macros.h" -#include "ppapi/c/pp_resource.h" -#include "ppapi/c/pp_size.h" -#include "ppapi/c/pp_stdint.h" - -#define PPB_IMAGECAPTURECONFIG_PRIVATE_INTERFACE_0_1 \ - "PPB_ImageCaptureConfig_Private;0.1" -#define PPB_IMAGECAPTURECONFIG_PRIVATE_INTERFACE \ - PPB_IMAGECAPTURECONFIG_PRIVATE_INTERFACE_0_1 - -/** - * @file - * This file defines the PPB_ImageCaptureConfig_Private interface for - * establishing an image capture configuration resource within the browser. - */ - - -/** - * @addtogroup Interfaces - * @{ - */ -/** - * The <code>PPB_ImageCaptureConfig_Private</code> interface contains pointers - * to several functions for establishing image capture configuration within the - * browser. The new configuration will take effect after <code> - * PPB_ImageCapture_Private.SetConfig</code> is called. - */ -struct PPB_ImageCaptureConfig_Private_0_1 { - /** - * Creates a PPB_ImageCaptureConfig_Private resource. - * - * @param[in] instance A <code>PP_Instance</code> identifying one instance of - * a module. - * - * @return A <code>PP_Resource</code> corresponding to a - * PPB_ImageCaptureConfig_Private resource if successful, 0 if failed. - */ - PP_Resource (*Create)(PP_Instance instance); - /** - * IsImageCaptureConfig() determines if the given resource is a - * <code>PPB_ImageCaptureConfig_Private</code>. - * - * @param[in] resource A <code>PP_Resource</code> corresponding to an image - * capture config resource. - * - * @return A <code>PP_Bool</code> containing <code>PP_TRUE</code> if the given - * resource is an <code>ImageCaptureConfig_Private</code> resource, otherwise - * <code>PP_FALSE</code>. - */ - PP_Bool (*IsImageCaptureConfig)(PP_Resource resource); - /** - * GetPreviewSize() returns the preview image size in pixels for the given - * <code>PPB_ImageCaptureConfig_Private</code>. - * - * @param[in] config A <code>PP_Resource</code> corresponding to an image - * capture config resource. - * @param[out] preview_size A <code>PP_Size</code> that indicates the - * requested preview image size. - */ - void (*GetPreviewSize)(PP_Resource config, struct PP_Size* preview_size); - /** - * SetPreviewSize() sets the preview image size for the given <code> - * PPB_ImageCaptureConfig_Private</code>. - * - * @param[in] config A <code>PP_Resource</code> corresponding to a - * <code>PPB_ImageCaptureConfig_Private</code>. - * @param[in] preview_size A <code>PP_Size</code> that indicates the requested - * preview image size. - */ - void (*SetPreviewSize)(PP_Resource config, - const struct PP_Size* preview_size); - /** - * GetJpegSize() returns the JPEG image size in pixels for the given - * <code>PPB_ImageCaptureConfig_Private</code>. - * - * @param[in] config A <code>PP_Resource</code> corresponding to an image - * capture config resource. - * @param[out] jpeg_size A <code>PP_Size</code> that indicates the current - * JPEG image size. - */ - void (*GetJpegSize)(PP_Resource config, struct PP_Size* jpeg_size); - /** - * SetJpegSize() sets the JPEG image size for the given - * <code>PPB_ImageCaptureConfig_Private</code>. - * - * @param[in] config A <code>PP_Resource</code> corresponding to a - * <code>PPB_ImageCaptureConfig_Private</code>. - * @param[in] jpeg_size A <code>PP_Size</code> that indicates the requested - * JPEG image size. - */ - void (*SetJpegSize)(PP_Resource config, const struct PP_Size* jpeg_size); -}; - -typedef struct PPB_ImageCaptureConfig_Private_0_1 - PPB_ImageCaptureConfig_Private; -/** - * @} - */ - -#endif /* PPAPI_C_PRIVATE_PPB_IMAGE_CAPTURE_CONFIG_PRIVATE_H_ */ - diff --git a/chromium/ppapi/c/private/ppb_image_capture_private.h b/chromium/ppapi/c/private/ppb_image_capture_private.h deleted file mode 100644 index 190c9a65a50..00000000000 --- a/chromium/ppapi/c/private/ppb_image_capture_private.h +++ /dev/null @@ -1,282 +0,0 @@ -/* Copyright 2014 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* From private/ppb_image_capture_private.idl, - * modified Wed Aug 13 17:26:13 2014. - */ - -#ifndef PPAPI_C_PRIVATE_PPB_IMAGE_CAPTURE_PRIVATE_H_ -#define PPAPI_C_PRIVATE_PPB_IMAGE_CAPTURE_PRIVATE_H_ - -#include "ppapi/c/pp_bool.h" -#include "ppapi/c/pp_completion_callback.h" -#include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_macros.h" -#include "ppapi/c/pp_resource.h" -#include "ppapi/c/pp_stdint.h" -#include "ppapi/c/pp_var.h" - -#define PPB_IMAGECAPTURE_PRIVATE_INTERFACE_0_1 "PPB_ImageCapture_Private;0.1" -#define PPB_IMAGECAPTURE_PRIVATE_INTERFACE \ - PPB_IMAGECAPTURE_PRIVATE_INTERFACE_0_1 - -/** - * @file - * Defines the <code>PPB_ImageCapture_Private</code> interface. Used for - * acquiring a single still image from a camera source. - */ - - -/** - * @addtogroup Typedefs - * @{ - */ -/** - * Callback function for <code>PPB_ImageCapture_Private.CaptureStillImage - * </code> to indicate the image has been captured from the sensor. This is a - * good opportunity to play a shutter sound or give other feedback of camera - * operation. This will occur after the image was captured, but before the - * actual data is available. - * - * Parameters: - * |user_data| The same pointer that was passed into <code> - * PPB_ImageCapture_Private.Create()</code>. - * |sequence_id| The sequence ID of the image capture, same as the one from - * CaptureStillImage. - */ -typedef void (*PPB_ImageCapture_Private_ShutterCallback)(void* user_data, - int64_t sequence_id); - -/** - * Callback function for <code>PPB_ImageCapture_Private.CaptureStillImage - * </code> to deliver a preview image. The client can use this to show the - * captured image. See <code>PPB_ImageCapture_Private.CaptureStillImage - * </code> for more information. - * - * Parameters: - * |user_data| The same pointer that was passed into <code> - * PPB_ImageCapture_Private.Create()</code>. - * |sequence_id| The sequence ID of the image capture, same as the one from - * CaptureStillImage. - * |preview| A <code>PP_Resource</code> corresponding to a VideoFrame - * resource used to store the preview image. - */ -typedef void (*PPB_ImageCapture_Private_PreviewCallback)(void* user_data, - int64_t sequence_id, - PP_Resource preview); - -/** - * Callback function for <code>PPB_ImageCapture_Private.CaptureStillImage - * </code> to deliver a still JPEG image. See <code> - * PPB_ImageCapture_Private.CaptureStillImage</code> for more information. - * - * Parameters: - * |user_data| The same pointer that was passed into <code> - * PPB_ImageCapture_Private.Create()</code>. - * |sequence_id| The sequence ID of the image capture, same as the one from - * CaptureStillImage. - * |jpeg| A <code>PP_Resource</code> corresponding to a VideoFrame - * resource used to store the JPEG image. - */ -typedef void (*PPB_ImageCapture_Private_JpegCallback)(void* user_data, - int64_t sequence_id, - PP_Resource jpeg); - -/** - * Callback function for <code>PPB_ImageCapture_Private.CaptureStillImage - * </code> to indicate the image capture has failed. - * - * Parameters: - * |user_data| The same pointer that was passed into <code> - * PPB_ImageCapture_Private.Create()</code>. - * |sequence_id| The sequence ID of the image capture, same as the one from - * CaptureStillImage. - * |int32_t| An error code from <code>pp_errors.h</code>. - */ -typedef void (*PPB_ImageCapture_Private_ErrorCallback)(void* user_data, - int64_t sequence_id, - int32_t pp_error); -/** - * @} - */ - -/** - * @addtogroup Interfaces - * @{ - */ -/** - * To capture a still image with this class, use the following steps. - * 1. Get a PPB_ImageCapture_Private object by Create(). - * 2. Call GetCameraCapabilities to get the supported preview sizes. - * 3. For optimal performance, set one of the supported preview size as the - * constraints of getUserMedia. Use the created MediaStreamVideoTrack for - * camera previews. - * 4. Set the same preview size and other settings by SetConfig. - * 5. Call CaptureStillImage to capture a still image. Play the shutter sound in - * the shutter callback. The image from the preview callback can be used for - * display. JPEG image will be returned to the JPEG callback. - */ -struct PPB_ImageCapture_Private_0_1 { - /** - * Creates a PPB_ImageCapture_Private resource. - * - * @param[in] instance A <code>PP_Instance</code> identifying one instance - * of a module. - * @param[in] camera_source_id A <code>PP_Var</code> identifying a camera - * source. The type is string. The ID can be obtained from - * MediaStreamTrack.getSources() or MediaStreamVideoTrack.id. If a - * MediaStreamVideoTrack is associated with the same source and the track - * is closed, this PPB_ImageCapture_Private object can still do image capture. - * @param[in] error_callback A <code>PPB_ImageCapture_Private_ErrorCallback - * </code> callback to indicate the image capture has failed. - * @param[inout] user_data An opaque pointer that will be passed to the - * callbacks of PPB_ImageCapture_Private. - * - * @return A <code>PP_Resource</code> corresponding to a - * PPB_ImageCapture_Private resource if successful, 0 if failed. - */ - PP_Resource (*Create)(PP_Instance instance, - struct PP_Var camera_source_id, - PPB_ImageCapture_Private_ErrorCallback error_callback, - void* user_data); - /** - * Determines if a resource is an image capture resource. - * - * @param[in] resource The <code>PP_Resource</code> to test. - * - * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given - * resource is an image capture resource or <code>PP_FALSE</code> - * otherwise. - */ - PP_Bool (*IsImageCapture)(PP_Resource resource); - /** - * Disconnects from the camera and cancels all pending capture requests. - * After this returns, no callbacks will be called. If <code> - * PPB_ImageCapture_Private</code> is destroyed and is not closed yet, this - * function will be automatically called. Calling this more than once has no - * effect. - * - * @param[in] image_capture A <code>PP_Resource</code> corresponding to an - * image capture resource. - * @param[in] callback <code>PP_CompletionCallback</code> to be called upon - * completion of <code>Close()</code>. - * - * @return An int32_t containing a result code from <code>pp_errors.h</code>. - */ - int32_t (*Close)(PP_Resource resource, struct PP_CompletionCallback callback); - /** - * Sets the configuration of the image capture. - * If <code>SetConfig()</code> is not called, default settings will be used. - * - * @param[in] image_capture A <code>PP_Resource</code> corresponding to an - * image capture resource. - * @param[in] config A <code>PP_ImageCaptureConfig_Private</code> object. - * @param[in] callback <code>PP_CompletionCallback</code> to be called upon - * completion of <code>SetConfig()</code>. - * - * @return An int32_t containing a result code from <code>pp_errors.h</code>. - * Returns <code>PP_ERROR_INPROGRESS</code> if there is a pending call of - * <code>SetConfig()</code> or <code>CaptureStillImage()</code>. - * If an error is returned, the configuration will not be changed. - */ - int32_t (*SetConfig)(PP_Resource image_capture, - PP_Resource config, - struct PP_CompletionCallback callback); - /** - * Gets the configuration of the image capture. - * - * @param[in] image_capture A <code>PP_Resource</code> corresponding to an - * image capture resource. - * @param[out] config A <code>PP_ImageCaptureConfig_Private</code> for storing - * the current image capture config on success. Otherwise, the values will not - * be changed. - * @param[in] callback <code>PP_CompletionCallback</code> to be called upon - * completion of <code>GetConfig()</code>. - * - * @return An int32_t containing a result code from <code>pp_errors.h</code>. - */ - int32_t (*GetConfig)(PP_Resource image_capture, - PP_Resource* config, - struct PP_CompletionCallback callback); - /** - * Gets the camera capabilities. - * - * The camera capabilities do not change for a given camera source. - * - * @param[in] image_capture A <code>PP_Resource</code> corresponding to an - * image capture resource. - * @param[out] capabilities A <code>PPB_CameraCapabilities_Private</code> for - * storing the image capture capabilities on success. Otherwise, the value - * will not be changed. - * @param[in] callback <code>PP_CompletionCallback</code> to be called upon - * completion of <code>GetCameraCapabilities()</code>. - * - * @return An int32_t containing a result code from <code>pp_errors.h</code>. - */ - int32_t (*GetCameraCapabilities)(PP_Resource image_capture, - PP_Resource* capabilities, - struct PP_CompletionCallback callback); - /** - * Captures a still JPEG image from the camera. - * - * Triggers an asynchronous image capture. The camera will initiate a series - * of callbacks to the application as the image capture progresses. The - * callbacks will be invoked in the order of shutter callback, preview - * callback, and JPEG callback. The shutter callback occurs after the image is - * captured. This can be used to trigger a sound to let the user know that - * image has been captured. The preview callback occurs when a scaled, fully - * processed preview image is available. The JPEG callback occurs when the - * compressed image is available. If there is an error after the capture is in - * progress, the error callback passed to <code> - * PPB_ImageCapture_Private.Create()</code> will be invoked. All the callbacks - * are invoked by the thread that calls this function. - * - * The size of the preview image in preview callback is determined by - * <code>PPB_ImageCaptureConfig_Private.SetPreviewSize</code>. The format is - * decided by the camera and can be got from <code>PPB_VideoFrame.GetFormat - * </code>. The size of the JPEG image is determined by <code> - * PPB_ImageCaptureConfig_Private.SetJpegSize</code>. - * - * The camera may need to stop and re-start streaming during image capture. If - * some MediaStreamVideoTrack are associated with the camera source, they will - * receive mute and unmute events. The mute event will be received before all - * the callbacks. The unmute event will be received after all the callbacks. - * The preview image will not be sent to the video tracks associated with the - * camera. - * - * @param[in] image_capture A <code>PP_Resource</code> corresponding to an - * image capture resource. - * @param[in] shutter_callback A <code> - * PPB_ImageCapture_Private_ShutterCallback</code> callback to indicate the - * image has been taken. - * @param[in] preview_callback A <code> - * PPB_ImageCapture_Private_PreviewCallback</code> callback to return a - * preview of the captured image. - * @param[in] jpeg_callback A <code> - * PPB_ImageCapture_Private_JpegCallback</code> callback to return captured - * JPEG image. - * @param[out] sequence_id The sequence ID is a unique monotonically - * increasing value starting from 0, incremented every time a new request like - * image capture is submitted. - * - * @return An int32_t containing a result code from <code>pp_errors.h</code>. - * PP_OK means the callbacks will be triggered. Other values mean the - * callbacks will not be triggered. - */ - int32_t (*CaptureStillImage)( - PP_Resource image_capture, - PPB_ImageCapture_Private_ShutterCallback shutter_callback, - PPB_ImageCapture_Private_PreviewCallback preview_callback, - PPB_ImageCapture_Private_JpegCallback jpeg_callback, - int64_t* sequence_id); -}; - -typedef struct PPB_ImageCapture_Private_0_1 PPB_ImageCapture_Private; -/** - * @} - */ - -#endif /* PPAPI_C_PRIVATE_PPB_IMAGE_CAPTURE_PRIVATE_H_ */ - diff --git a/chromium/ppapi/c/private/ppb_nacl_private.h b/chromium/ppapi/c/private/ppb_nacl_private.h deleted file mode 100644 index 764b853f351..00000000000 --- a/chromium/ppapi/c/private/ppb_nacl_private.h +++ /dev/null @@ -1,405 +0,0 @@ -/* Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* From private/ppb_nacl_private.idl modified Wed Oct 1 15:54:15 2014. */ - -#ifndef PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ -#define PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ - -#include "ppapi/c/pp_bool.h" -#include "ppapi/c/pp_completion_callback.h" -#include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_macros.h" -#include "ppapi/c/pp_stdint.h" -#include "ppapi/c/pp_var.h" -#include "ppapi/c/private/ppp_pexe_stream_handler.h" - -#define PPB_NACL_PRIVATE_INTERFACE_1_0 "PPB_NaCl_Private;1.0" -#define PPB_NACL_PRIVATE_INTERFACE PPB_NACL_PRIVATE_INTERFACE_1_0 - -/** - * @file - * This file contains NaCl private interfaces. This interface is not versioned - * and is for internal Chrome use. It may change without notice. */ - - -#include "ppapi/c/private/pp_file_handle.h" -#include "ppapi/c/private/ppb_instance_private.h" - -/** - * @addtogroup Enums - * @{ - */ -/** NaCl-specific errors that should be reported to the user. - * These error codes are reported via UMA so, if you edit them: - * 1) make sure you understand UMA first. - * 2) update src/tools/metrics/histograms/histograms.xml - * Values are explicitly specified to make sure they don't shift around when - * edited, and also to make reading about:histograms easier. - */ -typedef enum { - PP_NACL_ERROR_LOAD_SUCCESS = 0, - PP_NACL_ERROR_LOAD_ABORTED = 1, - PP_NACL_ERROR_UNKNOWN = 2, - PP_NACL_ERROR_MANIFEST_RESOLVE_URL = 3, - PP_NACL_ERROR_MANIFEST_LOAD_URL = 4, - PP_NACL_ERROR_MANIFEST_STAT = 5, - PP_NACL_ERROR_MANIFEST_TOO_LARGE = 6, - PP_NACL_ERROR_MANIFEST_OPEN = 7, - PP_NACL_ERROR_MANIFEST_MEMORY_ALLOC = 8, - PP_NACL_ERROR_MANIFEST_READ = 9, - PP_NACL_ERROR_MANIFEST_PARSING = 10, - PP_NACL_ERROR_MANIFEST_SCHEMA_VALIDATE = 11, - PP_NACL_ERROR_MANIFEST_GET_NEXE_URL = 12, - PP_NACL_ERROR_NEXE_LOAD_URL = 13, - PP_NACL_ERROR_NEXE_ORIGIN_PROTOCOL = 14, - PP_NACL_ERROR_NEXE_FH_DUP = 15, - PP_NACL_ERROR_NEXE_STAT = 16, - PP_NACL_ERROR_ELF_CHECK_IO = 17, - PP_NACL_ERROR_ELF_CHECK_FAIL = 18, - PP_NACL_ERROR_SEL_LDR_INIT = 19, - PP_NACL_ERROR_SEL_LDR_CREATE_LAUNCHER = 20, - PP_NACL_ERROR_SEL_LDR_FD = 21, - PP_NACL_ERROR_SEL_LDR_LAUNCH = 22, - /* Deprecated, safe to reuse the value because it's never logged in UMA. - */ - PP_NACL_ERROR_SEL_LDR_SEND_NEXE = 24, - PP_NACL_ERROR_SEL_LDR_HANDLE_PASSING = 25, - PP_NACL_ERROR_SEL_LDR_START_MODULE = 26, - PP_NACL_ERROR_SEL_LDR_START_STATUS = 27, - PP_NACL_ERROR_SRPC_CONNECTION_FAIL = 28, - PP_NACL_ERROR_START_PROXY_CHECK_PPP = 29, - PP_NACL_ERROR_START_PROXY_ALLOC = 30, - PP_NACL_ERROR_START_PROXY_MODULE = 31, - PP_NACL_ERROR_START_PROXY_INSTANCE = 32, - PP_NACL_ERROR_SEL_LDR_COMMUNICATION_CMD_CHANNEL = 33, - PP_NACL_ERROR_SEL_LDR_COMMUNICATION_REV_SETUP = 34, - PP_NACL_ERROR_SEL_LDR_COMMUNICATION_WRAPPER = 35, - PP_NACL_ERROR_SEL_LDR_COMMUNICATION_REV_SERVICE = 36, - PP_NACL_ERROR_START_PROXY_CRASH = 37, - PP_NACL_ERROR_MANIFEST_PROGRAM_MISSING_ARCH = 38, - PP_NACL_ERROR_PNACL_CACHE_OPEN_INPROGRESS = 39, - PP_NACL_ERROR_PNACL_CACHE_OPEN_NOACCESS = 40, - PP_NACL_ERROR_PNACL_CACHE_OPEN_NOQUOTA = 41, - PP_NACL_ERROR_PNACL_CACHE_OPEN_NOSPACE = 42, - PP_NACL_ERROR_PNACL_CACHE_OPEN_OTHER = 43, - PP_NACL_ERROR_PNACL_CACHE_DIRECTORY_CREATE = 44, - PP_NACL_ERROR_PNACL_CACHE_FILEOPEN_NOACCESS = 45, - PP_NACL_ERROR_PNACL_CACHE_FILEOPEN_NOQUOTA = 46, - PP_NACL_ERROR_PNACL_CACHE_FILEOPEN_NOSPACE = 47, - PP_NACL_ERROR_PNACL_CACHE_FILEOPEN_NOTAFILE = 48, - PP_NACL_ERROR_PNACL_CACHE_FILEOPEN_OTHER = 49, - PP_NACL_ERROR_PNACL_CACHE_FETCH_NOACCESS = 50, - PP_NACL_ERROR_PNACL_CACHE_FETCH_NOTFOUND = 51, - PP_NACL_ERROR_PNACL_CACHE_FETCH_OTHER = 52, - PP_NACL_ERROR_PNACL_CACHE_FINALIZE_COPY_NOQUOTA = 53, - PP_NACL_ERROR_PNACL_CACHE_FINALIZE_COPY_NOSPACE = 54, - PP_NACL_ERROR_PNACL_CACHE_FINALIZE_COPY_OTHER = 55, - PP_NACL_ERROR_PNACL_CACHE_FINALIZE_RENAME_NOACCESS = 56, - PP_NACL_ERROR_PNACL_CACHE_FINALIZE_RENAME_OTHER = 57, - PP_NACL_ERROR_PNACL_RESOURCE_FETCH = 58, - PP_NACL_ERROR_PNACL_PEXE_FETCH_ABORTED = 59, - PP_NACL_ERROR_PNACL_PEXE_FETCH_NOACCESS = 60, - PP_NACL_ERROR_PNACL_PEXE_FETCH_OTHER = 61, - PP_NACL_ERROR_PNACL_THREAD_CREATE = 62, - PP_NACL_ERROR_PNACL_LLC_SETUP = 63, - PP_NACL_ERROR_PNACL_LD_SETUP = 64, - PP_NACL_ERROR_PNACL_LLC_INTERNAL = 65, - PP_NACL_ERROR_PNACL_LD_INTERNAL = 66, - PP_NACL_ERROR_PNACL_CREATE_TEMP = 67, - /* This entry is no longer used, but should not be removed, because UMA - */ - PP_NACL_ERROR_PNACL_NOT_ENABLED = 68, - PP_NACL_ERROR_MANIFEST_NOACCESS_URL = 69, - PP_NACL_ERROR_NEXE_NOACCESS_URL = 70, - PP_NACL_ERROR_PNACL_CRASH_THROTTLED = 71, - /* If you add a code, read the enum comment above on how to update - */ - PP_NACL_ERROR_MAX -} PP_NaClError; - -/** Event types that NaCl may use when reporting load progress or errors. */ -typedef enum { - PP_NACL_EVENT_LOADSTART, - PP_NACL_EVENT_PROGRESS, - PP_NACL_EVENT_ERROR, - PP_NACL_EVENT_ABORT, - PP_NACL_EVENT_LOAD, - PP_NACL_EVENT_LOADEND, - PP_NACL_EVENT_CRASH -} PP_NaClEventType; - -typedef enum { - PP_SCHEME_CHROME_EXTENSION, - PP_SCHEME_DATA, - PP_SCHEME_OTHER -} PP_UrlSchemeType; - -typedef enum { - /* The trusted plugin begins in this ready state. */ - PP_NACL_READY_STATE_UNSENT = 0, - /* The manifest file has been requested, but not yet received. */ - PP_NACL_READY_STATE_OPENED = 1, - /* The manifest file has been received and the nexe successfully requested. */ - PP_NACL_READY_STATE_LOADING = 3, - /* The nexe has been loaded and the proxy started, so it is ready for - */ - PP_NACL_READY_STATE_DONE = 4 -} PP_NaClReadyState; - -/** Types of untrusted NaCl processes. Mirrors NaClAppProcessType from - * components/nacl/common/nacl_types.h. - */ -typedef enum { - PP_UNKNOWN_NACL_PROCESS_TYPE, - PP_NATIVE_NACL_PROCESS_TYPE, - PP_PNACL_PROCESS_TYPE, - PP_PNACL_TRANSLATOR_PROCESS_TYPE, - PP_NUM_NACL_PROCESS_TYPES -} PP_NaClAppProcessType; -/** - * @} - */ - -/** - * @addtogroup Structs - * @{ - */ -struct PP_PNaClOptions { - PP_Bool translate; - PP_Bool is_debug; - int32_t opt_level; -}; -/** - * @} - */ - -/** - * @addtogroup Typedefs - * @{ - */ -/* Callback invoked upon completion of PPP_ManifestService::OpenResource(). */ -typedef void (*PP_OpenResourceCompletionCallback)(void* user_data, - PP_FileHandle file_handle); -/** - * @} - */ - -/** - * @addtogroup Structs - * @{ - */ -/* Corresponds to NaClFileInfo in - * native_client/src/trusted/validator/nacl_file_info.h */ -struct PP_NaClFileInfo { - PP_FileHandle handle; - /* See NaClFileToken comment in nacl_file_info.h */ - uint64_t token_lo; - uint64_t token_hi; -}; -/** - * @} - */ - -/** - * @addtogroup Interfaces - * @{ - */ -/* PPB_NaCl_Private */ -struct PPB_NaCl_Private_1_0 { - /* Launches NaCl's sel_ldr process. Returns PP_EXTERNAL_PLUGIN_OK on success - * and writes a NaClHandle to imc_handle. Returns PP_EXTERNAL_PLUGIN_FAILED on - * failure. The |enable_ppapi_dev| parameter controls whether GetInterface - * returns 'Dev' interfaces to the NaCl plugin. - * The |nexe_file_info| is currently used only in non-SFI mode. It is the - * file handle for the main nexe file, which should be initially loaded. - * LaunchSelLdr takes the ownership of the file handle. - * The |uses_nonsfi_mode| flag indicates whether or not nonsfi-mode should - * be used with the binary pointed by the url. - */ - void (*LaunchSelLdr)(PP_Instance instance, - PP_Bool main_service_runtime, - const char* alleged_url, - const struct PP_NaClFileInfo* nexe_file_info, - PP_Bool uses_nonsfi_mode, - PP_Bool enable_ppapi_dev, - PP_NaClAppProcessType process_type, - void* imc_handle, - struct PP_CompletionCallback callback); - /* This function starts the IPC proxy so the nexe can communicate with the - * browser. - */ - PP_Bool (*StartPpapiProxy)(PP_Instance instance); - /* On POSIX systems, this function returns the file descriptor of - * /dev/urandom. On non-POSIX systems, this function returns 0. - */ - int32_t (*UrandomFD)(void); - /* Whether the Pepper 3D interfaces should be disabled in the NaCl PPAPI - * proxy. This is so paranoid admins can effectively prevent untrusted shader - * code to be processed by the graphics stack. - */ - PP_Bool (*Are3DInterfacesDisabled)(void); - /* This is Windows-specific. This is a replacement for DuplicateHandle() for - * use inside the Windows sandbox. Note that we provide this via dependency - * injection only to avoid the linkage problems that occur because the NaCl - * plugin is built as a separate DLL/DSO - * (see http://code.google.com/p/chromium/issues/detail?id=114439#c8). - */ - int32_t (*BrokerDuplicateHandle)(PP_FileHandle source_handle, - uint32_t process_id, - PP_FileHandle* target_handle, - uint32_t desired_access, - uint32_t options); - /* Returns a read-only (but executable) file descriptor / file info for - * a url for pnacl translator tools. Returns an invalid handle on failure. - */ - void (*GetReadExecPnaclFd)(const char* url, - struct PP_NaClFileInfo* out_file_info); - /* This creates a temporary file that will be deleted by the time - * the last handle is closed (or earlier on POSIX systems), and - * returns a posix handle to that temporary file. - */ - PP_FileHandle (*CreateTemporaryFile)(PP_Instance instance); - /* Return the number of processors in the system as reported by the OS */ - int32_t (*GetNumberOfProcessors)(void); - /* Return whether the non-SFI mode is enabled. */ - PP_Bool (*IsNonSFIModeEnabled)(void); - /* Report to the browser that translation of the pexe for |instance| - * has finished, or aborted with an error. If |success| is true, the - * browser may then store the translation in the cache. The renderer - * must first have called GetNexeFd for the same instance. (The browser is - * not guaranteed to store the nexe even if |success| is true; if there is - * an error on the browser side, or the file is too big for the cache, or - * the browser is in incognito mode, no notification will be delivered to - * the plugin.) - */ - void (*ReportTranslationFinished)(PP_Instance instance, - PP_Bool success, - int32_t opt_level, - int64_t pexe_size, - int64_t compile_time_us); - /* Dispatch a progress event on the DOM element where the given instance is - * embedded. - */ - void (*DispatchEvent)(PP_Instance instance, - PP_NaClEventType event_type, - const char* resource_url, - PP_Bool length_is_computable, - uint64_t loaded_bytes, - uint64_t total_bytes); - /* Report that the nexe loaded successfully. */ - void (*ReportLoadSuccess)(PP_Instance instance, - uint64_t loaded_bytes, - uint64_t total_bytes); - /* Report an error that occured while attempting to load a nexe. */ - void (*ReportLoadError)(PP_Instance instance, - PP_NaClError error, - const char* error_message); - /* Reports that loading a nexe was aborted. */ - void (*ReportLoadAbort)(PP_Instance instance); - /* Performs internal setup when an instance is created. */ - void (*InstanceCreated)(PP_Instance instance); - /* Performs internal cleanup when an instance is destroyed. */ - void (*InstanceDestroyed)(PP_Instance instance); - /* Return true if the NaCl debug stub is enabled and the app loaded from - * alleged_nmf_url will be attached to a debugger. - */ - PP_Bool (*NaClDebugEnabledForURL)(const char* alleged_nmf_url); - /* Returns the kind of SFI sandbox implemented by NaCl on this - * platform. - */ - const char* (*GetSandboxArch)(void); - /* Logs the message to the console. */ - void (*LogToConsole)(PP_Instance instance, const char* message); - /* Returns the NaCl readiness status for this instance. */ - PP_NaClReadyState (*GetNaClReadyState)(PP_Instance instance); - /* Logs the message via VLOG. */ - void (*Vlog)(const char* message); - /* Initializes internal state for a NaCl plugin. */ - void (*InitializePlugin)(PP_Instance instance, - uint32_t argc, - const char* argn[], - const char* argv[]); - /* Returns the size of the nexe. */ - int64_t (*GetNexeSize)(PP_Instance instance); - /* Requests the NaCl manifest specified in the plugin arguments. */ - void (*RequestNaClManifest)(PP_Instance instance, - struct PP_CompletionCallback callback); - struct PP_Var (*GetManifestBaseURL)(PP_Instance instance); - /* Processes the NaCl manifest once it's been retrieved. - * TODO(teravest): Move the rest of the supporting logic out of the trusted - * plugin. - */ - void (*ProcessNaClManifest)(PP_Instance instance, const char* program_url); - PP_Bool (*DevInterfacesEnabled)(PP_Instance instance); - PP_Bool (*GetManifestProgramURL)(PP_Instance instance, - struct PP_Var* full_url, - struct PP_PNaClOptions* pnacl_options, - PP_Bool* uses_nonsfi_mode); - /* Returns the filenames for the llc and ld tools. */ - PP_Bool (*GetPnaclResourceInfo)(PP_Instance instance, - struct PP_Var* llc_tool_name, - struct PP_Var* ld_tool_name); - /* PP_Var string of attributes describing the CPU features supported - * by the current architecture. The string is a comma-delimited list - * of attributes supported by LLVM in its -mattr= option: - * http://llvm.org/docs/CommandGuide/llc.html#cmdoption-mattr */ - struct PP_Var (*GetCpuFeatureAttrs)(void); - /* Downloads the .nexe file at the given URL to a file, and sets |file_info| - * to information for a handle to a file containing its contents. - * If metadata for identity-based validation caching is available - * then it sets token information in |file_info| (otherwise left untouched). - */ - void (*DownloadNexe)(PP_Instance instance, - const char* url, - struct PP_NaClFileInfo* file_info, - struct PP_CompletionCallback callback); - /* Reports the status of sel_ldr for UMA reporting. - * |max_status| has to be provided because the implementation of this - * interface can't access the NaClErrorCode enum. - */ - void (*ReportSelLdrStatus)(PP_Instance instance, - int32_t load_status, - int32_t max_status); - /* Logs time taken by an operation to UMA histograms. - * This function is safe to call on any thread. - */ - void (*LogTranslateTime)(const char* histogram_name, int64_t time_us); - /* Opens a manifest entry for the given instance. If this is for a helper - * process, we consult our internal pnacl.json instead of the user-supplied - * NMF. - * Fails for files which require PNaCl translation. - */ - void (*OpenManifestEntry)(PP_Instance instance, - PP_Bool is_helper_process, - const char* key, - struct PP_NaClFileInfo* file_info, - struct PP_CompletionCallback callback); - /* Sets the start time for PNaCl downloading and translation to the current - * time. - */ - void (*SetPNaClStartTime)(PP_Instance instance); - /* Downloads and streams a pexe file for PNaCl translation. - * Fetches the content at |pexe_url| for the given instance and opt_level. - * If a translated cached nexe is already available, |cache_hit_handle| - * is set and |cache_hit_callback| is called. - * Otherwise, |stream_callback| is called repeatedly with blocks of data - * as they are received. |stream_finished_callback| is called after all - * data has been received and dispatched to |stream_callback|. - */ - void (*StreamPexe)(PP_Instance instance, - const char* pexe_url, - int32_t opt_level, - const struct PPP_PexeStreamHandler_1_0* stream_handler, - void* stream_handler_user_data); -}; - -typedef struct PPB_NaCl_Private_1_0 PPB_NaCl_Private; -/** - * @} - */ - -#endif /* PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ */ - diff --git a/chromium/ppapi/c/private/ppb_pdf.h b/chromium/ppapi/c/private/ppb_pdf.h index fdd62fe3ffe..3e708ddecc0 100644 --- a/chromium/ppapi/c/private/ppb_pdf.h +++ b/chromium/ppapi/c/private/ppb_pdf.h @@ -169,6 +169,14 @@ struct PPB_PDF { // Sets the link currently under the cursor. void (*SetLinkUnderCursor)(PP_Instance instance, const char* url); + + // Gets pointers to both the mmap'd V8 snapshot files and their sizes. + // This is needed when loading V8's initial snapshot from external files. + void (*GetV8ExternalSnapshotData)(PP_Instance instance, + const char** natives_data_out, + int* natives_size_out, + const char** snapshot_data_out, + int* snapshot_size_out); }; #endif // PPAPI_C_PRIVATE_PPB_PDF_H_ diff --git a/chromium/ppapi/c/private/ppb_talk_private.h b/chromium/ppapi/c/private/ppb_talk_private.h deleted file mode 100644 index 7fc11ccc628..00000000000 --- a/chromium/ppapi/c/private/ppb_talk_private.h +++ /dev/null @@ -1,159 +0,0 @@ -/* Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* From private/ppb_talk_private.idl modified Thu Jun 6 10:54:19 2013. */ - -#ifndef PPAPI_C_PRIVATE_PPB_TALK_PRIVATE_H_ -#define PPAPI_C_PRIVATE_PPB_TALK_PRIVATE_H_ - -#include "ppapi/c/pp_completion_callback.h" -#include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_macros.h" -#include "ppapi/c/pp_resource.h" -#include "ppapi/c/pp_stdint.h" - -#define PPB_TALK_PRIVATE_INTERFACE_1_0 "PPB_Talk_Private;1.0" -#define PPB_TALK_PRIVATE_INTERFACE_2_0 "PPB_Talk_Private;2.0" -#define PPB_TALK_PRIVATE_INTERFACE PPB_TALK_PRIVATE_INTERFACE_2_0 - -/** - * @file - * This file contains the <code>PPB_Talk_Private</code> interface. - */ - - -/** - * @addtogroup Enums - * @{ - */ -/** - * The type of permissions that can be requested from the user. - */ -typedef enum { - /** - * Request permission for screencast. - */ - PP_TALKPERMISSION_SCREENCAST, - /** - * Request permission for Remote Desktop. - */ - PP_TALKPERMISSION_REMOTING, - /** - * Request permission for continuing Remote Desktop. - */ - PP_TALKPERMISSION_REMOTING_CONTINUE, - /** - * Number of permissions. - */ - PP_TALKPERMISSION_NUM_PERMISSIONS -} PP_TalkPermission; -PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TalkPermission, 4); - -/** - * Talk event types reported by the browser. - */ -typedef enum { - /** - * Indicates that the user took action to terminate the remoting session. - */ - PP_TALKEVENT_TERMINATE, - /** - * Indicates that an error occurred (e.g. failed to show the UI). - */ - PP_TALKEVENT_ERROR, - /** - * Number of events - */ - PP_TALKEVENT_NUM_EVENTS -} PP_TalkEvent; -PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TalkEvent, 4); -/** - * @} - */ - -/** - * @addtogroup Typedefs - * @{ - */ -/** - * Callback for Talk events. - */ -typedef void (*PP_TalkEventCallback)(void* user_data, PP_TalkEvent event); -/** - * @} - */ - -/** - * @addtogroup Interfaces - * @{ - */ -/** - * Extra interface for Talk. - */ -struct PPB_Talk_Private_2_0 { - /** - * Creates a Talk_Private resource. - */ - PP_Resource (*Create)(PP_Instance instance); - /** - * Requests permission from the user using a system modal dialog. - * - * <code>permission</code> specifies the type of permission to request from - * the user. - * - * <code>callback</code> is the completion callback. It will be issued with 1 - * as the result if the user gave permission, or 0 if the user denied. - * - * You can only have one call pending. It will return PP_OK_COMPLETIONPENDING - * if the request is queued, or PP_ERROR_INPROGRESS if there is already a - * request in progress. - */ - int32_t (*RequestPermission)(PP_Resource talk_resource, - PP_TalkPermission permission, - struct PP_CompletionCallback callback); - /** - * Shows the remoting-in-progress UI and registers a callback for events. - * - * <code>event_callback</code> is the callback for session releated events. - * It will only start receiving events after the completion callback has been - * issued. This callback will be called on the pepper main thread. - * - * <code>user_data</code> is an opaque value used when - * <code>event_callback</code> is invoked. - * - * <code>callback</code> is the completion callback. - * - * You can only have one call pending. It will return PP_OK_COMPLETIONPENDING - * if the request is queued, or PP_ERROR_INPROGRESS if there is already a - * request in progress. PP_ERROR_INPROGRESS will also be returned if a - * previous call to StartRemoting succeeded without a corresponding - * StopRemoting call. - */ - int32_t (*StartRemoting)(PP_Resource talk_resource, - PP_TalkEventCallback event_callback, - void* user_data, - struct PP_CompletionCallback callback); - /** - * Hides the remoting-in-progress UI and unregisters the event callback. - * - * <code>callback</code> is the completion callback. - */ - int32_t (*StopRemoting)(PP_Resource talk_resource, - struct PP_CompletionCallback callback); -}; - -typedef struct PPB_Talk_Private_2_0 PPB_Talk_Private; - -struct PPB_Talk_Private_1_0 { - PP_Resource (*Create)(PP_Instance instance); - int32_t (*GetPermission)(PP_Resource talk_resource, - struct PP_CompletionCallback callback); -}; -/** - * @} - */ - -#endif /* PPAPI_C_PRIVATE_PPB_TALK_PRIVATE_H_ */ - diff --git a/chromium/ppapi/c/private/ppb_testing_private.h b/chromium/ppapi/c/private/ppb_testing_private.h index 3d35ec7ea58..efe456a59b6 100644 --- a/chromium/ppapi/c/private/ppb_testing_private.h +++ b/chromium/ppapi/c/private/ppb_testing_private.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From private/ppb_testing_private.idl modified Mon Jul 28 15:12:12 2014. */ +/* From private/ppb_testing_private.idl modified Fri May 1 13:14:52 2015. */ #ifndef PPAPI_C_PRIVATE_PPB_TESTING_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_TESTING_PRIVATE_H_ @@ -93,6 +93,18 @@ struct PPB_Testing_Private_1_0 { */ PP_Bool (*IsOutOfProcess)(void); /** + * Posts the plugin's current Power Saver status to JavaScript. The plugin + * itself does not recieve anything. This is not idiomatic for Pepper, + * but convenient for testing. + */ + void (*PostPowerSaverStatus)(PP_Instance instance); + /** + * Subscribes to changes to the plugin's Power Saver status. The status + * changes are not forwarded to the plugin itself, but posted to JavaScript. + * This is not idiomatic for Pepper, but conveienent for testing. + */ + void (*SubscribeToPowerSaverNotifications)(PP_Instance instance); + /** * Passes the input event to the browser, which sends it back to the * plugin. The plugin should implement PPP_InputEvent and register for * the input event type. diff --git a/chromium/ppapi/c/private/ppp_content_decryptor_private.h b/chromium/ppapi/c/private/ppp_content_decryptor_private.h index 145d8436219..c8fe4eeb822 100644 --- a/chromium/ppapi/c/private/ppp_content_decryptor_private.h +++ b/chromium/ppapi/c/private/ppp_content_decryptor_private.h @@ -4,7 +4,7 @@ */ /* From private/ppp_content_decryptor_private.idl, - * modified Mon Aug 25 14:02:40 2014. + * modified Fri Apr 24 13:08:50 2015. */ #ifndef PPAPI_C_PRIVATE_PPP_CONTENT_DECRYPTOR_PRIVATE_H_ @@ -18,10 +18,10 @@ #include "ppapi/c/pp_var.h" #include "ppapi/c/private/pp_content_decryptor.h" -#define PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_12 \ - "PPP_ContentDecryptor_Private;0.12" +#define PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_15 \ + "PPP_ContentDecryptor_Private;0.15" #define PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE \ - PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_12 + PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_15 /** * @file @@ -42,14 +42,25 @@ * Decryption Module (CDM) for Encrypted Media Extensions: * http://www.w3.org/TR/encrypted-media/ */ -struct PPP_ContentDecryptor_Private_0_12 { +struct PPP_ContentDecryptor_Private_0_15 { /** * Initialize for the specified key system. * + * @param[in] promise_id A reference for the promise that gets resolved or + * rejected depending upon the success or failure of initialization. + * * @param[in] key_system A <code>PP_Var</code> of type * <code>PP_VARTYPE_STRING</code> containing the name of the key system. + * @param[in] allow_distinctive_identifier Inform the CDM that it may use a + * distinctive identifier. + * @param[in] allow_persistent_state Inform the CDM that it may use persistent + * state. */ - void (*Initialize)(PP_Instance instance, struct PP_Var key_system); + void (*Initialize)(PP_Instance instance, + uint32_t promise_id, + struct PP_Var key_system, + PP_Bool allow_distinctive_identifier, + PP_Bool allow_persistent_state); /** * Provides a server certificate to be used to encrypt messages to the * license server. @@ -64,49 +75,54 @@ struct PPP_ContentDecryptor_Private_0_12 { uint32_t promise_id, struct PP_Var server_certificate); /** - * Creates a session. <code>init_data_type</code> contains the MIME type of + * Creates a session and subsequently generates a request for a license. + * <code>init_data_type</code> contains the MIME type of * <code>init_data</code>. <code>init_data</code> is a data buffer * containing data for use in generating the request. * - * Note: <code>CreateSession()</code> must create a web session ID and provide - * it to the browser via <code>SessionCreated()</code> on the - * <code>PPB_ContentDecryptor_Private</code> interface. + * Note: <code>CreateSessionAndGenerateRequest()</code> must create a + * session ID and provide it to the browser via <code>SessionCreated()</code> + * on the <code>PPB_ContentDecryptor_Private</code> interface. * * @param[in] promise_id A reference for the promise that gets resolved or * rejected depending upon the success or failure when creating the session. * - * @param[in] init_data_type A <code>PP_Var</code> of type - * <code>PP_VARTYPE_STRING</code> containing the MIME type for init_data. + * @param[in] session_type A <code>PP_SessionType</code> that indicates the + * type of session to be created. + * + * @param[in] init_data_type A <code>PP_InitDataType</code> that indicates + * the Initialization Data Type for init_data. * * @param[in] init_data A <code>PP_Var</code> of type * <code>PP_VARTYPE_ARRAYBUFFER</code> containing container specific * initialization data. - * - * @param[in] session_type A <code>PP_SessionType</code> that indicates the - * type of session to be created. */ - void (*CreateSession)(PP_Instance instance, - uint32_t promise_id, - struct PP_Var init_data_type, - struct PP_Var init_data, - PP_SessionType session_type); + void (*CreateSessionAndGenerateRequest)(PP_Instance instance, + uint32_t promise_id, + PP_SessionType session_type, + PP_InitDataType init_data_type, + struct PP_Var init_data); /** - * Loads a session whose web session ID is <code>web_session_id</code>. + * Loads a session whose session ID is <code>session_id</code>. * * Note: After the session is successfully loaded, the CDM must call - * <code>SessionCreated()</code> with <code>web_session_id</code> on the + * <code>SessionCreated()</code> with <code>session_id</code> on the * <code>PPB_ContentDecryptor_Private</code> interface. * * @param[in] promise_id A reference for the promise that gets resolved or * rejected depending upon the success or failure of loading the session. * - * @param[in] web_session_id A <code>PP_Var</code> of type - * <code>PP_VARTYPE_STRING</code> containing the web session ID of the session + * @param[in] session_type A <code>PP_SessionType</code> that indicates the + * type of session to be loaded. + * + * @param[in] session_id A <code>PP_Var</code> of type + * <code>PP_VARTYPE_STRING</code> containing the session ID of the session * to load. */ void (*LoadSession)(PP_Instance instance, uint32_t promise_id, - struct PP_Var web_session_id); + PP_SessionType session_type, + struct PP_Var session_id); /** * Provides a license or other message to the decryptor. * @@ -122,8 +138,8 @@ struct PPP_ContentDecryptor_Private_0_12 { * @param[in] promise_id A reference for the promise that gets resolved or * rejected depending upon the success or failure of updating the session. * - * @param[in] web_session_id A <code>PP_Var</code> of type - * <code>PP_VARTYPE_STRING</code> containing the web session ID of the session + * @param[in] session_id A <code>PP_Var</code> of type + * <code>PP_VARTYPE_STRING</code> containing the session ID of the session * to be updated. * * @param[in] response A <code>PP_Var</code> of type @@ -132,7 +148,7 @@ struct PPP_ContentDecryptor_Private_0_12 { */ void (*UpdateSession)(PP_Instance instance, uint32_t promise_id, - struct PP_Var web_session_id, + struct PP_Var session_id, struct PP_Var response); /** * Close the specified session and related resources. @@ -140,14 +156,14 @@ struct PPP_ContentDecryptor_Private_0_12 { * @param[in] promise_id A reference for the promise that gets resolved or * rejected depending upon the success or failure of closing the session. * - * @param[in] web_session_id A <code>PP_Var</code> of type - * <code>PP_VARTYPE_STRING</code> containing the web session ID of the session + * @param[in] session_id A <code>PP_Var</code> of type + * <code>PP_VARTYPE_STRING</code> containing the session ID of the session * to be closed. * */ void (*CloseSession)(PP_Instance instance, uint32_t promise_id, - struct PP_Var web_session_id); + struct PP_Var session_id); /** * Remove stored data associated with this session. * @@ -155,29 +171,14 @@ struct PPP_ContentDecryptor_Private_0_12 { * rejected depending upon the success or failure of removing the session * data. * - * @param[in] web_session_id A <code>PP_Var</code> of type - * <code>PP_VARTYPE_STRING</code> containing the web session ID of the session + * @param[in] session_id A <code>PP_Var</code> of type + * <code>PP_VARTYPE_STRING</code> containing the session ID of the session * to be removed. * */ void (*RemoveSession)(PP_Instance instance, uint32_t promise_id, - struct PP_Var web_session_id); - /** - * Get the key IDs for keys in the session that the CDM knows are currently - * usable to decrypt media data. - * - * @param[in] promise_id A reference for the promise that gets resolved or - * rejected depending upon the success or failure of obtaining the key IDs. - * - * @param[in] web_session_id A <code>PP_Var</code> of type - * <code>PP_VARTYPE_STRING</code> containing the web session ID of the session - * to be queried. - * - */ - void (*GetUsableKeyIds)(PP_Instance instance, - uint32_t promise_id, - struct PP_Var web_session_id); + struct PP_Var session_id); /** * Decrypts the block and returns the unencrypted block via * <code>DeliverBlock()</code> on the @@ -304,7 +305,7 @@ struct PPP_ContentDecryptor_Private_0_12 { const struct PP_EncryptedBlockInfo* encrypted_block_info); }; -typedef struct PPP_ContentDecryptor_Private_0_12 PPP_ContentDecryptor_Private; +typedef struct PPP_ContentDecryptor_Private_0_15 PPP_ContentDecryptor_Private; /** * @} */ diff --git a/chromium/ppapi/c/private/ppp_pdf.h b/chromium/ppapi/c/private/ppp_pdf.h index 144e95cdff7..2a761b8618a 100644 --- a/chromium/ppapi/c/private/ppp_pdf.h +++ b/chromium/ppapi/c/private/ppp_pdf.h @@ -5,6 +5,7 @@ #ifndef PPAPI_C_PRIVATE_PPP_PDF_H_ #define PPAPI_C_PRIVATE_PPP_PDF_H_ +#include "ppapi/c/dev/pp_print_settings_dev.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_var.h" @@ -20,15 +21,48 @@ typedef enum { } PP_PrivatePageTransformType; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_PrivatePageTransformType, 4); -struct PPP_Pdf_1 { +typedef enum { + PP_PRIVATEDUPLEXMODE_NONE = 0, + PP_PRIVATEDUPLEXMODE_SIMPLEX = 1, + PP_PRIVATEDUPLEXMODE_SHORT_EDGE = 2, + PP_PRIVATEDUPLEXMODE_LONG_EDGE = 3, + PP_PRIVATEDUPLEXMODE_LAST = PP_PRIVATEDUPLEXMODE_LONG_EDGE +} PP_PrivateDuplexMode_Dev; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_PrivateDuplexMode_Dev, 4); + +struct PP_PdfPrintPresetOptions_Dev { + // Returns whether scaling is disabled. Returns same information as the + // PPP_Printing_Dev's method IsScalingDiabled(). + PP_Bool is_scaling_disabled; + + // Number of copies to be printed. + int32_t copies; + + // DuplexMode to be used for printing. + PP_PrivateDuplexMode_Dev duplex; + + // True if all the pages in the PDF are the same size. + PP_Bool is_page_size_uniform; + + // Only valid if |is_page_size_uniform| is true. The page size. + PP_Size uniform_page_size; +}; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_PdfPrintPresetOptions_Dev, 24); + +struct PPP_Pdf_1_1 { // Returns an absolute URL if the position is over a link. PP_Var (*GetLinkAtPosition)(PP_Instance instance, PP_Point point); // Requests that the plugin apply the given transform to its view. void (*Transform)(PP_Instance instance, PP_PrivatePageTransformType type); + + // Return true if print preset options are updated from document. + PP_Bool (*GetPrintPresetOptionsFromDocument)( + PP_Instance instance, + PP_PdfPrintPresetOptions_Dev* options); }; -typedef PPP_Pdf_1 PPP_Pdf; +typedef PPP_Pdf_1_1 PPP_Pdf; #endif // PPAPI_C_PRIVATE_PPP_PDF_H_ diff --git a/chromium/ppapi/cpp/BUILD.gn b/chromium/ppapi/cpp/BUILD.gn new file mode 100644 index 00000000000..2e121bee1da --- /dev/null +++ b/chromium/ppapi/cpp/BUILD.gn @@ -0,0 +1,26 @@ +# Copyright 2015 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. + +import("//ppapi/ppapi_sources.gni") + +# Link to this target to get the PPAPI C++ wrapper objects and plugin startup +# code. See also "objects" below. +source_set("cpp") { + sources = [ + "module_embedder.h", + "ppp_entrypoints.cc", + ] + + deps = [ + ":objects", + "//ppapi/c", + ] +} + +# Link to this target to get only the PPAPI C++ wrapper objects but not the +# plugin startup code. Some plugins need special startup code that they supply +# themselves. +source_set("objects") { + sources = rebase_path(ppapi_sources.cpp_source_files, ".", "..") +} diff --git a/chromium/ppapi/cpp/dev/file_chooser_dev.cc b/chromium/ppapi/cpp/dev/file_chooser_dev.cc index b7124a1044b..2efb346dbee 100644 --- a/chromium/ppapi/cpp/dev/file_chooser_dev.cc +++ b/chromium/ppapi/cpp/dev/file_chooser_dev.cc @@ -82,7 +82,7 @@ void FileChooser_Dev::CallbackConverter(void* user_data, int32_t result) { // number of items is 0. void* output_buf = data->output.GetDataBuffer( data->output.user_data, - selected_files.size(), sizeof(PP_Resource)); + static_cast<uint32_t>(selected_files.size()), sizeof(PP_Resource)); if (output_buf) { if (!selected_files.empty()) { memcpy(output_buf, &selected_files[0], diff --git a/chromium/ppapi/cpp/dev/ime_input_event_dev.cc b/chromium/ppapi/cpp/dev/ime_input_event_dev.cc index 9ddc16e9138..3396a3980a2 100644 --- a/chromium/ppapi/cpp/dev/ime_input_event_dev.cc +++ b/chromium/ppapi/cpp/dev/ime_input_event_dev.cc @@ -61,7 +61,8 @@ IMEInputEvent_Dev::IMEInputEvent_Dev( uint32_t dummy = 0; PassRefFromConstructor(get_interface<PPB_IMEInputEvent_Dev_0_2>()->Create( instance.pp_instance(), type, time_stamp, text.pp_var(), - segment_offsets.empty() ? 0 : segment_offsets.size() - 1, + segment_offsets.empty() ? 0u : + static_cast<uint32_t>(segment_offsets.size() - 1), segment_offsets.empty() ? &dummy : &segment_offsets[0], target_segment, selection.first, selection.second)); } diff --git a/chromium/ppapi/cpp/dev/scriptable_object_deprecated.cc b/chromium/ppapi/cpp/dev/scriptable_object_deprecated.cc index 1b701cb6651..19c4738c007 100644 --- a/chromium/ppapi/cpp/dev/scriptable_object_deprecated.cc +++ b/chromium/ppapi/cpp/dev/scriptable_object_deprecated.cc @@ -73,8 +73,8 @@ void GetAllPropertyNames(void* object, const PPB_Memory_Dev* memory_if = static_cast<const PPB_Memory_Dev*>( pp::Module::Get()->GetBrowserInterface(PPB_MEMORY_DEV_INTERFACE)); - *properties = static_cast<PP_Var*>( - memory_if->MemAlloc(sizeof(PP_Var) * props.size())); + *properties = static_cast<PP_Var*>(memory_if->MemAlloc( + static_cast<uint32_t>(sizeof(PP_Var) * props.size()))); for (size_t i = 0; i < props.size(); ++i) (*properties)[i] = props[i].Detach(); diff --git a/chromium/ppapi/cpp/dev/video_decoder_dev.cc b/chromium/ppapi/cpp/dev/video_decoder_dev.cc index dcc3b5d44a4..df34986401d 100644 --- a/chromium/ppapi/cpp/dev/video_decoder_dev.cc +++ b/chromium/ppapi/cpp/dev/video_decoder_dev.cc @@ -42,7 +42,7 @@ void VideoDecoder_Dev::AssignPictureBuffers( if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource()) return; get_interface<PPB_VideoDecoder_Dev>()->AssignPictureBuffers( - pp_resource(), buffers.size(), &buffers[0]); + pp_resource(), static_cast<uint32_t>(buffers.size()), &buffers[0]); } int32_t VideoDecoder_Dev::Decode( diff --git a/chromium/ppapi/cpp/input_event.cc b/chromium/ppapi/cpp/input_event.cc index 93385bfc4d2..90f41fa2b8f 100644 --- a/chromium/ppapi/cpp/input_event.cc +++ b/chromium/ppapi/cpp/input_event.cc @@ -364,7 +364,8 @@ IMEInputEvent::IMEInputEvent( uint32_t dummy = 0; PassRefFromConstructor(get_interface<PPB_IMEInputEvent_1_0>()->Create( instance.pp_instance(), type, time_stamp, text.pp_var(), - segment_offsets.empty() ? 0 : segment_offsets.size() - 1, + segment_offsets.empty() ? 0u : + static_cast<uint32_t>(segment_offsets.size() - 1), segment_offsets.empty() ? &dummy : &segment_offsets[0], target_segment, selection.first, selection.second)); } diff --git a/chromium/ppapi/cpp/private/BUILD.gn b/chromium/ppapi/cpp/private/BUILD.gn new file mode 100644 index 00000000000..0aae3f16034 --- /dev/null +++ b/chromium/ppapi/cpp/private/BUILD.gn @@ -0,0 +1,10 @@ +# Copyright 2015 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. + +source_set("internal_module") { + sources = [ + "internal_module.cc", + "internal_module.h", + ] +} diff --git a/chromium/ppapi/cpp/private/camera_capabilities_private.cc b/chromium/ppapi/cpp/private/camera_capabilities_private.cc new file mode 100644 index 00000000000..ad3d435e51e --- /dev/null +++ b/chromium/ppapi/cpp/private/camera_capabilities_private.cc @@ -0,0 +1,73 @@ +// Copyright 2015 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/cpp/private/camera_capabilities_private.h" + +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_size.h" +#include "ppapi/cpp/instance_handle.h" +#include "ppapi/cpp/module_impl.h" + +namespace pp { + +namespace { + +template <> +const char* interface_name<PPB_CameraCapabilities_Private_0_1>() { + return PPB_CAMERACAPABILITIES_PRIVATE_INTERFACE_0_1; +} + +} // namespace + +CameraCapabilities_Private::CameraCapabilities_Private() { +} + +CameraCapabilities_Private::CameraCapabilities_Private( + const CameraCapabilities_Private& other) + : Resource(other) { +} + +CameraCapabilities_Private::CameraCapabilities_Private(const Resource& resource) + : Resource(resource) { + PP_DCHECK(IsCameraCapabilities(resource)); +} + +CameraCapabilities_Private::CameraCapabilities_Private(PassRef, + PP_Resource resource) + : Resource(PASS_REF, resource) { +} + +CameraCapabilities_Private::~CameraCapabilities_Private() { +} + +void CameraCapabilities_Private::GetSupportedVideoCaptureFormats( + std::vector<PP_VideoCaptureFormat>* formats) { + if (!has_interface<PPB_CameraCapabilities_Private_0_1>()) { + PP_DCHECK(false); + return; + } + + uint32_t array_size; + PP_VideoCaptureFormat* array; + get_interface<PPB_CameraCapabilities_Private_0_1>() + ->GetSupportedVideoCaptureFormats(pp_resource(), &array_size, &array); + formats->clear(); + formats->reserve(array_size); + for (uint32_t i = 0; i < array_size; i++) { + formats->push_back(array[i]); + } +} + +// static +bool CameraCapabilities_Private::IsCameraCapabilities( + const Resource& resource) { + if (!has_interface<PPB_CameraCapabilities_Private_0_1>()) + return false; + + return PP_ToBool( + get_interface<PPB_CameraCapabilities_Private_0_1>()->IsCameraCapabilities( + resource.pp_resource())); +} + +} // namespace pp diff --git a/chromium/ppapi/cpp/private/camera_capabilities_private.h b/chromium/ppapi/cpp/private/camera_capabilities_private.h index 5151c759e77..e0dbfe328ff 100644 --- a/chromium/ppapi/cpp/private/camera_capabilities_private.h +++ b/chromium/ppapi/cpp/private/camera_capabilities_private.h @@ -6,6 +6,8 @@ #ifndef PPAPI_CPP_PRIVATE_CAMERA_CAPABILITIES_PRIVATE_H_ #define PPAPI_CPP_PRIVATE_CAMERA_CAPABILITIES_PRIVATE_H_ +#include <vector> + #include "ppapi/c/private/ppb_camera_capabilities_private.h" #include "ppapi/cpp/resource.h" #include "ppapi/cpp/size.h" @@ -36,12 +38,6 @@ class CameraCapabilities_Private : public Resource { /// resource. explicit CameraCapabilities_Private(const Resource& resource); - /// Constructs a <code>CameraCapabilities_Private</code> object. - /// - /// @param[in] instance The instance with which this resource will be - /// associated. - explicit CameraCapabilities_Private(const InstanceHandle& instance); - /// A constructor used when you have received a <code>PP_Resource</code> as a /// return value that has had 1 ref added for you. /// @@ -52,19 +48,14 @@ class CameraCapabilities_Private : public Resource { // Destructor. ~CameraCapabilities_Private(); - /// GetSupportedPreviewSizes() returns the supported preview sizes for the - /// given <code>CameraCapabilities_Private</code>. + /// GetSupportedVideoCaptureFormats() returns the supported video capture + /// formats. /// - /// @param[out] A vector of <code>Size</code> corresponding to the - /// supported preview sizes in pixels. - void GetSupportedPreviewSizes(std::vector<Size>* preview_sizes); - - /// GetSupportedJpegSize() returns the supported JPEG sizes for the given - /// <code>CameraCapabilities_Private</code>. - /// - /// @param[out] A vector of <code>Size</code> corresponding to the - /// supported JPEG image sizes in pixels. - void GetSupportedJpegSizes(std::vector<Size>* jpeg_sizes); + /// @param[out] formats A vector of <code>PP_VideoCaptureFormat</code> + /// corresponding to the supported video capture formats. This output vector + /// must be prepared by the caller beforehand. + void GetSupportedVideoCaptureFormats( + std::vector<PP_VideoCaptureFormat>* formats); /// IsCameraCapabilities() determines if the given resource is a /// <code>CameraCapabilities_Private</code>. @@ -80,4 +71,3 @@ class CameraCapabilities_Private : public Resource { } // namespace pp #endif /* PPAPI_CPP_PRIVATE_CAMERA_CAPABILITIES_PRIVATE_H_ */ - diff --git a/chromium/ppapi/cpp/private/camera_device_private.cc b/chromium/ppapi/cpp/private/camera_device_private.cc new file mode 100644 index 00000000000..1ca39f7dc63 --- /dev/null +++ b/chromium/ppapi/cpp/private/camera_device_private.cc @@ -0,0 +1,87 @@ +// Copyright 2015 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/cpp/private/camera_device_private.h" + +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/cpp/completion_callback.h" +#include "ppapi/cpp/instance_handle.h" +#include "ppapi/cpp/module_impl.h" +#include "ppapi/cpp/private/camera_capabilities_private.h" + +namespace pp { + +namespace { + +template <> +const char* interface_name<PPB_CameraDevice_Private_0_1>() { + return PPB_CAMERADEVICE_PRIVATE_INTERFACE_0_1; +} + +} // namespace + +CameraDevice_Private::CameraDevice_Private() { +} + +CameraDevice_Private::CameraDevice_Private(const CameraDevice_Private& other) + : Resource(other) { +} + +CameraDevice_Private::CameraDevice_Private(const Resource& resource) + : Resource(resource) { + PP_DCHECK(IsCameraDevice(resource)); +} + +CameraDevice_Private::CameraDevice_Private(const InstanceHandle& instance) { + if (has_interface<PPB_CameraDevice_Private_0_1>()) { + PassRefFromConstructor( + get_interface<PPB_CameraDevice_Private_0_1>()->Create( + instance.pp_instance())); + return; + } + PP_DCHECK(false); +} + +CameraDevice_Private::CameraDevice_Private(PassRef, PP_Resource resource) + : Resource(PASS_REF, resource) { +} + +CameraDevice_Private::~CameraDevice_Private() { +} + +int32_t CameraDevice_Private::Open(const Var& device_id, + const CompletionCallback& callback) { + if (!has_interface<PPB_CameraDevice_Private_0_1>()) + return callback.MayForce(PP_ERROR_NOINTERFACE); + + return get_interface<PPB_CameraDevice_Private_0_1>()->Open( + pp_resource(), device_id.pp_var(), callback.pp_completion_callback()); +} + +void CameraDevice_Private::Close() { + if (has_interface<PPB_CameraDevice_Private_0_1>()) + get_interface<PPB_CameraDevice_Private_0_1>()->Close(pp_resource()); +} + +int32_t CameraDevice_Private::GetCameraCapabilities( + const CompletionCallbackWithOutput<CameraCapabilities_Private>& callback) { + if (!has_interface<PPB_CameraDevice_Private_0_1>()) + return callback.MayForce(PP_ERROR_NOINTERFACE); + + return get_interface<PPB_CameraDevice_Private_0_1>()->GetCameraCapabilities( + pp_resource(), callback.output(), callback.pp_completion_callback()); +} + +// static +bool CameraDevice_Private::IsCameraDevice(const Resource& resource) { + if (!has_interface<PPB_CameraDevice_Private_0_1>()) + return false; + + return PP_ToBool( + get_interface<PPB_CameraDevice_Private_0_1>()->IsCameraDevice( + resource.pp_resource())); +} + +} // namespace pp diff --git a/chromium/ppapi/cpp/private/camera_device_private.h b/chromium/ppapi/cpp/private/camera_device_private.h new file mode 100644 index 00000000000..dce1e1b1747 --- /dev/null +++ b/chromium/ppapi/cpp/private/camera_device_private.h @@ -0,0 +1,103 @@ +/* Copyright 2014 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_CPP_PRIVATE_CAMERA_DEVICE_PRIVATE_H_ +#define PPAPI_CPP_PRIVATE_CAMERA_DEVICE_PRIVATE_H_ + +#include "ppapi/c/private/ppb_camera_device_private.h" +#include "ppapi/cpp/resource.h" +#include "ppapi/cpp/var.h" + +/// @file +/// Defines the <code>CameraDevice_Private</code> interface. Used for +/// manipulating a camera device. +namespace pp { + +class CameraCapabilities_Private; +class CompletionCallback; +class InstanceHandle; + +template <typename T> +class CompletionCallbackWithOutput; + +/// To query camera capabilities: +/// 1. Create a CameraDevice_Private object. +/// 2. Open() camera device with track id of MediaStream video track. +/// 3. Call GetCameraCapabilities() to get a +/// <code>CameraCapabilities_Private</code> object, which can be used to +/// query camera capabilities. +class CameraDevice_Private : public Resource { + public: + /// Default constructor for creating an is_null() + /// <code>CameraDevice_Private</code> object. + CameraDevice_Private(); + + /// The copy constructor for <code>CameraDevice_Private</code>. + /// + /// @param[in] other A reference to a <code>CameraDevice_Private</code>. + CameraDevice_Private(const CameraDevice_Private& other); + + /// Constructs a <code>CameraDevice_Private</code> from a + /// <code>Resource</code>. + /// + /// @param[in] resource A <code>PPB_CameraDevice_Private</code> resource. + explicit CameraDevice_Private(const Resource& resource); + + /// Constructs a CameraDevice_Private resource. + /// + /// @param[in] instance A <code>PP_Instance</code> identifying one instance + /// of a module. + explicit CameraDevice_Private(const InstanceHandle& instance); + + /// A constructor used when you have received a <code>PP_Resource</code> as a + /// return value that has had 1 ref added for you. + /// + /// @param[in] resource A <code>PPB_CameraDevice_Private</code> resource. + CameraDevice_Private(PassRef, PP_Resource resource); + + // Destructor. + ~CameraDevice_Private(); + + /// Opens a camera device. + /// + /// @param[in] device_id A <code>Var</code> identifying a camera + /// device. The type is string. The ID can be obtained from + /// MediaStreamTrack.getSources() or MediaStreamVideoTrack.id. + /// @param[in] callback A <code>CompletionCallback</code> to be called upon + /// completion of <code>Open()</code>. + /// + /// @return An int32_t containing a result code from <code>pp_errors.h</code>. + int32_t Open(const Var& device_id, const CompletionCallback& callback); + + /// Disconnects from the camera and cancels all pending requests. + /// After this returns, no callbacks will be called. If <code> + /// CameraDevice_Private</code> is destroyed and is not closed yet, this + /// function will be automatically called. Calling this more than once has no + /// effect. + void Close(); + + /// Gets the camera capabilities. + /// + /// The camera capabilities do not change for a given camera source. + /// + /// @param[in] callback A <code>CompletionCallbackWithOutput</code> + /// to be called upon completion. + /// + /// @return An int32_t containing a result code from <code>pp_errors.h</code>. + int32_t GetCameraCapabilities( + const CompletionCallbackWithOutput<CameraCapabilities_Private>& callback); + + /// Determines if a resource is a camera device resource. + /// + /// @param[in] resource The <code>Resource</code> to test. + /// + /// @return true if the given resource is a camera device resource or false + /// otherwise. + static bool IsCameraDevice(const Resource& resource); +}; + +} // namespace pp + +#endif /* PPAPI_CPP_PRIVATE_CAMERA_DEVICE_PRIVATE_H_ */ diff --git a/chromium/ppapi/cpp/private/content_decryptor_private.cc b/chromium/ppapi/cpp/private/content_decryptor_private.cc index 65f822cc2b0..f87ef18c95d 100644 --- a/chromium/ppapi/cpp/private/content_decryptor_private.cc +++ b/chromium/ppapi/cpp/private/content_decryptor_private.cc @@ -25,7 +25,10 @@ static const char kPPPContentDecryptorInterface[] = PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE; void Initialize(PP_Instance instance, - PP_Var key_system_arg) { + uint32_t promise_id, + PP_Var key_system_arg, + PP_Bool allow_distinctive_identifier, + PP_Bool allow_persistent_state) { void* object = Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); if (!object) @@ -35,8 +38,10 @@ void Initialize(PP_Instance instance, if (!key_system_var.is_string()) return; - static_cast<ContentDecryptor_Private*>(object)->Initialize( - key_system_var.AsString()); + static_cast<ContentDecryptor_Private*>(object) + ->Initialize(promise_id, key_system_var.AsString(), + PP_ToBool(allow_distinctive_identifier), + PP_ToBool(allow_persistent_state)); } void SetServerCertificate(PP_Instance instance, @@ -56,59 +61,54 @@ void SetServerCertificate(PP_Instance instance, ->SetServerCertificate(promise_id, server_certificate); } -void CreateSession(PP_Instance instance, - uint32_t promise_id, - PP_Var init_data_type_arg, - PP_Var init_data_arg, - PP_SessionType session_type) { +void CreateSessionAndGenerateRequest(PP_Instance instance, + uint32_t promise_id, + PP_SessionType session_type, + PP_InitDataType init_data_type, + PP_Var init_data_arg) { void* object = Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); if (!object) return; - pp::Var init_data_type_var(pp::PASS_REF, init_data_type_arg); - if (!init_data_type_var.is_string()) - return; - pp::Var init_data_var(pp::PASS_REF, init_data_arg); if (!init_data_var.is_array_buffer()) return; pp::VarArrayBuffer init_data_array_buffer(init_data_var); static_cast<ContentDecryptor_Private*>(object) - ->CreateSession(promise_id, - init_data_type_var.AsString(), - init_data_array_buffer, - session_type); + ->CreateSessionAndGenerateRequest(promise_id, session_type, + init_data_type, init_data_array_buffer); } void LoadSession(PP_Instance instance, uint32_t promise_id, - PP_Var web_session_id_arg) { + PP_SessionType session_type, + PP_Var session_id_arg) { void* object = Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); if (!object) return; - pp::Var web_session_id_var(web_session_id_arg); - if (!web_session_id_var.is_string()) + pp::Var session_id_var(session_id_arg); + if (!session_id_var.is_string()) return; static_cast<ContentDecryptor_Private*>(object) - ->LoadSession(promise_id, web_session_id_var.AsString()); + ->LoadSession(promise_id, session_type, session_id_var.AsString()); } void UpdateSession(PP_Instance instance, uint32_t promise_id, - PP_Var web_session_id_arg, + PP_Var session_id_arg, PP_Var response_arg) { void* object = Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); if (!object) return; - pp::Var web_session_id_var(web_session_id_arg); - if (!web_session_id_var.is_string()) + pp::Var session_id_var(session_id_arg); + if (!session_id_var.is_string()) return; pp::Var response_var(response_arg); @@ -117,55 +117,39 @@ void UpdateSession(PP_Instance instance, pp::VarArrayBuffer response(response_var); static_cast<ContentDecryptor_Private*>(object) - ->UpdateSession(promise_id, web_session_id_var.AsString(), response); + ->UpdateSession(promise_id, session_id_var.AsString(), response); } void CloseSession(PP_Instance instance, uint32_t promise_id, - PP_Var web_session_id_arg) { + PP_Var session_id_arg) { void* object = Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); if (!object) return; - pp::Var web_session_id_var(web_session_id_arg); - if (!web_session_id_var.is_string()) + pp::Var session_id_var(session_id_arg); + if (!session_id_var.is_string()) return; static_cast<ContentDecryptor_Private*>(object) - ->CloseSession(promise_id, web_session_id_var.AsString()); + ->CloseSession(promise_id, session_id_var.AsString()); } void RemoveSession(PP_Instance instance, uint32_t promise_id, - PP_Var web_session_id_arg) { - void* object = - Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); - if (!object) - return; - - pp::Var web_session_id_var(web_session_id_arg); - if (!web_session_id_var.is_string()) - return; - - static_cast<ContentDecryptor_Private*>(object) - ->RemoveSession(promise_id, web_session_id_var.AsString()); -} - -void GetUsableKeyIds(PP_Instance instance, - uint32_t promise_id, - PP_Var web_session_id_arg) { + PP_Var session_id_arg) { void* object = Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); if (!object) return; - pp::Var web_session_id_var(web_session_id_arg); - if (!web_session_id_var.is_string()) + pp::Var session_id_var(session_id_arg); + if (!session_id_var.is_string()) return; static_cast<ContentDecryptor_Private*>(object) - ->GetUsableKeyIds(promise_id, web_session_id_var.AsString()); + ->RemoveSession(promise_id, session_id_var.AsString()); } void Decrypt(PP_Instance instance, @@ -258,12 +242,11 @@ void DecryptAndDecode(PP_Instance instance, const PPP_ContentDecryptor_Private ppp_content_decryptor = { &Initialize, &SetServerCertificate, - &CreateSession, + &CreateSessionAndGenerateRequest, &LoadSession, &UpdateSession, &CloseSession, &RemoveSession, - &GetUsableKeyIds, &Decrypt, &InitializeAudioDecoder, &InitializeVideoDecoder, @@ -299,30 +282,12 @@ void ContentDecryptor_Private::PromiseResolved(uint32_t promise_id) { void ContentDecryptor_Private::PromiseResolvedWithSession( uint32_t promise_id, - const std::string& web_session_id) { + const std::string& session_id) { if (has_interface<PPB_ContentDecryptor_Private>()) { - pp::Var web_session_id_var(web_session_id); + pp::Var session_id_var(session_id); get_interface<PPB_ContentDecryptor_Private>()->PromiseResolvedWithSession( - associated_instance_.pp_instance(), - promise_id, - web_session_id_var.pp_var()); - } -} - -void ContentDecryptor_Private::PromiseResolvedWithKeyIds( - uint32_t promise_id, - const std::vector<std::vector<uint8_t> >& key_ids) { - if (has_interface<PPB_ContentDecryptor_Private>()) { - pp::VarArray key_ids_array = pp::VarArray(); - key_ids_array.SetLength(key_ids.size()); - for (size_t i = 0; i < key_ids.size(); ++i) { - const std::vector<uint8_t>& entry = key_ids[i]; - pp::VarArrayBuffer array_buffer(entry.size()); - memcpy(array_buffer.Map(), &entry[0], entry.size()); - key_ids_array.Set(i, array_buffer); - } - get_interface<PPB_ContentDecryptor_Private>()->PromiseResolvedWithKeyIds( - associated_instance_.pp_instance(), promise_id, key_ids_array.pp_var()); + associated_instance_.pp_instance(), promise_id, + session_id_var.pp_var()); } } @@ -343,75 +308,63 @@ void ContentDecryptor_Private::PromiseRejected( } void ContentDecryptor_Private::SessionMessage( - const std::string& web_session_id, + const std::string& session_id, + PP_CdmMessageType message_type, pp::VarArrayBuffer message, - const std::string& destination_url) { + const std::string& legacy_destination_url) { if (has_interface<PPB_ContentDecryptor_Private>()) { - pp::Var web_session_id_var(web_session_id); - pp::Var destination_url_var(destination_url); + pp::Var session_id_var(session_id); + pp::Var legacy_destination_url_var(legacy_destination_url); get_interface<PPB_ContentDecryptor_Private>()->SessionMessage( - associated_instance_.pp_instance(), - web_session_id_var.pp_var(), - message.pp_var(), - destination_url_var.pp_var()); + associated_instance_.pp_instance(), session_id_var.pp_var(), + message_type, message.pp_var(), legacy_destination_url_var.pp_var()); } } void ContentDecryptor_Private::SessionKeysChange( - const std::string& web_session_id, - bool has_additional_usable_key) { + const std::string& session_id, + bool has_additional_usable_key, + const std::vector<PP_KeyInformation>& key_information) { if (has_interface<PPB_ContentDecryptor_Private>()) { - pp::Var web_session_id_var(web_session_id); + pp::Var session_id_var(session_id); get_interface<PPB_ContentDecryptor_Private>()->SessionKeysChange( - associated_instance_.pp_instance(), - web_session_id_var.pp_var(), - PP_FromBool(has_additional_usable_key)); + associated_instance_.pp_instance(), session_id_var.pp_var(), + PP_FromBool(has_additional_usable_key), + static_cast<uint32_t>(key_information.size()), + key_information.empty() ? NULL : &key_information[0]); } } void ContentDecryptor_Private::SessionExpirationChange( - const std::string& web_session_id, + const std::string& session_id, PP_Time new_expiry_time) { if (has_interface<PPB_ContentDecryptor_Private>()) { - pp::Var web_session_id_var(web_session_id); + pp::Var session_id_var(session_id); get_interface<PPB_ContentDecryptor_Private>()->SessionExpirationChange( - associated_instance_.pp_instance(), - web_session_id_var.pp_var(), + associated_instance_.pp_instance(), session_id_var.pp_var(), new_expiry_time); } } -void ContentDecryptor_Private::SessionReady(const std::string& web_session_id) { +void ContentDecryptor_Private::SessionClosed(const std::string& session_id) { if (has_interface<PPB_ContentDecryptor_Private>()) { - pp::Var web_session_id_var(web_session_id); - get_interface<PPB_ContentDecryptor_Private>()->SessionReady( - associated_instance_.pp_instance(), web_session_id_var.pp_var()); - } -} - -void ContentDecryptor_Private::SessionClosed( - const std::string& web_session_id) { - if (has_interface<PPB_ContentDecryptor_Private>()) { - pp::Var web_session_id_var(web_session_id); + pp::Var session_id_var(session_id); get_interface<PPB_ContentDecryptor_Private>()->SessionClosed( - associated_instance_.pp_instance(), web_session_id_var.pp_var()); + associated_instance_.pp_instance(), session_id_var.pp_var()); } } -void ContentDecryptor_Private::SessionError( - const std::string& web_session_id, +void ContentDecryptor_Private::LegacySessionError( + const std::string& session_id, PP_CdmExceptionCode exception_code, uint32_t system_code, const std::string& error_description) { if (has_interface<PPB_ContentDecryptor_Private>()) { - pp::Var web_session_id_var(web_session_id); + pp::Var session_id_var(session_id); pp::Var error_description_var(error_description); - get_interface<PPB_ContentDecryptor_Private>()->SessionError( - associated_instance_.pp_instance(), - web_session_id_var.pp_var(), - exception_code, - system_code, - error_description_var.pp_var()); + get_interface<PPB_ContentDecryptor_Private>()->LegacySessionError( + associated_instance_.pp_instance(), session_id_var.pp_var(), + exception_code, system_code, error_description_var.pp_var()); } } diff --git a/chromium/ppapi/cpp/private/content_decryptor_private.h b/chromium/ppapi/cpp/private/content_decryptor_private.h index 25aba52c1f8..18d2367fc4b 100644 --- a/chromium/ppapi/cpp/private/content_decryptor_private.h +++ b/chromium/ppapi/cpp/private/content_decryptor_private.h @@ -34,24 +34,27 @@ class ContentDecryptor_Private { // TODO(tomfinegan): This could be optimized to pass pp::Var instead of // strings. The change would allow the CDM wrapper to reuse vars when // replying to the browser. - virtual void Initialize(const std::string& key_system) = 0; + virtual void Initialize(uint32_t promise_id, + const std::string& key_system, + bool allow_distinctive_identifier, + bool allow_persistent_state) = 0; virtual void SetServerCertificate(uint32_t promise_id, pp::VarArrayBuffer server_certificate) = 0; - virtual void CreateSession(uint32_t promise_id, - const std::string& init_data_type, - pp::VarArrayBuffer init_data, - PP_SessionType session_type) = 0; + virtual void CreateSessionAndGenerateRequest( + uint32_t promise_id, + PP_SessionType session_type, + PP_InitDataType init_data_type, + pp::VarArrayBuffer init_data) = 0; virtual void LoadSession(uint32_t promise_id, - const std::string& web_session_id) = 0; + PP_SessionType session_type, + const std::string& session_id) = 0; virtual void UpdateSession(uint32_t promise_id, - const std::string& web_session_id, + const std::string& session_id, pp::VarArrayBuffer response) = 0; virtual void CloseSession(uint32_t promise_id, - const std::string& web_session_id) = 0; + const std::string& session_id) = 0; virtual void RemoveSession(uint32_t promise_id, - const std::string& web_session_id) = 0; - virtual void GetUsableKeyIds(uint32_t promise_id, - const std::string& web_session_id) = 0; + const std::string& session_id) = 0; virtual void Decrypt(pp::Buffer_Dev encrypted_buffer, const PP_EncryptedBlockInfo& encrypted_block_info) = 0; virtual void InitializeAudioDecoder( @@ -74,27 +77,25 @@ class ContentDecryptor_Private { // to the browser. void PromiseResolved(uint32_t promise_id); void PromiseResolvedWithSession(uint32_t promise_id, - const std::string& web_session_id); - void PromiseResolvedWithKeyIds( - uint32_t promise_id, - const std::vector<std::vector<uint8_t> >& key_ids); + const std::string& session_id); void PromiseRejected(uint32_t promise_id, PP_CdmExceptionCode exception_code, uint32_t system_code, const std::string& error_description); - void SessionMessage(const std::string& web_session_id, + void SessionMessage(const std::string& session_id, + PP_CdmMessageType message_type, pp::VarArrayBuffer message, - const std::string& destination_url); - void SessionKeysChange(const std::string& web_session_id, - bool has_additional_usable_key); - void SessionExpirationChange(const std::string& web_session_id, + const std::string& legacy_destination_url); + void SessionKeysChange(const std::string& session_id, + bool has_additional_usable_key, + const std::vector<PP_KeyInformation>& key_information); + void SessionExpirationChange(const std::string& session_id, PP_Time new_expiry_time); - void SessionReady(const std::string& web_session_id); - void SessionClosed(const std::string& web_session_id); - void SessionError(const std::string& web_session_id, - PP_CdmExceptionCode exception_code, - uint32_t system_code, - const std::string& error_description); + void SessionClosed(const std::string& session_id); + void LegacySessionError(const std::string& session_id, + PP_CdmExceptionCode exception_code, + uint32_t system_code, + const std::string& error_description); // The plugin must not hold a reference to the encrypted buffer resource // provided to Decrypt() when it calls this method. The browser will reuse diff --git a/chromium/ppapi/cpp/private/flash_clipboard.cc b/chromium/ppapi/cpp/private/flash_clipboard.cc index 77e68ba3ad1..1fb5288b2bb 100644 --- a/chromium/ppapi/cpp/private/flash_clipboard.cc +++ b/chromium/ppapi/cpp/private/flash_clipboard.cc @@ -133,7 +133,7 @@ bool Clipboard::WriteData( rv = (get_interface<PPB_Flash_Clipboard_5_1>()->WriteData( instance.pp_instance(), clipboard_type, - data_items.size(), + static_cast<uint32_t>(data_items.size()), formats_ptr, data_items_ptr) == PP_OK); } else if (has_interface<PPB_Flash_Clipboard_5_0>()) { @@ -155,7 +155,7 @@ bool Clipboard::WriteData( rv = (get_interface<PPB_Flash_Clipboard_5_0>()->WriteData( instance.pp_instance(), clipboard_type, - data_items.size(), + static_cast<uint32_t>(data_items.size()), formats_ptr, data_items_ptr) == PP_OK); } else if (has_interface<PPB_Flash_Clipboard_4_0>()) { @@ -180,7 +180,7 @@ bool Clipboard::WriteData( rv = (get_interface<PPB_Flash_Clipboard_4_0>()->WriteData( instance.pp_instance(), clipboard_type, - data_items.size(), + static_cast<uint32_t>(data_items.size()), formats_ptr, data_items_ptr) == PP_OK); } diff --git a/chromium/ppapi/cpp/private/image_capture_config_private.h b/chromium/ppapi/cpp/private/image_capture_config_private.h deleted file mode 100644 index a4847fb35a4..00000000000 --- a/chromium/ppapi/cpp/private/image_capture_config_private.h +++ /dev/null @@ -1,99 +0,0 @@ -/* Copyright 2014 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_CPP_PRIVATE_IMAGE_CAPTURE_CONFIG_PRIVATE_H_ -#define PPAPI_CPP_PRIVATE_IMAGE_CAPTURE_CONFIG_PRIVATE_H_ - -#include "ppapi/c/private/ppb_image_capture_config_private.h" -#include "ppapi/cpp/resource.h" -#include "ppapi/cpp/size.h" - -/// @file -/// This file defines the ImageCaptureConfig_Private interface for -/// establishing an image capture configuration resource within the browser. -namespace pp { - -/// The <code>ImageCaptureConfig_Private</code> interface contains methods for -/// establishing image capture configuration within the browser. The new -/// configuration will take effect after <code> -/// ImageCaptureConfig_Private.SetConfig</code> is called. -class ImageCaptureConfig_Private { - public: - /// Default constructor for creating an is_null() - /// <code>ImageCaptureConfig_Private</code> object. - ImageCaptureConfig_Private(); - - /// The copy constructor for <code>ImageCaptureConfig_Private</code>. - /// - /// @param[in] other A reference to a <code>ImageCaptureConfig_Private - /// </code>. - ImageCaptureConfig_Private(const ImageCaptureConfig_Private& other); - - /// Constructs a <code>ImageCaptureConfig_Private</code> from a <code> - /// Resource</code>. - /// - /// @param[in] resource A <code>PPB_ImageCaptureConfig_Private</code> - /// resource. - explicit ImageCaptureConfig_Private(const Resource& resource); - - /// Constructs a <code>ImageCaptureConfig_Private</code> object. - /// - /// @param[in] instance The instance with which this resource will be - /// associated. - explicit ImageCaptureConfig_Private(const InstanceHandle& instance); - - /// A constructor used when you have received a <code>PP_Resource</code> as a - /// return value that has had 1 ref added for you. - /// - /// @param[in] resource A <code>PPB_ImageCaptureConfig_Private</code> - /// resource. - ImageCaptureConfig_Private(PassRef, PP_Resource resource); - - // Destructor. - ~ImageCaptureConfig_Private(); - - /// GetPreviewSize() returns the preview image size in pixels for the given - /// <code>ImageCaptureConfig_Private</code>. - /// - /// @param[out] preview_size A <code>Size</code> that indicates the - /// requested preview image size. - void GetPreviewSize(Size* preview_size); - - /// SetPreviewSize() sets the preview image size for the given <code> - /// ImageCaptureConfig_Private</code>. - /// - /// @param[in] preview_size A <code>Size</code> that indicates the - /// requested preview image size. - void SetPreviewSize(const Size& preview_size); - - /// GetJpegSize() returns the JPEG image size in pixels for the given - /// <code>ImageCaptureConfig_Private</code>. - /// - /// @param[out] jpeg_size A <code>Size</code> that indicates the current - /// JPEG image size. - void GetJpegSize(Size* jpeg_size); - - /// SetJpegSize() sets the JPEG image size for the given <code> - /// ImageCaptureConfig_Private</code>. - /// - /// @param[in] jpeg_size A <code>Size</code> that indicates the requested - /// JPEG image size. - void SetJpegSize(const Size& jpeg_size); - - /// IsImageCaptureConfig() determines if the given resource is a - /// <code>ImageCaptureConfig_Private</code>. - /// - /// @param[in] resource A <code>Resource</code> corresponding to an image - /// capture config resource. - /// - /// @return true if the given resource is an <code> - /// ImageCaptureConfig_Private</code> resource, otherwise false. - static bool IsImageCaptureConfig(const Resource& resource); -}; - -} // namespace pp - -#endif /* PPAPI_CPP_PRIVATE_IMAGE_CAPTURE_CONFIG_PRIVATE_H_ */ - diff --git a/chromium/ppapi/cpp/private/image_capture_private.h b/chromium/ppapi/cpp/private/image_capture_private.h deleted file mode 100644 index ab4afbbdcd9..00000000000 --- a/chromium/ppapi/cpp/private/image_capture_private.h +++ /dev/null @@ -1,179 +0,0 @@ -/* Copyright 2014 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_CPP_PRIVATE_IMAGE_CAPTURE_PRIVATE_H_ -#define PPAPI_CPP_PRIVATE_IMAGE_CAPTURE_PRIVATE_H_ - -#include "ppapi/c/private/ppb_image_capture_private.h" -#include "ppapi/cpp/completion_callback.h" -#include "ppapi/cpp/private/camera_capabilities_private.h" -#include "ppapi/cpp/private/image_capture_config_private.h" -#include "ppapi/cpp/resource.h" -#include "ppapi/cpp/var.h" - -/// @file -/// Defines the <code>ImageCapture_Private</code> interface. Used for -/// acquiring a single still image from a camera source. -namespace pp { - -/// To capture a still image with this class, use the following steps. -/// 1. Create an ImageCapture_Private object by the constructor. -/// 2. Call GetCameraCapabilities to get the supported preview sizes. -/// 3. For optimal performance, set one of the supported preview size as the -/// constraints of getUserMedia. Use the created MediaStreamVideoTrack for -/// camera previews. -/// 4. Set the same preview size and other settings by SetConfig. -/// 5. Call CaptureStillImage to capture a still image. Play the shutter sound -/// in the shutter callback. The image from the preview callback can be used -/// for display. JPEG image will be returned to the JPEG callback. -class ImageCapture_Private { - public: - /// Default constructor for creating an is_null() - /// <code>ImageCapture_Private</code> object. - ImageCapture_Private(); - - /// Creates an ImageCapture_Private resource. - /// - /// @param[in] instance A <code>PP_Instance</code> identifying one instance - /// of a module. - /// @param[in] camera_source_id A <code>Var</code> identifying a camera - /// source. The type is string. The ID can be obtained from - /// MediaStreamTrack.getSources() or MediaStreamVideoTrack.id. If a - /// MediaStreamVideoTrack is associated with the same source and the track - /// is closed, this ImageCapture_Private object can still do image capture. - /// @param[in] error_callback A <code>ImageCapture_Private_ErrorCallback - /// </code> callback to indicate the image capture has failed. - /// @param[inout] user_data An opaque pointer that will be passed to the - /// callbacks of ImageCapture_Private. - ImageCapture_Private(const InstanceHandle& instance, - const Var& camera_source_id, - PPB_ImageCapture_Private_ErrorCallback error_callback, - void* user_data); - - /// Constructs a <code>ImageCapture_Private</code> from a <code> - /// Resource</code>. - /// - /// @param[in] resource A <code>ImageCapture_Private</code> - /// resource. - explicit ImageCapture_Private(const Resource& resource); - - /// A constructor used when you have received a <code>PP_Resource</code> as a - /// return value that has had 1 ref added for you. - /// - /// @param[in] resource A <code>ImageCapture_Private</code> - /// resource. - ImageCapture_Private(PassRef, PP_Resource resource); - - // Destructor. - ~ImageCapture_Private(); - - /// Disconnects from the camera and cancels all pending capture requests. - /// After this returns, no callbacks will be called. If <code> - /// ImageCapture_Private</code> is destroyed and is not closed yet, this - /// function will be automatically called. Calling this more than once has no - /// effect. - /// - /// @param[in] callback <code>CompletionCallback</code> to be called upon - /// completion of <code>Close()</code>. - /// - /// @return An int32_t containing a result code from <code>pp_errors.h</code>. - int32_t Close(const CompletionCallback& callback); - - /// Sets the configuration of the image capture. - /// If <code>SetConfig()</code> is not called, default settings will be used. - /// - /// @param[in] config A <code>ImageCaptureConfig_Private</code> object. - /// @param[in] callback <code>CompletionCallback</code> to be called upon - /// completion of <code>SetConfig()</code>. - /// - /// @return An int32_t containing a result code from <code>pp_errors.h</code>. - /// Returns <code>PP_ERROR_INPROGRESS</code> if there is a pending call of - /// <code>SetConfig()</code> or <code>CaptureStillImage()</code>. - /// If an error is returned, the configuration will not be changed. - int32_t SetConfig(const ImageCaptureConfig_Private& config, - const CompletionCallback& callback); - - /// Gets the configuration of the image capture. - /// - /// @param[in] callback A <code>CompletionCallbackWithOutput</code> - /// to be called upon completion. - /// - /// @return An int32_t containing a result code from <code>pp_errors.h</code>. - int32_t GetConfig( - const CompletionCallbackWithOutput<ImageCaptureConfig_Private>& callback); - - /// Gets the camera capabilities. - /// - /// The camera capabilities do not change for a given camera source. - /// - /// @param[in] callback A <code>CompletionCallbackWithOutput</code> - /// to be called upon completion. - /// - /// @return An int32_t containing a result code from <code>pp_errors.h</code>. - int32_t GetCameraCapabilities( - const CompletionCallbackWithOutput<CameraCapabilities_Private>& callback); - - /// Captures a still JPEG image from the camera. - /// - /// Triggers an asynchronous image capture. The camera will initiate a series - /// of callbacks to the application as the image capture progresses. The - /// callbacks will be invoked in the order of shutter callback, preview - /// callback, and JPEG callback. The shutter callback occurs after the image - /// is captured. This can be used to trigger a sound to let the user know that - /// image has been captured. The preview callback occurs when a scaled, fully - /// processed preview image is available. The JPEG callback occurs when the - /// compressed image is available. If there is an error after the capture is - /// in progress, the error callback passed to <code> - /// ImageCapture_Private.Create()</code> will be invoked. All the callbacks - /// are invoked by the thread that calls this function. - /// - /// The size of the preview image in preview callback is determined by - /// <code>ImageCaptureConfig_Private.SetPreviewSize</code>. The format is - /// decided by the camera and can be got from <code>VideoFrame.GetFormat - /// </code>. The size of the JPEG image is determined by <code> - /// ImageCaptureConfig_Private.SetJpegSize</code>. - /// - /// The camera may need to stop and re-start streaming during image capture. - /// If some MediaStreamVideoTrack are associated with the camera source, they - /// will receive mute and unmute events. The mute event will be received - /// before all the callbacks. The unmute event will be received after all the - /// callbacks. The preview image will not be sent to the video tracks - /// associated with the camera. - /// - /// @param[in] shutter_callback A <code> - /// ImageCapture_Private_ShutterCallback</code> callback to indicate the - /// image has been taken. - /// @param[in] preview_callback A <code> - /// ImageCapture_Private_PreviewCallback</code> callback to return a - /// preview of the captured image. - /// @param[in] jpeg_callback A <code> - /// ImageCapture_Private_JpegCallback</code> callback to return captured - /// JPEG image. - /// @param[out] sequence_id The sequence ID is a unique monotonically - /// increasing value starting from 0, incremented every time a new request - /// like image capture is submitted. - /// - /// @return An int32_t containing a result code from <code>pp_errors.h</code>. - /// PP_OK means the callbacks will be triggered. Other values mean the - /// callbacks will not be triggered. - int32_t CaptureStillImage( - PPB_ImageCapture_Private_ShutterCallback shutter_callback, - PPB_ImageCapture_Private_PreviewCallback preview_callback, - PPB_ImageCapture_Private_JpegCallback jpeg_callback, - int64_t* sequence_id); - - /// Determines if a resource is an image capture resource. - /// - /// @param[in] resource The <code>Resource</code> to test. - /// - /// @return true if the given resource is an image capture resource or false - /// otherwise. - static bool IsImageCapture(const Resource& resource); -}; - -} // namespace pp - -#endif /* PPAPI_CPP_PRIVATE_IMAGE_CAPTURE_PRIVATE_H_ */ - diff --git a/chromium/ppapi/cpp/private/pdf.cc b/chromium/ppapi/cpp/private/pdf.cc index ac5b941fad4..17b0b4d2a71 100644 --- a/chromium/ppapi/cpp/private/pdf.cc +++ b/chromium/ppapi/cpp/private/pdf.cc @@ -197,4 +197,22 @@ void PDF::SetLinkUnderCursor(const InstanceHandle& instance, const char* url) { get_interface<PPB_PDF>()->SetLinkUnderCursor(instance.pp_instance(), url); } +// static +void PDF::GetV8ExternalSnapshotData(const InstanceHandle& instance, + const char** natives_data_out, + int* natives_size_out, + const char** snapshot_data_out, + int* snapshot_size_out) { + if (has_interface<PPB_PDF>()) { + get_interface<PPB_PDF>()->GetV8ExternalSnapshotData(instance.pp_instance(), + natives_data_out, natives_size_out, snapshot_data_out, + snapshot_size_out); + return; + } + *natives_data_out = NULL; + *snapshot_data_out = NULL; + *natives_size_out = 0; + *snapshot_size_out = 0; +} + } // namespace pp diff --git a/chromium/ppapi/cpp/private/pdf.h b/chromium/ppapi/cpp/private/pdf.h index 586952c98be..160c8264269 100644 --- a/chromium/ppapi/cpp/private/pdf.h +++ b/chromium/ppapi/cpp/private/pdf.h @@ -63,6 +63,11 @@ class PDF { const char* selected_text); static void SetLinkUnderCursor(const InstanceHandle& instance, const char* url); + static void GetV8ExternalSnapshotData(const InstanceHandle& instance, + const char** natives_data_out, + int* natives_size_out, + const char** snapshot_data_out, + int* snapshot_size_out); }; } // namespace pp diff --git a/chromium/ppapi/cpp/tcp_socket.cc b/chromium/ppapi/cpp/tcp_socket.cc index ab08ff3626c..900d2ad4959 100644 --- a/chromium/ppapi/cpp/tcp_socket.cc +++ b/chromium/ppapi/cpp/tcp_socket.cc @@ -21,13 +21,20 @@ template <> const char* interface_name<PPB_TCPSocket_1_1>() { return PPB_TCPSOCKET_INTERFACE_1_1; } +template <> const char* interface_name<PPB_TCPSocket_1_2>() { + return PPB_TCPSOCKET_INTERFACE_1_2; +} + } // namespace TCPSocket::TCPSocket() { } TCPSocket::TCPSocket(const InstanceHandle& instance) { - if (has_interface<PPB_TCPSocket_1_1>()) { + if (has_interface<PPB_TCPSocket_1_2>()) { + PassRefFromConstructor(get_interface<PPB_TCPSocket_1_2>()->Create( + instance.pp_instance())); + } else if (has_interface<PPB_TCPSocket_1_1>()) { PassRefFromConstructor(get_interface<PPB_TCPSocket_1_1>()->Create( instance.pp_instance())); } else if (has_interface<PPB_TCPSocket_1_0>()) { @@ -53,12 +60,17 @@ TCPSocket& TCPSocket::operator=(const TCPSocket& other) { // static bool TCPSocket::IsAvailable() { - return has_interface<PPB_TCPSocket_1_1>() || + return has_interface<PPB_TCPSocket_1_2>() || + has_interface<PPB_TCPSocket_1_1>() || has_interface<PPB_TCPSocket_1_0>(); } int32_t TCPSocket::Bind(const NetAddress& addr, const CompletionCallback& callback) { + if (has_interface<PPB_TCPSocket_1_2>()) { + return get_interface<PPB_TCPSocket_1_2>()->Bind( + pp_resource(), addr.pp_resource(), callback.pp_completion_callback()); + } if (has_interface<PPB_TCPSocket_1_1>()) { return get_interface<PPB_TCPSocket_1_1>()->Bind( pp_resource(), addr.pp_resource(), callback.pp_completion_callback()); @@ -68,6 +80,10 @@ int32_t TCPSocket::Bind(const NetAddress& addr, int32_t TCPSocket::Connect(const NetAddress& addr, const CompletionCallback& callback) { + if (has_interface<PPB_TCPSocket_1_2>()) { + return get_interface<PPB_TCPSocket_1_2>()->Connect( + pp_resource(), addr.pp_resource(), callback.pp_completion_callback()); + } if (has_interface<PPB_TCPSocket_1_1>()) { return get_interface<PPB_TCPSocket_1_1>()->Connect( pp_resource(), addr.pp_resource(), callback.pp_completion_callback()); @@ -80,6 +96,11 @@ int32_t TCPSocket::Connect(const NetAddress& addr, } NetAddress TCPSocket::GetLocalAddress() const { + if (has_interface<PPB_TCPSocket_1_2>()) { + return NetAddress( + PASS_REF, + get_interface<PPB_TCPSocket_1_2>()->GetLocalAddress(pp_resource())); + } if (has_interface<PPB_TCPSocket_1_1>()) { return NetAddress( PASS_REF, @@ -94,6 +115,11 @@ NetAddress TCPSocket::GetLocalAddress() const { } NetAddress TCPSocket::GetRemoteAddress() const { + if (has_interface<PPB_TCPSocket_1_2>()) { + return NetAddress( + PASS_REF, + get_interface<PPB_TCPSocket_1_2>()->GetRemoteAddress(pp_resource())); + } if (has_interface<PPB_TCPSocket_1_1>()) { return NetAddress( PASS_REF, @@ -110,6 +136,11 @@ NetAddress TCPSocket::GetRemoteAddress() const { int32_t TCPSocket::Read(char* buffer, int32_t bytes_to_read, const CompletionCallback& callback) { + if (has_interface<PPB_TCPSocket_1_2>()) { + return get_interface<PPB_TCPSocket_1_2>()->Read( + pp_resource(), buffer, bytes_to_read, + callback.pp_completion_callback()); + } if (has_interface<PPB_TCPSocket_1_1>()) { return get_interface<PPB_TCPSocket_1_1>()->Read( pp_resource(), buffer, bytes_to_read, @@ -126,6 +157,11 @@ int32_t TCPSocket::Read(char* buffer, int32_t TCPSocket::Write(const char* buffer, int32_t bytes_to_write, const CompletionCallback& callback) { + if (has_interface<PPB_TCPSocket_1_2>()) { + return get_interface<PPB_TCPSocket_1_2>()->Write( + pp_resource(), buffer, bytes_to_write, + callback.pp_completion_callback()); + } if (has_interface<PPB_TCPSocket_1_1>()) { return get_interface<PPB_TCPSocket_1_1>()->Write( pp_resource(), buffer, bytes_to_write, @@ -141,6 +177,10 @@ int32_t TCPSocket::Write(const char* buffer, int32_t TCPSocket::Listen(int32_t backlog, const CompletionCallback& callback) { + if (has_interface<PPB_TCPSocket_1_2>()) { + return get_interface<PPB_TCPSocket_1_2>()->Listen( + pp_resource(), backlog, callback.pp_completion_callback()); + } if (has_interface<PPB_TCPSocket_1_1>()) { return get_interface<PPB_TCPSocket_1_1>()->Listen( pp_resource(), backlog, callback.pp_completion_callback()); @@ -150,6 +190,10 @@ int32_t TCPSocket::Listen(int32_t backlog, int32_t TCPSocket::Accept( const CompletionCallbackWithOutput<TCPSocket>& callback) { + if (has_interface<PPB_TCPSocket_1_2>()) { + return get_interface<PPB_TCPSocket_1_2>()->Accept( + pp_resource(), callback.output(), callback.pp_completion_callback()); + } if (has_interface<PPB_TCPSocket_1_1>()) { return get_interface<PPB_TCPSocket_1_1>()->Accept( pp_resource(), callback.output(), callback.pp_completion_callback()); @@ -158,7 +202,9 @@ int32_t TCPSocket::Accept( } void TCPSocket::Close() { - if (has_interface<PPB_TCPSocket_1_1>()) { + if (has_interface<PPB_TCPSocket_1_2>()) { + get_interface<PPB_TCPSocket_1_2>()->Close(pp_resource()); + } else if (has_interface<PPB_TCPSocket_1_1>()) { get_interface<PPB_TCPSocket_1_1>()->Close(pp_resource()); } else if (has_interface<PPB_TCPSocket_1_0>()) { get_interface<PPB_TCPSocket_1_0>()->Close(pp_resource()); @@ -168,6 +214,10 @@ void TCPSocket::Close() { int32_t TCPSocket::SetOption(PP_TCPSocket_Option name, const Var& value, const CompletionCallback& callback) { + if (has_interface<PPB_TCPSocket_1_2>()) { + return get_interface<PPB_TCPSocket_1_2>()->SetOption( + pp_resource(), name, value.pp_var(), callback.pp_completion_callback()); + } if (has_interface<PPB_TCPSocket_1_1>()) { return get_interface<PPB_TCPSocket_1_1>()->SetOption( pp_resource(), name, value.pp_var(), callback.pp_completion_callback()); diff --git a/chromium/ppapi/cpp/udp_socket.cc b/chromium/ppapi/cpp/udp_socket.cc index bb4b1c895b0..19d2894775c 100644 --- a/chromium/ppapi/cpp/udp_socket.cc +++ b/chromium/ppapi/cpp/udp_socket.cc @@ -18,13 +18,27 @@ template <> const char* interface_name<PPB_UDPSocket_1_0>() { return PPB_UDPSOCKET_INTERFACE_1_0; } +template <> const char* interface_name<PPB_UDPSocket_1_1>() { + return PPB_UDPSOCKET_INTERFACE_1_1; +} + +template <> const char* interface_name<PPB_UDPSocket_1_2>() { + return PPB_UDPSOCKET_INTERFACE_1_2; +} + } // namespace UDPSocket::UDPSocket() { } UDPSocket::UDPSocket(const InstanceHandle& instance) { - if (has_interface<PPB_UDPSocket_1_0>()) { + if (has_interface<PPB_UDPSocket_1_2>()) { + PassRefFromConstructor(get_interface<PPB_UDPSocket_1_2>()->Create( + instance.pp_instance())); + } else if (has_interface<PPB_UDPSocket_1_1>()) { + PassRefFromConstructor(get_interface<PPB_UDPSocket_1_1>()->Create( + instance.pp_instance())); + } else if (has_interface<PPB_UDPSocket_1_0>()) { PassRefFromConstructor(get_interface<PPB_UDPSocket_1_0>()->Create( instance.pp_instance())); } @@ -47,11 +61,21 @@ UDPSocket& UDPSocket::operator=(const UDPSocket& other) { // static bool UDPSocket::IsAvailable() { - return has_interface<PPB_UDPSocket_1_0>(); + return has_interface<PPB_UDPSocket_1_2>() || + has_interface<PPB_UDPSocket_1_1>() || + has_interface<PPB_UDPSocket_1_0>(); } int32_t UDPSocket::Bind(const NetAddress& addr, const CompletionCallback& callback) { + if (has_interface<PPB_UDPSocket_1_2>()) { + return get_interface<PPB_UDPSocket_1_2>()->Bind( + pp_resource(), addr.pp_resource(), callback.pp_completion_callback()); + } + if (has_interface<PPB_UDPSocket_1_1>()) { + return get_interface<PPB_UDPSocket_1_1>()->Bind( + pp_resource(), addr.pp_resource(), callback.pp_completion_callback()); + } if (has_interface<PPB_UDPSocket_1_0>()) { return get_interface<PPB_UDPSocket_1_0>()->Bind( pp_resource(), addr.pp_resource(), callback.pp_completion_callback()); @@ -60,6 +84,16 @@ int32_t UDPSocket::Bind(const NetAddress& addr, } NetAddress UDPSocket::GetBoundAddress() { + if (has_interface<PPB_UDPSocket_1_2>()) { + return NetAddress( + PASS_REF, + get_interface<PPB_UDPSocket_1_2>()->GetBoundAddress(pp_resource())); + } + if (has_interface<PPB_UDPSocket_1_1>()) { + return NetAddress( + PASS_REF, + get_interface<PPB_UDPSocket_1_1>()->GetBoundAddress(pp_resource())); + } if (has_interface<PPB_UDPSocket_1_0>()) { return NetAddress( PASS_REF, @@ -72,6 +106,16 @@ int32_t UDPSocket::RecvFrom( char* buffer, int32_t num_bytes, const CompletionCallbackWithOutput<NetAddress>& callback) { + if (has_interface<PPB_UDPSocket_1_2>()) { + return get_interface<PPB_UDPSocket_1_2>()->RecvFrom( + pp_resource(), buffer, num_bytes, callback.output(), + callback.pp_completion_callback()); + } + if (has_interface<PPB_UDPSocket_1_1>()) { + return get_interface<PPB_UDPSocket_1_1>()->RecvFrom( + pp_resource(), buffer, num_bytes, callback.output(), + callback.pp_completion_callback()); + } if (has_interface<PPB_UDPSocket_1_0>()) { return get_interface<PPB_UDPSocket_1_0>()->RecvFrom( pp_resource(), buffer, num_bytes, callback.output(), @@ -84,6 +128,16 @@ int32_t UDPSocket::SendTo(const char* buffer, int32_t num_bytes, const NetAddress& addr, const CompletionCallback& callback) { + if (has_interface<PPB_UDPSocket_1_2>()) { + return get_interface<PPB_UDPSocket_1_2>()->SendTo( + pp_resource(), buffer, num_bytes, addr.pp_resource(), + callback.pp_completion_callback()); + } + if (has_interface<PPB_UDPSocket_1_1>()) { + return get_interface<PPB_UDPSocket_1_1>()->SendTo( + pp_resource(), buffer, num_bytes, addr.pp_resource(), + callback.pp_completion_callback()); + } if (has_interface<PPB_UDPSocket_1_0>()) { return get_interface<PPB_UDPSocket_1_0>()->SendTo( pp_resource(), buffer, num_bytes, addr.pp_resource(), @@ -93,6 +147,10 @@ int32_t UDPSocket::SendTo(const char* buffer, } void UDPSocket::Close() { + if (has_interface<PPB_UDPSocket_1_2>()) + return get_interface<PPB_UDPSocket_1_2>()->Close(pp_resource()); + if (has_interface<PPB_UDPSocket_1_1>()) + return get_interface<PPB_UDPSocket_1_1>()->Close(pp_resource()); if (has_interface<PPB_UDPSocket_1_0>()) return get_interface<PPB_UDPSocket_1_0>()->Close(pp_resource()); } @@ -100,6 +158,14 @@ void UDPSocket::Close() { int32_t UDPSocket::SetOption(PP_UDPSocket_Option name, const Var& value, const CompletionCallback& callback) { + if (has_interface<PPB_UDPSocket_1_2>()) { + return get_interface<PPB_UDPSocket_1_2>()->SetOption( + pp_resource(), name, value.pp_var(), callback.pp_completion_callback()); + } + if (has_interface<PPB_UDPSocket_1_1>()) { + return get_interface<PPB_UDPSocket_1_1>()->SetOption( + pp_resource(), name, value.pp_var(), callback.pp_completion_callback()); + } if (has_interface<PPB_UDPSocket_1_0>()) { return get_interface<PPB_UDPSocket_1_0>()->SetOption( pp_resource(), name, value.pp_var(), callback.pp_completion_callback()); @@ -107,4 +173,22 @@ int32_t UDPSocket::SetOption(PP_UDPSocket_Option name, return callback.MayForce(PP_ERROR_NOINTERFACE); } +int32_t UDPSocket::JoinGroup(const NetAddress& group, + const CompletionCallback callback) { + if (has_interface<PPB_UDPSocket_1_2>()) { + return get_interface<PPB_UDPSocket_1_2>()->JoinGroup( + pp_resource(), group.pp_resource(), callback.pp_completion_callback()); + } + return callback.MayForce(PP_ERROR_NOINTERFACE); +} + +int32_t UDPSocket::LeaveGroup(const NetAddress& group, + const CompletionCallback callback) { + if (has_interface<PPB_UDPSocket_1_2>()) { + return get_interface<PPB_UDPSocket_1_2>()->LeaveGroup( + pp_resource(), group.pp_resource(), callback.pp_completion_callback()); + } + return callback.MayForce(PP_ERROR_NOINTERFACE); +} + } // namespace pp diff --git a/chromium/ppapi/cpp/udp_socket.h b/chromium/ppapi/cpp/udp_socket.h index fa599d71d84..69e906ff209 100644 --- a/chromium/ppapi/cpp/udp_socket.h +++ b/chromium/ppapi/cpp/udp_socket.h @@ -125,6 +125,9 @@ class UDPSocket : public Resource { /// been sent; otherwise, an error code from <code>pp_errors.h</code>. /// <code>PP_ERROR_NOACCESS</code> will be returned if the caller doesn't have /// required permissions. + /// <code>PP_ERROR_INPROGRESS</code> will be returned if the socket is busy + /// sending. The caller should wait until a pending send completes before + /// retrying. int32_t SendTo(const char* buffer, int32_t num_bytes, const NetAddress& addr, @@ -153,6 +156,30 @@ class UDPSocket : public Resource { int32_t SetOption(PP_UDPSocket_Option name, const Var& value, const CompletionCallback& callback); + + /// Joins the multicast group with address specified by <code>group</code> + /// parameter, which is expected to be a <code>NetAddress</code> object. + /// + /// @param[in] group A <code>NetAddress</code> corresponding to the network + /// address of the multicast group. + /// @param[in] callback A <code>CompletionCallback</code> to be called upon + /// completion. + /// + /// @return An int32_t containing an error code from <code>pp_errors.h</code>. + int32_t JoinGroup(const NetAddress& group, + const CompletionCallback callback); + + /// Leaves the multicast group with address specified by <code>group</code> + /// parameter, which is expected to be a <code>NetAddress</code> object. + /// + /// @param[in] group A <code>NetAddress</code> corresponding to the network + /// address of the multicast group. + /// @param[in] callback A <code>CompletionCallback</code> to be called upon + /// completion. + /// + /// @return An int32_t containing an error code from <code>pp_errors.h</code>. + int32_t LeaveGroup(const NetAddress& group, + const CompletionCallback callback); }; } // namespace pp diff --git a/chromium/ppapi/cpp/video_decoder.cc b/chromium/ppapi/cpp/video_decoder.cc index 42236e42a2f..ea954a66fa3 100644 --- a/chromium/ppapi/cpp/video_decoder.cc +++ b/chromium/ppapi/cpp/video_decoder.cc @@ -69,7 +69,13 @@ VideoDecoder::VideoDecoder() { } VideoDecoder::VideoDecoder(const InstanceHandle& instance) { - if (has_interface<PPB_VideoDecoder_0_1>()) { + if (has_interface<PPB_VideoDecoder_1_0>()) { + PassRefFromConstructor( + get_interface<PPB_VideoDecoder_1_0>()->Create(instance.pp_instance())); + } else if (has_interface<PPB_VideoDecoder_0_2>()) { + PassRefFromConstructor( + get_interface<PPB_VideoDecoder_0_2>()->Create(instance.pp_instance())); + } else if (has_interface<PPB_VideoDecoder_0_1>()) { PassRefFromConstructor( get_interface<PPB_VideoDecoder_0_1>()->Create(instance.pp_instance())); } diff --git a/chromium/ppapi/cpp/video_encoder.cc b/chromium/ppapi/cpp/video_encoder.cc new file mode 100644 index 00000000000..969fc1ff951 --- /dev/null +++ b/chromium/ppapi/cpp/video_encoder.cc @@ -0,0 +1,221 @@ +// Copyright 2015 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/cpp/video_encoder.h" + +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/ppb_video_encoder.h" +#include "ppapi/cpp/completion_callback.h" +#include "ppapi/cpp/instance_handle.h" +#include "ppapi/cpp/module.h" +#include "ppapi/cpp/module_impl.h" + +namespace pp { + +namespace { + +template <> +const char* interface_name<PPB_VideoEncoder_0_1>() { + return PPB_VIDEOENCODER_INTERFACE_0_1; +} + +template <> +const char* interface_name<PPB_VideoEncoder_0_2>() { + return PPB_VIDEOENCODER_INTERFACE_0_2; +} + +// This struct is used to adapt +// CompletionCallbackWithOutput<std::vector<PP_VideoProfileDescription>> +// to the pre-0.2 APIs, which return PP_VideoProfileDescription_0_1. +// This struct is allocated on the heap, and deleted in +// CallbackProfileDescriptionConverter. +struct CallbackProfileDescription_0_1 { + explicit CallbackProfileDescription_0_1(const CompletionCallbackWithOutput< + std::vector<PP_VideoProfileDescription> >& cc) + : output_profiles(&profiles), + original_output_profiles(cc.output()), + original_callback(cc.pp_completion_callback()) {} + std::vector<PP_VideoProfileDescription_0_1> profiles; + ArrayOutputAdapter<PP_VideoProfileDescription_0_1> output_profiles; + PP_ArrayOutput original_output_profiles; + PP_CompletionCallback original_callback; +}; + +// Converts data from a 0.1 style callback to 0.2 callback. +void CallbackProfileDescriptionConverter(void* user_data, int32_t result) { + CallbackProfileDescription_0_1* data = + static_cast<CallbackProfileDescription_0_1*>(user_data); + if (result >= 0) { + PP_VideoProfileDescription* original_profiles = + static_cast<PP_VideoProfileDescription*>( + data->original_output_profiles.GetDataBuffer( + data->original_output_profiles.user_data, + static_cast<uint32_t>(data->profiles.size()), + static_cast<uint32_t>(sizeof(PP_VideoProfileDescription)))); + + for (size_t i = 0; i < data->profiles.size(); i++) { + const PP_VideoProfileDescription_0_1& profile = data->profiles[i]; + + original_profiles[i].profile = profile.profile; + original_profiles[i].max_resolution = profile.max_resolution; + original_profiles[i].max_framerate_numerator = + profile.max_framerate_numerator; + original_profiles[i].max_framerate_denominator = + profile.max_framerate_denominator; + original_profiles[i].hardware_accelerated = + PP_FromBool(profile.acceleration == PP_HARDWAREACCELERATION_ONLY); + } + } + + // Now execute the original callback. + PP_RunCompletionCallback(&data->original_callback, result); + delete data; +} + +} // namespace + +VideoEncoder::VideoEncoder() { +} + +VideoEncoder::VideoEncoder(const InstanceHandle& instance) { + if (has_interface<PPB_VideoEncoder_0_2>()) { + PassRefFromConstructor( + get_interface<PPB_VideoEncoder_0_2>()->Create(instance.pp_instance())); + } else if (has_interface<PPB_VideoEncoder_0_1>()) { + PassRefFromConstructor( + get_interface<PPB_VideoEncoder_0_1>()->Create(instance.pp_instance())); + } +} + +VideoEncoder::VideoEncoder(const VideoEncoder& other) : Resource(other) { +} + +int32_t VideoEncoder::GetSupportedProfiles(const CompletionCallbackWithOutput< + std::vector<PP_VideoProfileDescription> >& cc) { + if (has_interface<PPB_VideoEncoder_0_2>()) { + return get_interface<PPB_VideoEncoder_0_2>()->GetSupportedProfiles( + pp_resource(), cc.output(), cc.pp_completion_callback()); + } else if (has_interface<PPB_VideoEncoder_0_1>()) { + // Data for our callback wrapper. The callback handler will delete it. + CallbackProfileDescription_0_1* data = + new CallbackProfileDescription_0_1(cc); + return get_interface<PPB_VideoEncoder_0_1>()->GetSupportedProfiles( + pp_resource(), data->output_profiles.pp_array_output(), + PP_MakeCompletionCallback(&CallbackProfileDescriptionConverter, data)); + } + return cc.MayForce(PP_ERROR_NOINTERFACE); +} + +int32_t VideoEncoder::Initialize(const PP_VideoFrame_Format& input_format, + const Size& input_visible_size, + const PP_VideoProfile& output_profile, + const uint32_t initial_bitrate, + PP_HardwareAcceleration acceleration, + const CompletionCallback& cc) { + if (has_interface<PPB_VideoEncoder_0_2>()) { + return get_interface<PPB_VideoEncoder_0_2>()->Initialize( + pp_resource(), input_format, &input_visible_size.pp_size(), + output_profile, initial_bitrate, acceleration, + cc.pp_completion_callback()); + } else if (has_interface<PPB_VideoEncoder_0_1>()) { + return get_interface<PPB_VideoEncoder_0_1>()->Initialize( + pp_resource(), input_format, &input_visible_size.pp_size(), + output_profile, initial_bitrate, acceleration, + cc.pp_completion_callback()); + } + return cc.MayForce(PP_ERROR_NOINTERFACE); +} + +int32_t VideoEncoder::GetFramesRequired() { + if (has_interface<PPB_VideoEncoder_0_2>()) { + return get_interface<PPB_VideoEncoder_0_2>()->GetFramesRequired( + pp_resource()); + } else if (has_interface<PPB_VideoEncoder_0_1>()) { + return get_interface<PPB_VideoEncoder_0_1>()->GetFramesRequired( + pp_resource()); + } + return PP_ERROR_NOINTERFACE; +} + +int32_t VideoEncoder::GetFrameCodedSize(Size* coded_size) { + if (has_interface<PPB_VideoEncoder_0_2>()) { + return get_interface<PPB_VideoEncoder_0_2>()->GetFrameCodedSize( + pp_resource(), &coded_size->pp_size()); + } else if (has_interface<PPB_VideoEncoder_0_1>()) { + return get_interface<PPB_VideoEncoder_0_1>()->GetFrameCodedSize( + pp_resource(), &coded_size->pp_size()); + } + return PP_ERROR_NOINTERFACE; +} + +int32_t VideoEncoder::GetVideoFrame( + const CompletionCallbackWithOutput<VideoFrame>& cc) { + if (has_interface<PPB_VideoEncoder_0_2>()) { + return get_interface<PPB_VideoEncoder_0_2>()->GetVideoFrame( + pp_resource(), cc.output(), cc.pp_completion_callback()); + } else if (has_interface<PPB_VideoEncoder_0_1>()) { + return get_interface<PPB_VideoEncoder_0_1>()->GetVideoFrame( + pp_resource(), cc.output(), cc.pp_completion_callback()); + } + return cc.MayForce(PP_ERROR_NOINTERFACE); +} + +int32_t VideoEncoder::Encode(const VideoFrame& video_frame, + bool force_keyframe, + const CompletionCallback& cc) { + if (has_interface<PPB_VideoEncoder_0_2>()) { + return get_interface<PPB_VideoEncoder_0_2>()->Encode( + pp_resource(), video_frame.pp_resource(), PP_FromBool(force_keyframe), + cc.pp_completion_callback()); + } else if (has_interface<PPB_VideoEncoder_0_1>()) { + return get_interface<PPB_VideoEncoder_0_1>()->Encode( + pp_resource(), video_frame.pp_resource(), PP_FromBool(force_keyframe), + cc.pp_completion_callback()); + } + return cc.MayForce(PP_ERROR_NOINTERFACE); +} + +int32_t VideoEncoder::GetBitstreamBuffer( + const CompletionCallbackWithOutput<PP_BitstreamBuffer>& cc) { + if (has_interface<PPB_VideoEncoder_0_2>()) { + return get_interface<PPB_VideoEncoder_0_2>()->GetBitstreamBuffer( + pp_resource(), cc.output(), cc.pp_completion_callback()); + } else if (has_interface<PPB_VideoEncoder_0_1>()) { + return get_interface<PPB_VideoEncoder_0_1>()->GetBitstreamBuffer( + pp_resource(), cc.output(), cc.pp_completion_callback()); + } + return cc.MayForce(PP_ERROR_NOINTERFACE); +} + +void VideoEncoder::RecycleBitstreamBuffer( + const PP_BitstreamBuffer& bitstream_buffer) { + if (has_interface<PPB_VideoEncoder_0_2>()) { + get_interface<PPB_VideoEncoder_0_2>()->RecycleBitstreamBuffer( + pp_resource(), &bitstream_buffer); + } else if (has_interface<PPB_VideoEncoder_0_1>()) { + get_interface<PPB_VideoEncoder_0_1>()->RecycleBitstreamBuffer( + pp_resource(), &bitstream_buffer); + } +} + +void VideoEncoder::RequestEncodingParametersChange(uint32_t bitrate, + uint32_t framerate) { + if (has_interface<PPB_VideoEncoder_0_2>()) { + get_interface<PPB_VideoEncoder_0_2>()->RequestEncodingParametersChange( + pp_resource(), bitrate, framerate); + } else if (has_interface<PPB_VideoEncoder_0_1>()) { + get_interface<PPB_VideoEncoder_0_1>()->RequestEncodingParametersChange( + pp_resource(), bitrate, framerate); + } +} + +void VideoEncoder::Close() { + if (has_interface<PPB_VideoEncoder_0_2>()) { + get_interface<PPB_VideoEncoder_0_2>()->Close(pp_resource()); + } else if (has_interface<PPB_VideoEncoder_0_1>()) { + get_interface<PPB_VideoEncoder_0_1>()->Close(pp_resource()); + } +} + +} // namespace pp diff --git a/chromium/ppapi/cpp/video_encoder.h b/chromium/ppapi/cpp/video_encoder.h new file mode 100644 index 00000000000..44160d90168 --- /dev/null +++ b/chromium/ppapi/cpp/video_encoder.h @@ -0,0 +1,179 @@ +// Copyright 2015 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_CPP_VIDEO_ENCODER_H_ +#define PPAPI_CPP_VIDEO_ENCODER_H_ + +#include "ppapi/c/pp_codecs.h" +#include "ppapi/c/pp_size.h" +#include "ppapi/cpp/completion_callback.h" +#include "ppapi/cpp/resource.h" +#include "ppapi/cpp/size.h" +#include "ppapi/cpp/video_frame.h" + +/// @file +/// This file defines the API to create and use a VideoEncoder resource. + +namespace pp { + +class InstanceHandle; + +/// Video encoder interface. +/// +/// Typical usage: +/// - Call Create() to create a new video encoder resource. +/// - Call GetSupportedFormats() to determine which codecs and profiles are +/// available. +/// - Call Initialize() to initialize the encoder for a supported profile. +/// - Call GetVideoFrame() to get a blank frame and fill it in, or get a video +/// frame from another resource, e.g. <code>PPB_MediaStreamVideoTrack</code>. +/// - Call Encode() to push the video frame to the encoder. If an external frame +/// is pushed, wait for completion to recycle the frame. +/// - Call GetBitstreamBuffer() continuously (waiting for each previous call to +/// complete) to pull encoded pictures from the encoder. +/// - Call RecycleBitstreamBuffer() after consuming the data in the bitstream +/// buffer. +/// - To destroy the encoder, the plugin should release all of its references to +/// it. Any pending callbacks will abort before the encoder is destroyed. +/// +/// Available video codecs vary by platform. +/// All: theora, vorbis, vp8. +/// Chrome and ChromeOS: h264. +/// ChromeOS: mpeg4. +class VideoEncoder : public Resource { + public: + /// Default constructor for creating an is_null() <code>VideoEncoder</code> + /// object. + VideoEncoder(); + + /// A constructor used to create a <code>VideoEncoder</code> and associate it + /// with the provided <code>Instance</code>. + /// @param[in] instance The instance with which this resource will be + /// associated. + explicit VideoEncoder(const InstanceHandle& instance); + + /// The copy constructor for <code>VideoEncoder</code>. + /// @param[in] other A reference to a <code>VideoEncoder</code>. + VideoEncoder(const VideoEncoder& other); + + /// Gets an array of supported video encoder profiles. + /// These can be used to choose a profile before calling Initialize(). + /// + /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be + /// called upon completion with the PP_VideoProfileDescription structs. + /// + /// @return If >= 0, the number of supported profiles returned, otherwise an + /// error code from <code>pp_errors.h</code>. + int32_t GetSupportedProfiles(const CompletionCallbackWithOutput< + std::vector<PP_VideoProfileDescription> >& cc); + + /// Initializes a video encoder resource. This should be called after + /// GetSupportedProfiles() and before any functions below. + /// + /// @param[in] input_format The <code>PP_VideoFrame_Format</code> of the + /// frames which will be encoded. + /// @param[in] input_visible_size A <code>Size</code> specifying the + /// dimensions of the visible part of the input frames. + /// @param[in] output_profile A <code>PP_VideoProfile</code> specifying the + /// codec profile of the encoded output stream. + /// @param[in] acceleration A <code>PP_HardwareAcceleration</code> specifying + /// whether to use a hardware accelerated or a software implementation. + /// @param[in] callback A <code>CompletionCallback</code> to be called upon + /// completion. + /// + /// @return An int32_t containing an error code from <code>pp_errors.h</code>. + /// Returns PP_ERROR_NOTSUPPORTED if video encoding is not available, or the + /// requested codec profile is not supported. + /// Returns PP_ERROR_NOMEMORY if frame and bitstream buffers can't be created. + int32_t Initialize(const PP_VideoFrame_Format& input_format, + const Size& input_visible_size, + const PP_VideoProfile& output_profile, + const uint32_t initial_bitrate, + PP_HardwareAcceleration acceleration, + const CompletionCallback& cc); + + /// Gets the number of input video frames that the encoder may hold while + /// encoding. If the plugin is providing the video frames, it should have at + /// least this many available. + /// + /// @return An int32_t containing the number of frames required, or an error + /// code from <code>pp_errors.h</code>. + /// Returns PP_ERROR_FAILED if Initialize() has not successfully completed. + int32_t GetFramesRequired(); + + /// Gets the coded size of the video frames required by the encoder. Coded + /// size is the logical size of the input frames, in pixels. The encoder may + /// have hardware alignment requirements that make this different from + /// |input_visible_size|, as requested in the call to Initialize(). + /// + /// @param[in] coded_size A <code>Size</code> to hold the coded size. + /// + /// @return An int32_t containing a result code from <code>pp_errors.h</code>. + /// Returns PP_ERROR_FAILED if Initialize() has not successfully completed. + int32_t GetFrameCodedSize(Size* coded_size); + + /// Gets a blank video frame which can be filled with video data and passed + /// to the encoder. + /// + /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be + /// called upon completion with the blank <code>VideoFrame</code> resource. + /// + /// @return An int32_t containing an error code from <code>pp_errors.h</code>. + int32_t GetVideoFrame(const CompletionCallbackWithOutput<VideoFrame>& cc); + + /// Encodes a video frame. + /// + /// @param[in] video_frame The <code>VideoFrame</code> to be encoded. + /// @param[in] force_keyframe A <code>PP_Bool> specifying whether the encoder + /// should emit a key frame for this video frame. + /// @param[in] callback A <code>CompletionCallback</code> to be called upon + /// completion. Plugins that pass <code>VideoFrame</code> resources owned + /// by other resources should wait for completion before reusing them. + /// + /// @return An int32_t containing an error code from <code>pp_errors.h</code>. + /// Returns PP_ERROR_FAILED if Initialize() has not successfully completed. + int32_t Encode(const VideoFrame& video_frame, + bool force_keyframe, + const CompletionCallback& cc); + + /// Gets the next encoded bitstream buffer from the encoder. + /// + /// @param[out] bitstream_buffer A <code>PP_BitstreamBuffer</code> containing + /// encoded video data. + /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be + /// called upon completion with the next bitstream buffer. The plugin can call + /// GetBitstreamBuffer from the callback in order to continuously "pull" + /// bitstream buffers from the encoder. + /// + /// @return An int32_t containing an error code from <code>pp_errors.h</code>. + /// Returns PP_ERROR_FAILED if Initialize() has not successfully completed. + /// Returns PP_ERROR_INPROGRESS if a prior call to GetBitstreamBuffer() has + /// not completed. + int32_t GetBitstreamBuffer( + const CompletionCallbackWithOutput<PP_BitstreamBuffer>& cc); + + /// Recycles a bitstream buffer back to the encoder. + /// + /// @param[in] bitstream_buffer A <code>PP_BitstreamBuffer</code> that is no + /// longer needed by the plugin. + void RecycleBitstreamBuffer(const PP_BitstreamBuffer& bitstream_buffer); + + /// Requests a change to encoding parameters. This is only a request, + /// fulfilled on a best-effort basis. + /// + /// @param[in] bitrate The requested new bitrate, in bits per second. + /// @param[in] framerate The requested new framerate, in frames per second. + void RequestEncodingParametersChange(uint32_t bitrate, uint32_t framerate); + + /// Closes the video encoder, and cancels any pending encodes. Any pending + /// callbacks will still run, reporting <code>PP_ERROR_ABORTED</code> . It is + /// not valid to call any encoder functions after a call to this method. + /// <strong>Note:</strong> Destroying the video encoder closes it implicitly, + /// so you are not required to call Close(). + void Close(); +}; + +} // namespace pp + +#endif // PPAPI_CPP_VIDEO_ENCODER_H_ diff --git a/chromium/ppapi/examples/2d/BUILD.gn b/chromium/ppapi/examples/2d/BUILD.gn new file mode 100644 index 00000000000..94b8ed69b8b --- /dev/null +++ b/chromium/ppapi/examples/2d/BUILD.gn @@ -0,0 +1,44 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +group("2d") { + testonly = true + deps = [ + ":graphics_2d", + ":paint_manager", + ":scroll", + ] +} + +ppapi_example("graphics_2d") { + output_name = "ppapi_example_graphics_2d" + sources = [ + "graphics_2d_example.c", + ] + deps = [ + "//ppapi/c", + ] +} + +ppapi_example("paint_manager") { + output_name = "ppapi_example_paint_manager" + sources = [ + "paint_manager_example.cc", + ] + deps = [ + "//ppapi/cpp", + ] +} + +ppapi_example("scroll") { + output_name = "ppapi_example_scroll" + sources = [ + "scroll.cc", + ] + deps = [ + "//ppapi/cpp", + ] +} diff --git a/chromium/ppapi/examples/2d/graphics_2d_example.c b/chromium/ppapi/examples/2d/graphics_2d_example.c index 085f0cf4a80..0f3261792f5 100644 --- a/chromium/ppapi/examples/2d/graphics_2d_example.c +++ b/chromium/ppapi/examples/2d/graphics_2d_example.c @@ -33,6 +33,7 @@ const PPB_View* g_view_interface; struct InstanceInfo { PP_Instance pp_instance; struct PP_Size last_size; + PP_Resource graphics; struct InstanceInfo* next; }; @@ -61,11 +62,18 @@ void FlushCompletionCallback(void* user_data, int32_t result) { } void Repaint(struct InstanceInfo* instance, const struct PP_Size* size) { - PP_Resource image, graphics; + PP_Resource image; struct PP_ImageDataDesc image_desc; uint32_t* image_data; int num_words, i; + /* Ensure the graphics 2d is ready. */ + if (!instance->graphics) { + instance->graphics = MakeAndBindGraphics2D(instance->pp_instance, size); + if (!instance->graphics) + return; + } + /* Create image data to paint into. */ image = g_image_data_interface->Create( instance->pp_instance, PP_IMAGEDATAFORMAT_BGRA_PREMUL, size, PP_TRUE); @@ -83,18 +91,11 @@ void Repaint(struct InstanceInfo* instance, const struct PP_Size* size) { for (i = 0; i < num_words; i++) image_data[i] = 0xFF0000FF; - /* Create the graphics 2d and paint the image to it. */ - graphics = MakeAndBindGraphics2D(instance->pp_instance, size); - if (!graphics) { - g_core_interface->ReleaseResource(image); - return; - } - - g_graphics_2d_interface->ReplaceContents(graphics, image); - g_graphics_2d_interface->Flush(graphics, + /* Paint image to graphics 2d. */ + g_graphics_2d_interface->ReplaceContents(instance->graphics, image); + g_graphics_2d_interface->Flush(instance->graphics, PP_MakeCompletionCallback(&FlushCompletionCallback, NULL)); - g_core_interface->ReleaseResource(graphics); g_core_interface->ReleaseResource(image); } @@ -118,6 +119,7 @@ PP_Bool Instance_DidCreate(PP_Instance instance, info->pp_instance = instance; info->last_size.width = 0; info->last_size.height = 0; + info->graphics = 0; /* Insert into linked list of live instances. */ info->next = all_instances; @@ -134,6 +136,7 @@ void Instance_DidDestroy(PP_Instance instance) { while (cur) { if (instance == cur->pp_instance) { *prev_ptr = cur->next; + g_core_interface->ReleaseResource(cur->graphics); free(cur); return; } diff --git a/chromium/ppapi/examples/BUILD.gn b/chromium/ppapi/examples/BUILD.gn new file mode 100644 index 00000000000..9369c585383 --- /dev/null +++ b/chromium/ppapi/examples/BUILD.gn @@ -0,0 +1,37 @@ +# Copyright 2015 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. + +group("examples") { + testonly = true + deps = [ + "//ppapi/examples/2d", + "//ppapi/examples/audio", + "//ppapi/examples/audio_input", + "//ppapi/examples/compositor", + "//ppapi/examples/crxfs", + "//ppapi/examples/enumerate_devices", + "//ppapi/examples/file_chooser", + "//ppapi/examples/flash_topmost", + "//ppapi/examples/font", + "//ppapi/examples/gamepad", + "//ppapi/examples/gles2", + "//ppapi/examples/gles2_spinning_cube", + "//ppapi/examples/ime", + "//ppapi/examples/input", + "//ppapi/examples/media_stream_audio", + "//ppapi/examples/media_stream_video", + "//ppapi/examples/mouse_cursor", + "//ppapi/examples/mouse_lock", + "//ppapi/examples/printing", + "//ppapi/examples/scaling", + "//ppapi/examples/scripting", + "//ppapi/examples/stub", + "//ppapi/examples/threading", + "//ppapi/examples/url_loader", + "//ppapi/examples/video_capture", + "//ppapi/examples/video_decode", + "//ppapi/examples/video_effects", + "//ppapi/examples/video_encode", + ] +} diff --git a/chromium/ppapi/examples/audio/BUILD.gn b/chromium/ppapi/examples/audio/BUILD.gn new file mode 100644 index 00000000000..0b3deb8bdcb --- /dev/null +++ b/chromium/ppapi/examples/audio/BUILD.gn @@ -0,0 +1,15 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +ppapi_example("audio") { + output_name = "ppapi_example_audio" + sources = [ + "audio.cc", + ] + deps = [ + "//ppapi/cpp", + ] +} diff --git a/chromium/ppapi/examples/audio_input/BUILD.gn b/chromium/ppapi/examples/audio_input/BUILD.gn new file mode 100644 index 00000000000..ac11766176e --- /dev/null +++ b/chromium/ppapi/examples/audio_input/BUILD.gn @@ -0,0 +1,15 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +ppapi_example("audio_input") { + output_name = "ppapi_example_audio_input" + sources = [ + "audio_input.cc", + ] + deps = [ + "//ppapi/cpp", + ] +} diff --git a/chromium/ppapi/examples/audio_input/audio_input.cc b/chromium/ppapi/examples/audio_input/audio_input.cc index 06cea4381b6..bf7496e33f5 100644 --- a/chromium/ppapi/examples/audio_input/audio_input.cc +++ b/chromium/ppapi/examples/audio_input/audio_input.cc @@ -196,8 +196,8 @@ class MyInstance : public pp::Instance { // Draw the latency as a red bar at the bottom. PP_DCHECK(latency_ >= 0); - int latency_bar_length = - latency_ < 1 ? size.width() * latency_ : size.width(); + int latency_bar_length = latency_ < 1 ? + static_cast<int>(size.width() * latency_) : size.width(); for (int x = 0; x < latency_bar_length; ++x) { *image.GetAddr32(pp::Point(x, mid_height + max_amplitude)) = 0xffff0000; } diff --git a/chromium/ppapi/examples/compositor/BUILD.gn b/chromium/ppapi/examples/compositor/BUILD.gn new file mode 100644 index 00000000000..d7007a111eb --- /dev/null +++ b/chromium/ppapi/examples/compositor/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +ppapi_example("compositor") { + output_name = "ppapi_example_compositor" + sources = [ + "compositor.cc", + "spinning_cube.cc", + "spinning_cube.h", + ] + deps = [ + "//ppapi/cpp", + "//ppapi/lib/gl/gles2", + ] +} diff --git a/chromium/ppapi/examples/compositor/compositor.cc b/chromium/ppapi/examples/compositor/compositor.cc index d13e48a7c03..df2962a9e14 100644 --- a/chromium/ppapi/examples/compositor/compositor.cc +++ b/chromium/ppapi/examples/compositor/compositor.cc @@ -285,8 +285,8 @@ void DemoInstance::Paint(int32_t result, int32_t frame) { void DemoInstance::PrepareLayers(int32_t frame) { int32_t rv; - float factor_sin = sin(M_PI / 180 * frame); - float factor_cos = cos(M_PI / 180 * frame); + float factor_sin = sin(static_cast<float>(M_PI) / 180 * frame); + float factor_cos = cos(static_cast<float>(M_PI) / 180 * frame); { // Set the background color layer. if (color_layer_.is_null()) { @@ -315,7 +315,7 @@ void DemoInstance::PrepareLayers(int32_t frame) { image_layer_ = compositor_.AddLayer(); assert(!image_layer_.is_null()); } - float x = frame % 800; + float x = static_cast<float>(frame % 800); float y = 200 - 200 * factor_sin; const float transform[16] = { fabsf(factor_sin) + 0.2f, 0.0f, 0.0f, 0.0f, @@ -330,9 +330,9 @@ void DemoInstance::PrepareLayers(int32_t frame) { uint8_t *p = static_cast<uint8_t*>(image.data()); for (int x = 0; x < kImageWidth; ++x) { for (int y = 0; y < kImageHeight; ++y) { - *(p++) = frame; - *(p++) = frame * x; - *(p++) = frame * y; + *(p++) = static_cast<uint8_t>(frame); + *(p++) = static_cast<uint8_t>(frame * x); + *(p++) = static_cast<uint8_t>(frame * y); *(p++) = 255; } } @@ -361,7 +361,7 @@ void DemoInstance::PrepareLayers(int32_t frame) { assert(rv == PP_OK); } - int32_t delta = 200 * fabsf(factor_sin); + int32_t delta = static_cast<int32_t>(200 * fabsf(factor_sin)); if (delta != 0) { int32_t x_y = 25 + delta; int32_t w_h = 650 - delta - delta; diff --git a/chromium/ppapi/examples/crxfs/BUILD.gn b/chromium/ppapi/examples/crxfs/BUILD.gn new file mode 100644 index 00000000000..f038c04d6fb --- /dev/null +++ b/chromium/ppapi/examples/crxfs/BUILD.gn @@ -0,0 +1,15 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +ppapi_example("crxfs") { + output_name = "ppapi_example_crxfs" + sources = [ + "crxfs.cc", + ] + deps = [ + "//ppapi/cpp", + ] +} diff --git a/chromium/ppapi/examples/enumerate_devices/BUILD.gn b/chromium/ppapi/examples/enumerate_devices/BUILD.gn new file mode 100644 index 00000000000..c7d79d97707 --- /dev/null +++ b/chromium/ppapi/examples/enumerate_devices/BUILD.gn @@ -0,0 +1,15 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +ppapi_example("enumerate_devices") { + output_name = "ppapi_example_enumerate_devices" + sources = [ + "enumerate_devices.cc", + ] + deps = [ + "//ppapi/cpp", + ] +} diff --git a/chromium/ppapi/examples/file_chooser/BUILD.gn b/chromium/ppapi/examples/file_chooser/BUILD.gn new file mode 100644 index 00000000000..d7b64766e95 --- /dev/null +++ b/chromium/ppapi/examples/file_chooser/BUILD.gn @@ -0,0 +1,15 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +ppapi_example("file_chooser") { + output_name = "ppapi_example_file_chooser" + sources = [ + "file_chooser.cc", + ] + deps = [ + "//ppapi/cpp", + ] +} diff --git a/chromium/ppapi/examples/flash_topmost/BUILD.gn b/chromium/ppapi/examples/flash_topmost/BUILD.gn new file mode 100644 index 00000000000..a0ec3487eee --- /dev/null +++ b/chromium/ppapi/examples/flash_topmost/BUILD.gn @@ -0,0 +1,15 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +ppapi_example("flash_topmost") { + output_name = "ppapi_example_flash_topmost" + sources = [ + "flash_topmost.cc", + ] + deps = [ + "//ppapi/cpp", + ] +} diff --git a/chromium/ppapi/examples/font/BUILD.gn b/chromium/ppapi/examples/font/BUILD.gn new file mode 100644 index 00000000000..632a4280c96 --- /dev/null +++ b/chromium/ppapi/examples/font/BUILD.gn @@ -0,0 +1,15 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +ppapi_example("font") { + output_name = "ppapi_example_simple_font" + sources = [ + "simple_font.cc", + ] + deps = [ + "//ppapi/cpp", + ] +} diff --git a/chromium/ppapi/examples/gamepad/BUILD.gn b/chromium/ppapi/examples/gamepad/BUILD.gn new file mode 100644 index 00000000000..b928c93f9b3 --- /dev/null +++ b/chromium/ppapi/examples/gamepad/BUILD.gn @@ -0,0 +1,15 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +ppapi_example("gamepad") { + output_name = "ppapi_example_gamepad" + sources = [ + "gamepad.cc", + ] + deps = [ + "//ppapi/cpp", + ] +} diff --git a/chromium/ppapi/examples/gamepad/gamepad.cc b/chromium/ppapi/examples/gamepad/gamepad.cc index a94ccd43c1b..d2b08844ebe 100644 --- a/chromium/ppapi/examples/gamepad/gamepad.cc +++ b/chromium/ppapi/examples/gamepad/gamepad.cc @@ -79,8 +79,6 @@ class MyInstance : public pp::Instance { device_context_.ReplaceContents(&image); device_context_.Flush( callback_factory_.NewCallback(&MyInstance::OnFlush)); - } else { - printf("NullImage\n"); } } @@ -92,7 +90,7 @@ class MyInstance : public pp::Instance { PP_GamepadsSampleData gamepad_data; gamepad_->Sample(pp_instance(), &gamepad_data); - if (gamepad_data.length > 1 && gamepad_data.items[0].connected) { + if (gamepad_data.length > 0 && gamepad_data.items[0].connected) { int width2 = size.width() / 2; int height2 = size.height() / 2; // Draw 2 axes @@ -108,7 +106,7 @@ class MyInstance : public pp::Instance { for (size_t i = 0; i < gamepad_data.items[0].buttons_length; ++i) { float button_val = gamepad_data.items[0].buttons[i]; uint32_t colour = static_cast<uint32_t>((button_val * 192) + 63) << 24; - int x = i * 8 + 10; + int x = static_cast<int>(i) * 8 + 10; int y = 10; FillRect(&image, x - 3, y - 3, 7, 7, colour); } diff --git a/chromium/ppapi/examples/gles2/BUILD.gn b/chromium/ppapi/examples/gles2/BUILD.gn new file mode 100644 index 00000000000..4a86017b02f --- /dev/null +++ b/chromium/ppapi/examples/gles2/BUILD.gn @@ -0,0 +1,16 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +ppapi_example("gles2") { + output_name = "ppapi_example_gles2" + sources = [ + "gles2.cc", + ] + deps = [ + "//ppapi/cpp", + "//ppapi/lib/gl/gles2", + ] +} diff --git a/chromium/ppapi/examples/gles2/gles2.cc b/chromium/ppapi/examples/gles2/gles2.cc index 7a2ca050d98..af2aaea4f6c 100644 --- a/chromium/ppapi/examples/gles2/gles2.cc +++ b/chromium/ppapi/examples/gles2/gles2.cc @@ -156,9 +156,9 @@ void GLES2DemoInstance::InitGL(int32_t result) { void GLES2DemoInstance::FlickerAndPaint(int32_t result, bool paint_blue) { if (result != 0 || !context_) return; - float r = paint_blue ? 0 : 1; + float r = paint_blue ? 0 : 1.f; float g = 0; - float b = paint_blue ? 1 : 0; + float b = paint_blue ? 1.f : 0; float a = 0.75; gles2_if_->ClearColor(context_->pp_resource(), r, g, b, a); gles2_if_->Clear(context_->pp_resource(), GL_COLOR_BUFFER_BIT); diff --git a/chromium/ppapi/examples/gles2_spinning_cube/BUILD.gn b/chromium/ppapi/examples/gles2_spinning_cube/BUILD.gn new file mode 100644 index 00000000000..26d1ecfb3b5 --- /dev/null +++ b/chromium/ppapi/examples/gles2_spinning_cube/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +ppapi_example("gles2_spinning_cube") { + output_name = "ppapi_example_gles2_spinning_cube" + sources = [ + "gles2_spinning_cube.cc", + "spinning_cube.cc", + "spinning_cube.h", + ] + deps = [ + "//ppapi/cpp", + "//ppapi/lib/gl/gles2", + ] +} diff --git a/chromium/ppapi/examples/ime/BUILD.gn b/chromium/ppapi/examples/ime/BUILD.gn new file mode 100644 index 00000000000..79b4a9e55d0 --- /dev/null +++ b/chromium/ppapi/examples/ime/BUILD.gn @@ -0,0 +1,15 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +ppapi_example("ime") { + output_name = "ppapi_example_ime" + sources = [ + "ime.cc", + ] + deps = [ + "//ppapi/cpp", + ] +} diff --git a/chromium/ppapi/examples/ime/ime.cc b/chromium/ppapi/examples/ime/ime.cc index 26c2f4225a9..805d14052f5 100644 --- a/chromium/ppapi/examples/ime/ime.cc +++ b/chromium/ppapi/examples/ime/ime.cc @@ -112,7 +112,8 @@ class TextFieldStatusNotifyingHandler : public TextFieldStatusHandler { textinput_control_.SetTextInputType(PP_TEXTINPUT_TYPE_NONE); } virtual void UpdateSelection(const std::string& text) { - textinput_control_.UpdateSurroundingText(text, 0, text.size()); + textinput_control_.UpdateSurroundingText( + text, 0, static_cast<uint32_t>(text.size())); } private: diff --git a/chromium/ppapi/examples/input/BUILD.gn b/chromium/ppapi/examples/input/BUILD.gn new file mode 100644 index 00000000000..38340f91a13 --- /dev/null +++ b/chromium/ppapi/examples/input/BUILD.gn @@ -0,0 +1,15 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +ppapi_example("input") { + output_name = "ppapi_example_input" + sources = [ + "pointer_event_input.cc", + ] + deps = [ + "//ppapi/cpp", + ] +} diff --git a/chromium/ppapi/examples/media_stream_audio/BUILD.gn b/chromium/ppapi/examples/media_stream_audio/BUILD.gn new file mode 100644 index 00000000000..39a8ae99f45 --- /dev/null +++ b/chromium/ppapi/examples/media_stream_audio/BUILD.gn @@ -0,0 +1,15 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +ppapi_example("media_stream_audio") { + output_name = "ppapi_example_media_stream_audio" + sources = [ + "media_stream_audio.cc", + ] + deps = [ + "//ppapi/cpp", + ] +} diff --git a/chromium/ppapi/examples/media_stream_video/BUILD.gn b/chromium/ppapi/examples/media_stream_video/BUILD.gn new file mode 100644 index 00000000000..578e8f67e7a --- /dev/null +++ b/chromium/ppapi/examples/media_stream_video/BUILD.gn @@ -0,0 +1,16 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +ppapi_example("media_stream_video") { + output_name = "ppapi_example_media_stream_video" + sources = [ + "media_stream_video.cc", + ] + deps = [ + "//ppapi/cpp", + "//ppapi/lib/gl/gles2", + ] +} diff --git a/chromium/ppapi/examples/mouse_cursor/BUILD.gn b/chromium/ppapi/examples/mouse_cursor/BUILD.gn new file mode 100644 index 00000000000..03d2a1917bb --- /dev/null +++ b/chromium/ppapi/examples/mouse_cursor/BUILD.gn @@ -0,0 +1,15 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +ppapi_example("mouse_cursor") { + output_name = "ppapi_example_mouse_cursor" + sources = [ + "mouse_cursor.cc", + ] + deps = [ + "//ppapi/cpp", + ] +} diff --git a/chromium/ppapi/examples/mouse_lock/BUILD.gn b/chromium/ppapi/examples/mouse_lock/BUILD.gn new file mode 100644 index 00000000000..7b98278a646 --- /dev/null +++ b/chromium/ppapi/examples/mouse_lock/BUILD.gn @@ -0,0 +1,15 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +ppapi_example("mouse_lock") { + output_name = "ppapi_example_mouse_lock" + sources = [ + "mouse_lock.cc", + ] + deps = [ + "//ppapi/cpp", + ] +} diff --git a/chromium/ppapi/examples/ppapi_example.gni b/chromium/ppapi/examples/ppapi_example.gni new file mode 100644 index 00000000000..5345b1df0c1 --- /dev/null +++ b/chromium/ppapi/examples/ppapi_example.gni @@ -0,0 +1,28 @@ +# Copyright 2015 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. + +# Declares a PPAPI example target of the correct type for the current platform +# and with the right linker flags. +template("ppapi_example") { + # TODO(GYP) on Mac this should be loadable_module. + shared_library(target_name) { + testonly = true + if (defined(invoker.output_name)) { + output_name = invoker.output_name + } + sources = invoker.sources + deps = invoker.deps + + if (is_mac) { + # TODO(GYP) this should be a mac bundle + output_extension = "plugin" + ldflags = [ + # Not to strip important symbols by -Wl,-dead_strip. + "-Wl,-exported_symbol,_PPP_GetInterface", + "-Wl,-exported_symbol,_PPP_InitializeModule", + "-Wl,-exported_symbol,_PPP_ShutdownModule", + ] + } + } +} diff --git a/chromium/ppapi/examples/printing/BUILD.gn b/chromium/ppapi/examples/printing/BUILD.gn new file mode 100644 index 00000000000..64c950d7b10 --- /dev/null +++ b/chromium/ppapi/examples/printing/BUILD.gn @@ -0,0 +1,15 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +ppapi_example("printing") { + output_name = "ppapi_example_printing" + sources = [ + "printing.cc", + ] + deps = [ + "//ppapi/cpp", + ] +} diff --git a/chromium/ppapi/examples/printing/printing.cc b/chromium/ppapi/examples/printing/printing.cc index b87fc4feefc..37a7273d8f4 100644 --- a/chromium/ppapi/examples/printing/printing.cc +++ b/chromium/ppapi/examples/printing/printing.cc @@ -67,7 +67,7 @@ class MyInstance : public pp::Instance, public pp::Printing_Dev { const PP_PrintPageNumberRange_Dev* page_ranges, uint32_t page_range_count) { size_t pdf_len = strlen(pdf_data); - pp::Buffer_Dev buffer(this, pdf_len); + pp::Buffer_Dev buffer(this, static_cast<uint32_t>(pdf_len)); memcpy(buffer.data(), pdf_data, pdf_len); return buffer; diff --git a/chromium/ppapi/examples/scaling/BUILD.gn b/chromium/ppapi/examples/scaling/BUILD.gn new file mode 100644 index 00000000000..fdc42e0a7ec --- /dev/null +++ b/chromium/ppapi/examples/scaling/BUILD.gn @@ -0,0 +1,15 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +ppapi_example("scaling") { + output_name = "ppapi_example_scaling" + sources = [ + "scaling.cc", + ] + deps = [ + "//ppapi/cpp", + ] +} diff --git a/chromium/ppapi/examples/scaling/scaling.cc b/chromium/ppapi/examples/scaling/scaling.cc index 01d9265123e..6a7c4ebb08b 100644 --- a/chromium/ppapi/examples/scaling/scaling.cc +++ b/chromium/ppapi/examples/scaling/scaling.cc @@ -51,8 +51,8 @@ class MyInstance : public pp::Instance { device_scale_ = view.GetDeviceScale(); css_scale_ = view.GetCSSScale(); - pixel_width_ = width_ * device_scale_; - pixel_height_ = height_ * device_scale_; + pixel_width_ = static_cast<int>(width_ * device_scale_); + pixel_height_ = static_cast<int>(height_ * device_scale_); SetupGraphics(); } @@ -94,15 +94,16 @@ class MyInstance : public pp::Instance { void HandleMouseDown(const pp::InputEvent& event) { pp::MouseInputEvent mouse_event(event); pp::Point position(mouse_event.GetPosition()); - pp::Point position_device(position.x() * device_scale_, - position.y() * device_scale_); + pp::Point position_device( + static_cast<int32_t>(position.x() * device_scale_), + static_cast<int32_t>(position.y() * device_scale_)); std::stringstream stream; stream << "Mousedown at DIP (" << position.x() << ", " << position.y() << "), device pixel (" << position_device.x() << ", " << position_device.y() << ")"; if (css_scale_ > 0.0f) { - pp::Point position_css(position.x() / css_scale_, - position.y() / css_scale_); + pp::Point position_css(static_cast<int32_t>(position.x() / css_scale_), + static_cast<int32_t>(position.y() / css_scale_)); stream << ", CSS pixel (" << position_css.x() << ", " << position_css.y() <<")"; } else { @@ -179,7 +180,7 @@ class MyInstance : public pp::Instance { for (int x = 0; x < width; ++x) { int dx = (width / 2) - x; int dy = (height / 2) - y; - float dist_squared = (dx * dx) + (dy * dy); + float dist_squared = static_cast<float>((dx * dx) + (dy * dy)); if (x == 0 || y == 0 || x == width - 1 || y == width - 1 || x == y || width - x - 1 == y) { *pixel++ = 0xFF0000FF; diff --git a/chromium/ppapi/examples/scripting/BUILD.gn b/chromium/ppapi/examples/scripting/BUILD.gn new file mode 100644 index 00000000000..f57e73f7139 --- /dev/null +++ b/chromium/ppapi/examples/scripting/BUILD.gn @@ -0,0 +1,15 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +ppapi_example("scripting") { + output_name = "ppapi_example_post_message" + sources = [ + "post_message.cc", + ] + deps = [ + "//ppapi/cpp", + ] +} diff --git a/chromium/ppapi/examples/stub/BUILD.gn b/chromium/ppapi/examples/stub/BUILD.gn new file mode 100644 index 00000000000..9d2a452d145 --- /dev/null +++ b/chromium/ppapi/examples/stub/BUILD.gn @@ -0,0 +1,33 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +group("stub") { + testonly = true + deps = [ + ":c_stub", + ":cc_stub", + ] +} + +ppapi_example("c_stub") { + output_name = "ppapi_example_c_stub" + sources = [ + "stub.c", + ] + deps = [ + "//ppapi/c", + ] +} + +ppapi_example("cc_stub") { + output_name = "ppapi_example_cc_stub" + sources = [ + "stub.cc", + ] + deps = [ + "//ppapi/cpp", + ] +} diff --git a/chromium/ppapi/examples/threading/BUILD.gn b/chromium/ppapi/examples/threading/BUILD.gn new file mode 100644 index 00000000000..8861dd863ee --- /dev/null +++ b/chromium/ppapi/examples/threading/BUILD.gn @@ -0,0 +1,15 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +ppapi_example("threading") { + output_name = "ppapi_example_threading" + sources = [ + "threading.cc", + ] + deps = [ + "//ppapi/cpp", + ] +} diff --git a/chromium/ppapi/examples/url_loader/BUILD.gn b/chromium/ppapi/examples/url_loader/BUILD.gn new file mode 100644 index 00000000000..693325a97c5 --- /dev/null +++ b/chromium/ppapi/examples/url_loader/BUILD.gn @@ -0,0 +1,33 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +group("url_loader") { + testonly = true + deps = [ + ":file", + ":streaming", + ] +} + +ppapi_example("file") { + output_name = "ppapi_example_url_loader" + sources = [ + "streaming.cc", + ] + deps = [ + "//ppapi/cpp", + ] +} + +ppapi_example("streaming") { + output_name = "ppapi_example_file" + sources = [ + "stream_to_file.cc", + ] + deps = [ + "//ppapi/cpp", + ] +} diff --git a/chromium/ppapi/examples/video_capture/BUILD.gn b/chromium/ppapi/examples/video_capture/BUILD.gn new file mode 100644 index 00000000000..ab48184f237 --- /dev/null +++ b/chromium/ppapi/examples/video_capture/BUILD.gn @@ -0,0 +1,16 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +ppapi_example("video_capture") { + output_name = "ppapi_example_vc" + sources = [ + "video_capture.cc", + ] + deps = [ + "//ppapi/cpp", + "//ppapi/lib/gl/gles2", + ] +} diff --git a/chromium/ppapi/examples/video_decode/BUILD.gn b/chromium/ppapi/examples/video_decode/BUILD.gn new file mode 100644 index 00000000000..dfbc28e7fc9 --- /dev/null +++ b/chromium/ppapi/examples/video_decode/BUILD.gn @@ -0,0 +1,37 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +group("video_decode") { + testonly = true + deps = [ + ":dev", + ":stable", + ] +} + +ppapi_example("dev") { + output_name = "ppapi_example_video_decode_dev" + sources = [ + "testdata.h", + "video_decode_dev.cc", + ] + deps = [ + "//ppapi/cpp", + "//ppapi/lib/gl/gles2", + ] +} + +ppapi_example("stable") { + output_name = "ppapi_example_video_decode" + sources = [ + "testdata.h", + "video_decode.cc", + ] + deps = [ + "//ppapi/cpp", + "//ppapi/lib/gl/gles2", + ] +} diff --git a/chromium/ppapi/examples/video_decode/OWNERS b/chromium/ppapi/examples/video_decode/OWNERS index ec1eaca9cdf..7de84a45419 100644 --- a/chromium/ppapi/examples/video_decode/OWNERS +++ b/chromium/ppapi/examples/video_decode/OWNERS @@ -1 +1 @@ -vrk@chromium.org +bbudge@chromium.org diff --git a/chromium/ppapi/examples/video_decode/video_decode.cc b/chromium/ppapi/examples/video_decode/video_decode.cc index acd18694764..10e0536b741 100644 --- a/chromium/ppapi/examples/video_decode/video_decode.cc +++ b/chromium/ppapi/examples/video_decode/video_decode.cc @@ -484,8 +484,8 @@ void MyInstance::PaintNextPicture() { gles2_if_->UseProgram(graphics_3d, shader_rectangle_arb_.program); gles2_if_->Uniform2f(graphics_3d, shader_rectangle_arb_.texcoord_scale_location, - picture.texture_size.width, - picture.texture_size.height); + static_cast<GLfloat>(picture.texture_size.width), + static_cast<GLfloat>(picture.texture_size.height)); } else { assert(picture.texture_target == GL_TEXTURE_EXTERNAL_OES); CreateExternalOESProgramOnce(); @@ -662,11 +662,12 @@ Shader MyInstance::CreateProgram(const char* vertex_shader, // Create shader program. shader.program = gles2_if_->CreateProgram(context_->pp_resource()); CreateShader( - shader.program, GL_VERTEX_SHADER, vertex_shader, strlen(vertex_shader)); + shader.program, GL_VERTEX_SHADER, vertex_shader, + static_cast<uint32_t>(strlen(vertex_shader))); CreateShader(shader.program, GL_FRAGMENT_SHADER, fragment_shader, - strlen(fragment_shader)); + static_cast<int>(strlen(fragment_shader))); gles2_if_->LinkProgram(context_->pp_resource(), shader.program); gles2_if_->UseProgram(context_->pp_resource(), shader.program); gles2_if_->Uniform1i( diff --git a/chromium/ppapi/examples/video_decode/video_decode_dev.cc b/chromium/ppapi/examples/video_decode/video_decode_dev.cc index a3e301652f4..1cacb1b37e4 100644 --- a/chromium/ppapi/examples/video_decode/video_decode_dev.cc +++ b/chromium/ppapi/examples/video_decode/video_decode_dev.cc @@ -341,11 +341,12 @@ void VideoDecodeDemoInstance::DecoderClient::DecodeNextNALU() { size_t start_pos = encoded_data_next_pos_to_decode_; size_t end_pos; GetNextNALUBoundary(start_pos, &end_pos); - pp::Buffer_Dev* buffer = new pp::Buffer_Dev(gles2_, end_pos - start_pos); + pp::Buffer_Dev* buffer = new pp::Buffer_Dev( + gles2_, static_cast<uint32_t>(end_pos - start_pos)); PP_VideoBitstreamBuffer_Dev bitstream_buffer; int id = ++next_bitstream_buffer_id_; bitstream_buffer.id = id; - bitstream_buffer.size = end_pos - start_pos; + bitstream_buffer.size = static_cast<uint32_t>(end_pos - start_pos); bitstream_buffer.data = buffer->pp_resource(); memcpy(buffer->data(), kData + start_pos, end_pos - start_pos); assert(bitstream_buffers_by_id_.insert(std::make_pair(id, buffer)).second); @@ -441,8 +442,8 @@ void VideoDecodeDemoInstance::PictureReady(PP_Resource decoder, context_->pp_resource(), shader_rectangle_arb_.program); gles2_if_->Uniform2f(context_->pp_resource(), shader_rectangle_arb_.texcoord_scale_location, - info.buffer.size.width, - info.buffer.size.height); + static_cast<GLfloat>(info.buffer.size.width), + static_cast<GLfloat>(info.buffer.size.height)); } gles2_if_->Viewport(context_->pp_resource(), x, y, @@ -637,9 +638,9 @@ Shader VideoDecodeDemoInstance::CreateProgram(const char* vertex_shader, // Create shader program. shader.program = gles2_if_->CreateProgram(context_->pp_resource()); CreateShader(shader.program, GL_VERTEX_SHADER, vertex_shader, - strlen(vertex_shader)); + static_cast<int>(strlen(vertex_shader))); CreateShader(shader.program, GL_FRAGMENT_SHADER, fragment_shader, - strlen(fragment_shader)); + static_cast<int>(strlen(fragment_shader))); gles2_if_->LinkProgram(context_->pp_resource(), shader.program); gles2_if_->UseProgram(context_->pp_resource(), shader.program); gles2_if_->Uniform1i( diff --git a/chromium/ppapi/examples/video_effects/BUILD.gn b/chromium/ppapi/examples/video_effects/BUILD.gn new file mode 100644 index 00000000000..a93a08d2a4f --- /dev/null +++ b/chromium/ppapi/examples/video_effects/BUILD.gn @@ -0,0 +1,15 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +ppapi_example("video_effects") { + output_name = "video_effects" + sources = [ + "video_effects.cc", + ] + deps = [ + "//ppapi/cpp", + ] +} diff --git a/chromium/ppapi/examples/video_encode/BUILD.gn b/chromium/ppapi/examples/video_encode/BUILD.gn new file mode 100644 index 00000000000..eaa3586f6fd --- /dev/null +++ b/chromium/ppapi/examples/video_encode/BUILD.gn @@ -0,0 +1,15 @@ +# Copyright 2015 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. + +import("//ppapi/examples/ppapi_example.gni") + +ppapi_example("video_encode") { + output_name = "ppapi_example_video_encode" + sources = [ + "video_encode.cc", + ] + deps = [ + "//ppapi/cpp", + ] +} diff --git a/chromium/ppapi/examples/video_encode/video_encode.cc b/chromium/ppapi/examples/video_encode/video_encode.cc new file mode 100644 index 00000000000..c6a09211a8c --- /dev/null +++ b/chromium/ppapi/examples/video_encode/video_encode.cc @@ -0,0 +1,579 @@ +// Copyright 2015 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 <math.h> +#include <stdio.h> +#include <string.h> + +#include <iostream> +#include <map> +#include <sstream> +#include <vector> + +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/ppb_console.h" +#include "ppapi/cpp/input_event.h" +#include "ppapi/cpp/instance.h" +#include "ppapi/cpp/media_stream_video_track.h" +#include "ppapi/cpp/module.h" +#include "ppapi/cpp/rect.h" +#include "ppapi/cpp/var.h" +#include "ppapi/cpp/var_array_buffer.h" +#include "ppapi/cpp/var_dictionary.h" +#include "ppapi/cpp/video_encoder.h" +#include "ppapi/cpp/video_frame.h" +#include "ppapi/utility/completion_callback_factory.h" + +// When compiling natively on Windows, PostMessage can be #define-d to +// something else. +#ifdef PostMessage +#undef PostMessage +#endif + +// Use assert as a poor-man's CHECK, even in non-debug mode. +// Since <assert.h> redefines assert on every inclusion (it doesn't use +// include-guards), make sure this is the last file #include'd in this file. +#undef NDEBUG +#include <assert.h> + +#define fourcc(a, b, c, d) \ + (((uint32_t)(a) << 0) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | \ + ((uint32_t)(d) << 24)) + +namespace { + +// IVF container writer. It is possible to parse H264 bitstream using +// NAL units but for VP8 we need a container to at least find encoded +// pictures as well as the picture sizes. +class IVFWriter { + public: + IVFWriter() {} + ~IVFWriter() {} + + uint32_t GetFileHeaderSize() const { return 32; } + uint32_t GetFrameHeaderSize() const { return 12; } + uint32_t WriteFileHeader(uint8_t* mem, int32_t width, int32_t height); + uint32_t WriteFrameHeader(uint8_t* mem, uint64_t pts, size_t frame_size); + + private: + void PutLE16(uint8_t* mem, int val) const { + mem[0] = (val >> 0) & 0xff; + mem[1] = (val >> 8) & 0xff; + } + void PutLE32(uint8_t* mem, int val) const { + mem[0] = (val >> 0) & 0xff; + mem[1] = (val >> 8) & 0xff; + mem[2] = (val >> 16) & 0xff; + mem[3] = (val >> 24) & 0xff; + } +}; + +uint32_t IVFWriter::WriteFileHeader(uint8_t* mem, + int32_t width, + int32_t height) { + mem[0] = 'D'; + mem[1] = 'K'; + mem[2] = 'I'; + mem[3] = 'F'; + PutLE16(mem + 4, 0); // version + PutLE16(mem + 6, 32); // header size + PutLE32(mem + 8, fourcc('V', 'P', '8', '0')); // fourcc + PutLE16(mem + 12, static_cast<uint16_t>(width)); // width + PutLE16(mem + 14, static_cast<uint16_t>(height)); // height + PutLE32(mem + 16, 30); // rate + PutLE32(mem + 20, 1); // scale + PutLE32(mem + 24, 0xffffffff); // length + PutLE32(mem + 28, 0); // unused + + return 32; +} + +uint32_t IVFWriter::WriteFrameHeader(uint8_t* mem, + uint64_t pts, + size_t frame_size) { + PutLE32(mem, (int)frame_size); + PutLE32(mem + 4, (int)(pts & 0xFFFFFFFF)); + PutLE32(mem + 8, (int)(pts >> 32)); + + return 12; +} + +// This object is the global object representing this plugin library as long +// as it is loaded. +class VideoEncoderModule : public pp::Module { + public: + VideoEncoderModule() : pp::Module() {} + virtual ~VideoEncoderModule() {} + + virtual pp::Instance* CreateInstance(PP_Instance instance); +}; + +class VideoEncoderInstance : public pp::Instance { + public: + VideoEncoderInstance(PP_Instance instance, pp::Module* module); + virtual ~VideoEncoderInstance(); + + // pp::Instance implementation. + virtual void HandleMessage(const pp::Var& var_message); + + private: + void AddVideoProfile(PP_VideoProfile profile, const std::string& profile_str); + void InitializeVideoProfiles(); + PP_VideoProfile VideoProfileFromString(const std::string& str); + std::string VideoProfileToString(PP_VideoProfile profile); + + void ConfigureTrack(); + void OnConfiguredTrack(int32_t result); + void ProbeEncoder(); + void OnEncoderProbed(int32_t result, + const std::vector<PP_VideoProfileDescription> profiles); + void StartEncoder(); + void OnInitializedEncoder(int32_t result); + void ScheduleNextEncode(); + void GetEncoderFrameTick(int32_t result); + void GetEncoderFrame(const pp::VideoFrame& track_frame); + void OnEncoderFrame(int32_t result, + pp::VideoFrame encoder_frame, + pp::VideoFrame track_frame); + int32_t CopyVideoFrame(pp::VideoFrame dest, pp::VideoFrame src); + void EncodeFrame(const pp::VideoFrame& frame); + void OnEncodeDone(int32_t result); + void OnGetBitstreamBuffer(int32_t result, PP_BitstreamBuffer buffer); + void StartTrackFrames(); + void StopTrackFrames(); + void OnTrackFrame(int32_t result, pp::VideoFrame frame); + + void StopEncode(); + + void LogError(int32_t error, const std::string& message); + void Log(const std::string& message); + + void PostDataMessage(const void* buffer, uint32_t size); + void PostSignalMessage(const char* name); + + typedef std::map<std::string, PP_VideoProfile> VideoProfileFromStringMap; + VideoProfileFromStringMap profile_from_string_; + + typedef std::map<PP_VideoProfile, std::string> VideoProfileToStringMap; + VideoProfileToStringMap profile_to_string_; + + bool is_encoding_; + bool is_receiving_track_frames_; + + pp::VideoEncoder video_encoder_; + pp::MediaStreamVideoTrack video_track_; + pp::CompletionCallbackFactory<VideoEncoderInstance> callback_factory_; + + PP_VideoProfile video_profile_; + PP_VideoFrame_Format frame_format_; + + pp::Size requested_size_; + pp::Size frame_size_; + pp::Size encoder_size_; + uint32_t encoded_frames_; + + pp::VideoFrame current_track_frame_; + + IVFWriter ivf_writer_; +}; + +VideoEncoderInstance::VideoEncoderInstance(PP_Instance instance, + pp::Module* module) + : pp::Instance(instance), + is_encoding_(false), + callback_factory_(this), +#if defined(USE_VP8_INSTEAD_OF_H264) + video_profile_(PP_VIDEOPROFILE_VP8_ANY), +#else + video_profile_(PP_VIDEOPROFILE_H264MAIN), +#endif + frame_format_(PP_VIDEOFRAME_FORMAT_I420), + encoded_frames_(0) { + InitializeVideoProfiles(); + ProbeEncoder(); +} + +VideoEncoderInstance::~VideoEncoderInstance() { +} + +void VideoEncoderInstance::AddVideoProfile(PP_VideoProfile profile, + const std::string& profile_str) { + profile_to_string_.insert(std::make_pair(profile, profile_str)); + profile_from_string_.insert(std::make_pair(profile_str, profile)); +} + +void VideoEncoderInstance::InitializeVideoProfiles() { + AddVideoProfile(PP_VIDEOPROFILE_H264BASELINE, "h264baseline"); + AddVideoProfile(PP_VIDEOPROFILE_H264MAIN, "h264main"); + AddVideoProfile(PP_VIDEOPROFILE_H264EXTENDED, "h264extended"); + AddVideoProfile(PP_VIDEOPROFILE_H264HIGH, "h264high"); + AddVideoProfile(PP_VIDEOPROFILE_H264HIGH10PROFILE, "h264high10"); + AddVideoProfile(PP_VIDEOPROFILE_H264HIGH422PROFILE, "h264high422"); + AddVideoProfile(PP_VIDEOPROFILE_H264HIGH444PREDICTIVEPROFILE, + "h264high444predictive"); + AddVideoProfile(PP_VIDEOPROFILE_H264SCALABLEBASELINE, "h264scalablebaseline"); + AddVideoProfile(PP_VIDEOPROFILE_H264SCALABLEHIGH, "h264scalablehigh"); + AddVideoProfile(PP_VIDEOPROFILE_H264STEREOHIGH, "h264stereohigh"); + AddVideoProfile(PP_VIDEOPROFILE_H264MULTIVIEWHIGH, "h264multiviewhigh"); + AddVideoProfile(PP_VIDEOPROFILE_VP8_ANY, "vp8"); + AddVideoProfile(PP_VIDEOPROFILE_VP9_ANY, "vp9"); +} + +PP_VideoProfile VideoEncoderInstance::VideoProfileFromString( + const std::string& str) { + VideoProfileFromStringMap::iterator it = profile_from_string_.find(str); + if (it == profile_from_string_.end()) + return PP_VIDEOPROFILE_VP8_ANY; + return it->second; +} + +std::string VideoEncoderInstance::VideoProfileToString( + PP_VideoProfile profile) { + VideoProfileToStringMap::iterator it = profile_to_string_.find(profile); + if (it == profile_to_string_.end()) + return "unknown"; + return it->second; +} + +void VideoEncoderInstance::ConfigureTrack() { + if (encoder_size_.IsEmpty()) + frame_size_ = requested_size_; + else + frame_size_ = encoder_size_; + + int32_t attrib_list[] = {PP_MEDIASTREAMVIDEOTRACK_ATTRIB_FORMAT, + frame_format_, + PP_MEDIASTREAMVIDEOTRACK_ATTRIB_WIDTH, + frame_size_.width(), + PP_MEDIASTREAMVIDEOTRACK_ATTRIB_HEIGHT, + frame_size_.height(), + PP_MEDIASTREAMVIDEOTRACK_ATTRIB_NONE}; + + pp::VarDictionary dict; + dict.Set(pp::Var("status"), pp::Var("configuring video track")); + dict.Set(pp::Var("width"), pp::Var(frame_size_.width())); + dict.Set(pp::Var("height"), pp::Var(frame_size_.height())); + PostMessage(dict); + + video_track_.Configure( + attrib_list, + callback_factory_.NewCallback(&VideoEncoderInstance::OnConfiguredTrack)); +} + +void VideoEncoderInstance::OnConfiguredTrack(int32_t result) { + if (result != PP_OK) { + LogError(result, "Cannot configure track"); + return; + } + + if (is_encoding_) { + StartTrackFrames(); + ScheduleNextEncode(); + } else + StartEncoder(); +} + +void VideoEncoderInstance::ProbeEncoder() { + video_encoder_ = pp::VideoEncoder(this); + video_encoder_.GetSupportedProfiles(callback_factory_.NewCallbackWithOutput( + &VideoEncoderInstance::OnEncoderProbed)); +} + +void VideoEncoderInstance::OnEncoderProbed( + int32_t result, + const std::vector<PP_VideoProfileDescription> profiles) { + pp::VarDictionary dict; + dict.Set(pp::Var("name"), pp::Var("supportedProfiles")); + pp::VarArray js_profiles; + dict.Set(pp::Var("profiles"), js_profiles); + + if (result < 0) { + LogError(result, "Cannot get supported profiles"); + PostMessage(dict); + } + + int32_t idx = 0; + for (const PP_VideoProfileDescription& profile : profiles) + js_profiles.Set(idx++, pp::Var(VideoProfileToString(profile.profile))); + PostMessage(dict); +} + +void VideoEncoderInstance::StartEncoder() { + video_encoder_ = pp::VideoEncoder(this); + + int32_t error = video_encoder_.Initialize( + frame_format_, frame_size_, video_profile_, 2000000, + PP_HARDWAREACCELERATION_WITHFALLBACK, + callback_factory_.NewCallback( + &VideoEncoderInstance::OnInitializedEncoder)); + if (error != PP_OK_COMPLETIONPENDING) { + LogError(error, "Cannot initialize encoder"); + return; + } +} + +void VideoEncoderInstance::OnInitializedEncoder(int32_t result) { + if (result != PP_OK) { + LogError(result, "Encoder initialization failed"); + return; + } + + is_encoding_ = true; + PostSignalMessage("started"); + + if (video_encoder_.GetFrameCodedSize(&encoder_size_) != PP_OK) { + LogError(result, "Cannot get encoder coded frame size"); + return; + } + + video_encoder_.GetBitstreamBuffer(callback_factory_.NewCallbackWithOutput( + &VideoEncoderInstance::OnGetBitstreamBuffer)); + + if (encoder_size_ != frame_size_) + ConfigureTrack(); + else { + StartTrackFrames(); + ScheduleNextEncode(); + } +} + +void VideoEncoderInstance::ScheduleNextEncode() { + pp::Module::Get()->core()->CallOnMainThread( + 1000 / 30, + callback_factory_.NewCallback(&VideoEncoderInstance::GetEncoderFrameTick), + 0); +} + +void VideoEncoderInstance::GetEncoderFrameTick(int32_t result) { + if (is_encoding_) { + if (!current_track_frame_.is_null()) { + pp::VideoFrame frame = current_track_frame_; + current_track_frame_.detach(); + GetEncoderFrame(frame); + } + ScheduleNextEncode(); + } +} + +void VideoEncoderInstance::GetEncoderFrame(const pp::VideoFrame& track_frame) { + video_encoder_.GetVideoFrame(callback_factory_.NewCallbackWithOutput( + &VideoEncoderInstance::OnEncoderFrame, track_frame)); +} + +void VideoEncoderInstance::OnEncoderFrame(int32_t result, + pp::VideoFrame encoder_frame, + pp::VideoFrame track_frame) { + if (result == PP_ERROR_ABORTED) { + video_track_.RecycleFrame(track_frame); + return; + } + if (result != PP_OK) { + video_track_.RecycleFrame(track_frame); + LogError(result, "Cannot get video frame from video encoder"); + return; + } + + track_frame.GetSize(&frame_size_); + + if (frame_size_ != encoder_size_) { + video_track_.RecycleFrame(track_frame); + LogError(PP_ERROR_FAILED, "MediaStreamVideoTrack frame size incorrect"); + return; + } + + if (CopyVideoFrame(encoder_frame, track_frame) == PP_OK) + EncodeFrame(encoder_frame); + video_track_.RecycleFrame(track_frame); +} + +int32_t VideoEncoderInstance::CopyVideoFrame(pp::VideoFrame dest, + pp::VideoFrame src) { + if (dest.GetDataBufferSize() < src.GetDataBufferSize()) { + std::ostringstream oss; + oss << "Incorrect destination video frame buffer size : " + << dest.GetDataBufferSize() << " < " << src.GetDataBufferSize(); + LogError(PP_ERROR_FAILED, oss.str()); + return PP_ERROR_FAILED; + } + + dest.SetTimestamp(src.GetTimestamp()); + memcpy(dest.GetDataBuffer(), src.GetDataBuffer(), src.GetDataBufferSize()); + return PP_OK; +} + +void VideoEncoderInstance::EncodeFrame(const pp::VideoFrame& frame) { + video_encoder_.Encode( + frame, PP_FALSE, + callback_factory_.NewCallback(&VideoEncoderInstance::OnEncodeDone)); +} + +void VideoEncoderInstance::OnEncodeDone(int32_t result) { + if (result == PP_ERROR_ABORTED) + return; + if (result != PP_OK) + LogError(result, "Encode failed"); +} + +void VideoEncoderInstance::OnGetBitstreamBuffer(int32_t result, + PP_BitstreamBuffer buffer) { + if (result == PP_ERROR_ABORTED) + return; + if (result != PP_OK) { + LogError(result, "Cannot get bitstream buffer"); + return; + } + + encoded_frames_++; + PostDataMessage(buffer.buffer, buffer.size); + video_encoder_.RecycleBitstreamBuffer(buffer); + + video_encoder_.GetBitstreamBuffer(callback_factory_.NewCallbackWithOutput( + &VideoEncoderInstance::OnGetBitstreamBuffer)); +} + +void VideoEncoderInstance::StartTrackFrames() { + is_receiving_track_frames_ = true; + video_track_.GetFrame(callback_factory_.NewCallbackWithOutput( + &VideoEncoderInstance::OnTrackFrame)); +} + +void VideoEncoderInstance::StopTrackFrames() { + is_receiving_track_frames_ = false; + if (!current_track_frame_.is_null()) { + video_track_.RecycleFrame(current_track_frame_); + current_track_frame_.detach(); + } +} + +void VideoEncoderInstance::OnTrackFrame(int32_t result, pp::VideoFrame frame) { + if (result == PP_ERROR_ABORTED) + return; + + if (!current_track_frame_.is_null()) { + video_track_.RecycleFrame(current_track_frame_); + current_track_frame_.detach(); + } + + if (result != PP_OK) { + LogError(result, "Cannot get video frame from video track"); + return; + } + + current_track_frame_ = frame; + if (is_receiving_track_frames_) + video_track_.GetFrame(callback_factory_.NewCallbackWithOutput( + &VideoEncoderInstance::OnTrackFrame)); +} + +void VideoEncoderInstance::StopEncode() { + video_encoder_.Close(); + StopTrackFrames(); + video_track_.Close(); + is_encoding_ = false; + encoded_frames_ = 0; +} + +// + +void VideoEncoderInstance::HandleMessage(const pp::Var& var_message) { + if (!var_message.is_dictionary()) { + LogToConsole(PP_LOGLEVEL_ERROR, pp::Var("Invalid message!")); + return; + } + + pp::VarDictionary dict_message(var_message); + std::string command = dict_message.Get("command").AsString(); + + if (command == "start") { + requested_size_ = pp::Size(dict_message.Get("width").AsInt(), + dict_message.Get("height").AsInt()); + pp::Var var_track = dict_message.Get("track"); + if (!var_track.is_resource()) { + LogToConsole(PP_LOGLEVEL_ERROR, pp::Var("Given track is not a resource")); + return; + } + pp::Resource resource_track = var_track.AsResource(); + video_track_ = pp::MediaStreamVideoTrack(resource_track); + video_encoder_ = pp::VideoEncoder(); + video_profile_ = VideoProfileFromString( + dict_message.Get("profile").AsString()); + ConfigureTrack(); + } else if (command == "stop") { + StopEncode(); + PostSignalMessage("stopped"); + } else { + LogToConsole(PP_LOGLEVEL_ERROR, pp::Var("Invalid command!")); + } +} + +void VideoEncoderInstance::PostDataMessage(const void* buffer, uint32_t size) { + pp::VarDictionary dictionary; + + dictionary.Set(pp::Var("name"), pp::Var("data")); + + pp::VarArrayBuffer array_buffer; + uint8_t* data_ptr; + uint32_t data_offset = 0; + if (video_profile_ == PP_VIDEOPROFILE_VP8_ANY || + video_profile_ == PP_VIDEOPROFILE_VP9_ANY) { + uint32_t frame_offset = 0; + if (encoded_frames_ == 1) { + array_buffer = pp::VarArrayBuffer( + size + ivf_writer_.GetFileHeaderSize() + + ivf_writer_.GetFrameHeaderSize()); + data_ptr = static_cast<uint8_t*>(array_buffer.Map()); + frame_offset = ivf_writer_.WriteFileHeader( + data_ptr, frame_size_.width(), frame_size_.height()); + } else { + array_buffer = pp::VarArrayBuffer( + size + ivf_writer_.GetFrameHeaderSize()); + data_ptr = static_cast<uint8_t*>(array_buffer.Map()); + } + data_offset = frame_offset + + ivf_writer_.WriteFrameHeader(data_ptr + frame_offset, + encoded_frames_, + size); + } else { + array_buffer = pp::VarArrayBuffer(size); + data_ptr = static_cast<uint8_t*>(array_buffer.Map()); + } + + memcpy(data_ptr + data_offset, buffer, size); + array_buffer.Unmap(); + dictionary.Set(pp::Var("data"), array_buffer); + + PostMessage(dictionary); +} + +void VideoEncoderInstance::PostSignalMessage(const char* name) { + pp::VarDictionary dictionary; + dictionary.Set(pp::Var("name"), pp::Var(name)); + + PostMessage(dictionary); +} + +void VideoEncoderInstance::LogError(int32_t error, const std::string& message) { + std::string msg("Error: "); + msg.append(pp::Var(error).DebugString()); + msg.append(" : "); + msg.append(message); + LogToConsole(PP_LOGLEVEL_ERROR, pp::Var(msg)); +} + +void VideoEncoderInstance::Log(const std::string& message) { + LogToConsole(PP_LOGLEVEL_LOG, pp::Var(message)); +} + +pp::Instance* VideoEncoderModule::CreateInstance(PP_Instance instance) { + return new VideoEncoderInstance(instance, this); +} + +} // anonymous namespace + +namespace pp { +// Factory function for your specialization of the Module object. +Module* CreateModule() { + return new VideoEncoderModule(); +} +} // namespace pp diff --git a/chromium/ppapi/examples/video_encode/video_encode.html b/chromium/ppapi/examples/video_encode/video_encode.html new file mode 100644 index 00000000000..9f3b248c2f8 --- /dev/null +++ b/chromium/ppapi/examples/video_encode/video_encode.html @@ -0,0 +1,129 @@ +<!DOCTYPE html> +<html> + <!-- + Copyright 2015 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. + --> +<head> + <title>Video Encoder Example</title> + <script type="text/javascript"> + var plugin; + var track; + var video; + + function $(id) { + return document.getElementById(id); + } + + function success(stream) { + track = stream.getVideoTracks()[0]; + video.src = URL.createObjectURL(stream); + video.play(); + + var list = $('profileList'); + var profile = (list.length < 1) ? 'vp8' + : list.options[list.selectedIndex].value; + + plugin.postMessage({ + command: 'start', + track: track, + profile: profile, + width: 640, + height: 480 + }); + } + + function failure(e) { + console.log("Error: ", e); + } + + function startRecord() { + $('length').innerHTML = ' Size: ' + dataArray.byteLength + ' bytes'; + navigator.webkitGetUserMedia({audio: false, video: true}, + success, failure); + } + + function stopRecord() { + plugin.postMessage({ + command: "stop" + }); + var video = $('video'); + video.pause(); + track.stop(); + } + + function saveBlob(blob) { + var blobUrl = URL.createObjectURL(blob); + window.location = blobUrl; + } + + function handleMessage(msg) { + if (msg.data.name == 'started') { + console.log('recording!'); + } else if (msg.data.name == 'data') { + appendData(msg.data.data); + } else if (msg.data.name == 'stopped') { + console.log('done recording! bytes: ' + dataArray.byteLength); + } else if (msg.data.name == 'supportedProfiles') { + console.log('profiles: ', msg.data); + var profileList = $('profileList'); + for (var i = 0; i < msg.data.profiles.length; i++) { + var item = document.createElement('option'); + item.label = item.value = msg.data.profiles[i]; + profileList.appendChild(item); + } + } + } + + function resetData() { + window.dataArray = new ArrayBuffer(0); + } + + function appendData(data) { + var tmp = new Uint8Array(dataArray.byteLength + data.byteLength); + tmp.set(new Uint8Array(dataArray), 0 ); + tmp.set(new Uint8Array(data), dataArray.byteLength); + dataArray = tmp.buffer; + $('length').innerHTML = ' Size: ' + dataArray.byteLength + ' bytes'; + } + + function initialize() { + plugin = $('plugin'); + plugin.addEventListener('message', handleMessage, false); + + video = $('video'); + + $('start').addEventListener('click', function (e) { + resetData(); + startRecord(); + }); + $('stop').addEventListener('click', function (e) { + stopRecord(); + }); + $('download').addEventListener('click', function (e) { + saveBlob(new Blob([dataArray], { type: "application/octet-stream" })); + }); + } + + document.addEventListener('DOMContentLoaded', initialize, false); + </script> +</head> + +<body> + <h1>Video Encoder API Example</h1><br> + This example demonstrates receiving frames from a video MediaStreamTrack and + encoding them in a plugin. + <br> + <select id="profileList"></select> + <input type="button" id="start" value="Start Recording"/> + <input type="button" id="stop" value="Stop Recording"/> + <input type="button" id="download" value="Download Recording"/> + <div id="length"></div> + <br> + <div> + <embed id="plugin" type="application/x-ppapi-example-video-encode"/> + <video id="video" width="640" height="480"/> + </div> +</body> +</html> diff --git a/chromium/ppapi/generators/OWNERS b/chromium/ppapi/generators/OWNERS index c3be9543d98..cdb12bcc536 100644 --- a/chromium/ppapi/generators/OWNERS +++ b/chromium/ppapi/generators/OWNERS @@ -1,5 +1,8 @@ -yzshen@chromium.org +bradnelson@chromium.org +dmichael@chromium.org noelallen@chromium.org noelallen@google.com -sehr@google.com sehr@chromium.org +sehr@google.com +teravest@chromium.org +yzshen@chromium.org diff --git a/chromium/ppapi/generators/idl_c_proto.py b/chromium/ppapi/generators/idl_c_proto.py index d6b9ebc5637..d5c99a7095d 100755 --- a/chromium/ppapi/generators/idl_c_proto.py +++ b/chromium/ppapi/generators/idl_c_proto.py @@ -620,7 +620,7 @@ class CGen(object): newest_dev = rel last_rel = build_list[-1] - # TODO(noelallen) : Bug 157017 finish multiversion support + # TODO(bradnelson) : Bug 157017 finish multiversion support if node.IsA('Struct'): if len(build_list) != 1: node.Error('Can not support multiple versions of node.') diff --git a/chromium/ppapi/generators/idl_outfile.py b/chromium/ppapi/generators/idl_outfile.py index 053cf3ea05b..f6a16275cce 100755 --- a/chromium/ppapi/generators/idl_outfile.py +++ b/chromium/ppapi/generators/idl_outfile.py @@ -54,6 +54,7 @@ class IDLOutFile(object): curwords = curline.split() oldwords = oldline.split() + # It wasn't a perfect match. Check for changes we should ignore. # Unmatched lines must be the same length if len(curwords) != len(oldwords): return False @@ -67,16 +68,19 @@ class IDLOutFile(object): if len(curwords) > 4 and curwords[1] == 'Copyright': if curwords[4:] == oldwords[4:]: continue - # Ignore changes to auto generation timestamp when line unwrapped + # Ignore changes to auto generation timestamp. # // From FILENAME.idl modified DAY MON DATE TIME YEAR. # /* From FILENAME.idl modified DAY MON DATE TIME YEAR. */ - if len(curwords) > 8 and curwords[1] == 'From': + # The line may be wrapped, so first deal with the first "From" line. + if curwords[1] == 'From': if curwords[0:4] == oldwords[0:4]: continue # Ignore changes to auto generation timestamp when line is wrapped - # * modified DAY MON DATE TIME YEAR. - if len(curwords) > 6 and curwords[1] == 'modified': - continue + if index > 0: + two_line_oldwords = oldlines[index - 1].split() + oldwords[1:] + two_line_curwords = curlines[index - 1].split() + curwords[1:] + if len(two_line_curwords) > 8 and two_line_curwords[1] == 'From': + if two_line_curwords[0:4] == two_line_oldwords[0:4]: continue return False return True diff --git a/chromium/ppapi/generators/idl_parser.py b/chromium/ppapi/generators/idl_parser.py index 51941d7cd9c..823dcf5aeda 100755 --- a/chromium/ppapi/generators/idl_parser.py +++ b/chromium/ppapi/generators/idl_parser.py @@ -385,7 +385,7 @@ class IDLParser(IDLLexer): # Name=HEX | INT | OCT | FLOAT # Name="STRING" # Name=Function(arg ...) -# TODO(noelallen) -Not currently supported: +# TODO(bradnelson) -Not currently supported: # ** Name(arg ...) ... # ** Name=Scope::Value # diff --git a/chromium/ppapi/generators/idl_thunk.py b/chromium/ppapi/generators/idl_thunk.py index 5e037a22129..5df8e6badc6 100755 --- a/chromium/ppapi/generators/idl_thunk.py +++ b/chromium/ppapi/generators/idl_thunk.py @@ -360,7 +360,9 @@ def DefineMember(filenode, node, member, release, include_version, meta): """ cgen = CGen() rtype, name, arrays, args = cgen.GetComponents(member, release, 'return') - log_body = '\"%s::%s()\";' % (node.GetName(), member.GetName()) + log_body = '\"%s::%s()\";' % (node.GetName(), + cgen.GetStructName(member, release, + include_version)) if len(log_body) > 69: # Prevent lines over 80 characters. body = 'VLOG(4) <<\n' body += ' %s\n' % log_body diff --git a/chromium/ppapi/host/BUILD.gn b/chromium/ppapi/host/BUILD.gn new file mode 100644 index 00000000000..51bd0c511c7 --- /dev/null +++ b/chromium/ppapi/host/BUILD.gn @@ -0,0 +1,44 @@ +# Copyright 2015 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. + +component("host") { + output_name = "ppapi_host" + + sources = [ + "dispatch_host_message.h", + "error_conversion.cc", + "error_conversion.h", + "host_factory.h", + "host_message_context.cc", + "host_message_context.h", + "instance_message_filter.cc", + "instance_message_filter.h", + "message_filter_host.cc", + "message_filter_host.h", + "ppapi_host.cc", + "ppapi_host.h", + "ppapi_host_export.h", + "resource_host.cc", + "resource_host.h", + "resource_message_filter.cc", + "resource_message_filter.h", + "resource_message_handler.cc", + "resource_message_handler.h", + ] + + defines = [ "PPAPI_HOST_IMPLEMENTATION" ] + + deps = [ + "//base", + "//ipc", + "//media:shared_memory_support", + "//ppapi/shared_impl", + "//ppapi/c", + "//ppapi/proxy:ipc", + "//ppapi/proxy", + "//ui/events:events_base", + "//ui/surface", + "//url", + ] +} diff --git a/chromium/ppapi/host/dispatch_host_message.h b/chromium/ppapi/host/dispatch_host_message.h index 218b8f7b877..80b8a343a7f 100644 --- a/chromium/ppapi/host/dispatch_host_message.h +++ b/chromium/ppapi/host/dispatch_host_message.h @@ -22,43 +22,45 @@ struct HostMessageContext; template <class ObjT, class Method> inline int32_t DispatchResourceCall(ObjT* obj, Method method, HostMessageContext* context, - Tuple0& arg) { + Tuple<>& arg) { return (obj->*method)(context); } template <class ObjT, class Method, class A> inline int32_t DispatchResourceCall(ObjT* obj, Method method, HostMessageContext* context, - Tuple1<A>& arg) { - return (obj->*method)(context, arg.a); + Tuple<A>& arg) { + return (obj->*method)(context, get<0>(arg)); } template<class ObjT, class Method, class A, class B> inline int32_t DispatchResourceCall(ObjT* obj, Method method, HostMessageContext* context, - Tuple2<A, B>& arg) { - return (obj->*method)(context, arg.a, arg.b); + Tuple<A, B>& arg) { + return (obj->*method)(context, get<0>(arg), get<1>(arg)); } template<class ObjT, class Method, class A, class B, class C> inline int32_t DispatchResourceCall(ObjT* obj, Method method, HostMessageContext* context, - Tuple3<A, B, C>& arg) { - return (obj->*method)(context, arg.a, arg.b, arg.c); + Tuple<A, B, C>& arg) { + return (obj->*method)(context, get<0>(arg), get<1>(arg), get<2>(arg)); } template<class ObjT, class Method, class A, class B, class C, class D> inline int32_t DispatchResourceCall(ObjT* obj, Method method, HostMessageContext* context, - Tuple4<A, B, C, D>& arg) { - return (obj->*method)(context, arg.a, arg.b, arg.c, arg.d); + Tuple<A, B, C, D>& arg) { + return (obj->*method)(context, get<0>(arg), get<1>(arg), get<2>(arg), + get<3>(arg)); } template<class ObjT, class Method, class A, class B, class C, class D, class E> inline int32_t DispatchResourceCall(ObjT* obj, Method method, HostMessageContext* context, - Tuple5<A, B, C, D, E>& arg) { - return (obj->*method)(context, arg.a, arg.b, arg.c, arg.d, arg.e); + Tuple<A, B, C, D, E>& arg) { + return (obj->*method)(context, get<0>(arg), get<1>(arg), get<2>(arg), + get<3>(arg), get<4>(arg)); } // Note that this only works for message with 1 or more parameters. For diff --git a/chromium/ppapi/host/error_conversion.cc b/chromium/ppapi/host/error_conversion.cc index 2b7d73c9ad7..f97b121b9c0 100644 --- a/chromium/ppapi/host/error_conversion.cc +++ b/chromium/ppapi/host/error_conversion.cc @@ -53,6 +53,7 @@ int32_t NetErrorToPepperError(int net_error) { case net::ERR_CONNECTION_FAILED: return PP_ERROR_CONNECTION_FAILED; case net::ERR_NAME_NOT_RESOLVED: + case net::ERR_ICANN_NAME_COLLISION: return PP_ERROR_NAME_NOT_RESOLVED; case net::ERR_ADDRESS_INVALID: return PP_ERROR_ADDRESS_INVALID; diff --git a/chromium/ppapi/host/host_factory.h b/chromium/ppapi/host/host_factory.h index d4b8ea76cd8..e2dcce7a732 100644 --- a/chromium/ppapi/host/host_factory.h +++ b/chromium/ppapi/host/host_factory.h @@ -7,6 +7,7 @@ #include "base/memory/scoped_ptr.h" #include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_resource.h" namespace IPC { class Message; @@ -32,7 +33,7 @@ class HostFactory { virtual scoped_ptr<ResourceHost> CreateResourceHost( PpapiHost* host, - const proxy::ResourceMessageCallParams& params, + PP_Resource resource, PP_Instance instance, const IPC::Message& message) = 0; }; diff --git a/chromium/ppapi/host/ppapi_host.cc b/chromium/ppapi/host/ppapi_host.cc index 130bc875569..fa312bb69b0 100644 --- a/chromium/ppapi/host/ppapi_host.cc +++ b/chromium/ppapi/host/ppapi_host.cc @@ -123,14 +123,16 @@ void PpapiHost::SendUnsolicitedReplyWithHandles( } scoped_ptr<ResourceHost> PpapiHost::CreateResourceHost( - const proxy::ResourceMessageCallParams& params, + PP_Resource resource, PP_Instance instance, const IPC::Message& nested_msg) { scoped_ptr<ResourceHost> resource_host; DCHECK(!host_factory_filters_.empty()); // Caller forgot to add a factory. for (size_t i = 0; i < host_factory_filters_.size(); i++) { - resource_host = host_factory_filters_[i]->CreateResourceHost( - this, params, instance, nested_msg).Pass(); + resource_host = + host_factory_filters_[i] + ->CreateResourceHost(this, resource, instance, nested_msg) + .Pass(); if (resource_host.get()) break; } @@ -232,8 +234,8 @@ void PpapiHost::OnHostMsgResourceCreated( } // Run through all filters until one grabs this message. - scoped_ptr<ResourceHost> resource_host = CreateResourceHost(params, instance, - nested_msg); + scoped_ptr<ResourceHost> resource_host = + CreateResourceHost(params.pp_resource(), instance, nested_msg); if (!resource_host.get()) { NOTREACHED(); diff --git a/chromium/ppapi/host/ppapi_host.h b/chromium/ppapi/host/ppapi_host.h index 3df435a16cd..d4361dfeffd 100644 --- a/chromium/ppapi/host/ppapi_host.h +++ b/chromium/ppapi/host/ppapi_host.h @@ -46,15 +46,15 @@ class PPAPI_HOST_EXPORT PpapiHost : public IPC::Sender, public IPC::Listener { // (AddHostFactoryFilter) and instance messages (AddInstanceMessageFilter) // after construction. PpapiHost(IPC::Sender* sender, const PpapiPermissions& perms); - virtual ~PpapiHost(); + ~PpapiHost() override; const PpapiPermissions& permissions() const { return permissions_; } // Sender implementation. Forwards to the sender_. - virtual bool Send(IPC::Message* msg) override; + bool Send(IPC::Message* msg) override; // Listener implementation. - virtual bool OnMessageReceived(const IPC::Message& msg) override; + bool OnMessageReceived(const IPC::Message& msg) override; // Sends the given reply message to the plugin. void SendReply(const ReplyMessageContext& context, @@ -70,10 +70,9 @@ class PPAPI_HOST_EXPORT PpapiHost : public IPC::Sender, public IPC::Listener { const std::vector<proxy::SerializedHandle>& handles); // Create a ResourceHost with the given |nested_msg|. - scoped_ptr<ResourceHost> CreateResourceHost( - const proxy::ResourceMessageCallParams& params, - PP_Instance instance, - const IPC::Message& nested_msg); + scoped_ptr<ResourceHost> CreateResourceHost(PP_Resource resource, + PP_Instance instance, + const IPC::Message& nested_msg); // Adds the given host resource as a pending one (with no corresponding // PluginResource object and no PP_Resource ID yet). The pending resource ID diff --git a/chromium/ppapi/host/resource_host.h b/chromium/ppapi/host/resource_host.h index 517cf0a331f..6bf499608b7 100644 --- a/chromium/ppapi/host/resource_host.h +++ b/chromium/ppapi/host/resource_host.h @@ -31,7 +31,7 @@ class ResourceMessageFilter; class PPAPI_HOST_EXPORT ResourceHost : public ResourceMessageHandler { public: ResourceHost(PpapiHost* host, PP_Instance instance, PP_Resource resource); - virtual ~ResourceHost(); + ~ResourceHost() override; PpapiHost* host() { return host_; } PP_Instance pp_instance() const { return pp_instance_; } @@ -40,8 +40,8 @@ class PPAPI_HOST_EXPORT ResourceHost : public ResourceMessageHandler { // This runs any message filters in |message_filters_|. If the message is not // handled by these filters then the host's own message handler is run. True // is always returned (the message will always be handled in some way). - virtual bool HandleMessage(const IPC::Message& msg, - HostMessageContext* context) override; + bool HandleMessage(const IPC::Message& msg, + HostMessageContext* context) override; // Sets the PP_Resource ID when the plugin attaches to a pending resource // host. This will notify subclasses by calling @@ -51,8 +51,8 @@ class PPAPI_HOST_EXPORT ResourceHost : public ResourceMessageHandler { // PpapiHostMsg_AttachToPendingHost. void SetPPResourceForPendingHost(PP_Resource pp_resource); - virtual void SendReply(const ReplyMessageContext& context, - const IPC::Message& msg) override; + void SendReply(const ReplyMessageContext& context, + const IPC::Message& msg) override; // Simple RTTI. A subclass that is a host for one of these APIs will override // the appropriate function and return true. diff --git a/chromium/ppapi/host/resource_message_filter.h b/chromium/ppapi/host/resource_message_filter.h index af7a4f66908..5488f98a4bd 100644 --- a/chromium/ppapi/host/resource_message_filter.h +++ b/chromium/ppapi/host/resource_message_filter.h @@ -48,16 +48,15 @@ struct PPAPI_HOST_EXPORT ResourceMessageFilterDeleteTraits { // subclass as follows: // class MyMessageFilter : public ResourceMessageFilter { // protected: -// virtual scoped_refptr<base::TaskRunner> OverrideTaskRunnerForMessage( +// scoped_refptr<base::TaskRunner> OverrideTaskRunnerForMessage( // const IPC::Message& message) override { // if (message.type() == MyMessage::ID) // return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); // return NULL; // } // -// virtual int32_t OnResourceMessageReceived( -// const IPC::Message& msg, -// HostMessageContext* context) override { +// int32_t OnResourceMessageReceived(const IPC::Message& msg, +// HostMessageContext* context) override { // IPC_BEGIN_MESSAGE_MAP(MyMessageFilter, msg) // PPAPI_DISPATCH_HOST_RESOURCE_CALL(MyMessage, OnMyMessage) // IPC_END_MESSAGE_MAP() @@ -96,15 +95,15 @@ class PPAPI_HOST_EXPORT ResourceMessageFilter // This will dispatch the message handler on the target thread. It returns // true if the message was handled by this filter and false otherwise. - virtual bool HandleMessage(const IPC::Message& msg, - HostMessageContext* context) override; + bool HandleMessage(const IPC::Message& msg, + HostMessageContext* context) override; // This can be called from any thread. - virtual void SendReply(const ReplyMessageContext& context, - const IPC::Message& msg) override; + void SendReply(const ReplyMessageContext& context, + const IPC::Message& msg) override; protected: - virtual ~ResourceMessageFilter(); + ~ResourceMessageFilter() override; // Please see the comments of |resource_host_| for on which thread it can be // used and when it is NULL. diff --git a/chromium/ppapi/host/resource_message_filter_unittest.cc b/chromium/ppapi/host/resource_message_filter_unittest.cc index fbd8de48f95..59bbc59eeb1 100644 --- a/chromium/ppapi/host/resource_message_filter_unittest.cc +++ b/chromium/ppapi/host/resource_message_filter_unittest.cc @@ -59,9 +59,8 @@ class MyResourceHost : public ResourceHost { AddFilter(filter); } - virtual int32_t OnResourceMessageReceived( - const IPC::Message& msg, - HostMessageContext* context) override { + int32_t OnResourceMessageReceived(const IPC::Message& msg, + HostMessageContext* context) override { last_handled_msg_ = msg; if (msg.type() == msg_type_) { context->reply_msg = IPC::Message(0, reply_msg_type_, @@ -71,8 +70,8 @@ class MyResourceHost : public ResourceHost { return PP_ERROR_FAILED; } - virtual void SendReply(const ReplyMessageContext& context, - const IPC::Message& msg) override { + void SendReply(const ReplyMessageContext& context, + const IPC::Message& msg) override { last_reply_msg_ = msg; last_reply_message_loop_ = base::MessageLoop::current(); g_handler_completion.Signal(); @@ -110,14 +109,14 @@ class MyResourceFilter : public ResourceMessageFilter { const IPC::Message& last_handled_msg() const { return last_handled_msg_; } base::MessageLoop* last_message_loop() const { return last_message_loop_; } - virtual scoped_refptr<base::TaskRunner> OverrideTaskRunnerForMessage( + scoped_refptr<base::TaskRunner> OverrideTaskRunnerForMessage( const IPC::Message& msg) override { if (msg.type() == msg_type_) return message_loop_proxy_; return NULL; } - virtual int32_t OnResourceMessageReceived( + int32_t OnResourceMessageReceived( const IPC::Message& msg, HostMessageContext* context) override { last_handled_msg_ = msg; diff --git a/chromium/ppapi/lib/gl/gles2/BUILD.gn b/chromium/ppapi/lib/gl/gles2/BUILD.gn new file mode 100644 index 00000000000..81bdde4b389 --- /dev/null +++ b/chromium/ppapi/lib/gl/gles2/BUILD.gn @@ -0,0 +1,21 @@ +# Copyright 2015 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. + +config("gles2_config") { + include_dirs = [ "//ppapi/lib/gl/include" ] +} + +source_set("gles2") { + sources = [ + "gl2ext_ppapi.c", + "gl2ext_ppapi.h", + "gles2.c", + ] + + public_configs = [ ":gles2_config" ] + + public_deps = [ + "//ppapi/c", + ] +} diff --git a/chromium/ppapi/lib/gl/include/GLES2/gl2ext.h b/chromium/ppapi/lib/gl/include/GLES2/gl2ext.h index d82e8385e28..bef2b8ce815 100644 --- a/chromium/ppapi/lib/gl/include/GLES2/gl2ext.h +++ b/chromium/ppapi/lib/gl/include/GLES2/gl2ext.h @@ -1811,14 +1811,11 @@ typedef void (GL_APIENTRYP PFNGLRATELIMITOFFSCREENCONTEXTCHROMIUM) (); #ifndef GL_CHROMIUM_get_multiple #define GL_CHROMIUM_get_multiple 1 #ifdef GL_GLEXT_PROTOTYPES -#define glGetMultipleIntegervCHROMIUM GLES2_GET_FUN(GetMultipleIntegervCHROMIUM) #define glGetProgramInfoCHROMIUM GLES2_GET_FUN(GetProgramInfovCHROMIUM) #if !defined(GLES2_USE_CPP_BINDINGS) -GL_APICALL void GL_APIENTRY glGetMultipleIntegervCHROMIUM (const GLenum* pnames, GLuint count, GLint* results, GLsizeiptr size); GL_APICALL void GL_APIENTRY glGetProgramInfoCHROMIUM (GLuint program, GLsizei bufsize, GLsizei* size, void* info); #endif #else -typedef void (GL_APIENTRYP PFNGLGETMULTIPLEINTEGERVCHROMIUM) (); typedef void (GL_APIENTRYP PFNGLGETPROGRAMINFOCHROMIUM) (); #endif #endif @@ -1956,11 +1953,30 @@ typedef void (GL_APIENTRYP PFNGLTEXIMAGEIOSURFACE2DCHROMIUM) (GLenum target, GLs #endif #ifdef GL_GLEXT_PROTOTYPES #define glCopyTextureCHROMIUM GLES2_GET_FUN(CopyTextureCHROMIUM) +#define glCopySubTextureCHROMIUM GLES2_GET_FUN(CopySubTextureCHROMIUM) #if !defined(GLES2_USE_CPP_BINDINGS) -GL_APICALL void GL_APIENTRY glCopyTextureCHROMIUM (GLenum target, GLenum source_id, GLenum dest_id, GLint level); +GL_APICALL void GL_APIENTRY glCopyTextureCHROMIUM(GLenum target, + GLenum source_id, + GLenum dest_id, + GLint internalformat, + GLenum dest_type); +GL_APICALL void GL_APIENTRY glCopySubTextureCHROMIUM(GLenum target, + GLenum source_id, + GLenum dest_id, + GLint xoffset, + GLint yoffset); #endif #else -typedef void (GL_APIENTRYP PFNGLCOPYTEXTURECHROMIUM) (GLenum target, GLenum source_id, GLenum dest_id, GLint level); +typedef void(GL_APIENTRYP PFNGLCOPYTEXTURECHROMIUM)(GLenum target, + GLenum source_id, + GLenum dest_id, + GLint internalformat, + GLenum dest_type); +typedef void(GL_APIENTRYP PFNGLCOPYSUBTEXTURECHROMIUM)(GLenum target, + GLenum source_id, + GLenum dest_id, + GLint xoffset, + GLint yoffset); #endif #endif diff --git a/chromium/ppapi/nacl_irt/DEPS b/chromium/ppapi/nacl_irt/DEPS index 8e4bc776b36..a173f60f864 100644 --- a/chromium/ppapi/nacl_irt/DEPS +++ b/chromium/ppapi/nacl_irt/DEPS @@ -1,15 +1,16 @@ include_rules = [ "+components/tracing", + # Required for Mojo IRT support. + "+mojo/nacl/mojo_irt.h", + # We don't want the proxy to depend on the C++ layer, which is appropriate # for plugins only. "-ppapi/cpp", # The untrusted build references the NaCl integrated runtime (IRT). "+native_client/src/public", - "+native_client/src/shared/srpc/nacl_srpc.h", "+native_client/src/untrusted/irt/irt.h", - "+native_client/src/untrusted/irt/irt_private.h", # The IRT also needs to know the errno and sysconf enums. "+native_client/src/trusted/service_runtime/include/sys/errno.h", "+native_client/src/trusted/service_runtime/include/sys/unistd.h", diff --git a/chromium/ppapi/nacl_irt/irt_manifest.h b/chromium/ppapi/nacl_irt/irt_manifest.h index b1e09235747..5938a45e5f2 100644 --- a/chromium/ppapi/nacl_irt/irt_manifest.h +++ b/chromium/ppapi/nacl_irt/irt_manifest.h @@ -5,6 +5,9 @@ #ifndef PPAPI_NACL_IRT_IRT_MANIFEST_H_ #define PPAPI_NACL_IRT_IRT_MANIFEST_H_ +#include <map> +#include <string> + #include "ppapi/proxy/ppapi_proxy_export.h" namespace ppapi { @@ -16,6 +19,11 @@ namespace ppapi { // on failure. See also irt_open_resource()'s comment. PPAPI_PROXY_EXPORT int IrtOpenResource(const char* file, int* fd); +#if !defined(OS_NACL_SFI) +PPAPI_PROXY_EXPORT void RegisterPreopenedDescriptorsNonSfi( + std::map<std::string, int>* key_fd_map); +#endif + } // namespace ppapi #endif // PPAPI_NACL_IRT_IRT_MANIFEST_H_ diff --git a/chromium/ppapi/nacl_irt/irt_ppapi.cc b/chromium/ppapi/nacl_irt/irt_ppapi.cc index ce17f8a1ef5..a9c13eb8907 100644 --- a/chromium/ppapi/nacl_irt/irt_ppapi.cc +++ b/chromium/ppapi/nacl_irt/irt_ppapi.cc @@ -8,7 +8,6 @@ #include "native_client/src/public/irt_core.h" #include "native_client/src/trusted/service_runtime/include/sys/unistd.h" #include "native_client/src/untrusted/irt/irt.h" -#include "native_client/src/untrusted/irt/irt_private.h" #include "ppapi/nacl_irt/irt_manifest.h" #include "ppapi/nacl_irt/irt_ppapi.h" #include "ppapi/nacl_irt/plugin_main.h" @@ -18,14 +17,6 @@ static struct PP_StartFunctions g_pp_functions; int irt_ppapi_start(const struct PP_StartFunctions* funcs) { -#if !defined(OS_NACL_NONSFI) - // Disable NaCl's open_resource() interface on this thread. - // TODO(hidehiko): This flag is no longer used because, even in SFI mode, - // we switched from SRPC to Chrome IPC for open_resource() implementation. - // Remove this flag. - g_is_main_thread = 1; -#endif - g_pp_functions = *funcs; return PpapiPluginMain(); } @@ -99,5 +90,6 @@ size_t chrome_irt_query(const char* interface_ident, sizeof(irt_interfaces)); if (result != 0) return result; + return nacl_irt_query_core(interface_ident, table, tablesize); } diff --git a/chromium/ppapi/nacl_irt/manifest_service.cc b/chromium/ppapi/nacl_irt/manifest_service.cc index c9f1404e444..a97c5d42d02 100644 --- a/chromium/ppapi/nacl_irt/manifest_service.cc +++ b/chromium/ppapi/nacl_irt/manifest_service.cc @@ -13,9 +13,13 @@ #include "ppapi/nacl_irt/plugin_startup.h" #include "ppapi/proxy/ppapi_messages.h" -namespace ppapi { +#if !defined(OS_NACL_SFI) +#include <pthread.h> +#include <map> +#include <string> +#endif -const char kFilePrefix[] = "files/"; +namespace ppapi { // IPC channel is asynchronously set up. So, the NaCl process may try to // send a OpenResource message to the host before the connection is @@ -29,7 +33,7 @@ class ManifestMessageFilter : public IPC::SyncMessageFilter { true /* manual_reset */, false /* initially_signaled */) { } - virtual bool Send(IPC::Message* message) override { + bool Send(IPC::Message* message) override { // Wait until set up is actually done. connected_event_.Wait(); return SyncMessageFilter::Send(message); @@ -37,19 +41,19 @@ class ManifestMessageFilter : public IPC::SyncMessageFilter { // When set up is done, OnFilterAdded is called on IO thread. Unblocks the // Send(). - virtual void OnFilterAdded(IPC::Sender* sender) override { + void OnFilterAdded(IPC::Sender* sender) override { SyncMessageFilter::OnFilterAdded(sender); connected_event_.Signal(); } // If an error is found, unblocks the Send(), too, to return an error. - virtual void OnChannelError() override { + void OnChannelError() override { SyncMessageFilter::OnChannelError(); connected_event_.Signal(); } // Similar to OnChannelError, unblocks the Send() on the channel closing. - virtual void OnChannelClosing() override { + void OnChannelClosing() override { SyncMessageFilter::OnChannelClosing(); connected_event_.Signal(); } @@ -92,10 +96,10 @@ bool ManifestService::OpenResource(const char* file, int* fd) { // File tokens are ignored here, but needed when the message is processed // inside NaClIPCAdapter. - uint64_t file_token_lo; - uint64_t file_token_hi; + uint64_t file_token_lo = 0; + uint64_t file_token_hi = 0; if (!filter_->Send(new PpapiHostMsg_OpenResource( - std::string(kFilePrefix) + file, + file, &ipc_fd, &file_token_lo, &file_token_hi))) { @@ -104,16 +108,11 @@ bool ManifestService::OpenResource(const char* file, int* fd) { return false; } -#if defined(OS_NACL_SFI) // File tokens are used internally by NaClIPCAdapter and should have // been cleared from the message when it is received here. - // Note that, on Non-SFI NaCl, the IPC channel is directly connected to the - // renderer process, so NaClIPCAdapter does not work. It means, - // file_token_{lo,hi} fields may be properly filled, although it is just - // ignored here. + // These tokens should never be set for Non-SFI mode. CHECK(file_token_lo == 0); CHECK(file_token_hi == 0); -#endif // Copy the file if we received a valid file descriptor. Otherwise, if we got // a reply, the file doesn't exist, so provide an fd of -1. @@ -125,11 +124,43 @@ bool ManifestService::OpenResource(const char* file, int* fd) { return true; } +#if !defined(OS_NACL_SFI) +namespace { + +pthread_mutex_t g_mu = PTHREAD_MUTEX_INITIALIZER; +std::map<std::string, int>* g_prefetched_fds; + +} // namespace + +void RegisterPreopenedDescriptorsNonSfi( + std::map<std::string, int>* key_fd_map) { + pthread_mutex_lock(&g_mu); + DCHECK(!g_prefetched_fds); + g_prefetched_fds = key_fd_map; + pthread_mutex_unlock(&g_mu); +} +#endif + int IrtOpenResource(const char* file, int* fd) { // Remove leading '/' character. if (file[0] == '/') ++file; +#if !defined(OS_NACL_SFI) + // Fast path for prefetched FDs. + pthread_mutex_lock(&g_mu); + if (g_prefetched_fds) { + std::map<std::string, int>::iterator it = g_prefetched_fds->find(file); + if (it != g_prefetched_fds->end()) { + *fd = it->second; + g_prefetched_fds->erase(it); + pthread_mutex_unlock(&g_mu); + return 0; + } + } + pthread_mutex_unlock(&g_mu); +#endif + ManifestService* manifest_service = GetManifestService(); if (manifest_service == NULL || !manifest_service->OpenResource(file, fd)) { diff --git a/chromium/ppapi/nacl_irt/plugin_main.cc b/chromium/ppapi/nacl_irt/plugin_main.cc index 2b5e3b1a196..eb4f300c231 100644 --- a/chromium/ppapi/nacl_irt/plugin_main.cc +++ b/chromium/ppapi/nacl_irt/plugin_main.cc @@ -18,10 +18,6 @@ #include "ppapi/proxy/plugin_globals.h" #include "ppapi/shared_impl/ppb_audio_shared.h" -#if defined(__native_client__) -#include "native_client/src/shared/srpc/nacl_srpc.h" -#endif - void PpapiPluginRegisterThreadCreator( const struct PP_ThreadFunctions* thread_functions) { // Initialize all classes that need to create threads that call back into @@ -31,21 +27,9 @@ void PpapiPluginRegisterThreadCreator( int PpapiPluginMain() { base::MessageLoop loop; - ppapi::proxy::PluginGlobals plugin_globals; - -#if defined(OS_NACL_SFI) - // Currently on non-SFI mode, we don't use SRPC server on plugin. - // TODO(hidehiko): Make sure this SRPC is actually used on SFI-mode. - - // Start up the SRPC server on another thread. Otherwise, when it blocks - // on an RPC, the PPAPI proxy will hang. Do this before we initialize the - // module and start the PPAPI proxy so that the NaCl plugin can continue - // loading the app. - static struct NaClSrpcHandlerDesc srpc_methods[] = { { NULL, NULL } }; - if (!NaClSrpcAcceptClientOnThread(srpc_methods)) { - return 1; - } -#endif + ppapi::proxy::PluginGlobals plugin_globals( + scoped_refptr<base::TaskRunner>( + ppapi::GetIOThread()->message_loop_proxy())); ppapi::PpapiDispatcher ppapi_dispatcher( ppapi::GetIOThread()->message_loop_proxy(), diff --git a/chromium/ppapi/nacl_irt/ppapi_dispatcher.cc b/chromium/ppapi/nacl_irt/ppapi_dispatcher.cc index 0600fc19a27..343c71c2655 100644 --- a/chromium/ppapi/nacl_irt/ppapi_dispatcher.cc +++ b/chromium/ppapi/nacl_irt/ppapi_dispatcher.cc @@ -60,13 +60,18 @@ PpapiDispatcher::PpapiDispatcher(scoped_refptr<base::MessageLoopProxy> io_loop, IPC::ChannelHandle channel_handle( "NaCl IPC", base::FileDescriptor(browser_ipc_fd, false)); + proxy::PluginGlobals* globals = proxy::PluginGlobals::Get(); // Delay initializing the SyncChannel until after we add filters. This // ensures that the filters won't miss any messages received by // the channel. channel_ = IPC::SyncChannel::Create(this, GetIPCMessageLoop(), GetShutdownEvent()); - channel_->AddFilter(new proxy::PluginMessageFilter( - NULL, proxy::PluginGlobals::Get()->resource_reply_thread_registrar())); + scoped_refptr<ppapi::proxy::PluginMessageFilter> plugin_filter( + new ppapi::proxy::PluginMessageFilter( + NULL, globals->resource_reply_thread_registrar())); + channel_->AddFilter(plugin_filter.get()); + globals->RegisterResourceMessageFilters(plugin_filter.get()); + channel_->AddFilter( new tracing::ChildTraceMessageFilter(message_loop_.get())); channel_->Init(channel_handle, IPC::Channel::MODE_SERVER, true); @@ -165,10 +170,10 @@ void PpapiDispatcher::OnMsgInitializeNaClDispatcher( } command_line_and_logging_initialized = true; - CommandLine::Init(0, NULL); + base::CommandLine::Init(0, NULL); for (size_t i = 0; i < args.switch_names.size(); ++i) { DCHECK(i < args.switch_values.size()); - CommandLine::ForCurrentProcess()->AppendSwitchASCII( + base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( args.switch_names[i], args.switch_values[i]); } logging::LoggingSettings settings; @@ -213,7 +218,7 @@ void PpapiDispatcher::OnPluginDispatcherMessageReceived( // The first parameter should be a plugin dispatcher ID. PickleIterator iter(msg); uint32 id = 0; - if (!msg.ReadUInt32(&iter, &id)) { + if (!iter.ReadUInt32(&id)) { NOTREACHED(); return; } diff --git a/chromium/ppapi/nacl_irt/ppapi_dispatcher.h b/chromium/ppapi/nacl_irt/ppapi_dispatcher.h index 0b436067dde..c03b8b0f01f 100644 --- a/chromium/ppapi/nacl_irt/ppapi_dispatcher.h +++ b/chromium/ppapi/nacl_irt/ppapi_dispatcher.h @@ -52,34 +52,32 @@ class PpapiDispatcher : public proxy::PluginDispatcher::PluginDelegate, int renderer_ipc_fd); // PluginDispatcher::PluginDelegate implementation. - virtual base::MessageLoopProxy* GetIPCMessageLoop() override; - virtual base::WaitableEvent* GetShutdownEvent() override; - virtual IPC::PlatformFileForTransit ShareHandleWithRemote( + base::MessageLoopProxy* GetIPCMessageLoop() override; + base::WaitableEvent* GetShutdownEvent() override; + IPC::PlatformFileForTransit ShareHandleWithRemote( base::PlatformFile handle, base::ProcessId peer_pid, bool should_close_source) override; - virtual std::set<PP_Instance>* GetGloballySeenInstanceIDSet() override; - virtual uint32 Register( - proxy::PluginDispatcher* plugin_dispatcher) override; - virtual void Unregister(uint32 plugin_dispatcher_id) override; + std::set<PP_Instance>* GetGloballySeenInstanceIDSet() override; + uint32 Register(proxy::PluginDispatcher* plugin_dispatcher) override; + void Unregister(uint32 plugin_dispatcher_id) override; // PluginProxyDelegate implementation. - virtual IPC::Sender* GetBrowserSender() override; - virtual std::string GetUILanguage() override; - virtual void PreCacheFont(const void* logfontw) override; - virtual void SetActiveURL(const std::string& url) override; - virtual PP_Resource CreateBrowserFont( - proxy::Connection connection, - PP_Instance instance, - const PP_BrowserFont_Trusted_Description& desc, - const Preferences& prefs) override; + IPC::Sender* GetBrowserSender() override; + std::string GetUILanguage() override; + void PreCacheFont(const void* logfontw) override; + void SetActiveURL(const std::string& url) override; + PP_Resource CreateBrowserFont(proxy::Connection connection, + PP_Instance instance, + const PP_BrowserFont_Trusted_Description& desc, + const Preferences& prefs) override; // IPC::Listener implementation. - virtual bool OnMessageReceived(const IPC::Message& message) override; - virtual void OnChannelError() override; + bool OnMessageReceived(const IPC::Message& message) override; + void OnChannelError() override; // IPC::Sender implementation - virtual bool Send(IPC::Message* message) override; + bool Send(IPC::Message* message) override; private: void OnMsgInitializeNaClDispatcher(const PpapiNaClPluginArgs& args); diff --git a/chromium/ppapi/nacl_irt/public/irt_nonsfi.h b/chromium/ppapi/nacl_irt/public/irt_nonsfi.h deleted file mode 100644 index acc0eaccf90..00000000000 --- a/chromium/ppapi/nacl_irt/public/irt_nonsfi.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2014 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_NACL_IRT_PUBLIC_IRT_NONSFI_H_ -#define PPAPI_NACL_IRT_PUBLIC_IRT_NONSFI_H_ - -#include <stddef.h> - -/* - * This interface is only available on ARM, only for Non-SFI. - */ -#define NACL_IRT_ICACHE_v0_1 "nacl-irt-icache-0.1" -struct nacl_irt_icache { - /* - * clear_cache() makes instruction cache and data cache for the address - * range from |addr| to |(intptr_t)addr + size| (exclusive) coherent. - */ - int (*clear_cache)(void* addr, size_t size); -}; - -#endif // PPAPI_NACL_IRT_PUBLIC_IRT_NONSFI_H_ diff --git a/chromium/ppapi/native_client/BUILD.gn b/chromium/ppapi/native_client/BUILD.gn new file mode 100644 index 00000000000..488f44f3475 --- /dev/null +++ b/chromium/ppapi/native_client/BUILD.gn @@ -0,0 +1,37 @@ +# Copyright 2015 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. + +import("//build/config/features.gni") + +if (enable_nacl && enable_nacl_untrusted) { + group("ppapi_lib") { + deps = [ + "//native_client/src/untrusted/pthread", + "//ppapi/native_client/src/untrusted/irt_stub:ppapi_stub_lib", + ] + } + + executable("nacl_irt") { + deps = [ + "//base", + "//components/tracing", + "//gpu/command_buffer/client", + "//gpu/command_buffer/common", + "//gpu/command_buffer/client:gles2_implementation", + "//gpu/ipc", + "//ipc", + "//media:shared_memory_support", + "//native_client/src/untrusted/irt:irt_core_lib", + "//native_client/src/shared/srpc", + "//native_client/src/shared/platform", + "//native_client/src/tools/tls_edit($host_toolchain)", + "//native_client/src/untrusted/nacl:imc_syscalls", + "//native_client/src/shared/gio", + "//ppapi/native_client/src/untrusted/pnacl_irt_shim:irt", + "//ppapi/proxy", + "//ppapi/proxy:ipc", + "//ppapi/shared_impl", + ] + } +} diff --git a/chromium/ppapi/native_client/DEPS b/chromium/ppapi/native_client/DEPS index 60de970472d..64d0e992b3c 100644 --- a/chromium/ppapi/native_client/DEPS +++ b/chromium/ppapi/native_client/DEPS @@ -1,8 +1,5 @@ include_rules = [ "+native_client/src/include", - "+native_client/src/public", "+native_client/src/shared/platform", - "+native_client/src/shared/srpc", - "+native_client/src/trusted/weak_ref", "+native_client/src/untrusted", ] diff --git a/chromium/ppapi/native_client/chrome_main.scons b/chromium/ppapi/native_client/chrome_main.scons index 2e75425731c..b6154c6e590 100644 --- a/chromium/ppapi/native_client/chrome_main.scons +++ b/chromium/ppapi/native_client/chrome_main.scons @@ -44,15 +44,11 @@ ppapi_scons_files['irt_variant_test_scons_files'] = [ # 'inbrowser_test_runner' must be in the irt_variant list # otherwise it will run no tests. 'tests/nacl_browser/inbrowser_test_runner/nacl.scons', - # Disabled by Brad Chen 4 Sep to try to green Chromium - # nacl_integration tests - #'tests/nacl_browser/fault_injection/nacl.scons', ] ppapi_scons_files['untrusted_scons_files'] = [ 'src/shared/ppapi/nacl.scons', 'src/untrusted/irt_stub/nacl.scons', - 'src/untrusted/nacl_ppapi_util/nacl.scons', ] @@ -106,29 +102,6 @@ def ChromeBinary(env): pre_base_env.AddMethod(ChromeBinary) -def GetPPAPIPluginPath(env, allow_64bit_redirect=True): - if 'force_ppapi_plugin' in ARGUMENTS: - return env.SConstructAbsPath(ARGUMENTS['force_ppapi_plugin']) - if env.Bit('mac'): - fn = env.File('${STAGING_DIR}/ppNaClPlugin') - else: - fn = env.File('${STAGING_DIR}/${SHLIBPREFIX}ppNaClPlugin${SHLIBSUFFIX}') - if allow_64bit_redirect and env.Bit('target_x86_64'): - # On 64-bit Windows and on Mac, we need the 32-bit plugin because - # the browser is 32-bit. - # Unfortunately it is tricky to build the 32-bit plugin (and all the - # libraries it needs) in a 64-bit build... so we'll assume it has already - # been built in a previous invocation. - # TODO(ncbray) better 32/64 builds. - if env.Bit('windows'): - fn = env.subst(fn).abspath.replace('-win-x86-64', '-win-x86-32') - elif env.Bit('mac'): - fn = env.subst(fn).abspath.replace('-mac-x86-64', '-mac-x86-32') - return fn - -pre_base_env.AddMethod(GetPPAPIPluginPath) - - # runnable-ld.so log has following format: # lib_name => path_to_lib (0x....address) def ParseLibInfoInRunnableLdLog(line): @@ -535,7 +508,7 @@ pre_base_env.AddMethod(PPAPIBrowserTester) # Disabled for ARM and MIPS because Chrome binaries for ARM and MIPS are not # available. def PPAPIBrowserTesterIsBroken(env): - return env.Bit('target_arm') or env.Bit('target_mips32') + return env.Bit('build_arm') or env.Bit('build_mips32') pre_base_env.AddMethod(PPAPIBrowserTesterIsBroken) diff --git a/chromium/ppapi/native_client/native_client.gyp b/chromium/ppapi/native_client/native_client.gyp index 91f081be639..41b74f796d4 100644 --- a/chromium/ppapi/native_client/native_client.gyp +++ b/chromium/ppapi/native_client/native_client.gyp @@ -23,7 +23,6 @@ { 'destination': '>(tc_include_dir_newlib)/nacl', 'files': [ - 'src/trusted/weak_ref/call_on_main_thread.h', 'src/shared/ppapi_proxy/ppruntime.h', ], }, @@ -41,7 +40,6 @@ { 'destination': '>(tc_include_dir_glibc)/include/nacl', 'files': [ - 'src/trusted/weak_ref/call_on_main_thread.h', 'src/shared/ppapi_proxy/ppruntime.h', ], }, @@ -129,6 +127,7 @@ '-llatency_info_nacl', '-lpnacl_irt_shim_for_irt', '-lppapi_proxy_nacl', + '-lmojo_irt', '-lppapi_ipc_nacl', '-lppapi_shared_nacl', '-lgles2_implementation_nacl', @@ -169,6 +168,7 @@ ['target_arch=="ia32" or target_arch=="x64"', { 'extra_deps_newlib64': [ '>(tc_lib_dir_irt64)/libppapi_proxy_nacl.a', + '>(tc_lib_dir_irt64)/libmojo_irt.a', '>(tc_lib_dir_irt64)/libppapi_ipc_nacl.a', '>(tc_lib_dir_irt64)/libppapi_shared_nacl.a', '>(tc_lib_dir_irt64)/libgles2_implementation_nacl.a', @@ -190,6 +190,7 @@ ], 'extra_deps_newlib32': [ '>(tc_lib_dir_irt32)/libppapi_proxy_nacl.a', + '>(tc_lib_dir_irt32)/libmojo_irt.a', '>(tc_lib_dir_irt32)/libppapi_ipc_nacl.a', '>(tc_lib_dir_irt32)/libppapi_shared_nacl.a', '>(tc_lib_dir_irt32)/libgles2_implementation_nacl.a', @@ -213,6 +214,7 @@ ['target_arch=="arm"', { 'extra_deps_arm': [ '>(tc_lib_dir_irt_arm)/libppapi_proxy_nacl.a', + '>(tc_lib_dir_irt_arm)/libmojo_irt.a', '>(tc_lib_dir_irt_arm)/libppapi_ipc_nacl.a', '>(tc_lib_dir_irt_arm)/libppapi_shared_nacl.a', '>(tc_lib_dir_irt_arm)/libgles2_implementation_nacl.a', @@ -236,6 +238,7 @@ ['target_arch=="mipsel"', { 'extra_deps_mips': [ '>(tc_lib_dir_irt_mips)/libppapi_proxy_nacl.a', + '>(tc_lib_dir_irt_mips)/libmojo_irt.a', '>(tc_lib_dir_irt_mips)/libppapi_ipc_nacl.a', '>(tc_lib_dir_irt_mips)/libppapi_shared_nacl.a', '>(tc_lib_dir_irt_mips)/libgles2_implementation_nacl.a', @@ -273,6 +276,7 @@ '../../ipc/ipc_nacl.gyp:ipc_nacl', '../../base/base_nacl.gyp:base_nacl', '../../media/media_nacl.gyp:shared_memory_support_nacl', + '../../mojo/mojo_nacl_untrusted.gyp:libmojo_irt', '../../native_client/src/untrusted/irt/irt.gyp:irt_browser_lib', '../../native_client/src/shared/srpc/srpc.gyp:srpc_lib', '../../native_client/src/shared/platform/platform.gyp:platform_lib', diff --git a/chromium/ppapi/native_client/src/trusted/plugin/DEPS b/chromium/ppapi/native_client/src/trusted/plugin/DEPS deleted file mode 100644 index 34d9609d757..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/DEPS +++ /dev/null @@ -1,8 +0,0 @@ -include_rules = [ - "+native_client/src/shared/imc/nacl_imc_c.h", - "+native_client/src/trusted/desc", - "+native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h", - "+native_client/src/trusted/reverse_service/reverse_service.h", - "+native_client/src/trusted/service_runtime/include", - "+native_client/src/trusted/service_runtime/nacl_error_code.h", -] diff --git a/chromium/ppapi/native_client/src/trusted/plugin/module_ppapi.cc b/chromium/ppapi/native_client/src/trusted/plugin/module_ppapi.cc deleted file mode 100644 index bcdaf7d47e0..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/module_ppapi.cc +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "native_client/src/shared/imc/nacl_imc_c.h" -#include "native_client/src/shared/platform/nacl_secure_random.h" -#include "native_client/src/shared/platform/nacl_time.h" -#include "native_client/src/trusted/desc/nrd_all_modules.h" - -#include "ppapi/native_client/src/trusted/plugin/module_ppapi.h" -#include "ppapi/native_client/src/trusted/plugin/plugin.h" -#include "ppapi/native_client/src/trusted/plugin/utility.h" - -namespace plugin { - -ModulePpapi::ModulePpapi() : pp::Module(), - init_was_successful_(false), - private_interface_(NULL) { - MODULE_PRINTF(("ModulePpapi::ModulePpapi (this=%p)\n", - static_cast<void*>(this))); -} - -ModulePpapi::~ModulePpapi() { - if (init_was_successful_) { - NaClSrpcModuleFini(); - NaClNrdAllModulesFini(); - } - MODULE_PRINTF(("ModulePpapi::~ModulePpapi (this=%p)\n", - static_cast<void*>(this))); -} - -bool ModulePpapi::Init() { - // Ask the browser for an interface which provides missing functions - private_interface_ = reinterpret_cast<const PPB_NaCl_Private*>( - GetBrowserInterface(PPB_NACL_PRIVATE_INTERFACE)); - - if (NULL == private_interface_) { - MODULE_PRINTF(("ModulePpapi::Init failed: " - "GetBrowserInterface returned NULL\n")); - return false; - } - SetNaClInterface(private_interface_); - -#if NACL_LINUX || NACL_OSX - // Note that currently we do not need random numbers inside the - // NaCl trusted plugin on Unix, but NaClSecureRngModuleInit() is - // strict and will raise a fatal error unless we provide it with a - // /dev/urandom FD beforehand. - NaClSecureRngModuleSetUrandomFd(dup(private_interface_->UrandomFD())); -#endif - - // In the plugin, we don't need high resolution time of day. - NaClAllowLowResolutionTimeOfDay(); - NaClNrdAllModulesInit(); - NaClSrpcModuleInit(); - -#if NACL_WINDOWS - NaClSetBrokerDuplicateHandleFunc(private_interface_->BrokerDuplicateHandle); -#endif - - init_was_successful_ = true; - return true; -} - -pp::Instance* ModulePpapi::CreateInstance(PP_Instance pp_instance) { - MODULE_PRINTF(("ModulePpapi::CreateInstance (pp_instance=%" NACL_PRId32 - ")\n", - pp_instance)); - Plugin* plugin = new Plugin(pp_instance); - MODULE_PRINTF(("ModulePpapi::CreateInstance (return %p)\n", - static_cast<void* >(plugin))); - return plugin; -} - -} // namespace plugin - - -namespace pp { - -Module* CreateModule() { - MODULE_PRINTF(("CreateModule ()\n")); - return new plugin::ModulePpapi(); -} - -} // namespace pp diff --git a/chromium/ppapi/native_client/src/trusted/plugin/module_ppapi.h b/chromium/ppapi/native_client/src/trusted/plugin/module_ppapi.h deleted file mode 100644 index ee7bd1980ee..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/module_ppapi.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2013 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "ppapi/c/private/ppb_nacl_private.h" -#include "ppapi/cpp/module.h" - -namespace plugin { - -class ModulePpapi : public pp::Module { - public: - ModulePpapi(); - - virtual ~ModulePpapi(); - - virtual bool Init(); - - virtual pp::Instance* CreateInstance(PP_Instance pp_instance); - - private: - bool init_was_successful_; - const PPB_NaCl_Private* private_interface_; -}; - -} // namespace plugin - - -namespace pp { - -Module* CreateModule(); - -} // namespace pp diff --git a/chromium/ppapi/native_client/src/trusted/plugin/nacl_subprocess.cc b/chromium/ppapi/native_client/src/trusted/plugin/nacl_subprocess.cc deleted file mode 100644 index c9d68d7a0ca..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/nacl_subprocess.cc +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/native_client/src/trusted/plugin/nacl_subprocess.h" - -#include <stdarg.h> - -#include "native_client/src/shared/srpc/nacl_srpc.h" -#include "ppapi/native_client/src/trusted/plugin/plugin_error.h" -#include "ppapi/native_client/src/trusted/plugin/srpc_params.h" - -namespace plugin { - -std::string NaClSubprocess::detailed_description() const { - std::stringstream ss; - ss << description() - << "={ this=" << static_cast<const void*>(this) - << ", srpc_client=" << static_cast<void*>(srpc_client_.get()) - << ", service_runtime=" << static_cast<void*>(service_runtime_.get()) - << " }"; - return ss.str(); -} - -// Shutdown the socket connection and service runtime, in that order. -void NaClSubprocess::Shutdown() { - srpc_client_.reset(NULL); - if (service_runtime_.get() != NULL) { - service_runtime_->Shutdown(); - service_runtime_.reset(NULL); - } -} - -NaClSubprocess::~NaClSubprocess() { - Shutdown(); -} - -bool NaClSubprocess::StartSrpcServices() { - srpc_client_.reset(service_runtime_->SetupAppChannel()); - return NULL != srpc_client_.get(); -} - -bool NaClSubprocess::InvokeSrpcMethod(const std::string& method_name, - const std::string& input_signature, - SrpcParams* params, - ...) { - va_list vl; - va_start(vl, params); - bool result = VInvokeSrpcMethod(method_name, input_signature, params, vl); - va_end(vl); - return result; -} - -bool NaClSubprocess::VInvokeSrpcMethod(const std::string& method_name, - const std::string& input_signature, - SrpcParams* params, - va_list vl) { - if (NULL == srpc_client_.get()) { - PLUGIN_PRINTF(("VInvokeSrpcMethod (no srpc_client_)\n")); - return false; - } - if (!srpc_client_->HasMethod(method_name)) { - PLUGIN_PRINTF(("VInvokeSrpcMethod (no %s method found)\n", - method_name.c_str())); - return false; - } - if (!srpc_client_->InitParams(method_name, params)) { - PLUGIN_PRINTF(("VInvokeSrpcMethod (InitParams failed)\n")); - return false; - } - // Marshall inputs. - for (size_t i = 0; i < input_signature.length(); ++i) { - char c = input_signature[i]; - // Only handle the limited number of SRPC types used for PNaCl. - // Add more as needed. - switch (c) { - default: - PLUGIN_PRINTF(("PnaclSrpcLib::InvokeSrpcMethod unhandled type: %c\n", - c)); - return false; - case NACL_SRPC_ARG_TYPE_BOOL: { - int input = va_arg(vl, int); - params->ins()[i]->u.bval = input; - break; - } - case NACL_SRPC_ARG_TYPE_DOUBLE: { - double input = va_arg(vl, double); - params->ins()[i]->u.dval = input; - break; - } - case NACL_SRPC_ARG_TYPE_CHAR_ARRAY: { - // SrpcParam's destructor *should* free the allocated array - const char* orig_arr = va_arg(vl, const char*); - size_t len = va_arg(vl, size_t); - char* input = (char *)malloc(len); - if (!input) { - PLUGIN_PRINTF(("VInvokeSrpcMethod (allocation failure)\n")); - return false; - } - memcpy(input, orig_arr, len); - params->ins()[i]->arrays.carr = input; - params->ins()[i]->u.count = static_cast<nacl_abi_size_t>(len); - break; - } - case NACL_SRPC_ARG_TYPE_HANDLE: { - NaClSrpcImcDescType input = va_arg(vl, NaClSrpcImcDescType); - params->ins()[i]->u.hval = input; - break; - } - case NACL_SRPC_ARG_TYPE_INT: { - int32_t input = va_arg(vl, int32_t); - params->ins()[i]->u.ival = input; - break; - } - case NACL_SRPC_ARG_TYPE_LONG: { - int64_t input = va_arg(vl, int64_t); - params->ins()[i]->u.lval = input; - break; - } - case NACL_SRPC_ARG_TYPE_STRING: { - // SrpcParam's destructor *should* free the dup'ed string. - const char* orig_str = va_arg(vl, const char*); - char* input = strdup(orig_str); - if (!input) { - PLUGIN_PRINTF(("VInvokeSrpcMethod (allocation failure)\n")); - return false; - } - params->ins()[i]->arrays.str = input; - break; - } - } - } - return srpc_client_->Invoke(method_name, params); -} - -} // namespace plugin diff --git a/chromium/ppapi/native_client/src/trusted/plugin/nacl_subprocess.h b/chromium/ppapi/native_client/src/trusted/plugin/nacl_subprocess.h deleted file mode 100644 index 0c231c61c9d..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/nacl_subprocess.h +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Instances of NaCl modules spun up within the plugin as a subprocess. -// This may represent the "main" nacl module, or it may represent helpers -// that perform various tasks within the plugin, for example, -// a NaCl module for a compiler could be loaded to translate LLVM bitcode -// into native code. - -#ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_NACL_SUBPROCESS_H_ -#define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_NACL_SUBPROCESS_H_ - -#include <stdarg.h> - -#include "native_client/src/include/nacl_macros.h" -#include "native_client/src/include/portability.h" - -#include "ppapi/native_client/src/trusted/plugin/service_runtime.h" -#include "ppapi/native_client/src/trusted/plugin/srpc_client.h" - -namespace plugin { - -class Plugin; -class ServiceRuntime; -class SrpcParams; - - -// A class representing an instance of a NaCl module, loaded by the plugin. -class NaClSubprocess { - public: - NaClSubprocess(const std::string& description, - ServiceRuntime* service_runtime, - SrpcClient* srpc_client) - : description_(description), - service_runtime_(service_runtime), - srpc_client_(srpc_client) { - } - virtual ~NaClSubprocess(); - - ServiceRuntime* service_runtime() const { return service_runtime_.get(); } - void set_service_runtime(ServiceRuntime* service_runtime) { - service_runtime_.reset(service_runtime); - } - - // The socket used for communicating w/ the NaCl module. - SrpcClient* srpc_client() const { return srpc_client_.get(); } - - // A basic description of the subprocess. - std::string description() const { return description_; } - - // A detailed description of the subprocess that may contain addresses. - // Only use for debugging, but do not expose this to untrusted webapps. - std::string detailed_description() const; - - // Start up interfaces. - bool StartSrpcServices(); - - // Invoke an Srpc Method. |out_params| must be allocated and cleaned up - // outside of this function, but it will be initialized by this function, and - // on success any out-params (if any) will be placed in |out_params|. - // Input types must be listed in |input_signature|, with the actual - // arguments passed in as var-args. Returns |true| on success. - bool InvokeSrpcMethod(const std::string& method_name, - const std::string& input_signature, - SrpcParams* out_params, - ...); - - // Fully shut down the subprocess. - void Shutdown(); - - private: - NACL_DISALLOW_COPY_AND_ASSIGN(NaClSubprocess); - - bool VInvokeSrpcMethod(const std::string& method_name, - const std::string& signature, - SrpcParams* params, - va_list vl); - - std::string description_; - - // The service runtime representing the NaCl module instance. - nacl::scoped_ptr<ServiceRuntime> service_runtime_; - // Ownership of srpc_client taken from the service runtime. - nacl::scoped_ptr<SrpcClient> srpc_client_; -}; - -} // namespace plugin - -#endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_NACL_SUBPROCESS_H_ diff --git a/chromium/ppapi/native_client/src/trusted/plugin/plugin.cc b/chromium/ppapi/native_client/src/trusted/plugin/plugin.cc deleted file mode 100644 index 518751c6981..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/plugin.cc +++ /dev/null @@ -1,415 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/native_client/src/trusted/plugin/plugin.h" - -#include <sys/stat.h> -#include <sys/types.h> - -#include <string> - -#include "native_client/src/include/nacl_base.h" -#include "native_client/src/include/nacl_macros.h" -#include "native_client/src/include/nacl_scoped_ptr.h" -#include "native_client/src/include/portability.h" -#include "native_client/src/include/portability_io.h" -#include "native_client/src/shared/platform/nacl_check.h" -#include "native_client/src/trusted/desc/nacl_desc_wrapper.h" - -#include "ppapi/c/pp_errors.h" -#include "ppapi/c/private/ppb_nacl_private.h" -#include "ppapi/cpp/module.h" - -#include "ppapi/native_client/src/trusted/plugin/nacl_subprocess.h" -#include "ppapi/native_client/src/trusted/plugin/plugin_error.h" -#include "ppapi/native_client/src/trusted/plugin/service_runtime.h" -#include "ppapi/native_client/src/trusted/plugin/utility.h" - -namespace plugin { - -namespace { - -// Up to 20 seconds -const int64_t kTimeSmallMin = 1; // in ms -const int64_t kTimeSmallMax = 20000; // in ms -const uint32_t kTimeSmallBuckets = 100; - -} // namespace - -void Plugin::ShutDownSubprocesses() { - PLUGIN_PRINTF(("Plugin::ShutDownSubprocesses (this=%p)\n", - static_cast<void*>(this))); - - // Shut down service runtime. This must be done before all other calls so - // they don't block forever when waiting for the upcall thread to exit. - main_subprocess_.Shutdown(); - - PLUGIN_PRINTF(("Plugin::ShutDownSubprocess (this=%p, return)\n", - static_cast<void*>(this))); -} - -void Plugin::HistogramTimeSmall(const std::string& name, - int64_t ms) { - if (ms < 0) return; - uma_interface_.HistogramCustomTimes(name, - ms, - kTimeSmallMin, kTimeSmallMax, - kTimeSmallBuckets); -} - -bool Plugin::LoadHelperNaClModuleInternal(NaClSubprocess* subprocess, - const SelLdrStartParams& params) { - CHECK(!pp::Module::Get()->core()->IsMainThread()); - ServiceRuntime* service_runtime = - new ServiceRuntime(this, - pp_instance(), - false, // No main_service_runtime. - false, // No non-SFI mode (i.e. in SFI-mode). - pp::BlockUntilComplete()); - subprocess->set_service_runtime(service_runtime); - - // Now start the SelLdr instance. This must be created on the main thread. - bool service_runtime_started = false; - pp::CompletionCallback sel_ldr_callback = - callback_factory_.NewCallback(&Plugin::SignalStartSelLdrDone, - &service_runtime_started, - service_runtime); - pp::CompletionCallback callback = - callback_factory_.NewCallback(&Plugin::StartSelLdrOnMainThread, - service_runtime, params, - sel_ldr_callback); - pp::Module::Get()->core()->CallOnMainThread(0, callback, 0); - if (!service_runtime->WaitForSelLdrStart()) { - PLUGIN_PRINTF(("Plugin::LoadHelperNaClModule " - "WaitForSelLdrStart timed out!\n")); - return false; - } - PLUGIN_PRINTF(("Plugin::LoadHelperNaClModule (service_runtime_started=%d)\n", - service_runtime_started)); - if (!service_runtime_started) - return false; - - // Now actually start the nexe. - // - // We can't use pp::BlockUntilComplete() inside an in-process plugin, so we - // have to roll our own blocking logic, similar to WaitForSelLdrStart() - // above, except without timeout logic. - pp::Module::Get()->core()->CallOnMainThread( - 0, - callback_factory_.NewCallback(&Plugin::StartNexe, service_runtime)); - return service_runtime->WaitForNexeStart(); -} - -void Plugin::StartSelLdrOnMainThread(int32_t pp_error, - ServiceRuntime* service_runtime, - const SelLdrStartParams& params, - pp::CompletionCallback callback) { - CHECK(pp_error == PP_OK); - service_runtime->StartSelLdr(params, callback); -} - -void Plugin::SignalStartSelLdrDone(int32_t pp_error, - bool* started, - ServiceRuntime* service_runtime) { - *started = (pp_error == PP_OK); - service_runtime->SignalStartSelLdrDone(); -} - -void Plugin::LoadNaClModule(PP_NaClFileInfo file_info, - bool uses_nonsfi_mode, - PP_NaClAppProcessType process_type, - const pp::CompletionCallback& init_done_cb) { - CHECK(pp::Module::Get()->core()->IsMainThread()); - // Before forking a new sel_ldr process, ensure that we do not leak - // the ServiceRuntime object for an existing subprocess, and that any - // associated listener threads do not go unjoined because if they - // outlive the Plugin object, they will not be memory safe. - ShutDownSubprocesses(); - pp::Var manifest_base_url = - pp::Var(pp::PASS_REF, nacl_interface_->GetManifestBaseURL(pp_instance())); - std::string manifest_base_url_str = manifest_base_url.AsString(); - - SelLdrStartParams params(manifest_base_url_str, - file_info, - process_type); - ErrorInfo error_info; - ServiceRuntime* service_runtime = new ServiceRuntime( - this, pp_instance(), true, uses_nonsfi_mode, init_done_cb); - main_subprocess_.set_service_runtime(service_runtime); - if (NULL == service_runtime) { - error_info.SetReport( - PP_NACL_ERROR_SEL_LDR_INIT, - "sel_ldr init failure " + main_subprocess_.description()); - ReportLoadError(error_info); - return; - } - - // We don't take any action once nexe loading has completed, so pass an empty - // callback here for |callback|. - pp::CompletionCallback callback = callback_factory_.NewCallback( - &Plugin::StartNexe, service_runtime); - StartSelLdrOnMainThread( - static_cast<int32_t>(PP_OK), service_runtime, params, callback); -} - -void Plugin::StartNexe(int32_t pp_error, ServiceRuntime* service_runtime) { - CHECK(pp::Module::Get()->core()->IsMainThread()); - if (pp_error != PP_OK) - return; - service_runtime->StartNexe(); -} - -bool Plugin::LoadNaClModuleContinuationIntern() { - ErrorInfo error_info; - if (!uses_nonsfi_mode_) { - if (!main_subprocess_.StartSrpcServices()) { - // The NaCl process probably crashed. On Linux, a crash causes this - // error, while on other platforms, the error is detected below, when we - // attempt to start the proxy. Report a module initialization error here, - // to make it less confusing for developers. - NaClLog(LOG_ERROR, "LoadNaClModuleContinuationIntern: " - "StartSrpcServices failed\n"); - error_info.SetReport(PP_NACL_ERROR_START_PROXY_MODULE, - "could not initialize module."); - ReportLoadError(error_info); - return false; - } - } - - return PP_ToBool(nacl_interface_->StartPpapiProxy(pp_instance())); -} - -NaClSubprocess* Plugin::LoadHelperNaClModule(const std::string& helper_url, - PP_NaClFileInfo file_info, - ErrorInfo* error_info) { - nacl::scoped_ptr<NaClSubprocess> nacl_subprocess( - new NaClSubprocess("helper module", NULL, NULL)); - if (NULL == nacl_subprocess.get()) { - error_info->SetReport(PP_NACL_ERROR_SEL_LDR_INIT, - "unable to allocate helper subprocess."); - return NULL; - } - - // Do not report UMA stats for translator-related nexes. - // TODO(sehr): define new UMA stats for translator related nexe events. - // NOTE: The PNaCl translator nexes are not built to use the IRT. This is - // done to save on address space and swap space. - SelLdrStartParams params(helper_url, - file_info, - PP_PNACL_TRANSLATOR_PROCESS_TYPE); - - // Helper NaCl modules always use the PNaCl manifest, as there is no - // corresponding NMF. - if (!LoadHelperNaClModuleInternal(nacl_subprocess.get(), params)) - return NULL; - - // We need not wait for the init_done callback. We can block - // here in StartSrpcServices, since helper NaCl modules - // are spawned from a private thread. - // - // TODO(bsy): if helper module crashes, we should abort. - // crash_cb is not used here, so we are relying on crashes - // being detected in StartSrpcServices or later. - // - // NB: More refactoring might be needed, however, if helper - // NaCl modules have their own manifest. Currently the - // manifest is a per-plugin-instance object, not a per - // NaClSubprocess object. - if (!nacl_subprocess->StartSrpcServices()) { - error_info->SetReport(PP_NACL_ERROR_SRPC_CONNECTION_FAIL, - "SRPC connection failure for " + - nacl_subprocess->description()); - return NULL; - } - - PLUGIN_PRINTF(("Plugin::LoadHelperNaClModule (%s, %s)\n", - helper_url.c_str(), - nacl_subprocess.get()->detailed_description().c_str())); - - return nacl_subprocess.release(); -} - -// All failures of this function will show up as "Missing Plugin-in", so -// there is no need to log to JS console that there was an initialization -// failure. Note that module loading functions will log their own errors. -bool Plugin::Init(uint32_t argc, const char* argn[], const char* argv[]) { - nacl_interface_->InitializePlugin(pp_instance(), argc, argn, argv); - wrapper_factory_ = new nacl::DescWrapperFactory(); - pp::CompletionCallback open_cb = - callback_factory_.NewCallback(&Plugin::NaClManifestFileDidOpen); - nacl_interface_->RequestNaClManifest(pp_instance(), - open_cb.pp_completion_callback()); - return true; -} - -Plugin::Plugin(PP_Instance pp_instance) - : pp::Instance(pp_instance), - main_subprocess_("main subprocess", NULL, NULL), - uses_nonsfi_mode_(false), - wrapper_factory_(NULL), - nacl_interface_(NULL), - uma_interface_(this) { - callback_factory_.Initialize(this); - nacl_interface_ = GetNaClInterface(); - CHECK(nacl_interface_ != NULL); - - // Notify PPB_NaCl_Private that the instance is created before altering any - // state that it tracks. - nacl_interface_->InstanceCreated(pp_instance); - nexe_file_info_ = kInvalidNaClFileInfo; -} - -Plugin::~Plugin() { - int64_t shutdown_start = NaClGetTimeOfDayMicroseconds(); - - // Destroy the coordinator while the rest of the data is still there - pnacl_coordinator_.reset(NULL); - - nacl_interface_->InstanceDestroyed(pp_instance()); - - // ShutDownSubprocesses shuts down the main subprocess, which shuts - // down the main ServiceRuntime object, which kills the subprocess. - // As a side effect of the subprocess being killed, the reverse - // services thread(s) will get EOF on the reverse channel(s), and - // the thread(s) will exit. In ServiceRuntime::Shutdown, we invoke - // ReverseService::WaitForServiceThreadsToExit(), so that there will - // not be an extent thread(s) hanging around. This means that the - // ~Plugin will block until this happens. This is a requirement, - // since the renderer should be free to unload the plugin code, and - // we cannot have threads running code that gets unloaded before - // they exit. - // - // By waiting for the threads here, we also ensure that the Plugin - // object and the subprocess and ServiceRuntime objects is not - // (fully) destroyed while the threads are running, so resources - // that are destroyed after ShutDownSubprocesses (below) are - // guaranteed to be live and valid for access from the service - // threads. - // - // The main_subprocess object, which wraps the main service_runtime - // object, is dtor'd implicitly after the explicit code below runs, - // so the main service runtime object will not have been dtor'd, - // though the Shutdown method may have been called, during the - // lifetime of the service threads. - ShutDownSubprocesses(); - - delete wrapper_factory_; - - HistogramTimeSmall( - "NaCl.Perf.ShutdownTime.Total", - (NaClGetTimeOfDayMicroseconds() - shutdown_start) - / NACL_MICROS_PER_MILLI); -} - -bool Plugin::HandleDocumentLoad(const pp::URLLoader& url_loader) { - // We don't know if the plugin will handle the document load, but return - // true in order to give it a chance to respond once the proxy is started. - return true; -} - -void Plugin::NexeFileDidOpen(int32_t pp_error) { - if (pp_error != PP_OK) - return; - LoadNaClModule( - nexe_file_info_, - uses_nonsfi_mode_, - PP_NATIVE_NACL_PROCESS_TYPE, - callback_factory_.NewCallback(&Plugin::NexeFileDidOpenContinuation)); -} - -void Plugin::NexeFileDidOpenContinuation(int32_t pp_error) { - UNREFERENCED_PARAMETER(pp_error); - NaClLog(4, "Entered NexeFileDidOpenContinuation\n"); - if (LoadNaClModuleContinuationIntern()) { - NaClLog(4, "NexeFileDidOpenContinuation: success;" - " setting histograms\n"); - int64_t nexe_size = nacl_interface_->GetNexeSize(pp_instance()); - nacl_interface_->ReportLoadSuccess( - pp_instance(), nexe_size, nexe_size); - } else { - NaClLog(4, "NexeFileDidOpenContinuation: failed."); - } - NaClLog(4, "Leaving NexeFileDidOpenContinuation\n"); -} - -void Plugin::BitcodeDidTranslate(int32_t pp_error) { - PLUGIN_PRINTF(("Plugin::BitcodeDidTranslate (pp_error=%" NACL_PRId32 ")\n", - pp_error)); - if (pp_error != PP_OK) { - // Error should have been reported by pnacl. Just return. - return; - } - - // Inform JavaScript that we successfully translated the bitcode to a nexe. - PP_FileHandle handle = pnacl_coordinator_->TakeTranslatedFileHandle(); - - PP_NaClFileInfo info; - info.handle = handle; - info.token_lo = 0; - info.token_hi = 0; - LoadNaClModule( - info, - false, /* uses_nonsfi_mode */ - PP_PNACL_PROCESS_TYPE, - callback_factory_.NewCallback(&Plugin::BitcodeDidTranslateContinuation)); -} - -void Plugin::BitcodeDidTranslateContinuation(int32_t pp_error) { - NaClLog(4, "Entered BitcodeDidTranslateContinuation\n"); - UNREFERENCED_PARAMETER(pp_error); - if (LoadNaClModuleContinuationIntern()) { - int64_t loaded; - int64_t total; - // TODO(teravest): Tighten this up so we can get rid of - // GetCurrentProgress(). loaded should always equal total. - pnacl_coordinator_->GetCurrentProgress(&loaded, &total); - nacl_interface_->ReportLoadSuccess(pp_instance(), loaded, total); - } -} - -void Plugin::NaClManifestFileDidOpen(int32_t pp_error) { - PLUGIN_PRINTF(("Plugin::NaClManifestFileDidOpen (pp_error=%" - NACL_PRId32 ")\n", pp_error)); - if (pp_error != PP_OK) - return; - - PP_Var pp_program_url; - PP_PNaClOptions pnacl_options = {PP_FALSE, PP_FALSE, 2}; - PP_Bool uses_nonsfi_mode; - if (nacl_interface_->GetManifestProgramURL( - pp_instance(), &pp_program_url, &pnacl_options, &uses_nonsfi_mode)) { - std::string program_url = pp::Var(pp::PASS_REF, pp_program_url).AsString(); - // TODO(teravest): Make ProcessNaClManifest take responsibility for more of - // this function. - nacl_interface_->ProcessNaClManifest(pp_instance(), program_url.c_str()); - uses_nonsfi_mode_ = PP_ToBool(uses_nonsfi_mode); - if (pnacl_options.translate) { - pp::CompletionCallback translate_callback = - callback_factory_.NewCallback(&Plugin::BitcodeDidTranslate); - pnacl_coordinator_.reset( - PnaclCoordinator::BitcodeToNative(this, - program_url, - pnacl_options, - translate_callback)); - return; - } else { - pp::CompletionCallback open_callback = - callback_factory_.NewCallback(&Plugin::NexeFileDidOpen); - // Will always call the callback on success or failure. - nacl_interface_->DownloadNexe(pp_instance(), - program_url.c_str(), - &nexe_file_info_, - open_callback.pp_completion_callback()); - return; - } - } -} - -void Plugin::ReportLoadError(const ErrorInfo& error_info) { - nacl_interface_->ReportLoadError(pp_instance(), - error_info.error_code(), - error_info.message().c_str()); -} - -} // namespace plugin diff --git a/chromium/ppapi/native_client/src/trusted/plugin/plugin.gyp b/chromium/ppapi/native_client/src/trusted/plugin/plugin.gyp deleted file mode 100644 index dc89f4e2d48..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/plugin.gyp +++ /dev/null @@ -1,36 +0,0 @@ -# -*- python -*- -# Copyright (c) 2011 The Native Client Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -{ - 'includes': [ - 'plugin.gypi', - ], - 'targets': [ - { - 'target_name': 'nacl_trusted_plugin', - 'type': 'static_library', - 'sources': [ - '<@(common_sources)', - ], - 'dependencies': [ - '<(DEPTH)/media/media.gyp:shared_memory_support', - '<(DEPTH)/native_client/src/shared/gio/gio.gyp:gio', - '<(DEPTH)/native_client/src/shared/imc/imc.gyp:imc', - '<(DEPTH)/native_client/src/shared/platform/platform.gyp:platform', - '<(DEPTH)/native_client/src/shared/srpc/srpc.gyp:nonnacl_srpc', - '<(DEPTH)/native_client/src/trusted/desc/desc.gyp:nrd_xfer', - '<(DEPTH)/native_client/src/trusted/nonnacl_util/nonnacl_util.gyp:sel_ldr_launcher_base', - '<(DEPTH)/native_client/src/trusted/platform_qualify/platform_qualify.gyp:platform_qual_lib', - '<(DEPTH)/native_client/src/trusted/simple_service/simple_service.gyp:simple_service', - '<(DEPTH)/native_client/src/trusted/reverse_service/reverse_service.gyp:reverse_service', - '<(DEPTH)/native_client/src/trusted/weak_ref/weak_ref.gyp:weak_ref', - '<(DEPTH)/ppapi/ppapi.gyp:ppapi_cpp_objects', - '<(DEPTH)/ppapi/ppapi.gyp:ppapi_internal_module', - ], - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - 'msvs_disabled_warnings': [4267, ], - }, - ], -} diff --git a/chromium/ppapi/native_client/src/trusted/plugin/plugin.gypi b/chromium/ppapi/native_client/src/trusted/plugin/plugin.gypi deleted file mode 100644 index aa8f3ac6f3f..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/plugin.gypi +++ /dev/null @@ -1,82 +0,0 @@ -# Copyright (c) 2012 The Native Client Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -{ - 'variables': { - 'chromium_code': 1, # Use higher warning level. - 'common_sources': [ - 'module_ppapi.cc', - 'nacl_subprocess.cc', - 'plugin.cc', - 'pnacl_coordinator.cc', - 'pnacl_resources.cc', - 'pnacl_translate_thread.cc', - 'ppapi_entrypoints.cc', - 'sel_ldr_launcher_chrome.cc', - 'service_runtime.cc', - 'srpc_client.cc', - 'srpc_params.cc', - 'temporary_file.cc', - 'utility.cc', - ], - }, - 'includes': [ - '../../../../../native_client/build/common.gypi', - ], - 'target_defaults': { - 'variables': { - 'target_platform': 'none', - }, - 'conditions': [ - ['OS=="linux"', { - 'cflags': [ - '-Wno-long-long', - ], - 'cflags!': [ - '-Wno-unused-parameter', # be a bit stricter to match NaCl flags. - ], - 'conditions': [ - ['asan!=1 and msan!=1 and ubsan_vptr!=1', { - 'ldflags': [ - # Catch unresolved symbols. - '-Wl,-z,defs', - ], - }], - ], - 'libraries': [ - '-ldl', - ], - }], - ['OS=="mac"', { - 'cflags': [ - '-Wno-long-long', - ], - 'cflags!': [ - '-Wno-unused-parameter', # be a bit stricter to match NaCl flags. - ], - 'link_settings': { - 'libraries': [ - '$(SDKROOT)/System/Library/Frameworks/Carbon.framework', - ], - }, - }], - ['OS=="win"', { - 'defines': [ - 'WIN32', - '_WINDOWS' - ], - 'flags': [ - '-fPIC', - '-Wno-long-long', - ], - 'link_settings': { - 'libraries': [ - '-lgdi32.lib', - '-luser32.lib', - ], - }, - }], - ], - }, -} diff --git a/chromium/ppapi/native_client/src/trusted/plugin/plugin.h b/chromium/ppapi/native_client/src/trusted/plugin/plugin.h deleted file mode 100644 index 1fe082a6436..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/plugin.h +++ /dev/null @@ -1,202 +0,0 @@ -// -*- c++ -*- -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// The portable representation of an instance and root scriptable object. -// The PPAPI version of the plugin instantiates a subclass of this class. - -#ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_ -#define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_ - -#include <stdio.h> - -#include <string> - -#include "native_client/src/include/nacl_macros.h" -#include "native_client/src/include/nacl_scoped_ptr.h" - -#include "ppapi/c/private/ppb_nacl_private.h" -#include "ppapi/cpp/instance.h" -#include "ppapi/cpp/private/uma_private.h" -#include "ppapi/cpp/url_loader.h" -#include "ppapi/cpp/var.h" -#include "ppapi/cpp/view.h" - -#include "ppapi/native_client/src/trusted/plugin/nacl_subprocess.h" -#include "ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h" -#include "ppapi/native_client/src/trusted/plugin/service_runtime.h" -#include "ppapi/native_client/src/trusted/plugin/utility.h" - -#include "ppapi/utility/completion_callback_factory.h" - -namespace nacl { -class DescWrapper; -class DescWrapperFactory; -} // namespace nacl - -namespace pp { -class CompletionCallback; -class URLLoader; -class URLUtil_Dev; -} - -namespace plugin { - -class ErrorInfo; -class Manifest; - -int32_t ConvertFileDescriptor(PP_FileHandle handle); - -const PP_NaClFileInfo kInvalidNaClFileInfo = { - PP_kInvalidFileHandle, - 0, // token_lo - 0, // token_hi -}; - -class Plugin : public pp::Instance { - public: - explicit Plugin(PP_Instance instance); - - // ----- Methods inherited from pp::Instance: - - // Initializes this plugin with <embed/object ...> tag attribute count |argc|, - // names |argn| and values |argn|. Returns false on failure. - // Gets called by the browser right after New(). - virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]); - - // Handles document load, when the plugin is a MIME type handler. - virtual bool HandleDocumentLoad(const pp::URLLoader& url_loader); - - // Load support. - // - // Starts NaCl module but does not wait until low-level - // initialization (e.g. ld.so dynamic loading of manifest files) is - // done. The module will become ready later, asynchronously. Other - // event handlers should block until the module is ready before - // trying to communicate with it, i.e., until nacl_ready_state is - // DONE. - // - // NB: currently we do not time out, so if the untrusted code - // does not signal that it is ready, then we will deadlock the main - // thread of the renderer on this subsequent event delivery. We - // should include a time-out at which point we declare the - // nacl_ready_state to be done, and let the normal crash detection - // mechanism(s) take over. - void LoadNaClModule(PP_NaClFileInfo file_info, - bool uses_nonsfi_mode, - PP_NaClAppProcessType process_type, - const pp::CompletionCallback& init_done_cb); - - // Finish hooking interfaces up, after low-level initialization is - // complete. - bool LoadNaClModuleContinuationIntern(); - - // Continuation for starting SRPC/JSProxy services as appropriate. - // This is invoked as a callback when the NaCl module makes the - // init_done reverse RPC to tell us that low-level initialization - // such as ld.so processing is done. That initialization requires - // that the main thread be free in order to do Pepper - // main-thread-only operations such as file processing. - bool LoadNaClModuleContinuation(int32_t pp_error); - - // Load support. - // A helper SRPC NaCl module can be loaded given a PP_NaClFileInfo. - // Blocks until the helper module signals initialization is done. - // Does not update nacl_module_origin(). - // Returns NULL or the NaClSubprocess of the new helper NaCl module. - NaClSubprocess* LoadHelperNaClModule(const std::string& helper_url, - PP_NaClFileInfo file_info, - ErrorInfo* error_info); - - // Report an error that was encountered while loading a module. - void ReportLoadError(const ErrorInfo& error_info); - - nacl::DescWrapperFactory* wrapper_factory() const { return wrapper_factory_; } - - const PPB_NaCl_Private* nacl_interface() const { return nacl_interface_; } - pp::UMAPrivate& uma_interface() { return uma_interface_; } - - private: - NACL_DISALLOW_COPY_AND_ASSIGN(Plugin); - // The browser will invoke the destructor via the pp::Instance - // pointer to this object, not from base's Delete(). - ~Plugin(); - - // Shuts down socket connection, service runtime, and receive thread, - // in this order, for the main nacl subprocess. - void ShutDownSubprocesses(); - - // Histogram helper functions, internal to Plugin so they can use - // uma_interface_ normally. - void HistogramTimeSmall(const std::string& name, int64_t ms); - - // Loads and starts a helper (e.g. llc, ld) NaCl module. - // Only to be used from a background (non-main) thread for the PNaCl - // translator. This will fully initialize the |subprocess| if the load was - // successful. - bool LoadHelperNaClModuleInternal(NaClSubprocess* subprocess, - const SelLdrStartParams& params); - - // Start sel_ldr from the main thread, given the start params. - // |pp_error| is set by CallOnMainThread (should be PP_OK). - void StartSelLdrOnMainThread(int32_t pp_error, - ServiceRuntime* service_runtime, - const SelLdrStartParams& params, - pp::CompletionCallback callback); - - // Signals that StartSelLdr has finished. - // This is invoked on the main thread. - void SignalStartSelLdrDone(int32_t pp_error, - bool* started, - ServiceRuntime* service_runtime); - - // This is invoked on the main thread. - void StartNexe(int32_t pp_error, ServiceRuntime* service_runtime); - - // Callback used when getting the URL for the .nexe file. If the URL loading - // is successful, the file descriptor is opened and can be passed to sel_ldr - // with the sandbox on. - void NexeFileDidOpen(int32_t pp_error); - void NexeFileDidOpenContinuation(int32_t pp_error); - - // Callback used when a .nexe is translated from bitcode. If the translation - // is successful, the file descriptor is opened and can be passed to sel_ldr - // with the sandbox on. - void BitcodeDidTranslate(int32_t pp_error); - void BitcodeDidTranslateContinuation(int32_t pp_error); - - // NaCl ISA selection manifest file support. The manifest file is specified - // using the "nacl" attribute in the <embed> tag. First, the manifest URL (or - // data: URI) is fetched, then the JSON is parsed. Once a valid .nexe is - // chosen for the sandbox ISA, any current service runtime is shut down, the - // .nexe is loaded and run. - - // Callback used when getting the manifest file as a local file descriptor. - void NaClManifestFileDidOpen(int32_t pp_error); - - // Processes the JSON manifest string and starts loading the nexe. - void ProcessNaClManifest(const std::string& manifest_json); - - // Keep track of the NaCl module subprocess that was spun up in the plugin. - NaClSubprocess main_subprocess_; - - bool uses_nonsfi_mode_; - - nacl::DescWrapperFactory* wrapper_factory_; - - pp::CompletionCallbackFactory<Plugin> callback_factory_; - - nacl::scoped_ptr<PnaclCoordinator> pnacl_coordinator_; - - int exit_status_; - - PP_NaClFileInfo nexe_file_info_; - - const PPB_NaCl_Private* nacl_interface_; - pp::UMAPrivate uma_interface_; -}; - -} // namespace plugin - -#endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_ diff --git a/chromium/ppapi/native_client/src/trusted/plugin/plugin_error.h b/chromium/ppapi/native_client/src/trusted/plugin/plugin_error.h deleted file mode 100644 index a30e793647a..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/plugin_error.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2011 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* - * Error codes and data structures used to report errors when loading a nexe. - */ - -#ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_ERROR_H -#define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_ERROR_H - -#include <string> - -#include "native_client/src/include/nacl_macros.h" -#include "ppapi/c/private/ppb_nacl_private.h" - -namespace plugin { - -class ErrorInfo { - public: - ErrorInfo() { - SetReport(PP_NACL_ERROR_UNKNOWN, std::string()); - } - - void SetReport(PP_NaClError error_code, const std::string& message) { - error_code_ = error_code; - message_ = message; - } - - PP_NaClError error_code() const { - return error_code_; - } - - const std::string& message() const { - return message_; - } - - private: - PP_NaClError error_code_; - std::string message_; - NACL_DISALLOW_COPY_AND_ASSIGN(ErrorInfo); -}; - -} // namespace plugin - -#endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_ERROR_H diff --git a/chromium/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc b/chromium/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc deleted file mode 100644 index 2c27e50dd6c..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc +++ /dev/null @@ -1,463 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h" - -#include <algorithm> -#include <utility> - -#include "native_client/src/include/portability_io.h" -#include "native_client/src/shared/platform/nacl_check.h" -#include "native_client/src/trusted/service_runtime/include/sys/stat.h" - -#include "ppapi/c/pp_bool.h" -#include "ppapi/c/pp_errors.h" -#include "ppapi/c/private/ppb_uma_private.h" - -#include "ppapi/native_client/src/trusted/plugin/plugin.h" -#include "ppapi/native_client/src/trusted/plugin/plugin_error.h" -#include "ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h" -#include "ppapi/native_client/src/trusted/plugin/service_runtime.h" -#include "ppapi/native_client/src/trusted/plugin/temporary_file.h" - -namespace plugin { - -namespace { - -const int32_t kSizeKBMin = 1; -const int32_t kSizeKBMax = 512*1024; // very large .pexe / .nexe. -const uint32_t kSizeKBBuckets = 100; - -const int32_t kRatioMin = 10; -const int32_t kRatioMax = 10*100; // max of 10x difference. -const uint32_t kRatioBuckets = 100; - -void HistogramSizeKB(pp::UMAPrivate& uma, - const std::string& name, int32_t kb) { - if (kb < 0) return; - uma.HistogramCustomCounts(name, - kb, - kSizeKBMin, kSizeKBMax, - kSizeKBBuckets); -} - -void HistogramRatio(pp::UMAPrivate& uma, - const std::string& name, int64_t a, int64_t b) { - if (a < 0 || b <= 0) return; - uma.HistogramCustomCounts(name, - 100 * a / b, - kRatioMin, kRatioMax, - kRatioBuckets); -} - -std::string GetArchitectureAttributes(Plugin* plugin) { - pp::Var attrs_var(pp::PASS_REF, - plugin->nacl_interface()->GetCpuFeatureAttrs()); - return attrs_var.AsString(); -} - -void DidCacheHit(void* user_data, PP_FileHandle nexe_file_handle) { - PnaclCoordinator* coordinator = static_cast<PnaclCoordinator*>(user_data); - coordinator->BitcodeStreamCacheHit(nexe_file_handle); -} - -void DidCacheMiss(void* user_data, int64_t expected_pexe_size, - PP_FileHandle temp_nexe_file) { - PnaclCoordinator* coordinator = static_cast<PnaclCoordinator*>(user_data); - coordinator->BitcodeStreamCacheMiss(expected_pexe_size, - temp_nexe_file); -} - -void DidStreamData(void* user_data, const void* stream_data, int32_t length) { - PnaclCoordinator* coordinator = static_cast<PnaclCoordinator*>(user_data); - coordinator->BitcodeStreamGotData(stream_data, length); -} - -void DidFinishStream(void* user_data, int32_t pp_error) { - PnaclCoordinator* coordinator = static_cast<PnaclCoordinator*>(user_data); - coordinator->BitcodeStreamDidFinish(pp_error); -} - -PPP_PexeStreamHandler kPexeStreamHandler = { - &DidCacheHit, - &DidCacheMiss, - &DidStreamData, - &DidFinishStream -}; - -} // namespace - -PnaclCoordinator* PnaclCoordinator::BitcodeToNative( - Plugin* plugin, - const std::string& pexe_url, - const PP_PNaClOptions& pnacl_options, - const pp::CompletionCallback& translate_notify_callback) { - PLUGIN_PRINTF(("PnaclCoordinator::BitcodeToNative (plugin=%p, pexe=%s)\n", - static_cast<void*>(plugin), pexe_url.c_str())); - PnaclCoordinator* coordinator = - new PnaclCoordinator(plugin, pexe_url, - pnacl_options, - translate_notify_callback); - - GetNaClInterface()->SetPNaClStartTime(plugin->pp_instance()); - int cpus = plugin->nacl_interface()->GetNumberOfProcessors(); - coordinator->split_module_count_ = std::min(4, std::max(1, cpus)); - - // First start a network request for the pexe, to tickle the component - // updater's On-Demand resource throttler, and to get Last-Modified/ETag - // cache information. We can cancel the request later if there's - // a bitcode->nexe cache hit. - coordinator->OpenBitcodeStream(); - return coordinator; -} - -PnaclCoordinator::PnaclCoordinator( - Plugin* plugin, - const std::string& pexe_url, - const PP_PNaClOptions& pnacl_options, - const pp::CompletionCallback& translate_notify_callback) - : translate_finish_error_(PP_OK), - plugin_(plugin), - translate_notify_callback_(translate_notify_callback), - translation_finished_reported_(false), - pexe_url_(pexe_url), - pnacl_options_(pnacl_options), - architecture_attributes_(GetArchitectureAttributes(plugin)), - split_module_count_(1), - error_already_reported_(false), - pexe_size_(0), - pexe_bytes_compiled_(0), - expected_pexe_size_(-1) { - callback_factory_.Initialize(this); -} - -PnaclCoordinator::~PnaclCoordinator() { - PLUGIN_PRINTF(("PnaclCoordinator::~PnaclCoordinator (this=%p, " - "translate_thread=%p\n", - static_cast<void*>(this), translate_thread_.get())); - // Stopping the translate thread will cause the translate thread to try to - // run translation_complete_callback_ on the main thread. This destructor is - // running from the main thread, and by the time it exits, callback_factory_ - // will have been destroyed. This will result in the cancellation of - // translation_complete_callback_, so no notification will be delivered. - if (translate_thread_.get() != NULL) - translate_thread_->AbortSubprocesses(); - if (!translation_finished_reported_) { - plugin_->nacl_interface()->ReportTranslationFinished( - plugin_->pp_instance(), - PP_FALSE, 0, 0, 0); - } - // Force deleting the translate_thread now. It must be deleted - // before any scoped_* fields hanging off of PnaclCoordinator - // since the thread may be accessing those fields. - // It will also be accessing obj_files_. - translate_thread_.reset(NULL); - for (size_t i = 0; i < obj_files_.size(); i++) - delete obj_files_[i]; -} - -PP_FileHandle PnaclCoordinator::TakeTranslatedFileHandle() { - DCHECK(temp_nexe_file_ != NULL); - return temp_nexe_file_->TakeFileHandle(); -} - -void PnaclCoordinator::ReportNonPpapiError(PP_NaClError err_code, - const std::string& message) { - ErrorInfo error_info; - error_info.SetReport(err_code, message); - plugin_->ReportLoadError(error_info); - ExitWithError(); -} - -void PnaclCoordinator::ReportPpapiError(PP_NaClError err_code, - int32_t pp_error, - const std::string& message) { - std::stringstream ss; - ss << "PnaclCoordinator: " << message << " (pp_error=" << pp_error << ")."; - ErrorInfo error_info; - error_info.SetReport(err_code, ss.str()); - plugin_->ReportLoadError(error_info); - ExitWithError(); -} - -void PnaclCoordinator::ExitWithError() { - PLUGIN_PRINTF(("PnaclCoordinator::ExitWithError\n")); - // Free all the intermediate callbacks we ever created. - // Note: this doesn't *cancel* the callbacks from the factories attached - // to the various helper classes (e.g., pnacl_resources). Thus, those - // callbacks may still run asynchronously. We let those run but ignore - // any other errors they may generate so that they do not end up running - // translate_notify_callback_, which has already been freed. - callback_factory_.CancelAll(); - if (!error_already_reported_) { - error_already_reported_ = true; - translation_finished_reported_ = true; - plugin_->nacl_interface()->ReportTranslationFinished( - plugin_->pp_instance(), - PP_FALSE, 0, 0, 0); - translate_notify_callback_.Run(PP_ERROR_FAILED); - } -} - -// Signal that Pnacl translation completed normally. -void PnaclCoordinator::TranslateFinished(int32_t pp_error) { - PLUGIN_PRINTF(("PnaclCoordinator::TranslateFinished (pp_error=%" - NACL_PRId32 ")\n", pp_error)); - // Bail out if there was an earlier error (e.g., pexe load failure), - // or if there is an error from the translation thread. - if (translate_finish_error_ != PP_OK || pp_error != PP_OK) { - plugin_->ReportLoadError(error_info_); - ExitWithError(); - return; - } - - // Send out one last progress event, to finish up the progress events - // that were delayed (see the delay inserted in BitcodeGotCompiled). - if (expected_pexe_size_ != -1) { - pexe_bytes_compiled_ = expected_pexe_size_; - GetNaClInterface()->DispatchEvent(plugin_->pp_instance(), - PP_NACL_EVENT_PROGRESS, - pexe_url_.c_str(), - PP_TRUE, - pexe_bytes_compiled_, - expected_pexe_size_); - } - struct nacl_abi_stat stbuf; - struct NaClDesc* desc = temp_nexe_file_->read_wrapper()->desc(); - if (0 == (*((struct NaClDescVtbl const *)desc->base.vtbl)->Fstat)(desc, - &stbuf)) { - size_t nexe_size = stbuf.nacl_abi_st_size; - HistogramSizeKB(plugin_->uma_interface(), - "NaCl.Perf.Size.PNaClTranslatedNexe", - static_cast<int64_t>(nexe_size / 1024)); - HistogramRatio(plugin_->uma_interface(), - "NaCl.Perf.Size.PexeNexeSizePct", pexe_size_, nexe_size); - } - // The nexe is written to the temp_nexe_file_. We must Reset() the file - // pointer to be able to read it again from the beginning. - temp_nexe_file_->Reset(); - - // Report to the browser that translation finished. The browser will take - // care of storing the nexe in the cache. - translation_finished_reported_ = true; - plugin_->nacl_interface()->ReportTranslationFinished( - plugin_->pp_instance(), PP_TRUE, pnacl_options_.opt_level, - pexe_size_, translate_thread_->GetCompileTime()); - - NexeReadDidOpen(PP_OK); -} - -void PnaclCoordinator::NexeReadDidOpen(int32_t pp_error) { - PLUGIN_PRINTF(("PnaclCoordinator::NexeReadDidOpen (pp_error=%" - NACL_PRId32 ")\n", pp_error)); - if (pp_error != PP_OK) { - if (pp_error == PP_ERROR_FILENOTFOUND) { - ReportPpapiError(PP_NACL_ERROR_PNACL_CACHE_FETCH_NOTFOUND, - pp_error, - "Failed to open translated nexe (not found)."); - return; - } - if (pp_error == PP_ERROR_NOACCESS) { - ReportPpapiError(PP_NACL_ERROR_PNACL_CACHE_FETCH_NOACCESS, - pp_error, - "Failed to open translated nexe (no access)."); - return; - } - ReportPpapiError(PP_NACL_ERROR_PNACL_CACHE_FETCH_OTHER, - pp_error, - "Failed to open translated nexe."); - return; - } - - translate_notify_callback_.Run(PP_OK); -} - -void PnaclCoordinator::OpenBitcodeStream() { - // Even though we haven't started downloading, create the translation - // thread object immediately. This ensures that any pieces of the file - // that get downloaded before the compilation thread is accepting - // SRPCs won't get dropped. - translate_thread_.reset(new PnaclTranslateThread()); - if (translate_thread_ == NULL) { - ReportNonPpapiError( - PP_NACL_ERROR_PNACL_THREAD_CREATE, - "PnaclCoordinator: could not allocate translation thread."); - return; - } - - GetNaClInterface()->StreamPexe(plugin_->pp_instance(), - pexe_url_.c_str(), - pnacl_options_.opt_level, - &kPexeStreamHandler, - this); -} - -void PnaclCoordinator::BitcodeStreamCacheHit(PP_FileHandle handle) { - if (handle == PP_kInvalidFileHandle) { - ReportNonPpapiError( - PP_NACL_ERROR_PNACL_CREATE_TEMP, - std::string( - "PnaclCoordinator: Got bad temp file handle from GetNexeFd")); - BitcodeStreamDidFinish(PP_ERROR_FAILED); - return; - } - temp_nexe_file_.reset(new TempFile(plugin_, handle)); - // Open it for reading as the cached nexe file. - NexeReadDidOpen(temp_nexe_file_->Open(false)); -} - -void PnaclCoordinator::BitcodeStreamCacheMiss(int64_t expected_pexe_size, - PP_FileHandle nexe_handle) { - // IMPORTANT: Make sure that PnaclResources::StartLoad() is only - // called after you receive a response to a request for a .pexe file. - // - // The component updater's resource throttles + OnDemand update/install - // should block the URL request until the compiler is present. Now we - // can load the resources (e.g. llc and ld nexes). - resources_.reset(new PnaclResources(plugin_)); - CHECK(resources_ != NULL); - - // The first step of loading resources: read the resource info file. - if (!resources_->ReadResourceInfo()) { - ExitWithError(); - return; - } - - // Second step of loading resources: call StartLoad to load pnacl-llc - // and pnacl-ld, based on the filenames found in the resource info file. - if (!resources_->StartLoad()) { - ReportNonPpapiError( - PP_NACL_ERROR_PNACL_RESOURCE_FETCH, - std::string("The Portable Native Client (pnacl) component is not " - "installed. Please consult chrome://components for more " - "information.")); - return; - } - - expected_pexe_size_ = expected_pexe_size; - - for (int i = 0; i < split_module_count_; i++) { - PP_FileHandle obj_handle = - plugin_->nacl_interface()->CreateTemporaryFile(plugin_->pp_instance()); - nacl::scoped_ptr<TempFile> temp_file(new TempFile(plugin_, obj_handle)); - int32_t pp_error = temp_file->Open(true); - if (pp_error != PP_OK) { - ReportPpapiError(PP_NACL_ERROR_PNACL_CREATE_TEMP, - pp_error, - "Failed to open scratch object file."); - return; - } else { - obj_files_.push_back(temp_file.release()); - } - } - invalid_desc_wrapper_.reset(plugin_->wrapper_factory()->MakeInvalid()); - - temp_nexe_file_.reset(new TempFile(plugin_, nexe_handle)); - // Open the nexe file for connecting ld and sel_ldr. - // Start translation when done with this last step of setup! - RunTranslate(temp_nexe_file_->Open(true)); -} - -void PnaclCoordinator::BitcodeStreamGotData(const void* data, int32_t length) { - DCHECK(translate_thread_.get()); - - translate_thread_->PutBytes(data, length); - if (data && length > 0) - pexe_size_ += length; -} - -void PnaclCoordinator::BitcodeStreamDidFinish(int32_t pp_error) { - PLUGIN_PRINTF(("PnaclCoordinator::BitcodeStreamDidFinish (pp_error=%" - NACL_PRId32 ")\n", pp_error)); - if (pp_error != PP_OK) { - // Defer reporting the error and cleanup until after the translation - // thread returns, because it may be accessing the coordinator's - // objects or writing to the files. - translate_finish_error_ = pp_error; - if (pp_error == PP_ERROR_ABORTED) { - error_info_.SetReport(PP_NACL_ERROR_PNACL_PEXE_FETCH_ABORTED, - "PnaclCoordinator: pexe load failed (aborted)."); - } - if (pp_error == PP_ERROR_NOACCESS) { - error_info_.SetReport(PP_NACL_ERROR_PNACL_PEXE_FETCH_NOACCESS, - "PnaclCoordinator: pexe load failed (no access)."); - } else { - std::stringstream ss; - ss << "PnaclCoordinator: pexe load failed (pp_error=" << pp_error << ")."; - error_info_.SetReport(PP_NACL_ERROR_PNACL_PEXE_FETCH_OTHER, ss.str()); - } - - if (translate_thread_->started()) - translate_thread_->AbortSubprocesses(); - else - TranslateFinished(pp_error); - } else { - // Compare download completion pct (100% now), to compile completion pct. - HistogramRatio(plugin_->uma_interface(), - "NaCl.Perf.PNaClLoadTime.PctCompiledWhenFullyDownloaded", - pexe_bytes_compiled_, pexe_size_); - translate_thread_->EndStream(); - } -} - -void PnaclCoordinator::BitcodeGotCompiled(int32_t pp_error, - int64_t bytes_compiled) { - DCHECK(pp_error == PP_OK); - pexe_bytes_compiled_ += bytes_compiled; - // Hold off reporting the last few bytes of progress, since we don't know - // when they are actually completely compiled. "bytes_compiled" only means - // that bytes were sent to the compiler. - if (expected_pexe_size_ != -1) { - if (!ShouldDelayProgressEvent()) { - GetNaClInterface()->DispatchEvent(plugin_->pp_instance(), - PP_NACL_EVENT_PROGRESS, - pexe_url_.c_str(), - PP_TRUE, - pexe_bytes_compiled_, - expected_pexe_size_); - } - } else { - GetNaClInterface()->DispatchEvent(plugin_->pp_instance(), - PP_NACL_EVENT_PROGRESS, - pexe_url_.c_str(), - PP_FALSE, - pexe_bytes_compiled_, - expected_pexe_size_); - } -} - -pp::CompletionCallback PnaclCoordinator::GetCompileProgressCallback( - int64_t bytes_compiled) { - return callback_factory_.NewCallback(&PnaclCoordinator::BitcodeGotCompiled, - bytes_compiled); -} - -void PnaclCoordinator::GetCurrentProgress(int64_t* bytes_loaded, - int64_t* bytes_total) { - *bytes_loaded = pexe_bytes_compiled_; - *bytes_total = expected_pexe_size_; -} - -void PnaclCoordinator::RunTranslate(int32_t pp_error) { - PLUGIN_PRINTF(("PnaclCoordinator::RunTranslate (pp_error=%" - NACL_PRId32 ")\n", pp_error)); - // Invoke llc followed by ld off the main thread. This allows use of - // blocking RPCs that would otherwise block the JavaScript main thread. - pp::CompletionCallback report_translate_finished = - callback_factory_.NewCallback(&PnaclCoordinator::TranslateFinished); - - CHECK(translate_thread_ != NULL); - translate_thread_->RunTranslate(report_translate_finished, - &obj_files_, - temp_nexe_file_.get(), - invalid_desc_wrapper_.get(), - &error_info_, - resources_.get(), - &pnacl_options_, - architecture_attributes_, - this, - plugin_); -} - -} // namespace plugin diff --git a/chromium/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h b/chromium/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h deleted file mode 100644 index 5561be6bd21..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h +++ /dev/null @@ -1,197 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_COORDINATOR_H_ -#define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_COORDINATOR_H_ - -#include <vector> - -#include "native_client/src/include/nacl_macros.h" -#include "native_client/src/shared/platform/nacl_sync_raii.h" -#include "native_client/src/shared/srpc/nacl_srpc.h" -#include "native_client/src/trusted/desc/nacl_desc_wrapper.h" - -#include "ppapi/cpp/completion_callback.h" - -#include "ppapi/native_client/src/trusted/plugin/nacl_subprocess.h" -#include "ppapi/native_client/src/trusted/plugin/plugin_error.h" -#include "ppapi/native_client/src/trusted/plugin/pnacl_resources.h" - -#include "ppapi/utility/completion_callback_factory.h" - -struct PP_PNaClOptions; - -namespace plugin { - -class Plugin; -class PnaclCoordinator; -class PnaclTranslateThread; -class TempFile; - -// A class invoked by Plugin to handle PNaCl client-side translation. -// Usage: -// (1) Invoke the factory method, e.g., -// PnaclCoordinator* coord = BitcodeToNative(plugin, -// "http://foo.com/my.pexe", -// pnacl_options, -// TranslateNotifyCallback); -// (2) TranslateNotifyCallback gets invoked when translation is complete. -// If the translation was successful, the pp_error argument is PP_OK. -// Other values indicate errors. -// (3) After finish_callback runs, get the file descriptor of the translated -// nexe, e.g., -// fd = coord->ReleaseTranslatedFD(); -// (4) Load the nexe from "fd". -// (5) delete coord. -// -// Translation proceeds in two steps: -// (1) llc translates the bitcode in pexe_url_ to an object in obj_file_. -// (2) ld links the object code in obj_file_ and produces a nexe in nexe_file_. -class PnaclCoordinator { - public: - // Maximum number of object files passable to the translator. Cannot be - // changed without changing the RPC signatures. - const static size_t kMaxTranslatorObjectFiles = 16; - virtual ~PnaclCoordinator(); - - // The factory method for translations. - static PnaclCoordinator* BitcodeToNative( - Plugin* plugin, - const std::string& pexe_url, - const PP_PNaClOptions& pnacl_options, - const pp::CompletionCallback& translate_notify_callback); - - // Call this to take ownership of the FD of the translated nexe after - // BitcodeToNative has completed (and the finish_callback called). - PP_FileHandle TakeTranslatedFileHandle(); - - // Return a callback that should be notified when |bytes_compiled| bytes - // have been compiled. - pp::CompletionCallback GetCompileProgressCallback(int64_t bytes_compiled); - - // Get the last known load progress. - void GetCurrentProgress(int64_t* bytes_loaded, int64_t* bytes_total); - - // Return true if we should delay the progress event reporting. - // This delay approximates: - // - the size of the buffer of bytes sent but not-yet-compiled by LLC. - // - the linking time. - bool ShouldDelayProgressEvent() { - const uint32_t kProgressEventSlopPct = 5; - return ((expected_pexe_size_ - pexe_bytes_compiled_) * 100 / - expected_pexe_size_) < kProgressEventSlopPct; - } - - - void BitcodeStreamCacheHit(PP_FileHandle handle); - void BitcodeStreamCacheMiss(int64_t expected_pexe_size, - PP_FileHandle handle); - - // Invoked when a pexe data chunk arrives (when using streaming translation) - void BitcodeStreamGotData(const void* data, int32_t length); - - // Invoked when the pexe download finishes (using streaming translation) - void BitcodeStreamDidFinish(int32_t pp_error); - - private: - NACL_DISALLOW_COPY_AND_ASSIGN(PnaclCoordinator); - - // BitcodeToNative is the factory method for PnaclCoordinators. - // Therefore the constructor is private. - PnaclCoordinator(Plugin* plugin, - const std::string& pexe_url, - const PP_PNaClOptions& pnacl_options, - const pp::CompletionCallback& translate_notify_callback); - - // Invoke to issue a GET request for bitcode. - void OpenBitcodeStream(); - - // Invoked when a pexe data chunk is compiled. - void BitcodeGotCompiled(int32_t pp_error, int64_t bytes_compiled); - // Once llc and ld nexes have been loaded and the two temporary files have - // been created, this starts the translation. Translation starts two - // subprocesses, one for llc and one for ld. - void RunTranslate(int32_t pp_error); - - // Invoked when translation is finished. - void TranslateFinished(int32_t pp_error); - - // Invoked when the read descriptor for nexe_file_ is created. - void NexeReadDidOpen(int32_t pp_error); - - // Bring control back to the plugin by invoking the - // |translate_notify_callback_|. This does not set the ErrorInfo report, - // it is assumed that it was already set. - void ExitWithError(); - // Run |translate_notify_callback_| with an error condition that is not - // PPAPI specific. Also set ErrorInfo report. - void ReportNonPpapiError(PP_NaClError err, const std::string& message); - // Run when faced with a PPAPI error condition. Bring control back to the - // plugin by invoking the |translate_notify_callback_|. - // Also set ErrorInfo report. - void ReportPpapiError(PP_NaClError err, - int32_t pp_error, const std::string& message); - - - // Keeps track of the pp_error upon entry to TranslateFinished, - // for inspection after cleanup. - int32_t translate_finish_error_; - - // The plugin owning the nexe for which we are doing translation. - Plugin* plugin_; - - pp::CompletionCallback translate_notify_callback_; - // Set to true when the translation (if applicable) is finished and the nexe - // file is loaded, (or when there was an error), and the browser has been - // notified via ReportTranslationFinished. If it is not set before - // plugin/coordinator destruction, the destructor will call - // ReportTranslationFinished. - bool translation_finished_reported_; - // Threadsafety is required to support file lookups. - pp::CompletionCallbackFactory<PnaclCoordinator, - pp::ThreadSafeThreadTraits> callback_factory_; - - // An auxiliary class that manages downloaded resources (llc and ld nexes). - nacl::scoped_ptr<PnaclResources> resources_; - - // The URL for the pexe file. - std::string pexe_url_; - // Options for translation. - PP_PNaClOptions pnacl_options_; - // Architecture-specific attributes used for translation. These are - // supplied by Chrome, not the developer, and are therefore different - // from PNaCl options. - std::string architecture_attributes_; - - // Object file, produced by the translator and consumed by the linker. - std::vector<TempFile*> obj_files_; - nacl::scoped_ptr<nacl::DescWrapper> invalid_desc_wrapper_; - // Number of split modules (threads) for llc - int split_module_count_; - - // Translated nexe file, produced by the linker. - nacl::scoped_ptr<TempFile> temp_nexe_file_; - - // Used to report information when errors (PPAPI or otherwise) are reported. - ErrorInfo error_info_; - - // True if an error was already reported, and translate_notify_callback_ - // was already run/consumed. - bool error_already_reported_; - - // State for timing and size information for UMA stats. - int64_t pexe_size_; // Count as we stream -- will converge to pexe size. - int64_t pexe_bytes_compiled_; // Count as we compile. - int64_t expected_pexe_size_; // Expected download total (-1 if unknown). - - // The helper thread used to do translations via SRPC. - // It accesses fields of PnaclCoordinator so it must have a - // shorter lifetime. - nacl::scoped_ptr<PnaclTranslateThread> translate_thread_; -}; - -//---------------------------------------------------------------------- - -} // namespace plugin; -#endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_COORDINATOR_H_ diff --git a/chromium/ppapi/native_client/src/trusted/plugin/pnacl_resources.cc b/chromium/ppapi/native_client/src/trusted/plugin/pnacl_resources.cc deleted file mode 100644 index 4c48c7fd999..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/pnacl_resources.cc +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/native_client/src/trusted/plugin/pnacl_resources.h" - -#include "native_client/src/include/portability_io.h" -#include "native_client/src/shared/platform/nacl_check.h" -#include "native_client/src/trusted/desc/nacl_desc_wrapper.h" -#include "ppapi/c/pp_errors.h" -#include "ppapi/native_client/src/trusted/plugin/plugin.h" -#include "ppapi/native_client/src/trusted/plugin/utility.h" - -namespace plugin { - -namespace { - -static const char kPnaclBaseUrl[] = "chrome://pnacl-translator/"; - -std::string GetFullUrl(const std::string& partial_url) { - return std::string(kPnaclBaseUrl) + GetNaClInterface()->GetSandboxArch() + - "/" + partial_url; -} - -} // namespace - -PnaclResources::PnaclResources(Plugin* plugin) - : plugin_(plugin) { - llc_file_info_ = kInvalidNaClFileInfo; - ld_file_info_ = kInvalidNaClFileInfo; -} - -PnaclResources::~PnaclResources() { - if (llc_file_info_.handle != PP_kInvalidFileHandle) - CloseFileHandle(llc_file_info_.handle); - if (ld_file_info_.handle != PP_kInvalidFileHandle) - CloseFileHandle(ld_file_info_.handle); -} - -bool PnaclResources::ReadResourceInfo() { - PP_Var pp_llc_tool_name_var; - PP_Var pp_ld_tool_name_var; - if (!plugin_->nacl_interface()->GetPnaclResourceInfo( - plugin_->pp_instance(), - &pp_llc_tool_name_var, - &pp_ld_tool_name_var)) { - return false; - } - pp::Var llc_tool_name(pp::PASS_REF, pp_llc_tool_name_var); - pp::Var ld_tool_name(pp::PASS_REF, pp_ld_tool_name_var); - llc_tool_name_ = GetFullUrl(llc_tool_name.AsString()); - ld_tool_name_ = GetFullUrl(ld_tool_name.AsString()); - return true; -} - -PP_NaClFileInfo PnaclResources::TakeLlcFileInfo() { - PP_NaClFileInfo to_return = llc_file_info_; - llc_file_info_ = kInvalidNaClFileInfo; - return to_return; -} - -PP_NaClFileInfo PnaclResources::TakeLdFileInfo() { - PP_NaClFileInfo to_return = ld_file_info_; - ld_file_info_ = kInvalidNaClFileInfo; - return to_return; -} - -bool PnaclResources::StartLoad() { - PLUGIN_PRINTF(("PnaclResources::StartLoad\n")); - - // Do a blocking load of each of the resources. - plugin_->nacl_interface()->GetReadExecPnaclFd(llc_tool_name_.c_str(), - &llc_file_info_); - plugin_->nacl_interface()->GetReadExecPnaclFd(ld_tool_name_.c_str(), - &ld_file_info_); - return (llc_file_info_.handle != PP_kInvalidFileHandle && - ld_file_info_.handle != PP_kInvalidFileHandle); -} - -} // namespace plugin diff --git a/chromium/ppapi/native_client/src/trusted/plugin/pnacl_resources.h b/chromium/ppapi/native_client/src/trusted/plugin/pnacl_resources.h deleted file mode 100644 index 6795b2a4946..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/pnacl_resources.h +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_RESOURCES_H_ -#define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_RESOURCES_H_ - -#include <map> -#include <vector> - -#include "native_client/src/include/nacl_macros.h" -#include "native_client/src/trusted/desc/nacl_desc_wrapper.h" - -#include "ppapi/c/private/ppb_nacl_private.h" -#include "ppapi/cpp/completion_callback.h" - -#include "ppapi/native_client/src/trusted/plugin/plugin_error.h" - -namespace plugin { - -class Plugin; - -// Loads a list of resources, providing a way to get file descriptors for -// these resources. URLs for resources are resolved by the manifest -// and point to pnacl component filesystem resources. -class PnaclResources { - public: - explicit PnaclResources(Plugin* plugin); - virtual ~PnaclResources(); - - // Read the resource info JSON file. This is the first step after - // construction; it has to be completed before StartLoad is called. - bool ReadResourceInfo(); - - // Start loading the resources. - bool StartLoad(); - - const std::string& GetLlcUrl() { return llc_tool_name_; } - const std::string& GetLdUrl() { return ld_tool_name_; } - - PP_NaClFileInfo TakeLlcFileInfo(); - PP_NaClFileInfo TakeLdFileInfo(); - - private: - NACL_DISALLOW_COPY_AND_ASSIGN(PnaclResources); - - // The plugin requesting the resource loading. - Plugin* plugin_; - - // Tool names for llc and ld; read from the resource info file. - std::string llc_tool_name_; - std::string ld_tool_name_; - - // File info for llc and ld executables, after they've been opened. - // Only valid after the callback for StartLoad() has been called, and until - // TakeLlcFileInfo()/TakeLdFileInfo() is called. - PP_NaClFileInfo llc_file_info_; - PP_NaClFileInfo ld_file_info_; -}; - -} // namespace plugin -#endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_RESOURCES_H_ diff --git a/chromium/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc b/chromium/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc deleted file mode 100644 index 8acabebe2d2..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc +++ /dev/null @@ -1,441 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h" - -#include <iterator> - -#include "native_client/src/trusted/desc/nacl_desc_wrapper.h" -#include "ppapi/cpp/var.h" -#include "ppapi/native_client/src/trusted/plugin/plugin.h" -#include "ppapi/native_client/src/trusted/plugin/plugin_error.h" -#include "ppapi/native_client/src/trusted/plugin/pnacl_resources.h" -#include "ppapi/native_client/src/trusted/plugin/srpc_params.h" -#include "ppapi/native_client/src/trusted/plugin/temporary_file.h" -#include "ppapi/native_client/src/trusted/plugin/utility.h" - -namespace plugin { -namespace { - -template <typename Val> -std::string MakeCommandLineArg(const char* key, const Val val) { - std::stringstream ss; - ss << key << val; - return ss.str(); -} - -void GetLlcCommandLine(Plugin* plugin, - std::vector<char>* split_args, - size_t obj_files_size, - int32_t opt_level, - bool is_debug, - const std::string &architecture_attributes) { - typedef std::vector<std::string> Args; - Args args; - - // TODO(dschuff): This CL override is ugly. Change llc to default to - // using the number of modules specified in the first param, and - // ignore multiple uses of -split-module - args.push_back(MakeCommandLineArg("-split-module=", obj_files_size)); - args.push_back(MakeCommandLineArg("-O=", opt_level)); - if (is_debug) - args.push_back("-bitcode-format=llvm"); - if (!architecture_attributes.empty()) - args.push_back("-mattr=" + architecture_attributes); - - for (Args::const_iterator arg(args.begin()); arg != args.end(); ++arg) { - std::copy(arg->begin(), arg->end(), std::back_inserter(*split_args)); - split_args->push_back('\x00'); - } -} - -} // namespace - -PnaclTranslateThread::PnaclTranslateThread() : llc_subprocess_active_(false), - ld_subprocess_active_(false), - subprocesses_aborted_(false), - done_(false), - compile_time_(0), - obj_files_(NULL), - nexe_file_(NULL), - coordinator_error_info_(NULL), - resources_(NULL), - coordinator_(NULL), - plugin_(NULL) { - NaClXMutexCtor(&subprocess_mu_); - NaClXMutexCtor(&cond_mu_); - NaClXCondVarCtor(&buffer_cond_); -} - -void PnaclTranslateThread::RunTranslate( - const pp::CompletionCallback& finish_callback, - const std::vector<TempFile*>* obj_files, - TempFile* nexe_file, - nacl::DescWrapper* invalid_desc_wrapper, - ErrorInfo* error_info, - PnaclResources* resources, - PP_PNaClOptions* pnacl_options, - const std::string &architecture_attributes, - PnaclCoordinator* coordinator, - Plugin* plugin) { - PLUGIN_PRINTF(("PnaclStreamingTranslateThread::RunTranslate)\n")); - obj_files_ = obj_files; - nexe_file_ = nexe_file; - invalid_desc_wrapper_ = invalid_desc_wrapper; - coordinator_error_info_ = error_info; - resources_ = resources; - pnacl_options_ = pnacl_options; - architecture_attributes_ = architecture_attributes; - coordinator_ = coordinator; - plugin_ = plugin; - - // Invoke llc followed by ld off the main thread. This allows use of - // blocking RPCs that would otherwise block the JavaScript main thread. - report_translate_finished_ = finish_callback; - translate_thread_.reset(new NaClThread); - if (translate_thread_ == NULL) { - TranslateFailed(PP_NACL_ERROR_PNACL_THREAD_CREATE, - "could not allocate thread struct."); - return; - } - const int32_t kArbitraryStackSize = 128 * 1024; - if (!NaClThreadCreateJoinable(translate_thread_.get(), - DoTranslateThread, - this, - kArbitraryStackSize)) { - TranslateFailed(PP_NACL_ERROR_PNACL_THREAD_CREATE, - "could not create thread."); - translate_thread_.reset(NULL); - } -} - -// Called from main thread to send bytes to the translator. -void PnaclTranslateThread::PutBytes(const void* bytes, int32_t count) { - CHECK(bytes != NULL); - NaClXMutexLock(&cond_mu_); - data_buffers_.push_back(std::vector<char>()); - data_buffers_.back().insert(data_buffers_.back().end(), - static_cast<const char*>(bytes), - static_cast<const char*>(bytes) + count); - NaClXCondVarSignal(&buffer_cond_); - NaClXMutexUnlock(&cond_mu_); -} - -void PnaclTranslateThread::EndStream() { - NaClXMutexLock(&cond_mu_); - done_ = true; - NaClXCondVarSignal(&buffer_cond_); - NaClXMutexUnlock(&cond_mu_); -} - -void WINAPI PnaclTranslateThread::DoTranslateThread(void* arg) { - PnaclTranslateThread* translator = - reinterpret_cast<PnaclTranslateThread*>(arg); - translator->DoTranslate(); -} - -void PnaclTranslateThread::DoTranslate() { - ErrorInfo error_info; - SrpcParams params; - std::vector<nacl::DescWrapper*> llc_out_files; - size_t i; - for (i = 0; i < obj_files_->size(); i++) - llc_out_files.push_back((*obj_files_)[i]->write_wrapper()); - for (; i < PnaclCoordinator::kMaxTranslatorObjectFiles; i++) - llc_out_files.push_back(invalid_desc_wrapper_); - - pp::Core* core = pp::Module::Get()->core(); - int64_t llc_start_time = NaClGetTimeOfDayMicroseconds(); - PP_NaClFileInfo llc_file_info = resources_->TakeLlcFileInfo(); - // On success, ownership of llc_file_info is transferred. - NaClSubprocess* llc_subprocess = plugin_->LoadHelperNaClModule( - resources_->GetLlcUrl(), llc_file_info, &error_info); - if (llc_subprocess == NULL) { - if (llc_file_info.handle != PP_kInvalidFileHandle) - CloseFileHandle(llc_file_info.handle); - TranslateFailed(PP_NACL_ERROR_PNACL_LLC_SETUP, - "Compile process could not be created: " + - error_info.message()); - return; - } - GetNaClInterface()->LogTranslateTime( - "NaCl.Perf.PNaClLoadTime.LoadCompiler", - NaClGetTimeOfDayMicroseconds() - llc_start_time); - - { - nacl::MutexLocker ml(&subprocess_mu_); - // If we received a call to AbortSubprocesses() before we had a chance to - // set llc_subprocess_, shut down and clean up the subprocess started here. - if (subprocesses_aborted_) { - llc_subprocess->service_runtime()->Shutdown(); - delete llc_subprocess; - return; - } - llc_subprocess_.reset(llc_subprocess); - llc_subprocess = NULL; - llc_subprocess_active_ = true; - } - - int64_t compile_start_time = NaClGetTimeOfDayMicroseconds(); - bool init_success; - - std::vector<char> split_args; - GetLlcCommandLine(plugin_, - &split_args, - obj_files_->size(), - pnacl_options_->opt_level, - pnacl_options_->is_debug, - architecture_attributes_); - init_success = llc_subprocess_->InvokeSrpcMethod( - "StreamInitWithSplit", - "ihhhhhhhhhhhhhhhhC", - ¶ms, - static_cast<int>(obj_files_->size()), - llc_out_files[0]->desc(), - llc_out_files[1]->desc(), - llc_out_files[2]->desc(), - llc_out_files[3]->desc(), - llc_out_files[4]->desc(), - llc_out_files[5]->desc(), - llc_out_files[6]->desc(), - llc_out_files[7]->desc(), - llc_out_files[8]->desc(), - llc_out_files[9]->desc(), - llc_out_files[10]->desc(), - llc_out_files[11]->desc(), - llc_out_files[12]->desc(), - llc_out_files[13]->desc(), - llc_out_files[14]->desc(), - llc_out_files[15]->desc(), - &split_args[0], - split_args.size()); - if (!init_success) { - if (llc_subprocess_->srpc_client()->GetLastError() == - NACL_SRPC_RESULT_APP_ERROR) { - // The error message is only present if the error was returned from llc - TranslateFailed(PP_NACL_ERROR_PNACL_LLC_INTERNAL, - std::string("Stream init failed: ") + - std::string(params.outs()[0]->arrays.str)); - } else { - TranslateFailed(PP_NACL_ERROR_PNACL_LLC_INTERNAL, - "Stream init internal error"); - } - return; - } - PLUGIN_PRINTF(("PnaclCoordinator: StreamInit successful\n")); - - // llc process is started. - while(!done_ || data_buffers_.size() > 0) { - NaClXMutexLock(&cond_mu_); - while(!done_ && data_buffers_.size() == 0) { - NaClXCondVarWait(&buffer_cond_, &cond_mu_); - } - PLUGIN_PRINTF(("PnaclTranslateThread awake (done=%d, size=%" NACL_PRIuS - ")\n", - done_, data_buffers_.size())); - if (data_buffers_.size() > 0) { - std::vector<char> data; - data.swap(data_buffers_.front()); - data_buffers_.pop_front(); - NaClXMutexUnlock(&cond_mu_); - PLUGIN_PRINTF(("StreamChunk\n")); - if (!llc_subprocess_->InvokeSrpcMethod("StreamChunk", - "C", - ¶ms, - &data[0], - data.size())) { - if (llc_subprocess_->srpc_client()->GetLastError() != - NACL_SRPC_RESULT_APP_ERROR) { - // If the error was reported by the translator, then we fall through - // and call StreamEnd, which returns a string describing the error, - // which we can then send to the Javascript console. Otherwise just - // fail here, since the translator has probably crashed or asserted. - TranslateFailed(PP_NACL_ERROR_PNACL_LLC_INTERNAL, - "Compile stream chunk failed. " - "The PNaCl translator has probably crashed."); - return; - } - break; - } else { - PLUGIN_PRINTF(("StreamChunk Successful\n")); - core->CallOnMainThread( - 0, - coordinator_->GetCompileProgressCallback(data.size()), - PP_OK); - } - } else { - NaClXMutexUnlock(&cond_mu_); - } - } - PLUGIN_PRINTF(("PnaclTranslateThread done with chunks\n")); - // Finish llc. - if (!llc_subprocess_->InvokeSrpcMethod("StreamEnd", std::string(), ¶ms)) { - PLUGIN_PRINTF(("PnaclTranslateThread StreamEnd failed\n")); - if (llc_subprocess_->srpc_client()->GetLastError() == - NACL_SRPC_RESULT_APP_ERROR) { - // The error string is only present if the error was sent back from llc. - TranslateFailed(PP_NACL_ERROR_PNACL_LLC_INTERNAL, - params.outs()[3]->arrays.str); - } else { - TranslateFailed(PP_NACL_ERROR_PNACL_LLC_INTERNAL, - "Compile StreamEnd internal error"); - } - return; - } - compile_time_ = NaClGetTimeOfDayMicroseconds() - compile_start_time; - GetNaClInterface()->LogTranslateTime("NaCl.Perf.PNaClLoadTime.CompileTime", - compile_time_); - - // Shut down the llc subprocess. - NaClXMutexLock(&subprocess_mu_); - llc_subprocess_active_ = false; - llc_subprocess_.reset(NULL); - NaClXMutexUnlock(&subprocess_mu_); - - if(!RunLdSubprocess()) { - return; - } - core->CallOnMainThread(0, report_translate_finished_, PP_OK); -} - -bool PnaclTranslateThread::RunLdSubprocess() { - ErrorInfo error_info; - SrpcParams params; - - std::vector<nacl::DescWrapper*> ld_in_files; - size_t i; - for (i = 0; i < obj_files_->size(); i++) { - // Reset object file for reading first. - if (!(*obj_files_)[i]->Reset()) { - TranslateFailed(PP_NACL_ERROR_PNACL_LD_SETUP, - "Link process could not reset object file"); - return false; - } - ld_in_files.push_back((*obj_files_)[i]->read_wrapper()); - } - for (; i < PnaclCoordinator::kMaxTranslatorObjectFiles; i++) - ld_in_files.push_back(invalid_desc_wrapper_); - - nacl::DescWrapper* ld_out_file = nexe_file_->write_wrapper(); - int64_t ld_start_time = NaClGetTimeOfDayMicroseconds(); - PP_NaClFileInfo ld_file_info = resources_->TakeLdFileInfo(); - // On success, ownership of ld_file_info is transferred. - nacl::scoped_ptr<NaClSubprocess> ld_subprocess( - plugin_->LoadHelperNaClModule(resources_->GetLdUrl(), - ld_file_info, - &error_info)); - if (ld_subprocess.get() == NULL) { - if (ld_file_info.handle != PP_kInvalidFileHandle) - CloseFileHandle(ld_file_info.handle); - TranslateFailed(PP_NACL_ERROR_PNACL_LD_SETUP, - "Link process could not be created: " + - error_info.message()); - return false; - } - GetNaClInterface()->LogTranslateTime( - "NaCl.Perf.PNaClLoadTime.LoadLinker", - NaClGetTimeOfDayMicroseconds() - ld_start_time); - { - nacl::MutexLocker ml(&subprocess_mu_); - // If we received a call to AbortSubprocesses() before we had a chance to - // set llc_subprocess_, shut down and clean up the subprocess started here. - if (subprocesses_aborted_) { - ld_subprocess->service_runtime()->Shutdown(); - return false; - } - DCHECK(ld_subprocess_.get() == NULL); - ld_subprocess_.swap(ld_subprocess); - ld_subprocess_active_ = true; - } - - int64_t link_start_time = NaClGetTimeOfDayMicroseconds(); - // Run LD. - bool success = ld_subprocess_->InvokeSrpcMethod( - "RunWithSplit", - "ihhhhhhhhhhhhhhhhh", - ¶ms, - static_cast<int>(obj_files_->size()), - ld_in_files[0]->desc(), - ld_in_files[1]->desc(), - ld_in_files[2]->desc(), - ld_in_files[3]->desc(), - ld_in_files[4]->desc(), - ld_in_files[5]->desc(), - ld_in_files[6]->desc(), - ld_in_files[7]->desc(), - ld_in_files[8]->desc(), - ld_in_files[9]->desc(), - ld_in_files[10]->desc(), - ld_in_files[11]->desc(), - ld_in_files[12]->desc(), - ld_in_files[13]->desc(), - ld_in_files[14]->desc(), - ld_in_files[15]->desc(), - ld_out_file->desc()); - if (!success) { - TranslateFailed(PP_NACL_ERROR_PNACL_LD_INTERNAL, - "link failed."); - return false; - } - GetNaClInterface()->LogTranslateTime( - "NaCl.Perf.PNaClLoadTime.LinkTime", - NaClGetTimeOfDayMicroseconds() - link_start_time); - PLUGIN_PRINTF(("PnaclCoordinator: link (translator=%p) succeeded\n", - this)); - // Shut down the ld subprocess. - NaClXMutexLock(&subprocess_mu_); - ld_subprocess_active_ = false; - ld_subprocess_.reset(NULL); - NaClXMutexUnlock(&subprocess_mu_); - return true; -} - -void PnaclTranslateThread::TranslateFailed( - PP_NaClError err_code, - const std::string& error_string) { - PLUGIN_PRINTF(("PnaclTranslateThread::TranslateFailed (error_string='%s')\n", - error_string.c_str())); - pp::Core* core = pp::Module::Get()->core(); - if (coordinator_error_info_->message().empty()) { - // Only use our message if one hasn't already been set by the coordinator - // (e.g. pexe load failed). - coordinator_error_info_->SetReport(err_code, - std::string("PnaclCoordinator: ") + - error_string); - } - core->CallOnMainThread(0, report_translate_finished_, PP_ERROR_FAILED); -} - -void PnaclTranslateThread::AbortSubprocesses() { - PLUGIN_PRINTF(("PnaclTranslateThread::AbortSubprocesses\n")); - NaClXMutexLock(&subprocess_mu_); - if (llc_subprocess_ != NULL && llc_subprocess_active_) { - llc_subprocess_->service_runtime()->Shutdown(); - llc_subprocess_active_ = false; - } - if (ld_subprocess_ != NULL && ld_subprocess_active_) { - ld_subprocess_->service_runtime()->Shutdown(); - ld_subprocess_active_ = false; - } - subprocesses_aborted_ = true; - NaClXMutexUnlock(&subprocess_mu_); - nacl::MutexLocker ml(&cond_mu_); - done_ = true; - // Free all buffered bitcode chunks - data_buffers_.clear(); - NaClXCondVarSignal(&buffer_cond_); -} - -PnaclTranslateThread::~PnaclTranslateThread() { - PLUGIN_PRINTF(("~PnaclTranslateThread (translate_thread=%p)\n", this)); - AbortSubprocesses(); - if (translate_thread_ != NULL) - NaClThreadJoin(translate_thread_.get()); - PLUGIN_PRINTF(("~PnaclTranslateThread joined\n")); - NaClCondVarDtor(&buffer_cond_); - NaClMutexDtor(&cond_mu_); - NaClMutexDtor(&subprocess_mu_); -} - -} // namespace plugin diff --git a/chromium/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h b/chromium/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h deleted file mode 100644 index 45656e79236..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_TRANSLATE_THREAD_H_ -#define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_TRANSLATE_THREAD_H_ - -#include <deque> -#include <vector> - -#include "native_client/src/include/nacl_macros.h" -#include "native_client/src/include/nacl_scoped_ptr.h" -#include "native_client/src/shared/platform/nacl_threads.h" -#include "native_client/src/shared/platform/nacl_sync_checked.h" - -#include "ppapi/cpp/completion_callback.h" - -#include "ppapi/native_client/src/trusted/plugin/plugin_error.h" -#include "ppapi/native_client/src/trusted/plugin/service_runtime.h" - -struct PP_PNaClOptions; - -namespace nacl { -class DescWrapper; -} - - -namespace plugin { - -class NaClSubprocess; -class Plugin; -class PnaclCoordinator; -class PnaclResources; -class TempFile; - -class PnaclTranslateThread { - public: - PnaclTranslateThread(); - ~PnaclTranslateThread(); - - // Start the translation process. It will continue to run and consume data - // as it is passed in with PutBytes. - void RunTranslate(const pp::CompletionCallback& finish_callback, - const std::vector<TempFile*>* obj_files, - TempFile* nexe_file, - nacl::DescWrapper* invalid_desc_wrapper, - ErrorInfo* error_info, - PnaclResources* resources, - PP_PNaClOptions* pnacl_options, - const std::string &architecture_attributes, - PnaclCoordinator* coordinator, - Plugin* plugin); - - // Kill the llc and/or ld subprocesses. This happens by closing the command - // channel on the plugin side, which causes the trusted code in the nexe to - // exit, which will cause any pending SRPCs to error. Because this is called - // on the main thread, the translation thread must not use the subprocess - // objects without the lock, other than InvokeSrpcMethod, which does not - // race with service runtime shutdown. - void AbortSubprocesses(); - - // Send bitcode bytes to the translator. Called from the main thread. - void PutBytes(const void* data, int count); - - // Notify the translator that the end of the bitcode stream has been reached. - // Called from the main thread. - void EndStream(); - - int64_t GetCompileTime() const { return compile_time_; } - - // Returns true if RunTranslate() has been called, false otherwise. - bool started() const { return plugin_ != NULL; } - - private: - // Helper thread entry point for translation. Takes a pointer to - // PnaclTranslateThread and calls DoTranslate(). - static void WINAPI DoTranslateThread(void* arg); - // Runs the streaming translation. Called from the helper thread. - void DoTranslate() ; - // Signal that Pnacl translation failed, from the translation thread only. - void TranslateFailed(PP_NaClError err_code, - const std::string& error_string); - // Run the LD subprocess, returning true on success. - // On failure, it returns false and runs the callback. - bool RunLdSubprocess(); - - - // Callback to run when tasks are completed or an error has occurred. - pp::CompletionCallback report_translate_finished_; - - nacl::scoped_ptr<NaClThread> translate_thread_; - - // Used to guard llc_subprocess and ld_subprocess - struct NaClMutex subprocess_mu_; - nacl::scoped_ptr<NaClSubprocess> llc_subprocess_; - nacl::scoped_ptr<NaClSubprocess> ld_subprocess_; - // Used to ensure the subprocesses don't get shutdown more than once. - bool llc_subprocess_active_; - bool ld_subprocess_active_; - - bool subprocesses_aborted_; - - // Condition variable to synchronize communication with the SRPC thread. - // SRPC thread waits on this condvar if data_buffers_ is empty (meaning - // there is no bitcode to send to the translator), and the main thread - // appends to data_buffers_ and signals it when it receives bitcode. - struct NaClCondVar buffer_cond_; - // Mutex for buffer_cond_. - struct NaClMutex cond_mu_; - // Data buffers from FileDownloader are enqueued here to pass from the - // main thread to the SRPC thread. Protected by cond_mu_ - std::deque<std::vector<char> > data_buffers_; - // Whether all data has been downloaded and copied to translation thread. - // Associated with buffer_cond_ - bool done_; - - int64_t compile_time_; - - // Data about the translation files, owned by the coordinator - const std::vector<TempFile*>* obj_files_; - TempFile* nexe_file_; - nacl::DescWrapper* invalid_desc_wrapper_; - ErrorInfo* coordinator_error_info_; - PnaclResources* resources_; - PP_PNaClOptions* pnacl_options_; - std::string architecture_attributes_; - PnaclCoordinator* coordinator_; - Plugin* plugin_; - private: - NACL_DISALLOW_COPY_AND_ASSIGN(PnaclTranslateThread); -}; - -} -#endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_TRANSLATE_THREAD_H_ diff --git a/chromium/ppapi/native_client/src/trusted/plugin/ppapi_entrypoints.cc b/chromium/ppapi/native_client/src/trusted/plugin/ppapi_entrypoints.cc deleted file mode 100644 index 51f4f575136..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/ppapi_entrypoints.cc +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2014 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/native_client/src/trusted/plugin/ppapi_entrypoints.h" - -#include "ppapi/c/pp_errors.h" -#include "ppapi/c/pp_module.h" -#include "ppapi/c/ppb.h" -#include "ppapi/cpp/module.h" -#include "ppapi/cpp/private/internal_module.h" -#include "ppapi/native_client/src/trusted/plugin/module_ppapi.h" - -namespace nacl_plugin { - -int32_t PPP_InitializeModule(PP_Module module_id, - PPB_GetInterface get_browser_interface) { - plugin::ModulePpapi* module = new plugin::ModulePpapi(); - if (!module->InternalInit(module_id, get_browser_interface)) { - delete module; - return PP_ERROR_FAILED; - } - - pp::InternalSetModuleSingleton(module); - return PP_OK; -} - -void PPP_ShutdownModule() { - delete pp::Module::Get(); - pp::InternalSetModuleSingleton(NULL); -} - -const void* PPP_GetInterface(const char* interface_name) { - if (!pp::Module::Get()) - return NULL; - return pp::Module::Get()->GetPluginInterface(interface_name); -} - -} // namespace nacl_plugin diff --git a/chromium/ppapi/native_client/src/trusted/plugin/ppapi_entrypoints.h b/chromium/ppapi/native_client/src/trusted/plugin/ppapi_entrypoints.h deleted file mode 100644 index 6681c2e2066..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/ppapi_entrypoints.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2014 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_NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PPAPI_ENTRYPOINTS_H_ -#define PPAPI_NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PPAPI_ENTRYPOINTS_H_ - -#include "ppapi/c/pp_module.h" -#include "ppapi/c/ppb.h" - -// Provides entry points for the trusted plugin. -namespace nacl_plugin { - -int PPP_InitializeModule(PP_Module module, - PPB_GetInterface get_browser_interface); -const void* PPP_GetInterface(const char* interface_name); -void PPP_ShutdownModule(); - -} // namespace nacl_plugin - -#endif // PPAPI_NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PPAPI_ENTRYPOINTS_H_ diff --git a/chromium/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc b/chromium/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc deleted file mode 100644 index fd76135693e..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "native_client/src/include/nacl_macros.h" -#include "native_client/src/shared/platform/nacl_check.h" -#include "ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h" - -namespace plugin { - -bool SelLdrLauncherChrome::Start(const char* url) { - NACL_NOTREACHED(); - return false; -} - -void SelLdrLauncherChrome::set_channel(NaClHandle channel) { - CHECK(channel_ == NACL_INVALID_HANDLE); - channel_ = channel; -} - -} // namespace plugin diff --git a/chromium/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h b/chromium/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h deleted file mode 100644 index c8857d84d81..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef PPAPI_NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SEL_LDR_LAUNCHER_CHROME_H_ -#define PPAPI_NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SEL_LDR_LAUNCHER_CHROME_H_ - -#include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h" -#include "ppapi/c/pp_instance.h" -#include "ppapi/c/private/ppb_nacl_private.h" -#include "ppapi/cpp/completion_callback.h" - -namespace plugin { - -class SelLdrLauncherChrome : public nacl::SelLdrLauncherBase { - public: - virtual bool Start(const char* url); - - // Provides a way for LaunchSelLdr() to write bootstrap channel information - // into this class. - void set_channel(NaClHandle channel); -}; - -} // namespace plugin - -#endif diff --git a/chromium/ppapi/native_client/src/trusted/plugin/service_runtime.cc b/chromium/ppapi/native_client/src/trusted/plugin/service_runtime.cc deleted file mode 100644 index c949907b42f..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/service_runtime.cc +++ /dev/null @@ -1,566 +0,0 @@ -/* - * Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#define NACL_LOG_MODULE_NAME "Plugin_ServiceRuntime" - -#include "ppapi/native_client/src/trusted/plugin/service_runtime.h" - -#include <string.h> -#include <string> -#include <utility> - -#include "base/compiler_specific.h" - -#include "native_client/src/include/portability_io.h" -#include "native_client/src/include/portability_string.h" -#include "native_client/src/include/nacl_macros.h" -#include "native_client/src/include/nacl_scoped_ptr.h" -#include "native_client/src/shared/platform/nacl_check.h" -#include "native_client/src/shared/platform/nacl_log.h" -#include "native_client/src/shared/platform/nacl_sync.h" -#include "native_client/src/shared/platform/nacl_sync_checked.h" -#include "native_client/src/shared/platform/nacl_sync_raii.h" -#include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h" - -#include "native_client/src/public/imc_types.h" -#include "native_client/src/public/nacl_file_info.h" -#include "native_client/src/trusted/service_runtime/nacl_error_code.h" - -#include "ppapi/c/pp_errors.h" -#include "ppapi/cpp/core.h" -#include "ppapi/cpp/completion_callback.h" - -#include "ppapi/native_client/src/trusted/plugin/plugin.h" -#include "ppapi/native_client/src/trusted/plugin/plugin_error.h" -#include "ppapi/native_client/src/trusted/plugin/pnacl_resources.h" -#include "ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h" -#include "ppapi/native_client/src/trusted/plugin/srpc_client.h" -#include "ppapi/native_client/src/trusted/plugin/utility.h" -#include "ppapi/native_client/src/trusted/weak_ref/call_on_main_thread.h" - -namespace plugin { - -OpenManifestEntryResource::~OpenManifestEntryResource() { -} - -PluginReverseInterface::PluginReverseInterface( - nacl::WeakRefAnchor* anchor, - PP_Instance pp_instance, - ServiceRuntime* service_runtime, - pp::CompletionCallback init_done_cb) - : anchor_(anchor), - pp_instance_(pp_instance), - service_runtime_(service_runtime), - shutting_down_(false), - init_done_cb_(init_done_cb) { - NaClXMutexCtor(&mu_); - NaClXCondVarCtor(&cv_); -} - -PluginReverseInterface::~PluginReverseInterface() { - NaClCondVarDtor(&cv_); - NaClMutexDtor(&mu_); -} - -void PluginReverseInterface::ShutDown() { - NaClLog(4, "PluginReverseInterface::Shutdown: entered\n"); - nacl::MutexLocker take(&mu_); - shutting_down_ = true; - NaClXCondVarBroadcast(&cv_); - NaClLog(4, "PluginReverseInterface::Shutdown: broadcasted, exiting\n"); -} - -void PluginReverseInterface::DoPostMessage(std::string message) { - // This feature is no longer used. - // TODO(teravest): Remove this once this is gone from nacl::ReverseInterface. -} - -void PluginReverseInterface::StartupInitializationComplete() { - NaClLog(4, "PluginReverseInterface::StartupInitializationComplete\n"); - if (init_done_cb_.pp_completion_callback().func != NULL) { - NaClLog(4, - "PluginReverseInterface::StartupInitializationComplete:" - " invoking CB\n"); - pp::Module::Get()->core()->CallOnMainThread(0, init_done_cb_, PP_OK); - } else { - NaClLog(1, - "PluginReverseInterface::StartupInitializationComplete:" - " init_done_cb_ not valid, skipping.\n"); - } -} - -// TODO(bsy): OpenManifestEntry should use the manifest to ResolveKey -// and invoke StreamAsFile with a completion callback that invokes -// GetPOSIXFileDesc. -bool PluginReverseInterface::OpenManifestEntry(std::string url_key, - struct NaClFileInfo* info) { - // This method should only ever be called from the PNaCl translator, as the - // IRT is not available there. - // TODO(teravest): Remove support for OpenManifestEntry here once - // crbug.com/302078 is resolved. - if (service_runtime_->main_service_runtime()) { - NaClLog(LOG_ERROR, - "OpenManifestEntry should only be used by PNaCl translator.\n"); - return false; - } - - bool op_complete = false; // NB: mu_ and cv_ also controls access to this! - // The to_open object is owned by the weak ref callback. Because this function - // waits for the callback to finish, the to_open object will be deallocated on - // the main thread before this function can return. The pointers it contains - // to stack variables will not leak. - OpenManifestEntryResource* to_open = - new OpenManifestEntryResource(url_key, info, &op_complete); - CHECK(to_open != NULL); - NaClLog(4, "PluginReverseInterface::OpenManifestEntry: %s\n", - url_key.c_str()); - // This assumes we are not on the main thread. If false, we deadlock. - plugin::WeakRefCallOnMainThread( - anchor_, - 0, - this, - &plugin::PluginReverseInterface::OpenManifestEntry_MainThreadContinuation, - to_open); - NaClLog(4, - "PluginReverseInterface::OpenManifestEntry:" - " waiting on main thread\n"); - - { - nacl::MutexLocker take(&mu_); - while (!shutting_down_ && !op_complete) - NaClXCondVarWait(&cv_, &mu_); - NaClLog(4, "PluginReverseInterface::OpenManifestEntry: done!\n"); - if (shutting_down_) { - NaClLog(4, - "PluginReverseInterface::OpenManifestEntry:" - " plugin is shutting down\n"); - return false; - } - } - - // info->desc has the returned descriptor if successful, else -1. - - // The caller is responsible for not closing info->desc. If it is - // closed prematurely, then another open could re-use the OS - // descriptor, confusing the opened_ map. If the caller is going to - // want to make a NaClDesc object and transfer it etc., then the - // caller should DUP the descriptor (but remember the original - // value) for use by the NaClDesc object, which closes when the - // object is destroyed. - NaClLog(4, - "PluginReverseInterface::OpenManifestEntry: info->desc = %d\n", - info->desc); - if (info->desc == -1) { - // TODO(bsy,ncbray): what else should we do with the error? This - // is a runtime error that may simply be a programming error in - // the untrusted code, or it may be something else wrong w/ the - // manifest. - NaClLog(4, "OpenManifestEntry: failed for key %s", url_key.c_str()); - } - return true; -} - -// Transfer point from OpenManifestEntry() which runs on the main thread -// (Some PPAPI actions -- like StreamAsFile -- can only run on the main thread). -// OpenManifestEntry() is waiting on a condvar for this continuation to -// complete. We Broadcast and awaken OpenManifestEntry() whenever we are done -// either here, or in a later MainThreadContinuation step, if there are -// multiple steps. -void PluginReverseInterface::OpenManifestEntry_MainThreadContinuation( - OpenManifestEntryResource* p, - int32_t err) { - UNREFERENCED_PARAMETER(err); - // CallOnMainThread continuations always called with err == PP_OK. - - NaClLog(4, "Entered OpenManifestEntry_MainThreadContinuation\n"); - - // Because p is owned by the callback of this invocation, so it is necessary - // to create another instance. - OpenManifestEntryResource* open_cont = new OpenManifestEntryResource(*p); - pp::CompletionCallback stream_cc = WeakRefNewCallback( - anchor_, - this, - &PluginReverseInterface::StreamAsFile_MainThreadContinuation, - open_cont); - - GetNaClInterface()->OpenManifestEntry( - pp_instance_, - PP_FromBool(!service_runtime_->main_service_runtime()), - p->url.c_str(), - &open_cont->pp_file_info, - stream_cc.pp_completion_callback()); - // p is deleted automatically. -} - -void PluginReverseInterface::StreamAsFile_MainThreadContinuation( - OpenManifestEntryResource* p, - int32_t result) { - NaClLog(4, "Entered StreamAsFile_MainThreadContinuation\n"); - { - nacl::MutexLocker take(&mu_); - if (result == PP_OK) { - // We downloaded this file to temporary storage for this plugin; it's - // reasonable to provide a file descriptor with write access. - p->file_info->desc = ConvertFileDescriptor(p->pp_file_info.handle, false); - p->file_info->file_token.lo = p->pp_file_info.token_lo; - p->file_info->file_token.hi = p->pp_file_info.token_hi; - NaClLog(4, - "StreamAsFile_MainThreadContinuation: PP_OK, desc %d\n", - p->file_info->desc); - } else { - NaClLog( - 4, - "StreamAsFile_MainThreadContinuation: !PP_OK, setting desc -1\n"); - p->file_info->desc = -1; - } - *p->op_complete_ptr = true; - NaClXCondVarBroadcast(&cv_); - } -} - -void PluginReverseInterface::ReportCrash() { - // This is now handled through Chromium IPC. -} - -void PluginReverseInterface::ReportExitStatus(int exit_status) { - // We do nothing here; reporting exit status is handled through a separate - // embedder interface. -} - -int64_t PluginReverseInterface::RequestQuotaForWrite( - std::string file_id, int64_t offset, int64_t bytes_to_write) { - return bytes_to_write; -} - -ServiceRuntime::ServiceRuntime(Plugin* plugin, - PP_Instance pp_instance, - bool main_service_runtime, - bool uses_nonsfi_mode, - pp::CompletionCallback init_done_cb) - : plugin_(plugin), - pp_instance_(pp_instance), - main_service_runtime_(main_service_runtime), - uses_nonsfi_mode_(uses_nonsfi_mode), - reverse_service_(NULL), - anchor_(new nacl::WeakRefAnchor()), - rev_interface_(new PluginReverseInterface(anchor_, pp_instance, this, - init_done_cb)), - start_sel_ldr_done_(false), - start_nexe_done_(false), - nexe_started_ok_(false), - bootstrap_channel_(NACL_INVALID_HANDLE) { - NaClSrpcChannelInitialize(&command_channel_); - NaClXMutexCtor(&mu_); - NaClXCondVarCtor(&cond_); -} - -bool ServiceRuntime::SetupCommandChannel() { - NaClLog(4, "ServiceRuntime::SetupCommand (this=%p, subprocess=%p)\n", - static_cast<void*>(this), - static_cast<void*>(subprocess_.get())); - // Set up the bootstrap channel in our subprocess so that we can establish - // SRPC. - subprocess_->set_channel(bootstrap_channel_); - - if (uses_nonsfi_mode_) { - // In non-SFI mode, no SRPC is used. Just skips and returns success. - return true; - } - - if (!subprocess_->SetupCommand(&command_channel_)) { - ErrorInfo error_info; - error_info.SetReport(PP_NACL_ERROR_SEL_LDR_COMMUNICATION_CMD_CHANNEL, - "ServiceRuntime: command channel creation failed"); - ReportLoadError(error_info); - return false; - } - return true; -} - -bool ServiceRuntime::InitReverseService() { - if (uses_nonsfi_mode_) { - // In non-SFI mode, no reverse service is set up. Just returns success. - return true; - } - - // Hook up the reverse service channel. We are the IMC client, but - // provide SRPC service. - NaClDesc* out_conn_cap; - NaClSrpcResultCodes rpc_result = - NaClSrpcInvokeBySignature(&command_channel_, - "reverse_setup::h", - &out_conn_cap); - - if (NACL_SRPC_RESULT_OK != rpc_result) { - ErrorInfo error_info; - error_info.SetReport(PP_NACL_ERROR_SEL_LDR_COMMUNICATION_REV_SETUP, - "ServiceRuntime: reverse setup rpc failed"); - ReportLoadError(error_info); - return false; - } - // Get connection capability to service runtime where the IMC - // server/SRPC client is waiting for a rendezvous. - NaClLog(4, "ServiceRuntime: got 0x%" NACL_PRIxPTR "\n", - (uintptr_t) out_conn_cap); - nacl::DescWrapper* conn_cap = plugin_->wrapper_factory()->MakeGenericCleanup( - out_conn_cap); - if (conn_cap == NULL) { - ErrorInfo error_info; - error_info.SetReport(PP_NACL_ERROR_SEL_LDR_COMMUNICATION_WRAPPER, - "ServiceRuntime: wrapper allocation failure"); - ReportLoadError(error_info); - return false; - } - out_conn_cap = NULL; // ownership passed - NaClLog(4, "ServiceRuntime::InitReverseService: starting reverse service\n"); - reverse_service_ = new nacl::ReverseService(conn_cap, rev_interface_->Ref()); - if (!reverse_service_->Start()) { - ErrorInfo error_info; - error_info.SetReport(PP_NACL_ERROR_SEL_LDR_COMMUNICATION_REV_SERVICE, - "ServiceRuntime: starting reverse services failed"); - ReportLoadError(error_info); - return false; - } - return true; -} - -bool ServiceRuntime::StartModule() { - // start the module. otherwise we cannot connect for multimedia - // subsystem since that is handled by user-level code (not secure!) - // in libsrpc. - int load_status = -1; - if (uses_nonsfi_mode_) { - // In non-SFI mode, we don't need to call start_module SRPC to launch - // the plugin. - load_status = LOAD_OK; - } else { - NaClSrpcResultCodes rpc_result = - NaClSrpcInvokeBySignature(&command_channel_, - "start_module::i", - &load_status); - - if (NACL_SRPC_RESULT_OK != rpc_result) { - ErrorInfo error_info; - error_info.SetReport(PP_NACL_ERROR_SEL_LDR_START_MODULE, - "ServiceRuntime: could not start nacl module"); - ReportLoadError(error_info); - return false; - } - } - - NaClLog(4, "ServiceRuntime::StartModule (load_status=%d)\n", load_status); - if (main_service_runtime_) { - if (load_status < 0 || load_status > NACL_ERROR_CODE_MAX) - load_status = LOAD_STATUS_UNKNOWN; - GetNaClInterface()->ReportSelLdrStatus(pp_instance_, - load_status, - NACL_ERROR_CODE_MAX); - } - - if (LOAD_OK != load_status) { - ErrorInfo error_info; - error_info.SetReport( - PP_NACL_ERROR_SEL_LDR_START_STATUS, - NaClErrorString(static_cast<NaClErrorCode>(load_status))); - ReportLoadError(error_info); - return false; - } - return true; -} - -void ServiceRuntime::StartSelLdr(const SelLdrStartParams& params, - pp::CompletionCallback callback) { - NaClLog(4, "ServiceRuntime::Start\n"); - - nacl::scoped_ptr<SelLdrLauncherChrome> - tmp_subprocess(new SelLdrLauncherChrome()); - if (NULL == tmp_subprocess.get()) { - NaClLog(LOG_ERROR, "ServiceRuntime::Start (subprocess create failed)\n"); - ErrorInfo error_info; - error_info.SetReport( - PP_NACL_ERROR_SEL_LDR_CREATE_LAUNCHER, - "ServiceRuntime: failed to create sel_ldr launcher"); - ReportLoadError(error_info); - pp::Module::Get()->core()->CallOnMainThread(0, callback, PP_ERROR_FAILED); - return; - } - - bool enable_dev_interfaces = - GetNaClInterface()->DevInterfacesEnabled(pp_instance_); - - GetNaClInterface()->LaunchSelLdr( - pp_instance_, - PP_FromBool(main_service_runtime_), - params.url.c_str(), - ¶ms.file_info, - PP_FromBool(uses_nonsfi_mode_), - PP_FromBool(enable_dev_interfaces), - params.process_type, - &bootstrap_channel_, - callback.pp_completion_callback()); - subprocess_.reset(tmp_subprocess.release()); -} - -bool ServiceRuntime::WaitForSelLdrStart() { - // Time to wait on condvar (for browser to create a new sel_ldr process on - // our behalf). Use 6 seconds to be *fairly* conservative. - // - // On surfaway, the CallOnMainThread above may never get scheduled - // to unblock this condvar, or the IPC reply from the browser to renderer - // might get canceled/dropped. However, it is currently important to - // avoid waiting indefinitely because ~PnaclCoordinator will attempt to - // join() the PnaclTranslateThread, and the PnaclTranslateThread is waiting - // for the signal before exiting. - static int64_t const kWaitTimeMicrosecs = 6 * NACL_MICROS_PER_UNIT; - int64_t left_to_wait = kWaitTimeMicrosecs; - int64_t deadline = NaClGetTimeOfDayMicroseconds() + left_to_wait; - nacl::MutexLocker take(&mu_); - while(!start_sel_ldr_done_ && left_to_wait > 0) { - struct nacl_abi_timespec left_timespec; - left_timespec.tv_sec = left_to_wait / NACL_MICROS_PER_UNIT; - left_timespec.tv_nsec = - (left_to_wait % NACL_MICROS_PER_UNIT) * NACL_NANOS_PER_MICRO; - NaClXCondVarTimedWaitRelative(&cond_, &mu_, &left_timespec); - int64_t now = NaClGetTimeOfDayMicroseconds(); - left_to_wait = deadline - now; - } - return start_sel_ldr_done_; -} - -void ServiceRuntime::SignalStartSelLdrDone() { - nacl::MutexLocker take(&mu_); - start_sel_ldr_done_ = true; - NaClXCondVarSignal(&cond_); -} - -bool ServiceRuntime::WaitForNexeStart() { - nacl::MutexLocker take(&mu_); - while (!start_nexe_done_) - NaClXCondVarWait(&cond_, &mu_); - return nexe_started_ok_; -} - -void ServiceRuntime::SignalNexeStarted(bool ok) { - nacl::MutexLocker take(&mu_); - start_nexe_done_ = true; - nexe_started_ok_ = ok; - NaClXCondVarSignal(&cond_); -} - -void ServiceRuntime::StartNexe() { - bool ok = StartNexeInternal(); - if (ok) { - NaClLog(4, "ServiceRuntime::StartNexe (success)\n"); - } else { - ReapLogs(); - } - // This only matters if a background thread is waiting, but we signal in all - // cases to simplify the code. - SignalNexeStarted(ok); -} - -bool ServiceRuntime::StartNexeInternal() { - if (!SetupCommandChannel()) - return false; - if (!InitReverseService()) - return false; - return StartModule(); -} - -void ServiceRuntime::ReapLogs() { - // TODO(teravest): We should allow the NaCl process to crash itself when a - // module fails to start, and remove the call to RemoteLog() here. The - // reverse channel is no longer needed for crash reporting. - // - // The reasoning behind the current code behavior follows: - // On a load failure the NaCl process does not crash itself to - // avoid a race where the no-more-senders error on the reverse - // channel service thread might cause the crash-detection logic to - // kick in before the start_module RPC reply has been received. So - // we induce a NaCl process crash here. - RemoteLog(LOG_FATAL, "reap logs\n"); - - // TODO(teravest): Release subprocess_ here since it's no longer needed. It - // was previously kept around to collect crash log output from the bootstrap - // channel. -} - -void ServiceRuntime::ReportLoadError(const ErrorInfo& error_info) { - if (main_service_runtime_) { - plugin_->ReportLoadError(error_info); - } -} - -SrpcClient* ServiceRuntime::SetupAppChannel() { - NaClLog(4, "ServiceRuntime::SetupAppChannel (subprocess_=%p)\n", - reinterpret_cast<void*>(subprocess_.get())); - nacl::DescWrapper* connect_desc = subprocess_->socket_addr()->Connect(); - if (NULL == connect_desc) { - NaClLog(LOG_ERROR, "ServiceRuntime::SetupAppChannel (connect failed)\n"); - return NULL; - } else { - NaClLog(4, "ServiceRuntime::SetupAppChannel (conect_desc=%p)\n", - static_cast<void*>(connect_desc)); - SrpcClient* srpc_client = SrpcClient::New(connect_desc); - NaClLog(4, "ServiceRuntime::SetupAppChannel (srpc_client=%p)\n", - static_cast<void*>(srpc_client)); - delete connect_desc; - return srpc_client; - } -} - -bool ServiceRuntime::RemoteLog(int severity, const std::string& msg) { - NaClSrpcResultCodes rpc_result = - NaClSrpcInvokeBySignature(&command_channel_, - "log:is:", - severity, - strdup(msg.c_str())); - return (NACL_SRPC_RESULT_OK == rpc_result); -} - -void ServiceRuntime::Shutdown() { - rev_interface_->ShutDown(); - anchor_->Abandon(); - // Abandon callbacks, tell service threads to quit if they were - // blocked waiting for main thread operations to finish. Note that - // some callbacks must still await their completion event, e.g., - // CallOnMainThread must still wait for the time out, or I/O events - // must finish, so resources associated with pending events cannot - // be deallocated. - - // Note that this does waitpid() to get rid of any zombie subprocess. - subprocess_.reset(NULL); - - NaClSrpcDtor(&command_channel_); - - // subprocess_ has been shut down, but threads waiting on messages - // from the service runtime may not have noticed yet. The low-level - // NaClSimpleRevService code takes care to refcount the data objects - // that it needs, and reverse_service_ is also refcounted. We wait - // for the service threads to get their EOF indications. - if (reverse_service_ != NULL) { - reverse_service_->WaitForServiceThreadsToExit(); - reverse_service_->Unref(); - reverse_service_ = NULL; - } -} - -ServiceRuntime::~ServiceRuntime() { - NaClLog(4, "ServiceRuntime::~ServiceRuntime (this=%p)\n", - static_cast<void*>(this)); - // We do this just in case Shutdown() was not called. - subprocess_.reset(NULL); - if (reverse_service_ != NULL) - reverse_service_->Unref(); - - rev_interface_->Unref(); - - anchor_->Unref(); - NaClCondVarDtor(&cond_); - NaClMutexDtor(&mu_); -} - -} // namespace plugin diff --git a/chromium/ppapi/native_client/src/trusted/plugin/service_runtime.h b/chromium/ppapi/native_client/src/trusted/plugin/service_runtime.h deleted file mode 100644 index a9341019f2d..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/service_runtime.h +++ /dev/null @@ -1,203 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -// A class containing information regarding a socket connection to a -// service runtime instance. - -#ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_ -#define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_ - -#include "native_client/src/include/nacl_macros.h" -#include "native_client/src/include/nacl_scoped_ptr.h" -#include "native_client/src/shared/platform/nacl_sync.h" -#include "native_client/src/shared/srpc/nacl_srpc.h" -#include "native_client/src/trusted/reverse_service/reverse_service.h" -#include "native_client/src/trusted/weak_ref/weak_ref.h" - -#include "ppapi/cpp/completion_callback.h" -#include "ppapi/native_client/src/trusted/plugin/utility.h" - -struct NaClFileInfo; - -namespace plugin { - -class ErrorInfo; -class Plugin; -class SelLdrLauncherChrome; -class SrpcClient; -class ServiceRuntime; - -// Struct of params used by StartSelLdr. Use a struct so that callback -// creation templates aren't overwhelmed with too many parameters. -struct SelLdrStartParams { - SelLdrStartParams(const std::string& url, - const PP_NaClFileInfo& file_info, - PP_NaClAppProcessType process_type) - : url(url), - file_info(file_info), - process_type(process_type) { - } - std::string url; - PP_NaClFileInfo file_info; - PP_NaClAppProcessType process_type; -}; - -// Callback resources are essentially our continuation state. -struct OpenManifestEntryResource { - public: - OpenManifestEntryResource(const std::string& target_url, - struct NaClFileInfo* finfo, - bool* op_complete) - : url(target_url), - file_info(finfo), - op_complete_ptr(op_complete) {} - ~OpenManifestEntryResource(); - - std::string url; - struct NaClFileInfo* file_info; - PP_NaClFileInfo pp_file_info; - bool* op_complete_ptr; -}; - -// Do not invoke from the main thread, since the main methods will -// invoke CallOnMainThread and then wait on a condvar for the task to -// complete: if invoked from the main thread, the main method not -// returning (and thus unblocking the main thread) means that the -// main-thread continuation methods will never get called, and thus -// we'd get a deadlock. -class PluginReverseInterface: public nacl::ReverseInterface { - public: - PluginReverseInterface(nacl::WeakRefAnchor* anchor, - PP_Instance pp_instance, - ServiceRuntime* service_runtime, - pp::CompletionCallback init_done_cb); - - virtual ~PluginReverseInterface(); - - void ShutDown(); - - virtual void DoPostMessage(std::string message); - - virtual void StartupInitializationComplete(); - - virtual bool OpenManifestEntry(std::string url_key, - struct NaClFileInfo *info); - - virtual void ReportCrash(); - - virtual void ReportExitStatus(int exit_status); - - // TODO(teravest): Remove this method once it's gone from - // nacl::ReverseInterface. - virtual int64_t RequestQuotaForWrite(std::string file_id, - int64_t offset, - int64_t bytes_to_write); - - protected: - virtual void OpenManifestEntry_MainThreadContinuation( - OpenManifestEntryResource* p, - int32_t err); - - virtual void StreamAsFile_MainThreadContinuation( - OpenManifestEntryResource* p, - int32_t result); - - private: - nacl::WeakRefAnchor* anchor_; // holds a ref - // Should be used only in main thread in WeakRef-protected callbacks. - PP_Instance pp_instance_; - ServiceRuntime* service_runtime_; - NaClMutex mu_; - NaClCondVar cv_; - bool shutting_down_; - - pp::CompletionCallback init_done_cb_; -}; - -// ServiceRuntime abstracts a NativeClient sel_ldr instance. -class ServiceRuntime { - public: - ServiceRuntime(Plugin* plugin, - PP_Instance pp_instance, - bool main_service_runtime, - bool uses_nonsfi_mode, - pp::CompletionCallback init_done_cb); - // The destructor terminates the sel_ldr process. - ~ServiceRuntime(); - - // Spawn the sel_ldr instance. - void StartSelLdr(const SelLdrStartParams& params, - pp::CompletionCallback callback); - - // If starting sel_ldr from a background thread, wait for sel_ldr to - // actually start. Returns |false| if timed out waiting for the process - // to start. Otherwise, returns |true| if StartSelLdr is complete - // (either successfully or unsuccessfully). - bool WaitForSelLdrStart(); - - // Signal to waiting threads that StartSelLdr is complete (either - // successfully or unsuccessfully). - void SignalStartSelLdrDone(); - - // If starting the nexe from a background thread, wait for the nexe to - // actually start. Returns |true| is the nexe started successfully. - bool WaitForNexeStart(); - - // Signal to waiting threads that LoadNexeAndStart is complete (either - // successfully or unsuccessfully). - void SignalNexeStarted(bool ok); - - // Establish an SrpcClient to the sel_ldr instance and start the nexe. - // This function must be called on the main thread. - // This function must only be called once. - void StartNexe(); - - // Starts the application channel to the nexe. - SrpcClient* SetupAppChannel(); - - bool RemoteLog(int severity, const std::string& msg); - Plugin* plugin() const { return plugin_; } - void Shutdown(); - - bool main_service_runtime() const { return main_service_runtime_; } - - private: - NACL_DISALLOW_COPY_AND_ASSIGN(ServiceRuntime); - bool StartNexeInternal(); - - bool SetupCommandChannel(); - bool InitReverseService(); - bool StartModule(); - void ReapLogs(); - - void ReportLoadError(const ErrorInfo& error_info); - - NaClSrpcChannel command_channel_; - Plugin* plugin_; - PP_Instance pp_instance_; - bool main_service_runtime_; - bool uses_nonsfi_mode_; - nacl::ReverseService* reverse_service_; - nacl::scoped_ptr<SelLdrLauncherChrome> subprocess_; - - nacl::WeakRefAnchor* anchor_; - - PluginReverseInterface* rev_interface_; - - // Mutex and CondVar to protect start_sel_ldr_done_ and nexe_started_. - NaClMutex mu_; - NaClCondVar cond_; - bool start_sel_ldr_done_; - bool start_nexe_done_; - bool nexe_started_ok_; - - NaClHandle bootstrap_channel_; -}; - -} // namespace plugin - -#endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_ diff --git a/chromium/ppapi/native_client/src/trusted/plugin/srpc_client.cc b/chromium/ppapi/native_client/src/trusted/plugin/srpc_client.cc deleted file mode 100644 index 5087fdfe6fe..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/srpc_client.cc +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "ppapi/native_client/src/trusted/plugin/srpc_client.h" - -#include <string.h> - -#include "native_client/src/shared/platform/nacl_log.h" -#include "ppapi/native_client/src/trusted/plugin/plugin.h" -#include "ppapi/native_client/src/trusted/plugin/srpc_params.h" -#include "ppapi/native_client/src/trusted/plugin/utility.h" - -namespace plugin { - -typedef bool (*RpcFunction)(void* obj, SrpcParams* params); - -// MethodInfo records the method names and type signatures of an SRPC server. -class MethodInfo { - public: - // statically defined method - called through a pointer - MethodInfo(const RpcFunction function_ptr, - const char* name, - const char* ins, - const char* outs, - // index is set to UINT_MAX for methods implemented by the plugin, - // All methods implemented by nacl modules have indexes - // that are lower than UINT_MAX. - const uint32_t index = UINT_MAX) : - function_ptr_(function_ptr), - name_(STRDUP(name)), - ins_(STRDUP(ins)), - outs_(STRDUP(outs)), - index_(index) { } - - ~MethodInfo() { - free(reinterpret_cast<void*>(name_)); - free(reinterpret_cast<void*>(ins_)); - free(reinterpret_cast<void*>(outs_)); - } - - RpcFunction function_ptr() const { return function_ptr_; } - char* name() const { return name_; } - char* ins() const { return ins_; } - char* outs() const { return outs_; } - uint32_t index() const { return index_; } - - private: - NACL_DISALLOW_COPY_AND_ASSIGN(MethodInfo); - RpcFunction function_ptr_; - char* name_; - char* ins_; - char* outs_; - uint32_t index_; -}; - -SrpcClient::SrpcClient() - : srpc_channel_initialised_(false) { - PLUGIN_PRINTF(("SrpcClient::SrpcClient (this=%p)\n", - static_cast<void*>(this))); - NaClSrpcChannelInitialize(&srpc_channel_); -} - -SrpcClient* SrpcClient::New(nacl::DescWrapper* wrapper) { - nacl::scoped_ptr<SrpcClient> srpc_client(new SrpcClient()); - if (!srpc_client->Init(wrapper)) { - PLUGIN_PRINTF(("SrpcClient::New (SrpcClient::Init failed)\n")); - return NULL; - } - return srpc_client.release(); -} - -bool SrpcClient::Init(nacl::DescWrapper* wrapper) { - PLUGIN_PRINTF(("SrpcClient::Init (this=%p, wrapper=%p)\n", - static_cast<void*>(this), - static_cast<void*>(wrapper))); - // Open the channel to pass RPC information back and forth - if (!NaClSrpcClientCtor(&srpc_channel_, wrapper->desc())) { - return false; - } - srpc_channel_initialised_ = true; - PLUGIN_PRINTF(("SrpcClient::Init (Ctor worked)\n")); - // Record the method names in a convenient way for later dispatches. - GetMethods(); - PLUGIN_PRINTF(("SrpcClient::Init (GetMethods worked)\n")); - return true; -} - -SrpcClient::~SrpcClient() { - PLUGIN_PRINTF(("SrpcClient::~SrpcClient (this=%p, has_srpc_channel=%d)\n", - static_cast<void*>(this), srpc_channel_initialised_)); - // And delete the connection. - if (srpc_channel_initialised_) { - PLUGIN_PRINTF(("SrpcClient::~SrpcClient (destroying srpc_channel)\n")); - NaClSrpcDtor(&srpc_channel_); - } - for (Methods::iterator iter = methods_.begin(); - iter != methods_.end(); - ++iter) { - delete iter->second; - } - PLUGIN_PRINTF(("SrpcClient::~SrpcClient (return)\n")); -} - -void SrpcClient::GetMethods() { - PLUGIN_PRINTF(("SrpcClient::GetMethods (this=%p)\n", - static_cast<void*>(this))); - if (NULL == srpc_channel_.client) { - return; - } - uint32_t method_count = NaClSrpcServiceMethodCount(srpc_channel_.client); - // Intern the methods into a mapping from identifiers to MethodInfo. - for (uint32_t i = 0; i < method_count; ++i) { - int retval; - const char* method_name; - const char* input_types; - const char* output_types; - - retval = NaClSrpcServiceMethodNameAndTypes(srpc_channel_.client, - i, - &method_name, - &input_types, - &output_types); - if (!retval) { - return; - } - if (!IsValidIdentifierString(method_name, NULL)) { - // If name is not an ECMAScript identifier, do not enter it into the - // methods_ table. - continue; - } - MethodInfo* method_info = - new MethodInfo(NULL, method_name, input_types, output_types, i); - if (NULL == method_info) { - return; - } - // Install in the map only if successfully read. - methods_[method_name] = method_info; - } -} - -bool SrpcClient::HasMethod(const std::string& method_name) { - bool has_method = (NULL != methods_[method_name]); - PLUGIN_PRINTF(( - "SrpcClient::HasMethod (this=%p, method_name='%s', return %d)\n", - static_cast<void*>(this), method_name.c_str(), has_method)); - return has_method; -} - -bool SrpcClient::InitParams(const std::string& method_name, - SrpcParams* params) { - MethodInfo* method_info = methods_[method_name]; - if (method_info) { - return params->Init(method_info->ins(), method_info->outs()); - } - return false; -} - -bool SrpcClient::Invoke(const std::string& method_name, SrpcParams* params) { - // It would be better if we could set the exception on each detailed failure - // case. However, there are calls to Invoke from within the plugin itself, - // and these could leave residual exceptions pending. This seems to be - // happening specifically with hard_shutdowns. - PLUGIN_PRINTF(("SrpcClient::Invoke (this=%p, method_name='%s', params=%p)\n", - static_cast<void*>(this), - method_name.c_str(), - static_cast<void*>(params))); - - // Ensure Invoke was called with a method name that has a binding. - if (NULL == methods_[method_name]) { - PLUGIN_PRINTF(("SrpcClient::Invoke (ident not in methods_)\n")); - return false; - } - - PLUGIN_PRINTF(("SrpcClient::Invoke (sending the rpc)\n")); - // Call the method - last_error_ = NaClSrpcInvokeV(&srpc_channel_, - methods_[method_name]->index(), - params->ins(), - params->outs()); - PLUGIN_PRINTF(("SrpcClient::Invoke (response=%d)\n", last_error_)); - if (NACL_SRPC_RESULT_OK != last_error_) { - PLUGIN_PRINTF(("SrpcClient::Invoke (err='%s', return 0)\n", - NaClSrpcErrorString(last_error_))); - return false; - } - - PLUGIN_PRINTF(("SrpcClient::Invoke (return 1)\n")); - return true; -} - -void SrpcClient::AttachService(NaClSrpcService* service, void* instance_data) { - srpc_channel_.server = service; - srpc_channel_.server_instance_data = instance_data; -} - -} // namespace plugin diff --git a/chromium/ppapi/native_client/src/trusted/plugin/srpc_client.h b/chromium/ppapi/native_client/src/trusted/plugin/srpc_client.h deleted file mode 100644 index 71ecbf7e491..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/srpc_client.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -// A representation of an SRPC connection. These can be either to the -// service runtime or to untrusted NaCl threads. - -#ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_CLIENT_H_ -#define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_CLIENT_H_ - -#include <map> -#include <string> - -#include "native_client/src/include/nacl_macros.h" -#include "native_client/src/shared/srpc/nacl_srpc.h" -#include "ppapi/native_client/src/trusted/plugin/utility.h" - -namespace nacl { -class DescWrapper; -} // namespace nacl - -namespace plugin { - -class ErrorInfo; -class MethodInfo; -class Plugin; -class SrpcParams; - -// SrpcClient represents an SRPC connection to a client. -class SrpcClient { - public: - // Factory method for creating SrpcClients. - static SrpcClient* New(nacl::DescWrapper* wrapper); - - // Init is passed a DescWrapper. The SrpcClient performs service - // discovery and provides the interface for future rpcs. - bool Init(nacl::DescWrapper* socket); - - // The destructor closes the connection to sel_ldr. - ~SrpcClient(); - - // Test whether the SRPC service has a given method. - bool HasMethod(const std::string& method_name); - // Invoke an SRPC method. - bool Invoke(const std::string& method_name, SrpcParams* params); - // Get the error status from that last method invocation - NaClSrpcError GetLastError() { return last_error_; } - bool InitParams(const std::string& method_name, SrpcParams* params); - - // Attach a service for reverse-direction (from .nexe) RPCs. - void AttachService(NaClSrpcService* service, void* instance_data); - - private: - NACL_DISALLOW_COPY_AND_ASSIGN(SrpcClient); - SrpcClient(); - void GetMethods(); - typedef std::map<std::string, MethodInfo*> Methods; - Methods methods_; - NaClSrpcChannel srpc_channel_; - bool srpc_channel_initialised_; - NaClSrpcError last_error_; -}; - -} // namespace plugin - -#endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_CLIENT_H_ diff --git a/chromium/ppapi/native_client/src/trusted/plugin/srpc_params.cc b/chromium/ppapi/native_client/src/trusted/plugin/srpc_params.cc deleted file mode 100644 index 593fe94dc84..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/srpc_params.cc +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - - -#include "ppapi/native_client/src/trusted/plugin/srpc_params.h" - -#include <stdlib.h> - -#include "native_client/src/shared/srpc/nacl_srpc.h" - - -namespace plugin { - -namespace { - -bool FillVec(NaClSrpcArg* vec[], const char* types) { - const size_t kLength = strlen(types); - if (kLength > NACL_SRPC_MAX_ARGS) { - return false; - } - // We use malloc/new here rather than new/delete, because the SRPC layer - // is written in C and hence will use malloc/free. - // This array will get deallocated by FreeArguments(). - if (kLength > 0) { - NaClSrpcArg* args = - reinterpret_cast<NaClSrpcArg*>(malloc(kLength * sizeof(*args))); - if (NULL == args) { - return false; - } - - memset(static_cast<void*>(args), 0, kLength * sizeof(*args)); - for (size_t i = 0; i < kLength; ++i) { - vec[i] = &args[i]; - args[i].tag = static_cast<NaClSrpcArgType>(types[i]); - } - } - vec[kLength] = NULL; - return true; -} - -void FreeSrpcArg(NaClSrpcArg* arg) { - switch (arg->tag) { - case NACL_SRPC_ARG_TYPE_CHAR_ARRAY: - free(arg->arrays.carr); - break; - case NACL_SRPC_ARG_TYPE_DOUBLE_ARRAY: - free(arg->arrays.darr); - break; - case NACL_SRPC_ARG_TYPE_HANDLE: - break; - case NACL_SRPC_ARG_TYPE_INT_ARRAY: - free(arg->arrays.iarr); - break; - case NACL_SRPC_ARG_TYPE_LONG_ARRAY: - free(arg->arrays.larr); - break; - case NACL_SRPC_ARG_TYPE_STRING: - // All strings that are passed in SrpcArg must be allocated using - // malloc! We cannot use browser's allocation API - // since some of SRPC arguments is handled outside of the plugin code. - free(arg->arrays.str); - break; - case NACL_SRPC_ARG_TYPE_VARIANT_ARRAY: - if (arg->arrays.varr) { - for (uint32_t i = 0; i < arg->u.count; i++) { - FreeSrpcArg(&arg->arrays.varr[i]); - } - } - break; - case NACL_SRPC_ARG_TYPE_OBJECT: - // This is a pointer to a scriptable object and should be released - // by the browser - break; - case NACL_SRPC_ARG_TYPE_BOOL: - case NACL_SRPC_ARG_TYPE_DOUBLE: - case NACL_SRPC_ARG_TYPE_INT: - case NACL_SRPC_ARG_TYPE_LONG: - case NACL_SRPC_ARG_TYPE_INVALID: - default: - break; - } -} - -void FreeArguments(NaClSrpcArg* vec[]) { - if (NULL == vec[0]) { - return; - } - for (NaClSrpcArg** argp = vec; *argp; ++argp) { - FreeSrpcArg(*argp); - } - // Free the vector containing the arguments themselves that was - // allocated with FillVec(). - free(vec[0]); -} - -} // namespace - -bool SrpcParams::Init(const char* in_types, const char* out_types) { - if (!FillVec(ins_, in_types)) { - return false; - } - if (!FillVec(outs_, out_types)) { - FreeArguments(ins_); - return false; - } - return true; -} - -void SrpcParams::FreeAll() { - FreeArguments(ins_); - FreeArguments(outs_); - memset(ins_, 0, sizeof(ins_)); - memset(outs_, 0, sizeof(outs_)); -} - -} // namespace plugin diff --git a/chromium/ppapi/native_client/src/trusted/plugin/srpc_params.h b/chromium/ppapi/native_client/src/trusted/plugin/srpc_params.h deleted file mode 100644 index cd807bde113..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/srpc_params.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Parameter types for SRPC Invocation. - -#ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_PARAMS_H -#define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_PARAMS_H - -#include "native_client/src/include/nacl_macros.h" -#include "native_client/src/include/portability_string.h" -#include "native_client/src/shared/srpc/nacl_srpc.h" - -namespace plugin { - -// A utility class that builds and deletes parameter vectors used in rpcs. -class SrpcParams { - public: - SrpcParams() { - memset(ins_, 0, sizeof(ins_)); - memset(outs_, 0, sizeof(outs_)); - } - - SrpcParams(const char* in_types, const char* out_types) { - if (!Init(in_types, out_types)) { - FreeAll(); - } - } - - ~SrpcParams() { - FreeAll(); - } - - bool Init(const char* in_types, const char* out_types); - - NaClSrpcArg** ins() const { return const_cast<NaClSrpcArg**>(ins_); } - NaClSrpcArg** outs() const { return const_cast<NaClSrpcArg**>(outs_); } - - private: - NACL_DISALLOW_COPY_AND_ASSIGN(SrpcParams); - void FreeAll(); - // The ins_ and outs_ arrays contain one more element, to hold a NULL pointer - // to indicate the end of the list. - NaClSrpcArg* ins_[NACL_SRPC_MAX_ARGS + 1]; - NaClSrpcArg* outs_[NACL_SRPC_MAX_ARGS + 1]; -}; - -} // namespace plugin - -#endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_PARAMS_H diff --git a/chromium/ppapi/native_client/src/trusted/plugin/temporary_file.cc b/chromium/ppapi/native_client/src/trusted/plugin/temporary_file.cc deleted file mode 100644 index d84ce77303f..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/temporary_file.cc +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/native_client/src/trusted/plugin/temporary_file.h" - -#include "native_client/src/include/portability_io.h" -#include "native_client/src/shared/platform/nacl_check.h" -#include "native_client/src/trusted/service_runtime/include/sys/stat.h" - -#include "ppapi/cpp/core.h" -#include "ppapi/cpp/instance.h" -#include "ppapi/cpp/module.h" -#include "ppapi/c/private/pp_file_handle.h" - -#include "ppapi/native_client/src/trusted/plugin/plugin.h" -#include "ppapi/native_client/src/trusted/plugin/utility.h" - -namespace plugin { - -TempFile::TempFile(Plugin* plugin, PP_FileHandle handle) - : plugin_(plugin), - internal_handle_(handle) { } - -TempFile::~TempFile() { } - -int32_t TempFile::Open(bool writeable) { - if (internal_handle_ == PP_kInvalidFileHandle) - return PP_ERROR_FAILED; - -#if NACL_WINDOWS - HANDLE handle = internal_handle_; - - //////// Now try the posix view. - int rdwr_flag = writeable ? _O_RDWR : _O_RDONLY; - int32_t posix_desc = _open_osfhandle(reinterpret_cast<intptr_t>(handle), - rdwr_flag | _O_BINARY - | _O_TEMPORARY | _O_SHORT_LIVED ); - - // Close the Windows HANDLE if it can't be converted. - if (posix_desc == -1) { - PLUGIN_PRINTF(("TempFile::Open failed to convert HANDLE to posix\n")); - CloseHandle(handle); - } - int32_t fd = posix_desc; -#else - int32_t fd = internal_handle_; -#endif - - if (fd < 0) - return PP_ERROR_FAILED; - - // dup the fd to make allow making separate read and write wrappers. - int32_t read_fd = DUP(fd); - if (read_fd == NACL_NO_FILE_DESC) - return PP_ERROR_FAILED; - - if (writeable) { - write_wrapper_.reset( - plugin_->wrapper_factory()->MakeFileDesc(fd, O_RDWR)); - } - - read_wrapper_.reset( - plugin_->wrapper_factory()->MakeFileDesc(read_fd, O_RDONLY)); - return PP_OK; -} - -bool TempFile::Reset() { - // Use the read_wrapper_ to reset the file pos. The write_wrapper_ is also - // backed by the same file, so it should also reset. - CHECK(read_wrapper_.get() != NULL); - nacl_off64_t newpos = read_wrapper_->Seek(0, SEEK_SET); - return newpos == 0; -} - -PP_FileHandle TempFile::TakeFileHandle() { - PP_FileHandle to_return = internal_handle_; - internal_handle_ = PP_kInvalidFileHandle; - read_wrapper_.release(); - write_wrapper_.release(); - return to_return; -} - -} // namespace plugin diff --git a/chromium/ppapi/native_client/src/trusted/plugin/temporary_file.h b/chromium/ppapi/native_client/src/trusted/plugin/temporary_file.h deleted file mode 100644 index a58879bb578..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/temporary_file.h +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_TEMPORARY_FILE_H_ -#define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_TEMPORARY_FILE_H_ - -#include "native_client/src/include/nacl_macros.h" -#include "native_client/src/trusted/desc/nacl_desc_wrapper.h" - -#include "ppapi/c/private/pp_file_handle.h" - -namespace plugin { - -class Plugin; - -// Translation creates two temporary files. The first temporary file holds -// the object file created by llc. The second holds the nexe produced by -// the linker. Both of these temporary files are used to both write and -// read according to the following matrix: -// -// PnaclCoordinator::obj_file_: -// written by: llc (passed in explicitly through SRPC) -// read by: ld (returned via lookup service from SRPC) -// PnaclCoordinator::nexe_file_: -// written by: ld (passed in explicitly through SRPC) -// read by: sel_ldr (passed in explicitly to command channel) -// - -// TempFile represents a file used as a temporary between stages in -// translation. It is automatically deleted when all handles are closed -// (or earlier -- immediately unlinked on POSIX systems). The file is only -// opened, once, but because both reading and writing are necessary (and in -// different processes), the user should reset / seek back to the beginning -// of the file between sessions. -class TempFile { - public: - // Create a TempFile. - TempFile(Plugin* plugin, PP_FileHandle handle); - ~TempFile(); - - // Opens a temporary file object and descriptor wrapper referring to the file. - // If |writeable| is true, the descriptor will be opened for writing, and - // write_wrapper will return a valid pointer, otherwise it will return NULL. - int32_t Open(bool writeable); - // Resets file position of the handle, for reuse. - bool Reset(); - - // Accessors. - // The nacl::DescWrapper* for the writeable version of the file. - nacl::DescWrapper* write_wrapper() { return write_wrapper_.get(); } - nacl::DescWrapper* read_wrapper() { return read_wrapper_.get(); } - - // Returns the handle to the file repesented and resets the internal handle - // and all wrappers. - PP_FileHandle TakeFileHandle(); - - private: - NACL_DISALLOW_COPY_AND_ASSIGN(TempFile); - - Plugin* plugin_; - nacl::scoped_ptr<nacl::DescWrapper> read_wrapper_; - nacl::scoped_ptr<nacl::DescWrapper> write_wrapper_; - PP_FileHandle internal_handle_; -}; - -} // namespace plugin - -#endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_TEMPORARY_FILE_H_ diff --git a/chromium/ppapi/native_client/src/trusted/plugin/utility.cc b/chromium/ppapi/native_client/src/trusted/plugin/utility.cc deleted file mode 100644 index eaf525016f4..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/utility.cc +++ /dev/null @@ -1,150 +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 <stdarg.h> -#include <stdlib.h> -#include <string.h> - -#include "native_client/src/include/portability_io.h" -#include "native_client/src/include/portability_process.h" -#include "native_client/src/shared/platform/nacl_check.h" -#include "ppapi/cpp/module.h" -#include "ppapi/native_client/src/trusted/plugin/utility.h" - -namespace plugin { - -int gNaClPluginDebugPrintEnabled = -1; - -/* - * Prints formatted message to the log. - */ -int NaClPluginPrintLog(const char *format, ...) { - va_list arg; - int out_size; - - static const int kStackBufferSize = 512; - char stack_buffer[kStackBufferSize]; - - // Just log locally to stderr if we can't use the nacl interface. - if (!GetNaClInterface()) { - va_start(arg, format); - int rc = vfprintf(stderr, format, arg); - va_end(arg); - return rc; - } - - va_start(arg, format); - out_size = vsnprintf(stack_buffer, kStackBufferSize, format, arg); - va_end(arg); - if (out_size < kStackBufferSize) { - GetNaClInterface()->Vlog(stack_buffer); - } else { - // Message too large for our stack buffer; we have to allocate memory - // instead. - char *buffer = static_cast<char*>(malloc(out_size + 1)); - va_start(arg, format); - vsnprintf(buffer, out_size + 1, format, arg); - va_end(arg); - GetNaClInterface()->Vlog(buffer); - free(buffer); - } - return out_size; -} - -/* - * Currently looks for presence of NACL_PLUGIN_DEBUG and returns - * 0 if absent and 1 if present. In the future we may include notions - * of verbosity level. - */ -int NaClPluginDebugPrintCheckEnv() { - char* env = getenv("NACL_PLUGIN_DEBUG"); - return (NULL != env); -} - -bool IsValidIdentifierString(const char* strval, uint32_t* length) { - // This function is supposed to recognize valid ECMAScript identifiers, - // as described in - // http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf - // It is currently restricted to only the ASCII subset. - // TODO(sehr): Recognize the full Unicode formulation of identifiers. - // TODO(sehr): Make this table-driven if efficiency becomes a problem. - if (NULL != length) { - *length = 0; - } - if (NULL == strval) { - return false; - } - static const char* kValidFirstChars = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz$_"; - static const char* kValidOtherChars = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz$_" - "0123456789"; - if (NULL == strchr(kValidFirstChars, strval[0])) { - return false; - } - uint32_t pos; - for (pos = 1; ; ++pos) { - if (0 == pos) { - // Unsigned overflow. - return false; - } - int c = strval[pos]; - if (0 == c) { - break; - } - if (NULL == strchr(kValidOtherChars, c)) { - return false; - } - } - if (NULL != length) { - *length = pos; - } - return true; -} - -// We cache the NaCl interface pointer and ensure that its set early on, on the -// main thread. This allows GetNaClInterface() to be used from non-main threads. -static const PPB_NaCl_Private* g_nacl_interface = NULL; - -const PPB_NaCl_Private* GetNaClInterface() { - return g_nacl_interface; -} - -void SetNaClInterface(const PPB_NaCl_Private* nacl_interface) { - g_nacl_interface = nacl_interface; -} - -void CloseFileHandle(PP_FileHandle file_handle) { -#if NACL_WINDOWS - CloseHandle(file_handle); -#else - close(file_handle); -#endif -} - -// Converts a PP_FileHandle to a POSIX file descriptor. -int32_t ConvertFileDescriptor(PP_FileHandle handle, bool read_only) { - PLUGIN_PRINTF(("ConvertFileDescriptor, handle=%d\n", handle)); -#if NACL_WINDOWS - int32_t file_desc = NACL_NO_FILE_DESC; - // On Windows, valid handles are 32 bit unsigned integers so this is safe. - file_desc = reinterpret_cast<intptr_t>(handle); - // Convert the Windows HANDLE from Pepper to a POSIX file descriptor. - int flags = _O_BINARY; - flags |= read_only ? _O_RDONLY : _O_RDWR; - int32_t posix_desc = _open_osfhandle(file_desc, flags); - if (posix_desc == -1) { - // Close the Windows HANDLE if it can't be converted. - CloseHandle(reinterpret_cast<HANDLE>(file_desc)); - return -1; - } - return posix_desc; -#else - return handle; -#endif -} - -} // namespace plugin diff --git a/chromium/ppapi/native_client/src/trusted/plugin/utility.h b/chromium/ppapi/native_client/src/trusted/plugin/utility.h deleted file mode 100644 index 8bb01943a35..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/utility.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. - */ - -// A collection of debugging related interfaces. - -#ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_UTILITY_H_ -#define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_UTILITY_H_ - -#include "native_client/src/include/nacl_macros.h" -#include "native_client/src/include/portability.h" -#include "native_client/src/shared/platform/nacl_threads.h" -#include "native_client/src/shared/platform/nacl_time.h" -#include "ppapi/c/private/pp_file_handle.h" -#include "ppapi/c/private/ppb_nacl_private.h" - -#define SRPC_PLUGIN_DEBUG 1 - -namespace plugin { - -// Tests that a string is a valid JavaScript identifier. According to the -// ECMAScript spec, this should be done in terms of unicode character -// categories. For now, we are simply limiting identifiers to the ASCII -// subset of that spec. If successful, it returns the length of the -// identifier in the location pointed to by length (if it is not NULL). -// TODO(sehr): add Unicode identifier support. -bool IsValidIdentifierString(const char* strval, uint32_t* length); - -const PPB_NaCl_Private* GetNaClInterface(); -void SetNaClInterface(const PPB_NaCl_Private* nacl_interface); - -void CloseFileHandle(PP_FileHandle file_handle); - -// Converts a PP_FileHandle to a POSIX file descriptor. -int32_t ConvertFileDescriptor(PP_FileHandle handle, bool read_only); - -// Debugging print utility -extern int gNaClPluginDebugPrintEnabled; -extern int NaClPluginPrintLog(const char *format, ...); -extern int NaClPluginDebugPrintCheckEnv(); -#if SRPC_PLUGIN_DEBUG -#define INIT_PLUGIN_LOGGING() do { \ - if (-1 == ::plugin::gNaClPluginDebugPrintEnabled) { \ - ::plugin::gNaClPluginDebugPrintEnabled = \ - ::plugin::NaClPluginDebugPrintCheckEnv(); \ - } \ -} while (0) - -#define PLUGIN_PRINTF(args) do { \ - INIT_PLUGIN_LOGGING(); \ - if (0 != ::plugin::gNaClPluginDebugPrintEnabled) { \ - ::plugin::NaClPluginPrintLog("PLUGIN %" NACL_PRIu64 ": ", \ - NaClGetTimeOfDayMicroseconds()); \ - ::plugin::NaClPluginPrintLog args; \ - } \ - } while (0) - -// MODULE_PRINTF is used in the module because PLUGIN_PRINTF uses a -// a timer that may not yet be initialized. -#define MODULE_PRINTF(args) do { \ - INIT_PLUGIN_LOGGING(); \ - if (0 != ::plugin::gNaClPluginDebugPrintEnabled) { \ - ::plugin::NaClPluginPrintLog("MODULE: "); \ - ::plugin::NaClPluginPrintLog args; \ - } \ - } while (0) -#else -# define PLUGIN_PRINTF(args) do { if (0) { printf args; } } while (0) -# define MODULE_PRINTF(args) do { if (0) { printf args; } } while (0) -/* allows DCE but compiler can still do format string checks */ -#endif - -} // namespace plugin - -#endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_UTILITY_H_ diff --git a/chromium/ppapi/native_client/src/trusted/weak_ref/call_on_main_thread.h b/chromium/ppapi/native_client/src/trusted/weak_ref/call_on_main_thread.h deleted file mode 100644 index a618795742d..00000000000 --- a/chromium/ppapi/native_client/src/trusted/weak_ref/call_on_main_thread.h +++ /dev/null @@ -1,252 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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. - */ - -// EXAMPLE USAGE -// -// class PluginReverseInterface { -// public: -// PluginReverseInterface(...) : anchor_(new nacl::WeakRefAnchor); -// ~PluginReverseInterface() { anchor_->Abandon(); } -// void Log(nacl::string message) { -// LogContinuation* continuation = new LogContinuation(message); -// plugin::WeakRefCallOnMainThread(anchor_, 0 /* ms delay */, -// this, &PluginReverseInterface::Log_cont, -// continuation); -// } -// void Log_cont(LogContinuation* cont, int32_t result) { -// plugin_->browser_interface()->AddToConsole(plugin_->instance_id(), -// cont->message); -// delete cont; -// } -// private: -// nacl::WeakRefAnchor* anchor_; -// } - -#ifndef NATIVE_CLIENT_SRC_TRUSTED_WEAK_REF_CALL_ON_MAIN_THREAD_H_ -#define NATIVE_CLIENT_SRC_TRUSTED_WEAK_REF_CALL_ON_MAIN_THREAD_H_ - -#include "native_client/src/trusted/weak_ref/weak_ref.h" - -#include "native_client/src/include/nacl_scoped_ptr.h" -#include "native_client/src/include/nacl_compiler_annotations.h" -#include "native_client/src/include/portability.h" - -#include "ppapi/c/pp_errors.h" // for PP_OK -#include "ppapi/cpp/completion_callback.h" // for pp::CompletionCallback -#include "ppapi/cpp/core.h" // for pp:: -#include "ppapi/cpp/module.h" // for pp::Module - -namespace plugin { - -// A typesafe utility to schedule a completion callback using weak -// references. The callback function callback_fn is invoked -// regardless of whether the anchor has been abandoned, since -// callback_fn takes a WeakRef<R>* as argument. The intention is that -// such callbacks, even deprived of any of its arguments (which has -// been deleted), may wish to do some cleanup / log a message. - -static char const* const kPpWeakRefModuleName = "pp_weak_ref"; - -template <typename R> pp::CompletionCallback WeakRefNewCallback( - nacl::WeakRefAnchor* anchor, - void callback_fn(nacl::WeakRef<R>* weak_data, int32_t err), - R* raw_data) { - nacl::WeakRef<R>* wp = anchor->MakeWeakRef<R>(raw_data); - // TODO(bsy): explore using another template to eliminate the - // following cast, making things completely typesafe. - pp::CompletionCallback cc_nrvo( - reinterpret_cast<void (*)(void*, int32_t)>( - callback_fn), - reinterpret_cast<void*>(wp)); - return cc_nrvo; -} - -template <typename R> void WeakRefCallOnMainThread( - nacl::WeakRefAnchor* anchor, - int32_t delay_in_milliseconds, - void callback_fn(nacl::WeakRef<R>* weak_data, int32_t err), - R* raw_data) { - pp::CompletionCallback cc = - WeakRefNewCallback(anchor, callback_fn, raw_data, &cc); - - pp::Module::Get()->core()->CallOnMainThread( - delay_in_milliseconds, - cc, - PP_OK); -} - -template <typename R> class WeakRefAutoAbandonWrapper { - public: - WeakRefAutoAbandonWrapper(void (*callback_fn)(R* raw_data, - int32_t err), - R* raw_data) - : orig_callback_fn(callback_fn), - orig_data(raw_data) {} - - void (*orig_callback_fn)(R* raw_data, int32_t err); - nacl::scoped_ptr<R> orig_data; -}; - -/* - * It would be nice if the function had the right type signature, - * i.e., void WeakRefAutoAbandoner(void *wr_data, int32_t) but then - * the formal argument list would not use the typename template - * argument R, making template resolution impossible. - */ -template <typename R> void WeakRefAutoAbandoner( - nacl::WeakRef<WeakRefAutoAbandonWrapper<R> >* wr, - int32_t err) { - nacl::scoped_ptr<WeakRefAutoAbandonWrapper<R> > p; - wr->ReleaseAndUnref(&p); - if (p == NULL) { - NaClLog2(kPpWeakRefModuleName, 4, - "WeakRefAutoAbandoner: weak ref NULL, anchor was abandoned\n"); - return; - } - NaClLog2(kPpWeakRefModuleName, 4, - "WeakRefAutoAbandoner: weak ref okay, invoking callback\n"); - (*p->orig_callback_fn)(p->orig_data.get(), err); - return; -} - -// A typesafe utility to schedule a completion callback using weak -// references. The callback function raw_callback_fn takes an R* as -// argument, and is not invoked if the anchor has been abandoned. -template <typename R> pp::CompletionCallback WeakRefNewCallback( - nacl::WeakRefAnchor* anchor, - void (*raw_callback_fn)(R* raw_data, int32_t err), - R* raw_data) { - - WeakRefAutoAbandonWrapper<R>* wref_auto_wrapper = - new WeakRefAutoAbandonWrapper<R>(raw_callback_fn, raw_data); - - CHECK(wref_auto_wrapper != NULL); - - nacl::WeakRef<WeakRefAutoAbandonWrapper<R> >* wp = - anchor->MakeWeakRef<WeakRefAutoAbandonWrapper<R> >( - wref_auto_wrapper); - void (*weak_ref_auto_abandoner_ptr)( - nacl::WeakRef<WeakRefAutoAbandonWrapper<R> >* wr, - int32_t err) = WeakRefAutoAbandoner<R>; - // TODO(bsy): see above - pp::CompletionCallback cc_nrvo( - reinterpret_cast<void (*)(void*, int32_t)>(weak_ref_auto_abandoner_ptr), - reinterpret_cast<void*>(wp)); - return cc_nrvo; -} - -template <typename R> void WeakRefCallOnMainThread( - nacl::WeakRefAnchor* anchor, - int32_t delay_in_milliseconds, - void raw_callback_fn(R* raw_data, int32_t err), - R* raw_data) { - pp::CompletionCallback cc = - WeakRefNewCallback(anchor, raw_callback_fn, raw_data, &cc); - pp::Module::Get()->core()->CallOnMainThread( - delay_in_milliseconds, - cc, - PP_OK); -} - - -template <typename R, typename E> -class WeakRefMemberFuncBinder { - public: - WeakRefMemberFuncBinder(E* object, - void (E::*raw_callback_fn)(R* raw_data, - int32_t err), - R* raw_data) - : object_(object), - raw_callback_fn_(raw_callback_fn), - data_(raw_data) {} - void Invoke(int32_t err) { - NaClLog2(kPpWeakRefModuleName, 4, - ("WeakRefMemberFuncBinder: Invoke obj 0x%" NACL_PRIxPTR - ", err%" NACL_PRId32 "\n"), - reinterpret_cast<uintptr_t>(object_), err); - (object_->*raw_callback_fn_)(data_.get(), err); - NaClLog2(kPpWeakRefModuleName, 4, - "WeakRefMemberFuncBinder: done\n"); - } - private: - E* object_; - void (E::*raw_callback_fn_)(R* raw_data, int32_t err); - nacl::scoped_ptr<R> data_; -}; - -template <typename R, typename E> -void WeakRefMemberFuncInvoker( - WeakRefMemberFuncBinder<R, E> *binder, int32_t err) { - NaClLog2(kPpWeakRefModuleName, 4, - "WeakRefMemberFuncInvoker: %" NACL_PRIxPTR " %" NACL_PRId32 "\n", - (uintptr_t) binder, - err); - binder->Invoke(err); - // delete binder not needed, since WeakRefAutoAbandoner holds binder - // in a scoped_ptr and will automatically delete on scope exit. -} - - -// A typesafe utility to schedule a completion callback using weak -// references, where the callback function is a member function. The -// member function must take only a raw argument data pointer and a -// completion status as formal parameters. The lifetime of the -// |object| and |raw_callback_fn| must be at least that of |anchor|. -// Typically |object| is just the object that controls the |anchor|, -// though it may be some sub-object that is contained within the -// actual controlling object. If the |anchor| is abandoned, the -// |raw_data| argument is deleted and the |raw_callback_fn| will not -// be invoked. -template <typename R, typename E> -pp::CompletionCallback WeakRefNewCallback( - nacl::WeakRefAnchor* anchor, - E* object, - void (E::*raw_callback_fn)(R* raw_data, int32_t err), - R* raw_data) { - NaClLog2(kPpWeakRefModuleName, 4, - "Entered WeakRefNewCallback\n"); - NaClLog2(kPpWeakRefModuleName, 4, - "object 0x%" NACL_PRIxPTR "\n", - reinterpret_cast<uintptr_t>(object)); - WeakRefMemberFuncBinder<R, E>* binder = - new WeakRefMemberFuncBinder<R, E>(object, - raw_callback_fn, - raw_data); - CHECK(binder != NULL); - NaClLog2(kPpWeakRefModuleName, 4, - "WeakRefNewCallback: binder %" NACL_PRIxPTR "\n", - (uintptr_t) binder); - void (*weak_ref_member_func_invoker_ptr)( - WeakRefMemberFuncBinder<R, E>* binder, - int32_t err) = WeakRefMemberFuncInvoker<R, E>; - return WeakRefNewCallback(anchor, weak_ref_member_func_invoker_ptr, - binder); -} - -template <typename R, typename E> void WeakRefCallOnMainThread( - nacl::WeakRefAnchor* anchor, - int32_t delay_in_milliseconds, - E* object, - void (E::*raw_callback_fn)(R* raw_data, int32_t err), - R* raw_data) { - NaClLog2(kPpWeakRefModuleName, 4, - "Entered WeakRefCallOnMainThread\n"); - pp::CompletionCallback cc = - WeakRefNewCallback(anchor, object, raw_callback_fn, raw_data); - NaClLog2(kPpWeakRefModuleName, 4, - "WeakRefCallOnMainThread: got cc\n"); - pp::Module::Get()->core()->CallOnMainThread( - delay_in_milliseconds, - cc, - PP_OK); - NaClLog2(kPpWeakRefModuleName, 4, - "WeakRefCallOnMainThread: invoked PP_CallOnMainThread\n"); -} - -} // namespace plugin - -#endif diff --git a/chromium/ppapi/native_client/src/untrusted/irt_stub/BUILD.gn b/chromium/ppapi/native_client/src/untrusted/irt_stub/BUILD.gn new file mode 100644 index 00000000000..484145f49e7 --- /dev/null +++ b/chromium/ppapi/native_client/src/untrusted/irt_stub/BUILD.gn @@ -0,0 +1,17 @@ +# Copyright 2015 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. + +assert(is_nacl, + "These targets must only be built using the untrusted NaCl toolchains.") + +# TODO(sbc): Make sure this library gets built with -fPIC. Right now it +# doesn't seem that is built at all. +source_set("ppapi_stub_lib") { + sources = [ + "plugin_main_irt.c", + "ppapi_plugin_main.c", + "ppapi_plugin_start.c", + "thread_creator.c", + ] +} diff --git a/chromium/ppapi/native_client/src/untrusted/irt_stub/irt_stub.gyp b/chromium/ppapi/native_client/src/untrusted/irt_stub/irt_stub.gyp index 2259578f24c..e1b2d85b6ea 100644 --- a/chromium/ppapi/native_client/src/untrusted/irt_stub/irt_stub.gyp +++ b/chromium/ppapi/native_client/src/untrusted/irt_stub/irt_stub.gyp @@ -16,18 +16,19 @@ 'build_newlib': 1, 'build_pnacl_newlib': 1, }, + # Always compile libppapi_stub with -fPIC so that -lppapi can be linked + # into shared libraries (libppapi.so is a linker script that pulls in + # ppapi_stub). + 'compile_flags': [ '-fPIC' ], 'include_dirs': [ '../../../..', ], 'sources': [ + 'plugin_main_irt.c', 'ppapi_plugin_main.c', 'ppapi_plugin_start.c', - 'plugin_main_irt.c', 'thread_creator.c' ], - 'dependencies': [ - '<(DEPTH)/native_client/tools.gyp:prep_toolchain', - ], }, ], } diff --git a/chromium/ppapi/native_client/src/untrusted/nacl_ppapi_util/nacl.scons b/chromium/ppapi/native_client/src/untrusted/nacl_ppapi_util/nacl.scons deleted file mode 100644 index e446d29bf95..00000000000 --- a/chromium/ppapi/native_client/src/untrusted/nacl_ppapi_util/nacl.scons +++ /dev/null @@ -1,12 +0,0 @@ -# -*- python -*- -# 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. - -Import('env') - -env.ComponentLibrary('nacl_ppapi_util', - ['string_buffer.cc', - 'nacl_ppapi_util.cc', - 'ppapi_srpc_main.c']) - diff --git a/chromium/ppapi/native_client/src/untrusted/nacl_ppapi_util/nacl_ppapi_util.cc b/chromium/ppapi/native_client/src/untrusted/nacl_ppapi_util/nacl_ppapi_util.cc deleted file mode 100644 index 93b2bacfcf4..00000000000 --- a/chromium/ppapi/native_client/src/untrusted/nacl_ppapi_util/nacl_ppapi_util.cc +++ /dev/null @@ -1,29 +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/native_client/src/untrusted/nacl_ppapi_util/nacl_ppapi_util.h" - -// TODO(bsy): move weak_ref module to the shared directory -#include "native_client/src/trusted/weak_ref/weak_ref.h" -#include "ppapi/native_client/src/trusted/weak_ref/call_on_main_thread.h" - - -namespace nacl_ppapi { - -static VoidResult kVoidResult; -VoidResult *const g_void_result = &kVoidResult; - -NaClPpapiPluginInstance::NaClPpapiPluginInstance(PP_Instance instance) - : pp::Instance(instance) { - anchor_ = new nacl::WeakRefAnchor(); -} - -NaClPpapiPluginInstance::~NaClPpapiPluginInstance() { - anchor_->Abandon(); - anchor_->Unref(); -} - -} // namespace nacl_ppapi diff --git a/chromium/ppapi/native_client/src/untrusted/nacl_ppapi_util/nacl_ppapi_util.h b/chromium/ppapi/native_client/src/untrusted/nacl_ppapi_util/nacl_ppapi_util.h deleted file mode 100644 index bbfd8bac39d..00000000000 --- a/chromium/ppapi/native_client/src/untrusted/nacl_ppapi_util/nacl_ppapi_util.h +++ /dev/null @@ -1,202 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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 NATIVE_CLIENT_SRC_UNTRUSTED_NACL_PPAPI_UTIL_NACL_PPAPI_UTIL_H_ -#define NATIVE_CLIENT_SRC_UNTRUSTED_NACL_PPAPI_UTIL_NACL_PPAPI_UTIL_H_ - -#include "ppapi/cpp/instance.h" -#include "ppapi/cpp/module.h" -#include "ppapi/cpp/var.h" - -#include "native_client/src/include/nacl_base.h" -#include "native_client/src/include/nacl_scoped_ptr.h" -#include "native_client/src/shared/platform/nacl_sync.h" -#include "native_client/src/shared/platform/nacl_sync_checked.h" -#include "native_client/src/shared/platform/nacl_sync_raii.h" - -// TODO(bsy): move weak_ref module to the shared directory -#include "native_client/src/trusted/weak_ref/weak_ref.h" -#include "ppapi/native_client/src/trusted/weak_ref/call_on_main_thread.h" - -// The nomenclature used in this file is intended to clarify thinking -// about the Pepper "main thread". The "main thread" is really an -// interrupt service thread, or an event handler thread, since it is -// bad to do blocking operations or execute code that runs for a long -// time on it. Event handlers should complete quickly -- possibly -// just enqueuing the event for processing by some worker thread -- -// and return, so that additional event dispatch can occur. - -// Code that does real work (and tests) should run in a separate, -// worker thread. The main event handler thread is where the -// post-message handler runs via a pp::Module virtual member function -// (HandleMessage), which represents the plugin instance. This plugin -// instance can go away at any time, e.g., due to surf-away. Thus, -// other threads should not use pointers to the pp::Module, since the -// object isn't reference counted (and probably shouldn't be, since -// it really have to shut down / clean up when Pepper tells it to), -// and main thread-only operations such as PostMessage or -// GetOSFileDescriptor on the FileIO_Dev PP_Resource must not be done -// from the worker threads. - -// Our solution to this is as follows: -// -// The plugin instance object holds a reference to a WeakRefAnchor -// object, and the plugin instance object's dtor invokes the Abandon -// method on the anchor. Since the nacl::WeakRefAnchor object is -// thread-safe and is reference counted, the anchor pointer may be -// passed to worker threads. Worker threads are responsible for -// maintaining the anchor refcount: each thread would hold a -// reference, and must Unref prior to thread exit. The worker threads -// can use plugin::WeakRefCallOnMainThread to enqueue continuation -// callbacks to run on the main thread -- these will get cancelled if -// the WeakRefAnchor was abandoned, which only occurs in the module -// object's dtor, which can only run in the main thread. Since the -// continuation won't run if the plugin instance is still valid, the -// continuation can safely use pointers to the instance to perform -// main-thread operations or to run member functions in the test -// object or in the module object. The worker thread may hold a -// pointer to the plugin instance object in order to schedule -// callbacks via plugin::WeakRefCallOnMainThread using a method -// pointer, but should not otherwise use the pointer. -// -// So, an operation (test) running on a worker thread must be broken -// into separate computation phases according to which thread is -// appropriate for invoking which operations. For compute-only phases -// or manifest RPCs (which block and also invoke CallOnMainThread), -// the computation should occur on the worker thread. When the worker -// thread needs to invoke a main-thread-only operation such as -// PostMessage, it should use its WeakRefAnchor objecct to schedule a -// main thread callback and then wait on a condition variable for the -// operation to complete. The main thread callback can invoke the -// main-thread-only operation, then signal the condition variable to -// wake up the worker thread prior to returning. After the worker -// thread wakes up, it can use other synchronization methods to -// determine if the worker thread should continue to run or exit -// (e.g., if the worker thread is associated with the plugin instance, -// then if the main thread work result is NULL, the worker thread -// should probably Unref its anchor (and do other cleanup) and exit. - -namespace nacl_ppapi { - -template <typename R> class EventThreadWorkStateWrapper; // fwd - -// the worker thread should own the EventThreadWorkState<R> object -template <typename R> -class EventThreadWorkState { - public: - EventThreadWorkState() - : done_(false), - result_(NULL) { - NaClXMutexCtor(&mu_); - NaClXCondVarCtor(&cv_); - } - - virtual ~EventThreadWorkState() { - NaClMutexDtor(&mu_); - NaClCondVarDtor(&cv_); - } - - // Pass ownership of result into the EventThreadWorkState. The value - // of result should be non-NULL to distinguish between - // completion/abandonment. - void SetResult(R *result) { - nacl::MutexLocker take(&mu_); - result_.reset(result); - } - - // Returns result if callback completed, NULL if abandoned - R *WaitForCompletion() { - nacl::MutexLocker take(&mu_); - while (!done_) { - NaClXCondVarWait(&cv_, &mu_); - } - return result_.release(); - } - - private: - friend class EventThreadWorkStateWrapper<R>; - void EventThreadWorkDone() { - nacl::MutexLocker take(&mu_); - done_ = true; - NaClXCondVarBroadcast(&cv_); - } - - NaClMutex mu_; - NaClCondVar cv_; - bool done_; - nacl::scoped_ptr<R> result_; - - DISALLOW_COPY_AND_ASSIGN(EventThreadWorkState); -}; - - -// Wrapper around EventThreadWorkState<R> or subclass thereof. The -// wrapper object should be created by a worker thread and the -// ownership passed into the COMT machinery, to be used and deleted on -// the main thread. This object is automatically deleted by the -// WeakRef machinery when the callback fires, and the dtor will just -// signal completion. If the anchor corresponding to the callback had -// not been abandoned, then the callback function should invoke -// SetResult before returning to pass ownership of a result object (R) -// from the main thread to the worker thread. -// -// Subclasses of EventThreadWorkStateWrapper may be used, so that -// contained input arguments are automatically deleted when the -// callback fires, or input arguments may be stashed in subclasses of -// EventThreadWorkState<R>. -template <typename R> -class EventThreadWorkStateWrapper { - public: - explicit EventThreadWorkStateWrapper(EventThreadWorkState<R> *ws): - ws_(ws) {} - virtual ~EventThreadWorkStateWrapper() { - ws_->EventThreadWorkDone(); - }; - - void SetResult(R *result) { - ws_->SetResult(result); - } - private: - EventThreadWorkState<R> *ws_; - - DISALLOW_COPY_AND_ASSIGN(EventThreadWorkStateWrapper); -}; - -class VoidResult; - -extern VoidResult *const g_void_result; - -class VoidResult { - public: - VoidResult() {} - void *operator new(size_t size) { return g_void_result; } - void operator delete(void *p) {} - private: - DISALLOW_COPY_AND_ASSIGN(VoidResult); -}; - -// Canonical pointer return value used with SetResult when the main -// thread operation does not return a result. The class declaration -// is private, so the compiler should refuse to allow the use of the -// delete operator. - -// A plugin instance object should be referred to only from the main -// thread. Pointers to the anchor object can be given to worker -// thread so they can schedule work on the main thread via COMT. -class NaClPpapiPluginInstance : public pp::Instance { - public: - explicit NaClPpapiPluginInstance(PP_Instance instance); - virtual ~NaClPpapiPluginInstance(); - nacl::WeakRefAnchor* anchor() const { return anchor_; } - protected: - nacl::WeakRefAnchor* anchor_; - DISALLOW_COPY_AND_ASSIGN(NaClPpapiPluginInstance); -}; - -} // namespace nacl_ppapi - -#endif diff --git a/chromium/ppapi/native_client/src/untrusted/nacl_ppapi_util/ppapi_srpc_main.c b/chromium/ppapi/native_client/src/untrusted/nacl_ppapi_util/ppapi_srpc_main.c deleted file mode 100644 index 92898a689e5..00000000000 --- a/chromium/ppapi/native_client/src/untrusted/nacl_ppapi_util/ppapi_srpc_main.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "native_client/src/shared/srpc/nacl_srpc.h" -#include "ppapi/native_client/src/untrusted/nacl_ppapi_util/ppapi_srpc_main.h" - -/* - * Here be dragons. Beware. - * - * We need to provide a main so that when this code is compiled with - * irt=1, we can invoke NaClSrpcModuleInit. This is not needed when - * we compile with irt=0 because the PpapiPluginMain uses SRPC and - * will invoke NaClSrpcModuleInit. However, with irt=1, there are two - * copies of the SRPC (and platform, and ...) libraries: the - * PpapiPluginMain code uses a copy of SRPC in the IRT, and the user - * code -- that's us -- has another copy. The two copies have - * separate allocators, globals, etc because of the IRT separation, so - * that the NaClSrpcModuleInit that is invoked in the IRT will not - * initialize the data structures used by the copy in the user code. - * - * The weak reference to the function __nacl_register_thread_creator - * is an IRT implementation-dependent hack. Here's how it works. In - * irt_stub, there is a definition for __nacl_register_thread_creator, - * so if this code is compiled and linked with irt=1, the weak symbol - * will be overridden with a real function, and the tests inside of - * main will succeed. If this code is compiled and linked with irt=0, - * however, we will not link against irt_stub (-lppapi which is a - * linker script which causes libppapi_stub.a to get included, which - * includes the code from the src/untrusted/irt_stub directory), and - * so the __nacl_register_thread_creator weak symbol will have the - * value zero. Voila, we call NaClSrpcModuleInit in the main function - * below if the scons command invocation had irt=1 set, and we will - * leave it to PpapiPluginMain to invoke NaClSrpcModuleInit when the - * scons invocation had irt=0 set. - * - * Yes, this could be conditionally linked in via scons magic by - * testing the irt bit, avoiding the weak attribute magic. - */ - -struct nacl_irt_ppapihook; - -void __nacl_register_thread_creator(const struct nacl_irt_ppapihook *) - __attribute__((weak)); - -int main(void) { - int rv; - - if (__nacl_register_thread_creator) { - if (!NaClSrpcModuleInit()) { - return 1; - } - } - - rv = PpapiPluginMain(); - - if (__nacl_register_thread_creator) { - NaClSrpcModuleFini(); - } - - return rv; -} diff --git a/chromium/ppapi/native_client/src/untrusted/nacl_ppapi_util/ppapi_srpc_main.h b/chromium/ppapi/native_client/src/untrusted/nacl_ppapi_util/ppapi_srpc_main.h deleted file mode 100644 index bc8d861e068..00000000000 --- a/chromium/ppapi/native_client/src/untrusted/nacl_ppapi_util/ppapi_srpc_main.h +++ /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. - */ - -#ifndef NATIVE_CLIENT_SRC_UNTRUSTED_NACL_PPAPI_UTIL_PPAPI_SRPC_MAIN_H_ -#define NATIVE_CLIENT_SRC_UNTRUSTED_NACL_PPAPI_UTIL_PPAPI_SRPC_MAIN_H_ - -#include "native_client/src/include/nacl_base.h" - -EXTERN_C_BEGIN - -extern int PpapiPluginMain(void); - -EXTERN_C_END - -#endif diff --git a/chromium/ppapi/native_client/src/untrusted/nacl_ppapi_util/string_buffer.cc b/chromium/ppapi/native_client/src/untrusted/nacl_ppapi_util/string_buffer.cc deleted file mode 100644 index 6964bbdf287..00000000000 --- a/chromium/ppapi/native_client/src/untrusted/nacl_ppapi_util/string_buffer.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 <stdarg.h> - -#include "ppapi/native_client/src/untrusted/nacl_ppapi_util/string_buffer.h" - -namespace nacl { - -StringBuffer::StringBuffer() { - nbytes_ = 1024; - insert_ = 0; - buffer_ = reinterpret_cast<char *>(malloc(nbytes_)); - if (NULL == buffer_) { - perror("StringBuffer Ctor malloc"); - abort(); - } - buffer_[0] = '\0'; -} - -void StringBuffer::DiscardOutput() { - insert_ = 0; - buffer_[0] = '\0'; -} - -StringBuffer::~StringBuffer() { - nbytes_ = 0; - insert_ = 0; - free(buffer_); - buffer_ = NULL; -} - -void StringBuffer::Printf(char const *fmt, ...) { - size_t space; - char *insert_pt; - va_list ap; - size_t written = 0; - char *new_buffer; - - for (;;) { - space = nbytes_ - insert_; - insert_pt = buffer_ + insert_; - va_start(ap, fmt); - written = vsnprintf(insert_pt, space, fmt, ap); - va_end(ap); - if (written < space) { - insert_ += written; - break; - } - // insufficient space -- grow the buffer - new_buffer = reinterpret_cast<char *>(realloc(buffer_, 2 * nbytes_)); - if (NULL == new_buffer) { - // give up - fprintf(stderr, "StringBufferPrintf: no memory\n"); - break; - } - nbytes_ *= 2; - buffer_ = new_buffer; - } -} - -} // namespace nacl diff --git a/chromium/ppapi/native_client/src/untrusted/nacl_ppapi_util/string_buffer.h b/chromium/ppapi/native_client/src/untrusted/nacl_ppapi_util/string_buffer.h deleted file mode 100644 index 028e33030d4..00000000000 --- a/chromium/ppapi/native_client/src/untrusted/nacl_ppapi_util/string_buffer.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef NATIVE_CLIENT_TESTS_MANIFEST_FILE_STRING_BUFFER_H_ -#define NATIVE_CLIENT_TESTS_MANIFEST_FILE_STRING_BUFFER_H_ - -#include <string> - -#include <stdio.h> -#include <stdlib.h> -#include <inttypes.h> - -namespace nacl { - -class StringBuffer { - public: - StringBuffer(); - ~StringBuffer(); - void DiscardOutput(); - void Printf(char const *fmt, ...) __attribute__((format(printf, 2, 3))); - std::string ToString() { - return std::string(buffer_, insert_); - } - - private: - size_t nbytes_; - size_t insert_; - char *buffer_; -}; - -} // namespace nacl - -#endif diff --git a/chromium/ppapi/native_client/src/untrusted/pnacl_irt_shim/BUILD.gn b/chromium/ppapi/native_client/src/untrusted/pnacl_irt_shim/BUILD.gn new file mode 100644 index 00000000000..4a6050d7309 --- /dev/null +++ b/chromium/ppapi/native_client/src/untrusted/pnacl_irt_shim/BUILD.gn @@ -0,0 +1,29 @@ +# Copyright 2015 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. + +assert(is_nacl, + "These targets must only be built using the untrusted NaCl toolchains.") + +source_set("aot") { + sources = [ + "irt_shim_ppapi.c", + "pnacl_shim.c", + "shim_entry.c", + "shim_ppapi.c", + ] +} + +source_set("browser") { + sources = [ + "shim_entry.c", + "shim_ppapi.c", + ] +} + +source_set("irt") { + sources = [ + "irt_shim_ppapi.c", + "pnacl_shim.c", + ] +} diff --git a/chromium/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_irt_shim.gyp b/chromium/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_irt_shim.gyp index f78126496bd..946437d9619 100644 --- a/chromium/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_irt_shim.gyp +++ b/chromium/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_irt_shim.gyp @@ -25,6 +25,8 @@ # variable, as it is no longer used. 'out_pnacl_newlib_x86_32_nonsfi': '>(tc_lib_dir_pnacl_translate)/lib-x86-32-nonsfi/>(nlib_target)', 'out_newlib32_nonsfi': '>(tc_lib_dir_pnacl_translate)/lib-x86-32-nonsfi/>(nlib_target)', + 'out_pnacl_newlib_arm_nonsfi': '>(tc_lib_dir_pnacl_translate)/lib-arm-nonsfi/>(nlib_target)', + 'out_newlib_arm_nonsfi': '>(tc_lib_dir_pnacl_translate)/lib-arm-nonsfi/>(nlib_target)', 'build_glibc': 0, 'build_newlib': 0, 'build_pnacl_newlib': 1, @@ -34,6 +36,7 @@ 'enable_arm': 1, 'enable_mips': 1, 'enable_x86_32_nonsfi': 1, + 'enable_arm_nonsfi': 1, 'sources': [ 'irt_shim_ppapi.c', 'pnacl_shim.c', @@ -48,9 +51,6 @@ '-DPNACL_SHIM_AOT', ], }, - 'dependencies': [ - '<(DEPTH)/native_client/tools.gyp:prep_toolchain', - ], }, # Smaller shim library for PNaCl in-browser translation. # Uses an unstable IRT hook interface to get the shim from the IRT itself. @@ -84,9 +84,6 @@ '--strip-debug', ], }, - 'dependencies': [ - '<(DEPTH)/native_client/tools.gyp:prep_toolchain', - ], }, { # Second half of shim library for PNaCl in-browser translation. @@ -106,9 +103,6 @@ 'pnacl_shim.c', ], }, - 'dependencies': [ - '<(DEPTH)/native_client/tools.gyp:prep_toolchain', - ], }, ], } diff --git a/chromium/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/chromium/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c index 82e09e80370..9b73b94f31d 100644 --- a/chromium/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c +++ b/chromium/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2014 The Chromium Authors. All rights reserved. +/* Copyright (c) 2015 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. */ @@ -23,7 +23,6 @@ #include "ppapi/c/ppb_console.h" #include "ppapi/c/ppb_core.h" #include "ppapi/c/ppb_file_io.h" -#include "ppapi/c/ppb_file_mapping.h" #include "ppapi/c/ppb_file_ref.h" #include "ppapi/c/ppb_file_system.h" #include "ppapi/c/ppb_graphics_2d.h" @@ -50,8 +49,10 @@ #include "ppapi/c/ppb_var_array_buffer.h" #include "ppapi/c/ppb_var_dictionary.h" #include "ppapi/c/ppb_video_decoder.h" +#include "ppapi/c/ppb_video_encoder.h" #include "ppapi/c/ppb_websocket.h" #include "ppapi/c/ppp_messaging.h" +#include "ppapi/c/private/ppb_camera_device_private.h" #include "ppapi/c/private/ppb_content_decryptor_private.h" #include "ppapi/c/private/ppb_display_color_profile_private.h" #include "ppapi/c/private/ppb_ext_crx_file_system_private.h" @@ -63,14 +64,11 @@ #include "ppapi/c/private/ppb_flash_drm.h" #include "ppapi/c/private/ppb_flash_menu.h" #include "ppapi/c/private/ppb_host_resolver_private.h" -#include "ppapi/c/private/ppb_image_capture_private.h" #include "ppapi/c/private/ppb_instance_private.h" #include "ppapi/c/private/ppb_isolated_file_system_private.h" -#include "ppapi/c/private/ppb_nacl_private.h" #include "ppapi/c/private/ppb_net_address_private.h" #include "ppapi/c/private/ppb_output_protection_private.h" #include "ppapi/c/private/ppb_platform_verification_private.h" -#include "ppapi/c/private/ppb_talk_private.h" #include "ppapi/c/private/ppb_tcp_server_socket_private.h" #include "ppapi/c/private/ppb_tcp_socket_private.h" #include "ppapi/c/private/ppb_testing_private.h" @@ -103,7 +101,6 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Console_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Core_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileIO_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileIO_1_1; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileMapping_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileRef_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileRef_1_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileRef_1_2; @@ -132,8 +129,11 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetworkMonitor_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetworkProxy_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TCPSocket_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TCPSocket_1_1; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TCPSocket_1_2; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TextInputController_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_UDPSocket_1_0; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_UDPSocket_1_1; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_UDPSocket_1_2; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_URLLoader_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_URLRequestInfo_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_URLResponseInfo_1_0; @@ -146,6 +146,8 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VarDictionary_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoDecoder_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoDecoder_0_2; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoDecoder_1_0; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoEncoder_0_1; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoEncoder_0_2; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_WebSocket_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Messaging_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_AudioInput_Dev_0_3; @@ -163,7 +165,8 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_3; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoDecoder_Dev_0_16; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Selection_Dev_0_3; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_12; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_CameraDevice_Private_0_1; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_14; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_DisplayColorProfile_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Ext_CrxFileSystem_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileIO_Private_0_1; @@ -180,17 +183,13 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Flash_DRM_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Flash_DRM_1_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Flash_Menu_0_2; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_HostResolver_Private_0_1; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_ImageCapture_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Instance_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_IsolatedFileSystem_Private_0_2; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NaCl_Private_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetAddress_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetAddress_Private_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetAddress_Private_1_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_OutputProtection_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_PlatformVerification_Private_0_2; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Talk_Private_1_0; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Talk_Private_2_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TCPServerSocket_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TCPServerSocket_Private_0_2; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TCPSocket_Private_0_3; @@ -204,7 +203,7 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_UMA_Private_0_3; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoDestination_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoSource_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_X509Certificate_Private_0_1; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_12; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_15; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Instance_Private_0_1; /* END Declarations for all Wrapper Infos. */ @@ -516,25 +515,6 @@ static int32_t Pnacl_M25_PPB_FileIO_ReadToArray(PP_Resource file_io, int64_t off /* End wrapper methods for PPB_FileIO_1_1 */ -/* Begin wrapper methods for PPB_FileMapping_0_1 */ - -static int32_t Pnacl_M34_PPB_FileMapping_Map(PP_Instance instance, PP_Resource file_io, int64_t length, uint32_t map_protection, uint32_t map_flags, int64_t offset, void** address, struct PP_CompletionCallback* callback) { - const struct PPB_FileMapping_0_1 *iface = Pnacl_WrapperInfo_PPB_FileMapping_0_1.real_iface; - return iface->Map(instance, file_io, length, map_protection, map_flags, offset, address, *callback); -} - -static int32_t Pnacl_M34_PPB_FileMapping_Unmap(PP_Instance instance, const void* address, int64_t length, struct PP_CompletionCallback* callback) { - const struct PPB_FileMapping_0_1 *iface = Pnacl_WrapperInfo_PPB_FileMapping_0_1.real_iface; - return iface->Unmap(instance, address, length, *callback); -} - -static int64_t Pnacl_M34_PPB_FileMapping_GetMapPageSize(PP_Instance instance) { - const struct PPB_FileMapping_0_1 *iface = Pnacl_WrapperInfo_PPB_FileMapping_0_1.real_iface; - return iface->GetMapPageSize(instance); -} - -/* End wrapper methods for PPB_FileMapping_0_1 */ - /* Begin wrapper methods for PPB_FileRef_1_0 */ static PP_Resource Pnacl_M14_PPB_FileRef_Create(PP_Resource file_system, const char* path) { @@ -1605,6 +1585,70 @@ static int32_t Pnacl_M31_PPB_TCPSocket_SetOption(PP_Resource tcp_socket, PP_TCPS /* End wrapper methods for PPB_TCPSocket_1_1 */ +/* Begin wrapper methods for PPB_TCPSocket_1_2 */ + +static PP_Resource Pnacl_M41_PPB_TCPSocket_Create(PP_Instance instance) { + const struct PPB_TCPSocket_1_2 *iface = Pnacl_WrapperInfo_PPB_TCPSocket_1_2.real_iface; + return iface->Create(instance); +} + +static PP_Bool Pnacl_M41_PPB_TCPSocket_IsTCPSocket(PP_Resource resource) { + const struct PPB_TCPSocket_1_2 *iface = Pnacl_WrapperInfo_PPB_TCPSocket_1_2.real_iface; + return iface->IsTCPSocket(resource); +} + +static int32_t Pnacl_M41_PPB_TCPSocket_Bind(PP_Resource tcp_socket, PP_Resource addr, struct PP_CompletionCallback* callback) { + const struct PPB_TCPSocket_1_2 *iface = Pnacl_WrapperInfo_PPB_TCPSocket_1_2.real_iface; + return iface->Bind(tcp_socket, addr, *callback); +} + +static int32_t Pnacl_M41_PPB_TCPSocket_Connect(PP_Resource tcp_socket, PP_Resource addr, struct PP_CompletionCallback* callback) { + const struct PPB_TCPSocket_1_2 *iface = Pnacl_WrapperInfo_PPB_TCPSocket_1_2.real_iface; + return iface->Connect(tcp_socket, addr, *callback); +} + +static PP_Resource Pnacl_M41_PPB_TCPSocket_GetLocalAddress(PP_Resource tcp_socket) { + const struct PPB_TCPSocket_1_2 *iface = Pnacl_WrapperInfo_PPB_TCPSocket_1_2.real_iface; + return iface->GetLocalAddress(tcp_socket); +} + +static PP_Resource Pnacl_M41_PPB_TCPSocket_GetRemoteAddress(PP_Resource tcp_socket) { + const struct PPB_TCPSocket_1_2 *iface = Pnacl_WrapperInfo_PPB_TCPSocket_1_2.real_iface; + return iface->GetRemoteAddress(tcp_socket); +} + +static int32_t Pnacl_M41_PPB_TCPSocket_Read(PP_Resource tcp_socket, char* buffer, int32_t bytes_to_read, struct PP_CompletionCallback* callback) { + const struct PPB_TCPSocket_1_2 *iface = Pnacl_WrapperInfo_PPB_TCPSocket_1_2.real_iface; + return iface->Read(tcp_socket, buffer, bytes_to_read, *callback); +} + +static int32_t Pnacl_M41_PPB_TCPSocket_Write(PP_Resource tcp_socket, const char* buffer, int32_t bytes_to_write, struct PP_CompletionCallback* callback) { + const struct PPB_TCPSocket_1_2 *iface = Pnacl_WrapperInfo_PPB_TCPSocket_1_2.real_iface; + return iface->Write(tcp_socket, buffer, bytes_to_write, *callback); +} + +static int32_t Pnacl_M41_PPB_TCPSocket_Listen(PP_Resource tcp_socket, int32_t backlog, struct PP_CompletionCallback* callback) { + const struct PPB_TCPSocket_1_2 *iface = Pnacl_WrapperInfo_PPB_TCPSocket_1_2.real_iface; + return iface->Listen(tcp_socket, backlog, *callback); +} + +static int32_t Pnacl_M41_PPB_TCPSocket_Accept(PP_Resource tcp_socket, PP_Resource* accepted_tcp_socket, struct PP_CompletionCallback* callback) { + const struct PPB_TCPSocket_1_2 *iface = Pnacl_WrapperInfo_PPB_TCPSocket_1_2.real_iface; + return iface->Accept(tcp_socket, accepted_tcp_socket, *callback); +} + +static void Pnacl_M41_PPB_TCPSocket_Close(PP_Resource tcp_socket) { + const struct PPB_TCPSocket_1_2 *iface = Pnacl_WrapperInfo_PPB_TCPSocket_1_2.real_iface; + iface->Close(tcp_socket); +} + +static int32_t Pnacl_M41_PPB_TCPSocket_SetOption(PP_Resource tcp_socket, PP_TCPSocket_Option name, struct PP_Var* value, struct PP_CompletionCallback* callback) { + const struct PPB_TCPSocket_1_2 *iface = Pnacl_WrapperInfo_PPB_TCPSocket_1_2.real_iface; + return iface->SetOption(tcp_socket, name, *value, *callback); +} + +/* End wrapper methods for PPB_TCPSocket_1_2 */ + /* Begin wrapper methods for PPB_TextInputController_1_0 */ static void Pnacl_M30_PPB_TextInputController_SetTextInputType(PP_Instance instance, PP_TextInput_Type type) { @@ -1673,6 +1717,104 @@ static int32_t Pnacl_M29_PPB_UDPSocket_SetOption(PP_Resource udp_socket, PP_UDPS /* End wrapper methods for PPB_UDPSocket_1_0 */ +/* Begin wrapper methods for PPB_UDPSocket_1_1 */ + +static PP_Resource Pnacl_M41_PPB_UDPSocket_Create(PP_Instance instance) { + const struct PPB_UDPSocket_1_1 *iface = Pnacl_WrapperInfo_PPB_UDPSocket_1_1.real_iface; + return iface->Create(instance); +} + +static PP_Bool Pnacl_M41_PPB_UDPSocket_IsUDPSocket(PP_Resource resource) { + const struct PPB_UDPSocket_1_1 *iface = Pnacl_WrapperInfo_PPB_UDPSocket_1_1.real_iface; + return iface->IsUDPSocket(resource); +} + +static int32_t Pnacl_M41_PPB_UDPSocket_Bind(PP_Resource udp_socket, PP_Resource addr, struct PP_CompletionCallback* callback) { + const struct PPB_UDPSocket_1_1 *iface = Pnacl_WrapperInfo_PPB_UDPSocket_1_1.real_iface; + return iface->Bind(udp_socket, addr, *callback); +} + +static PP_Resource Pnacl_M41_PPB_UDPSocket_GetBoundAddress(PP_Resource udp_socket) { + const struct PPB_UDPSocket_1_1 *iface = Pnacl_WrapperInfo_PPB_UDPSocket_1_1.real_iface; + return iface->GetBoundAddress(udp_socket); +} + +static int32_t Pnacl_M41_PPB_UDPSocket_RecvFrom(PP_Resource udp_socket, char* buffer, int32_t num_bytes, PP_Resource* addr, struct PP_CompletionCallback* callback) { + const struct PPB_UDPSocket_1_1 *iface = Pnacl_WrapperInfo_PPB_UDPSocket_1_1.real_iface; + return iface->RecvFrom(udp_socket, buffer, num_bytes, addr, *callback); +} + +static int32_t Pnacl_M41_PPB_UDPSocket_SendTo(PP_Resource udp_socket, const char* buffer, int32_t num_bytes, PP_Resource addr, struct PP_CompletionCallback* callback) { + const struct PPB_UDPSocket_1_1 *iface = Pnacl_WrapperInfo_PPB_UDPSocket_1_1.real_iface; + return iface->SendTo(udp_socket, buffer, num_bytes, addr, *callback); +} + +static void Pnacl_M41_PPB_UDPSocket_Close(PP_Resource udp_socket) { + const struct PPB_UDPSocket_1_1 *iface = Pnacl_WrapperInfo_PPB_UDPSocket_1_1.real_iface; + iface->Close(udp_socket); +} + +static int32_t Pnacl_M41_PPB_UDPSocket_SetOption(PP_Resource udp_socket, PP_UDPSocket_Option name, struct PP_Var* value, struct PP_CompletionCallback* callback) { + const struct PPB_UDPSocket_1_1 *iface = Pnacl_WrapperInfo_PPB_UDPSocket_1_1.real_iface; + return iface->SetOption(udp_socket, name, *value, *callback); +} + +/* End wrapper methods for PPB_UDPSocket_1_1 */ + +/* Begin wrapper methods for PPB_UDPSocket_1_2 */ + +static PP_Resource Pnacl_M43_PPB_UDPSocket_Create(PP_Instance instance) { + const struct PPB_UDPSocket_1_2 *iface = Pnacl_WrapperInfo_PPB_UDPSocket_1_2.real_iface; + return iface->Create(instance); +} + +static PP_Bool Pnacl_M43_PPB_UDPSocket_IsUDPSocket(PP_Resource resource) { + const struct PPB_UDPSocket_1_2 *iface = Pnacl_WrapperInfo_PPB_UDPSocket_1_2.real_iface; + return iface->IsUDPSocket(resource); +} + +static int32_t Pnacl_M43_PPB_UDPSocket_Bind(PP_Resource udp_socket, PP_Resource addr, struct PP_CompletionCallback* callback) { + const struct PPB_UDPSocket_1_2 *iface = Pnacl_WrapperInfo_PPB_UDPSocket_1_2.real_iface; + return iface->Bind(udp_socket, addr, *callback); +} + +static PP_Resource Pnacl_M43_PPB_UDPSocket_GetBoundAddress(PP_Resource udp_socket) { + const struct PPB_UDPSocket_1_2 *iface = Pnacl_WrapperInfo_PPB_UDPSocket_1_2.real_iface; + return iface->GetBoundAddress(udp_socket); +} + +static int32_t Pnacl_M43_PPB_UDPSocket_RecvFrom(PP_Resource udp_socket, char* buffer, int32_t num_bytes, PP_Resource* addr, struct PP_CompletionCallback* callback) { + const struct PPB_UDPSocket_1_2 *iface = Pnacl_WrapperInfo_PPB_UDPSocket_1_2.real_iface; + return iface->RecvFrom(udp_socket, buffer, num_bytes, addr, *callback); +} + +static int32_t Pnacl_M43_PPB_UDPSocket_SendTo(PP_Resource udp_socket, const char* buffer, int32_t num_bytes, PP_Resource addr, struct PP_CompletionCallback* callback) { + const struct PPB_UDPSocket_1_2 *iface = Pnacl_WrapperInfo_PPB_UDPSocket_1_2.real_iface; + return iface->SendTo(udp_socket, buffer, num_bytes, addr, *callback); +} + +static void Pnacl_M43_PPB_UDPSocket_Close(PP_Resource udp_socket) { + const struct PPB_UDPSocket_1_2 *iface = Pnacl_WrapperInfo_PPB_UDPSocket_1_2.real_iface; + iface->Close(udp_socket); +} + +static int32_t Pnacl_M43_PPB_UDPSocket_SetOption(PP_Resource udp_socket, PP_UDPSocket_Option name, struct PP_Var* value, struct PP_CompletionCallback* callback) { + const struct PPB_UDPSocket_1_2 *iface = Pnacl_WrapperInfo_PPB_UDPSocket_1_2.real_iface; + return iface->SetOption(udp_socket, name, *value, *callback); +} + +static int32_t Pnacl_M43_PPB_UDPSocket_JoinGroup(PP_Resource udp_socket, PP_Resource group, struct PP_CompletionCallback* callback) { + const struct PPB_UDPSocket_1_2 *iface = Pnacl_WrapperInfo_PPB_UDPSocket_1_2.real_iface; + return iface->JoinGroup(udp_socket, group, *callback); +} + +static int32_t Pnacl_M43_PPB_UDPSocket_LeaveGroup(PP_Resource udp_socket, PP_Resource group, struct PP_CompletionCallback* callback) { + const struct PPB_UDPSocket_1_2 *iface = Pnacl_WrapperInfo_PPB_UDPSocket_1_2.real_iface; + return iface->LeaveGroup(udp_socket, group, *callback); +} + +/* End wrapper methods for PPB_UDPSocket_1_2 */ + /* Begin wrapper methods for PPB_URLLoader_1_0 */ static PP_Resource Pnacl_M14_PPB_URLLoader_Create(PP_Instance instance) { @@ -2076,6 +2218,134 @@ static int32_t Pnacl_M40_PPB_VideoDecoder_Reset(PP_Resource video_decoder, struc /* End wrapper methods for PPB_VideoDecoder_1_0 */ +/* Begin wrapper methods for PPB_VideoEncoder_0_1 */ + +static PP_Resource Pnacl_M42_PPB_VideoEncoder_Create(PP_Instance instance) { + const struct PPB_VideoEncoder_0_1 *iface = Pnacl_WrapperInfo_PPB_VideoEncoder_0_1.real_iface; + return iface->Create(instance); +} + +static PP_Bool Pnacl_M42_PPB_VideoEncoder_IsVideoEncoder(PP_Resource resource) { + const struct PPB_VideoEncoder_0_1 *iface = Pnacl_WrapperInfo_PPB_VideoEncoder_0_1.real_iface; + return iface->IsVideoEncoder(resource); +} + +static int32_t Pnacl_M42_PPB_VideoEncoder_GetSupportedProfiles(PP_Resource video_encoder, struct PP_ArrayOutput* output, struct PP_CompletionCallback* callback) { + const struct PPB_VideoEncoder_0_1 *iface = Pnacl_WrapperInfo_PPB_VideoEncoder_0_1.real_iface; + return iface->GetSupportedProfiles(video_encoder, *output, *callback); +} + +static int32_t Pnacl_M42_PPB_VideoEncoder_Initialize(PP_Resource video_encoder, PP_VideoFrame_Format input_format, const struct PP_Size* input_visible_size, PP_VideoProfile output_profile, uint32_t initial_bitrate, PP_HardwareAcceleration acceleration, struct PP_CompletionCallback* callback) { + const struct PPB_VideoEncoder_0_1 *iface = Pnacl_WrapperInfo_PPB_VideoEncoder_0_1.real_iface; + return iface->Initialize(video_encoder, input_format, input_visible_size, output_profile, initial_bitrate, acceleration, *callback); +} + +static int32_t Pnacl_M42_PPB_VideoEncoder_GetFramesRequired(PP_Resource video_encoder) { + const struct PPB_VideoEncoder_0_1 *iface = Pnacl_WrapperInfo_PPB_VideoEncoder_0_1.real_iface; + return iface->GetFramesRequired(video_encoder); +} + +static int32_t Pnacl_M42_PPB_VideoEncoder_GetFrameCodedSize(PP_Resource video_encoder, struct PP_Size* coded_size) { + const struct PPB_VideoEncoder_0_1 *iface = Pnacl_WrapperInfo_PPB_VideoEncoder_0_1.real_iface; + return iface->GetFrameCodedSize(video_encoder, coded_size); +} + +static int32_t Pnacl_M42_PPB_VideoEncoder_GetVideoFrame(PP_Resource video_encoder, PP_Resource* video_frame, struct PP_CompletionCallback* callback) { + const struct PPB_VideoEncoder_0_1 *iface = Pnacl_WrapperInfo_PPB_VideoEncoder_0_1.real_iface; + return iface->GetVideoFrame(video_encoder, video_frame, *callback); +} + +static int32_t Pnacl_M42_PPB_VideoEncoder_Encode(PP_Resource video_encoder, PP_Resource video_frame, PP_Bool force_keyframe, struct PP_CompletionCallback* callback) { + const struct PPB_VideoEncoder_0_1 *iface = Pnacl_WrapperInfo_PPB_VideoEncoder_0_1.real_iface; + return iface->Encode(video_encoder, video_frame, force_keyframe, *callback); +} + +static int32_t Pnacl_M42_PPB_VideoEncoder_GetBitstreamBuffer(PP_Resource video_encoder, struct PP_BitstreamBuffer* bitstream_buffer, struct PP_CompletionCallback* callback) { + const struct PPB_VideoEncoder_0_1 *iface = Pnacl_WrapperInfo_PPB_VideoEncoder_0_1.real_iface; + return iface->GetBitstreamBuffer(video_encoder, bitstream_buffer, *callback); +} + +static void Pnacl_M42_PPB_VideoEncoder_RecycleBitstreamBuffer(PP_Resource video_encoder, const struct PP_BitstreamBuffer* bitstream_buffer) { + const struct PPB_VideoEncoder_0_1 *iface = Pnacl_WrapperInfo_PPB_VideoEncoder_0_1.real_iface; + iface->RecycleBitstreamBuffer(video_encoder, bitstream_buffer); +} + +static void Pnacl_M42_PPB_VideoEncoder_RequestEncodingParametersChange(PP_Resource video_encoder, uint32_t bitrate, uint32_t framerate) { + const struct PPB_VideoEncoder_0_1 *iface = Pnacl_WrapperInfo_PPB_VideoEncoder_0_1.real_iface; + iface->RequestEncodingParametersChange(video_encoder, bitrate, framerate); +} + +static void Pnacl_M42_PPB_VideoEncoder_Close(PP_Resource video_encoder) { + const struct PPB_VideoEncoder_0_1 *iface = Pnacl_WrapperInfo_PPB_VideoEncoder_0_1.real_iface; + iface->Close(video_encoder); +} + +/* End wrapper methods for PPB_VideoEncoder_0_1 */ + +/* Begin wrapper methods for PPB_VideoEncoder_0_2 */ + +static PP_Resource Pnacl_M44_PPB_VideoEncoder_Create(PP_Instance instance) { + const struct PPB_VideoEncoder_0_2 *iface = Pnacl_WrapperInfo_PPB_VideoEncoder_0_2.real_iface; + return iface->Create(instance); +} + +static PP_Bool Pnacl_M44_PPB_VideoEncoder_IsVideoEncoder(PP_Resource resource) { + const struct PPB_VideoEncoder_0_2 *iface = Pnacl_WrapperInfo_PPB_VideoEncoder_0_2.real_iface; + return iface->IsVideoEncoder(resource); +} + +static int32_t Pnacl_M44_PPB_VideoEncoder_GetSupportedProfiles(PP_Resource video_encoder, struct PP_ArrayOutput* output, struct PP_CompletionCallback* callback) { + const struct PPB_VideoEncoder_0_2 *iface = Pnacl_WrapperInfo_PPB_VideoEncoder_0_2.real_iface; + return iface->GetSupportedProfiles(video_encoder, *output, *callback); +} + +static int32_t Pnacl_M44_PPB_VideoEncoder_Initialize(PP_Resource video_encoder, PP_VideoFrame_Format input_format, const struct PP_Size* input_visible_size, PP_VideoProfile output_profile, uint32_t initial_bitrate, PP_HardwareAcceleration acceleration, struct PP_CompletionCallback* callback) { + const struct PPB_VideoEncoder_0_2 *iface = Pnacl_WrapperInfo_PPB_VideoEncoder_0_2.real_iface; + return iface->Initialize(video_encoder, input_format, input_visible_size, output_profile, initial_bitrate, acceleration, *callback); +} + +static int32_t Pnacl_M44_PPB_VideoEncoder_GetFramesRequired(PP_Resource video_encoder) { + const struct PPB_VideoEncoder_0_2 *iface = Pnacl_WrapperInfo_PPB_VideoEncoder_0_2.real_iface; + return iface->GetFramesRequired(video_encoder); +} + +static int32_t Pnacl_M44_PPB_VideoEncoder_GetFrameCodedSize(PP_Resource video_encoder, struct PP_Size* coded_size) { + const struct PPB_VideoEncoder_0_2 *iface = Pnacl_WrapperInfo_PPB_VideoEncoder_0_2.real_iface; + return iface->GetFrameCodedSize(video_encoder, coded_size); +} + +static int32_t Pnacl_M44_PPB_VideoEncoder_GetVideoFrame(PP_Resource video_encoder, PP_Resource* video_frame, struct PP_CompletionCallback* callback) { + const struct PPB_VideoEncoder_0_2 *iface = Pnacl_WrapperInfo_PPB_VideoEncoder_0_2.real_iface; + return iface->GetVideoFrame(video_encoder, video_frame, *callback); +} + +static int32_t Pnacl_M44_PPB_VideoEncoder_Encode(PP_Resource video_encoder, PP_Resource video_frame, PP_Bool force_keyframe, struct PP_CompletionCallback* callback) { + const struct PPB_VideoEncoder_0_2 *iface = Pnacl_WrapperInfo_PPB_VideoEncoder_0_2.real_iface; + return iface->Encode(video_encoder, video_frame, force_keyframe, *callback); +} + +static int32_t Pnacl_M44_PPB_VideoEncoder_GetBitstreamBuffer(PP_Resource video_encoder, struct PP_BitstreamBuffer* bitstream_buffer, struct PP_CompletionCallback* callback) { + const struct PPB_VideoEncoder_0_2 *iface = Pnacl_WrapperInfo_PPB_VideoEncoder_0_2.real_iface; + return iface->GetBitstreamBuffer(video_encoder, bitstream_buffer, *callback); +} + +static void Pnacl_M44_PPB_VideoEncoder_RecycleBitstreamBuffer(PP_Resource video_encoder, const struct PP_BitstreamBuffer* bitstream_buffer) { + const struct PPB_VideoEncoder_0_2 *iface = Pnacl_WrapperInfo_PPB_VideoEncoder_0_2.real_iface; + iface->RecycleBitstreamBuffer(video_encoder, bitstream_buffer); +} + +static void Pnacl_M44_PPB_VideoEncoder_RequestEncodingParametersChange(PP_Resource video_encoder, uint32_t bitrate, uint32_t framerate) { + const struct PPB_VideoEncoder_0_2 *iface = Pnacl_WrapperInfo_PPB_VideoEncoder_0_2.real_iface; + iface->RequestEncodingParametersChange(video_encoder, bitrate, framerate); +} + +static void Pnacl_M44_PPB_VideoEncoder_Close(PP_Resource video_encoder) { + const struct PPB_VideoEncoder_0_2 *iface = Pnacl_WrapperInfo_PPB_VideoEncoder_0_2.real_iface; + iface->Close(video_encoder); +} + +/* End wrapper methods for PPB_VideoEncoder_0_2 */ + /* Not generating wrapper methods for PPB_VideoFrame_0_1 */ /* Not generating wrapper methods for PPB_View_1_0 */ @@ -2772,89 +3042,108 @@ static struct PP_Var Pnacl_M13_PPP_Selection_Dev_GetSelectedText(PP_Instance ins /* Not generating wrapper methods for PPB_CameraCapabilities_Private_0_1 */ -/* Begin wrapper methods for PPB_ContentDecryptor_Private_0_12 */ +/* Begin wrapper methods for PPB_CameraDevice_Private_0_1 */ -static void Pnacl_M36_PPB_ContentDecryptor_Private_PromiseResolved(PP_Instance instance, uint32_t promise_id) { - const struct PPB_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_12.real_iface; - iface->PromiseResolved(instance, promise_id); +static PP_Resource Pnacl_M42_PPB_CameraDevice_Private_Create(PP_Instance instance) { + const struct PPB_CameraDevice_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_CameraDevice_Private_0_1.real_iface; + return iface->Create(instance); } -static void Pnacl_M36_PPB_ContentDecryptor_Private_PromiseResolvedWithSession(PP_Instance instance, uint32_t promise_id, struct PP_Var* web_session_id) { - const struct PPB_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_12.real_iface; - iface->PromiseResolvedWithSession(instance, promise_id, *web_session_id); +static PP_Bool Pnacl_M42_PPB_CameraDevice_Private_IsCameraDevice(PP_Resource resource) { + const struct PPB_CameraDevice_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_CameraDevice_Private_0_1.real_iface; + return iface->IsCameraDevice(resource); } -static void Pnacl_M36_PPB_ContentDecryptor_Private_PromiseResolvedWithKeyIds(PP_Instance instance, uint32_t promise_id, struct PP_Var* key_ids_array) { - const struct PPB_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_12.real_iface; - iface->PromiseResolvedWithKeyIds(instance, promise_id, *key_ids_array); +static int32_t Pnacl_M42_PPB_CameraDevice_Private_Open(PP_Resource camera_device, struct PP_Var* device_id, struct PP_CompletionCallback* callback) { + const struct PPB_CameraDevice_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_CameraDevice_Private_0_1.real_iface; + return iface->Open(camera_device, *device_id, *callback); } -static void Pnacl_M36_PPB_ContentDecryptor_Private_PromiseRejected(PP_Instance instance, uint32_t promise_id, PP_CdmExceptionCode exception_code, uint32_t system_code, struct PP_Var* error_description) { - const struct PPB_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_12.real_iface; - iface->PromiseRejected(instance, promise_id, exception_code, system_code, *error_description); +static void Pnacl_M42_PPB_CameraDevice_Private_Close(PP_Resource camera_device) { + const struct PPB_CameraDevice_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_CameraDevice_Private_0_1.real_iface; + iface->Close(camera_device); } -static void Pnacl_M36_PPB_ContentDecryptor_Private_SessionMessage(PP_Instance instance, struct PP_Var* web_session_id, struct PP_Var* message, struct PP_Var* destination_url) { - const struct PPB_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_12.real_iface; - iface->SessionMessage(instance, *web_session_id, *message, *destination_url); +static int32_t Pnacl_M42_PPB_CameraDevice_Private_GetCameraCapabilities(PP_Resource camera_device, PP_Resource* capabilities, struct PP_CompletionCallback* callback) { + const struct PPB_CameraDevice_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_CameraDevice_Private_0_1.real_iface; + return iface->GetCameraCapabilities(camera_device, capabilities, *callback); +} + +/* End wrapper methods for PPB_CameraDevice_Private_0_1 */ + +/* Begin wrapper methods for PPB_ContentDecryptor_Private_0_14 */ + +static void Pnacl_M44_PPB_ContentDecryptor_Private_PromiseResolved(PP_Instance instance, uint32_t promise_id) { + const struct PPB_ContentDecryptor_Private_0_14 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_14.real_iface; + iface->PromiseResolved(instance, promise_id); +} + +static void Pnacl_M44_PPB_ContentDecryptor_Private_PromiseResolvedWithSession(PP_Instance instance, uint32_t promise_id, struct PP_Var* session_id) { + const struct PPB_ContentDecryptor_Private_0_14 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_14.real_iface; + iface->PromiseResolvedWithSession(instance, promise_id, *session_id); +} + +static void Pnacl_M44_PPB_ContentDecryptor_Private_PromiseRejected(PP_Instance instance, uint32_t promise_id, PP_CdmExceptionCode exception_code, uint32_t system_code, struct PP_Var* error_description) { + const struct PPB_ContentDecryptor_Private_0_14 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_14.real_iface; + iface->PromiseRejected(instance, promise_id, exception_code, system_code, *error_description); } -static void Pnacl_M36_PPB_ContentDecryptor_Private_SessionKeysChange(PP_Instance instance, struct PP_Var* web_session_id, PP_Bool has_additional_usable_key) { - const struct PPB_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_12.real_iface; - iface->SessionKeysChange(instance, *web_session_id, has_additional_usable_key); +static void Pnacl_M44_PPB_ContentDecryptor_Private_SessionMessage(PP_Instance instance, struct PP_Var* session_id, PP_CdmMessageType message_type, struct PP_Var* message, struct PP_Var* legacy_destination_url) { + const struct PPB_ContentDecryptor_Private_0_14 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_14.real_iface; + iface->SessionMessage(instance, *session_id, message_type, *message, *legacy_destination_url); } -static void Pnacl_M36_PPB_ContentDecryptor_Private_SessionExpirationChange(PP_Instance instance, struct PP_Var* web_session_id, PP_Time new_expiry_time) { - const struct PPB_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_12.real_iface; - iface->SessionExpirationChange(instance, *web_session_id, new_expiry_time); +static void Pnacl_M44_PPB_ContentDecryptor_Private_SessionKeysChange(PP_Instance instance, struct PP_Var* session_id, PP_Bool has_additional_usable_key, uint32_t key_count, const struct PP_KeyInformation key_information[]) { + const struct PPB_ContentDecryptor_Private_0_14 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_14.real_iface; + iface->SessionKeysChange(instance, *session_id, has_additional_usable_key, key_count, key_information); } -static void Pnacl_M36_PPB_ContentDecryptor_Private_SessionReady(PP_Instance instance, struct PP_Var* web_session_id) { - const struct PPB_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_12.real_iface; - iface->SessionReady(instance, *web_session_id); +static void Pnacl_M44_PPB_ContentDecryptor_Private_SessionExpirationChange(PP_Instance instance, struct PP_Var* session_id, PP_Time new_expiry_time) { + const struct PPB_ContentDecryptor_Private_0_14 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_14.real_iface; + iface->SessionExpirationChange(instance, *session_id, new_expiry_time); } -static void Pnacl_M36_PPB_ContentDecryptor_Private_SessionClosed(PP_Instance instance, struct PP_Var* web_session_id) { - const struct PPB_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_12.real_iface; - iface->SessionClosed(instance, *web_session_id); +static void Pnacl_M44_PPB_ContentDecryptor_Private_SessionClosed(PP_Instance instance, struct PP_Var* session_id) { + const struct PPB_ContentDecryptor_Private_0_14 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_14.real_iface; + iface->SessionClosed(instance, *session_id); } -static void Pnacl_M36_PPB_ContentDecryptor_Private_SessionError(PP_Instance instance, struct PP_Var* web_session_id, PP_CdmExceptionCode exception_code, uint32_t system_code, struct PP_Var* error_description) { - const struct PPB_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_12.real_iface; - iface->SessionError(instance, *web_session_id, exception_code, system_code, *error_description); +static void Pnacl_M44_PPB_ContentDecryptor_Private_LegacySessionError(PP_Instance instance, struct PP_Var* session_id, PP_CdmExceptionCode exception_code, uint32_t system_code, struct PP_Var* error_description) { + const struct PPB_ContentDecryptor_Private_0_14 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_14.real_iface; + iface->LegacySessionError(instance, *session_id, exception_code, system_code, *error_description); } -static void Pnacl_M36_PPB_ContentDecryptor_Private_DeliverBlock(PP_Instance instance, PP_Resource decrypted_block, const struct PP_DecryptedBlockInfo* decrypted_block_info) { - const struct PPB_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_12.real_iface; +static void Pnacl_M44_PPB_ContentDecryptor_Private_DeliverBlock(PP_Instance instance, PP_Resource decrypted_block, const struct PP_DecryptedBlockInfo* decrypted_block_info) { + const struct PPB_ContentDecryptor_Private_0_14 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_14.real_iface; iface->DeliverBlock(instance, decrypted_block, decrypted_block_info); } -static void Pnacl_M36_PPB_ContentDecryptor_Private_DecoderInitializeDone(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id, PP_Bool success) { - const struct PPB_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_12.real_iface; +static void Pnacl_M44_PPB_ContentDecryptor_Private_DecoderInitializeDone(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id, PP_Bool success) { + const struct PPB_ContentDecryptor_Private_0_14 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_14.real_iface; iface->DecoderInitializeDone(instance, decoder_type, request_id, success); } -static void Pnacl_M36_PPB_ContentDecryptor_Private_DecoderDeinitializeDone(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) { - const struct PPB_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_12.real_iface; +static void Pnacl_M44_PPB_ContentDecryptor_Private_DecoderDeinitializeDone(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) { + const struct PPB_ContentDecryptor_Private_0_14 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_14.real_iface; iface->DecoderDeinitializeDone(instance, decoder_type, request_id); } -static void Pnacl_M36_PPB_ContentDecryptor_Private_DecoderResetDone(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) { - const struct PPB_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_12.real_iface; +static void Pnacl_M44_PPB_ContentDecryptor_Private_DecoderResetDone(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) { + const struct PPB_ContentDecryptor_Private_0_14 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_14.real_iface; iface->DecoderResetDone(instance, decoder_type, request_id); } -static void Pnacl_M36_PPB_ContentDecryptor_Private_DeliverFrame(PP_Instance instance, PP_Resource decrypted_frame, const struct PP_DecryptedFrameInfo* decrypted_frame_info) { - const struct PPB_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_12.real_iface; +static void Pnacl_M44_PPB_ContentDecryptor_Private_DeliverFrame(PP_Instance instance, PP_Resource decrypted_frame, const struct PP_DecryptedFrameInfo* decrypted_frame_info) { + const struct PPB_ContentDecryptor_Private_0_14 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_14.real_iface; iface->DeliverFrame(instance, decrypted_frame, decrypted_frame_info); } -static void Pnacl_M36_PPB_ContentDecryptor_Private_DeliverSamples(PP_Instance instance, PP_Resource audio_frames, const struct PP_DecryptedSampleInfo* decrypted_sample_info) { - const struct PPB_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_12.real_iface; +static void Pnacl_M44_PPB_ContentDecryptor_Private_DeliverSamples(PP_Instance instance, PP_Resource audio_frames, const struct PP_DecryptedSampleInfo* decrypted_sample_info) { + const struct PPB_ContentDecryptor_Private_0_14 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_14.real_iface; iface->DeliverSamples(instance, audio_frames, decrypted_sample_info); } -/* End wrapper methods for PPB_ContentDecryptor_Private_0_12 */ +/* End wrapper methods for PPB_ContentDecryptor_Private_0_14 */ /* Begin wrapper methods for PPB_DisplayColorProfile_Private_0_1 */ @@ -3427,47 +3716,6 @@ static PP_Bool Pnacl_M19_PPB_HostResolver_Private_GetNetAddress(PP_Resource host /* End wrapper methods for PPB_HostResolver_Private_0_1 */ -/* Not generating wrapper methods for PPB_ImageCaptureConfig_Private_0_1 */ - -/* Begin wrapper methods for PPB_ImageCapture_Private_0_1 */ - -static PP_Resource Pnacl_M39_PPB_ImageCapture_Private_Create(PP_Instance instance, struct PP_Var* camera_source_id, PPB_ImageCapture_Private_ErrorCallback error_callback, void* user_data) { - const struct PPB_ImageCapture_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_ImageCapture_Private_0_1.real_iface; - return iface->Create(instance, *camera_source_id, error_callback, user_data); -} - -static PP_Bool Pnacl_M39_PPB_ImageCapture_Private_IsImageCapture(PP_Resource resource) { - const struct PPB_ImageCapture_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_ImageCapture_Private_0_1.real_iface; - return iface->IsImageCapture(resource); -} - -static int32_t Pnacl_M39_PPB_ImageCapture_Private_Close(PP_Resource resource, struct PP_CompletionCallback* callback) { - const struct PPB_ImageCapture_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_ImageCapture_Private_0_1.real_iface; - return iface->Close(resource, *callback); -} - -static int32_t Pnacl_M39_PPB_ImageCapture_Private_SetConfig(PP_Resource image_capture, PP_Resource config, struct PP_CompletionCallback* callback) { - const struct PPB_ImageCapture_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_ImageCapture_Private_0_1.real_iface; - return iface->SetConfig(image_capture, config, *callback); -} - -static int32_t Pnacl_M39_PPB_ImageCapture_Private_GetConfig(PP_Resource image_capture, PP_Resource* config, struct PP_CompletionCallback* callback) { - const struct PPB_ImageCapture_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_ImageCapture_Private_0_1.real_iface; - return iface->GetConfig(image_capture, config, *callback); -} - -static int32_t Pnacl_M39_PPB_ImageCapture_Private_GetCameraCapabilities(PP_Resource image_capture, PP_Resource* capabilities, struct PP_CompletionCallback* callback) { - const struct PPB_ImageCapture_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_ImageCapture_Private_0_1.real_iface; - return iface->GetCameraCapabilities(image_capture, capabilities, *callback); -} - -static int32_t Pnacl_M39_PPB_ImageCapture_Private_CaptureStillImage(PP_Resource image_capture, PPB_ImageCapture_Private_ShutterCallback shutter_callback, PPB_ImageCapture_Private_PreviewCallback preview_callback, PPB_ImageCapture_Private_JpegCallback jpeg_callback, int64_t* sequence_id) { - const struct PPB_ImageCapture_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_ImageCapture_Private_0_1.real_iface; - return iface->CaptureStillImage(image_capture, shutter_callback, preview_callback, jpeg_callback, sequence_id); -} - -/* End wrapper methods for PPB_ImageCapture_Private_0_1 */ - /* Not generating wrapper methods for PPB_InputEvent_Private_0_1 */ /* Begin wrapper methods for PPB_Instance_Private_0_1 */ @@ -3498,190 +3746,6 @@ static int32_t Pnacl_M33_PPB_IsolatedFileSystem_Private_Open(PP_Instance instanc /* End wrapper methods for PPB_IsolatedFileSystem_Private_0_2 */ -/* Begin wrapper methods for PPB_NaCl_Private_1_0 */ - -static void Pnacl_M25_PPB_NaCl_Private_LaunchSelLdr(PP_Instance instance, PP_Bool main_service_runtime, const char* alleged_url, const struct PP_NaClFileInfo* nexe_file_info, PP_Bool uses_nonsfi_mode, PP_Bool enable_ppapi_dev, PP_NaClAppProcessType process_type, void* imc_handle, struct PP_CompletionCallback* callback) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - iface->LaunchSelLdr(instance, main_service_runtime, alleged_url, nexe_file_info, uses_nonsfi_mode, enable_ppapi_dev, process_type, imc_handle, *callback); -} - -static PP_Bool Pnacl_M25_PPB_NaCl_Private_StartPpapiProxy(PP_Instance instance) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - return iface->StartPpapiProxy(instance); -} - -static int32_t Pnacl_M25_PPB_NaCl_Private_UrandomFD(void) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - return iface->UrandomFD(); -} - -static PP_Bool Pnacl_M25_PPB_NaCl_Private_Are3DInterfacesDisabled(void) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - return iface->Are3DInterfacesDisabled(); -} - -static int32_t Pnacl_M25_PPB_NaCl_Private_BrokerDuplicateHandle(PP_FileHandle source_handle, uint32_t process_id, PP_FileHandle* target_handle, uint32_t desired_access, uint32_t options) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - return iface->BrokerDuplicateHandle(source_handle, process_id, target_handle, desired_access, options); -} - -static void Pnacl_M25_PPB_NaCl_Private_GetReadExecPnaclFd(const char* url, struct PP_NaClFileInfo* out_file_info) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - iface->GetReadExecPnaclFd(url, out_file_info); -} - -static PP_FileHandle Pnacl_M25_PPB_NaCl_Private_CreateTemporaryFile(PP_Instance instance) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - return iface->CreateTemporaryFile(instance); -} - -static int32_t Pnacl_M25_PPB_NaCl_Private_GetNumberOfProcessors(void) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - return iface->GetNumberOfProcessors(); -} - -static PP_Bool Pnacl_M25_PPB_NaCl_Private_IsNonSFIModeEnabled(void) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - return iface->IsNonSFIModeEnabled(); -} - -static void Pnacl_M25_PPB_NaCl_Private_ReportTranslationFinished(PP_Instance instance, PP_Bool success, int32_t opt_level, int64_t pexe_size, int64_t compile_time_us) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - iface->ReportTranslationFinished(instance, success, opt_level, pexe_size, compile_time_us); -} - -static void Pnacl_M25_PPB_NaCl_Private_DispatchEvent(PP_Instance instance, PP_NaClEventType event_type, const char* resource_url, PP_Bool length_is_computable, uint64_t loaded_bytes, uint64_t total_bytes) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - iface->DispatchEvent(instance, event_type, resource_url, length_is_computable, loaded_bytes, total_bytes); -} - -static void Pnacl_M25_PPB_NaCl_Private_ReportLoadSuccess(PP_Instance instance, uint64_t loaded_bytes, uint64_t total_bytes) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - iface->ReportLoadSuccess(instance, loaded_bytes, total_bytes); -} - -static void Pnacl_M25_PPB_NaCl_Private_ReportLoadError(PP_Instance instance, PP_NaClError error, const char* error_message) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - iface->ReportLoadError(instance, error, error_message); -} - -static void Pnacl_M25_PPB_NaCl_Private_ReportLoadAbort(PP_Instance instance) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - iface->ReportLoadAbort(instance); -} - -static void Pnacl_M25_PPB_NaCl_Private_InstanceCreated(PP_Instance instance) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - iface->InstanceCreated(instance); -} - -static void Pnacl_M25_PPB_NaCl_Private_InstanceDestroyed(PP_Instance instance) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - iface->InstanceDestroyed(instance); -} - -static PP_Bool Pnacl_M25_PPB_NaCl_Private_NaClDebugEnabledForURL(const char* alleged_nmf_url) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - return iface->NaClDebugEnabledForURL(alleged_nmf_url); -} - -static const char* Pnacl_M25_PPB_NaCl_Private_GetSandboxArch(void) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - return iface->GetSandboxArch(); -} - -static void Pnacl_M25_PPB_NaCl_Private_LogToConsole(PP_Instance instance, const char* message) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - iface->LogToConsole(instance, message); -} - -static PP_NaClReadyState Pnacl_M25_PPB_NaCl_Private_GetNaClReadyState(PP_Instance instance) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - return iface->GetNaClReadyState(instance); -} - -static void Pnacl_M25_PPB_NaCl_Private_Vlog(const char* message) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - iface->Vlog(message); -} - -static void Pnacl_M25_PPB_NaCl_Private_InitializePlugin(PP_Instance instance, uint32_t argc, const char* argn[], const char* argv[]) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - iface->InitializePlugin(instance, argc, argn, argv); -} - -static int64_t Pnacl_M25_PPB_NaCl_Private_GetNexeSize(PP_Instance instance) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - return iface->GetNexeSize(instance); -} - -static void Pnacl_M25_PPB_NaCl_Private_RequestNaClManifest(PP_Instance instance, struct PP_CompletionCallback* callback) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - iface->RequestNaClManifest(instance, *callback); -} - -static void Pnacl_M25_PPB_NaCl_Private_GetManifestBaseURL(struct PP_Var* _struct_result, PP_Instance instance) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - *_struct_result = iface->GetManifestBaseURL(instance); -} - -static void Pnacl_M25_PPB_NaCl_Private_ProcessNaClManifest(PP_Instance instance, const char* program_url) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - iface->ProcessNaClManifest(instance, program_url); -} - -static PP_Bool Pnacl_M25_PPB_NaCl_Private_DevInterfacesEnabled(PP_Instance instance) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - return iface->DevInterfacesEnabled(instance); -} - -static PP_Bool Pnacl_M25_PPB_NaCl_Private_GetManifestProgramURL(PP_Instance instance, struct PP_Var* full_url, struct PP_PNaClOptions* pnacl_options, PP_Bool* uses_nonsfi_mode) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - return iface->GetManifestProgramURL(instance, full_url, pnacl_options, uses_nonsfi_mode); -} - -static PP_Bool Pnacl_M25_PPB_NaCl_Private_GetPnaclResourceInfo(PP_Instance instance, struct PP_Var* llc_tool_name, struct PP_Var* ld_tool_name) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - return iface->GetPnaclResourceInfo(instance, llc_tool_name, ld_tool_name); -} - -static void Pnacl_M25_PPB_NaCl_Private_GetCpuFeatureAttrs(struct PP_Var* _struct_result) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - *_struct_result = iface->GetCpuFeatureAttrs(); -} - -static void Pnacl_M25_PPB_NaCl_Private_DownloadNexe(PP_Instance instance, const char* url, struct PP_NaClFileInfo* file_info, struct PP_CompletionCallback* callback) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - iface->DownloadNexe(instance, url, file_info, *callback); -} - -static void Pnacl_M25_PPB_NaCl_Private_ReportSelLdrStatus(PP_Instance instance, int32_t load_status, int32_t max_status) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - iface->ReportSelLdrStatus(instance, load_status, max_status); -} - -static void Pnacl_M25_PPB_NaCl_Private_LogTranslateTime(const char* histogram_name, int64_t time_us) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - iface->LogTranslateTime(histogram_name, time_us); -} - -static void Pnacl_M25_PPB_NaCl_Private_OpenManifestEntry(PP_Instance instance, PP_Bool is_helper_process, const char* key, struct PP_NaClFileInfo* file_info, struct PP_CompletionCallback* callback) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - iface->OpenManifestEntry(instance, is_helper_process, key, file_info, *callback); -} - -static void Pnacl_M25_PPB_NaCl_Private_SetPNaClStartTime(PP_Instance instance) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - iface->SetPNaClStartTime(instance); -} - -static void Pnacl_M25_PPB_NaCl_Private_StreamPexe(PP_Instance instance, const char* pexe_url, int32_t opt_level, const struct PPP_PexeStreamHandler_1_0* stream_handler, void* stream_handler_user_data) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - iface->StreamPexe(instance, pexe_url, opt_level, stream_handler, stream_handler_user_data); -} - -/* End wrapper methods for PPB_NaCl_Private_1_0 */ - /* Begin wrapper methods for PPB_NetAddress_Private_0_1 */ static PP_Bool Pnacl_M17_PPB_NetAddress_Private_AreEqual(const struct PP_NetAddress_Private* addr1, const struct PP_NetAddress_Private* addr2) { @@ -3857,44 +3921,6 @@ static int32_t Pnacl_M32_PPB_PlatformVerification_Private_ChallengePlatform(PP_R /* End wrapper methods for PPB_PlatformVerification_Private_0_2 */ -/* Begin wrapper methods for PPB_Talk_Private_1_0 */ - -static PP_Resource Pnacl_M19_PPB_Talk_Private_Create(PP_Instance instance) { - const struct PPB_Talk_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_Talk_Private_1_0.real_iface; - return iface->Create(instance); -} - -static int32_t Pnacl_M19_PPB_Talk_Private_GetPermission(PP_Resource talk_resource, struct PP_CompletionCallback* callback) { - const struct PPB_Talk_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_Talk_Private_1_0.real_iface; - return iface->GetPermission(talk_resource, *callback); -} - -/* End wrapper methods for PPB_Talk_Private_1_0 */ - -/* Begin wrapper methods for PPB_Talk_Private_2_0 */ - -static PP_Resource Pnacl_M29_PPB_Talk_Private_Create(PP_Instance instance) { - const struct PPB_Talk_Private_2_0 *iface = Pnacl_WrapperInfo_PPB_Talk_Private_2_0.real_iface; - return iface->Create(instance); -} - -static int32_t Pnacl_M29_PPB_Talk_Private_RequestPermission(PP_Resource talk_resource, PP_TalkPermission permission, struct PP_CompletionCallback* callback) { - const struct PPB_Talk_Private_2_0 *iface = Pnacl_WrapperInfo_PPB_Talk_Private_2_0.real_iface; - return iface->RequestPermission(talk_resource, permission, *callback); -} - -static int32_t Pnacl_M29_PPB_Talk_Private_StartRemoting(PP_Resource talk_resource, PP_TalkEventCallback event_callback, void* user_data, struct PP_CompletionCallback* callback) { - const struct PPB_Talk_Private_2_0 *iface = Pnacl_WrapperInfo_PPB_Talk_Private_2_0.real_iface; - return iface->StartRemoting(talk_resource, event_callback, user_data, *callback); -} - -static int32_t Pnacl_M29_PPB_Talk_Private_StopRemoting(PP_Resource talk_resource, struct PP_CompletionCallback* callback) { - const struct PPB_Talk_Private_2_0 *iface = Pnacl_WrapperInfo_PPB_Talk_Private_2_0.real_iface; - return iface->StopRemoting(talk_resource, *callback); -} - -/* End wrapper methods for PPB_Talk_Private_2_0 */ - /* Begin wrapper methods for PPB_TCPServerSocket_Private_0_1 */ static PP_Resource Pnacl_M18_PPB_TCPServerSocket_Private_Create(PP_Instance instance) { @@ -4172,6 +4198,16 @@ static PP_Bool Pnacl_M33_PPB_Testing_Private_IsOutOfProcess(void) { return iface->IsOutOfProcess(); } +static void Pnacl_M33_PPB_Testing_Private_PostPowerSaverStatus(PP_Instance instance) { + const struct PPB_Testing_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_Testing_Private_1_0.real_iface; + iface->PostPowerSaverStatus(instance); +} + +static void Pnacl_M33_PPB_Testing_Private_SubscribeToPowerSaverNotifications(PP_Instance instance) { + const struct PPB_Testing_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_Testing_Private_1_0.real_iface; + iface->SubscribeToPowerSaverNotifications(instance); +} + static void Pnacl_M33_PPB_Testing_Private_SimulateInputEvent(PP_Instance instance, PP_Resource input_event) { const struct PPB_Testing_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_Testing_Private_1_0.real_iface; iface->SimulateInputEvent(instance, input_event); @@ -4437,107 +4473,100 @@ static void Pnacl_M19_PPB_X509Certificate_Private_GetField(struct PP_Var* _struc /* End wrapper methods for PPB_X509Certificate_Private_0_1 */ -/* Begin wrapper methods for PPP_ContentDecryptor_Private_0_12 */ +/* Begin wrapper methods for PPP_ContentDecryptor_Private_0_15 */ -static void Pnacl_M36_PPP_ContentDecryptor_Private_Initialize(PP_Instance instance, struct PP_Var key_system) { - const struct PPP_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_12.real_iface; - void (*temp_fp)(PP_Instance instance, struct PP_Var* key_system) = - ((void (*)(PP_Instance instance, struct PP_Var* key_system))iface->Initialize); - temp_fp(instance, &key_system); +static void Pnacl_M44_PPP_ContentDecryptor_Private_Initialize(PP_Instance instance, uint32_t promise_id, struct PP_Var key_system, PP_Bool allow_distinctive_identifier, PP_Bool allow_persistent_state) { + const struct PPP_ContentDecryptor_Private_0_15 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_15.real_iface; + void (*temp_fp)(PP_Instance instance, uint32_t promise_id, struct PP_Var* key_system, PP_Bool allow_distinctive_identifier, PP_Bool allow_persistent_state) = + ((void (*)(PP_Instance instance, uint32_t promise_id, struct PP_Var* key_system, PP_Bool allow_distinctive_identifier, PP_Bool allow_persistent_state))iface->Initialize); + temp_fp(instance, promise_id, &key_system, allow_distinctive_identifier, allow_persistent_state); } -static void Pnacl_M36_PPP_ContentDecryptor_Private_SetServerCertificate(PP_Instance instance, uint32_t promise_id, struct PP_Var server_certificate) { - const struct PPP_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_12.real_iface; +static void Pnacl_M44_PPP_ContentDecryptor_Private_SetServerCertificate(PP_Instance instance, uint32_t promise_id, struct PP_Var server_certificate) { + const struct PPP_ContentDecryptor_Private_0_15 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_15.real_iface; void (*temp_fp)(PP_Instance instance, uint32_t promise_id, struct PP_Var* server_certificate) = ((void (*)(PP_Instance instance, uint32_t promise_id, struct PP_Var* server_certificate))iface->SetServerCertificate); temp_fp(instance, promise_id, &server_certificate); } -static void Pnacl_M36_PPP_ContentDecryptor_Private_CreateSession(PP_Instance instance, uint32_t promise_id, struct PP_Var init_data_type, struct PP_Var init_data, PP_SessionType session_type) { - const struct PPP_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_12.real_iface; - void (*temp_fp)(PP_Instance instance, uint32_t promise_id, struct PP_Var* init_data_type, struct PP_Var* init_data, PP_SessionType session_type) = - ((void (*)(PP_Instance instance, uint32_t promise_id, struct PP_Var* init_data_type, struct PP_Var* init_data, PP_SessionType session_type))iface->CreateSession); - temp_fp(instance, promise_id, &init_data_type, &init_data, session_type); -} - -static void Pnacl_M36_PPP_ContentDecryptor_Private_LoadSession(PP_Instance instance, uint32_t promise_id, struct PP_Var web_session_id) { - const struct PPP_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_12.real_iface; - void (*temp_fp)(PP_Instance instance, uint32_t promise_id, struct PP_Var* web_session_id) = - ((void (*)(PP_Instance instance, uint32_t promise_id, struct PP_Var* web_session_id))iface->LoadSession); - temp_fp(instance, promise_id, &web_session_id); +static void Pnacl_M44_PPP_ContentDecryptor_Private_CreateSessionAndGenerateRequest(PP_Instance instance, uint32_t promise_id, PP_SessionType session_type, PP_InitDataType init_data_type, struct PP_Var init_data) { + const struct PPP_ContentDecryptor_Private_0_15 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_15.real_iface; + void (*temp_fp)(PP_Instance instance, uint32_t promise_id, PP_SessionType session_type, PP_InitDataType init_data_type, struct PP_Var* init_data) = + ((void (*)(PP_Instance instance, uint32_t promise_id, PP_SessionType session_type, PP_InitDataType init_data_type, struct PP_Var* init_data))iface->CreateSessionAndGenerateRequest); + temp_fp(instance, promise_id, session_type, init_data_type, &init_data); } -static void Pnacl_M36_PPP_ContentDecryptor_Private_UpdateSession(PP_Instance instance, uint32_t promise_id, struct PP_Var web_session_id, struct PP_Var response) { - const struct PPP_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_12.real_iface; - void (*temp_fp)(PP_Instance instance, uint32_t promise_id, struct PP_Var* web_session_id, struct PP_Var* response) = - ((void (*)(PP_Instance instance, uint32_t promise_id, struct PP_Var* web_session_id, struct PP_Var* response))iface->UpdateSession); - temp_fp(instance, promise_id, &web_session_id, &response); +static void Pnacl_M44_PPP_ContentDecryptor_Private_LoadSession(PP_Instance instance, uint32_t promise_id, PP_SessionType session_type, struct PP_Var session_id) { + const struct PPP_ContentDecryptor_Private_0_15 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_15.real_iface; + void (*temp_fp)(PP_Instance instance, uint32_t promise_id, PP_SessionType session_type, struct PP_Var* session_id) = + ((void (*)(PP_Instance instance, uint32_t promise_id, PP_SessionType session_type, struct PP_Var* session_id))iface->LoadSession); + temp_fp(instance, promise_id, session_type, &session_id); } -static void Pnacl_M36_PPP_ContentDecryptor_Private_CloseSession(PP_Instance instance, uint32_t promise_id, struct PP_Var web_session_id) { - const struct PPP_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_12.real_iface; - void (*temp_fp)(PP_Instance instance, uint32_t promise_id, struct PP_Var* web_session_id) = - ((void (*)(PP_Instance instance, uint32_t promise_id, struct PP_Var* web_session_id))iface->CloseSession); - temp_fp(instance, promise_id, &web_session_id); +static void Pnacl_M44_PPP_ContentDecryptor_Private_UpdateSession(PP_Instance instance, uint32_t promise_id, struct PP_Var session_id, struct PP_Var response) { + const struct PPP_ContentDecryptor_Private_0_15 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_15.real_iface; + void (*temp_fp)(PP_Instance instance, uint32_t promise_id, struct PP_Var* session_id, struct PP_Var* response) = + ((void (*)(PP_Instance instance, uint32_t promise_id, struct PP_Var* session_id, struct PP_Var* response))iface->UpdateSession); + temp_fp(instance, promise_id, &session_id, &response); } -static void Pnacl_M36_PPP_ContentDecryptor_Private_RemoveSession(PP_Instance instance, uint32_t promise_id, struct PP_Var web_session_id) { - const struct PPP_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_12.real_iface; - void (*temp_fp)(PP_Instance instance, uint32_t promise_id, struct PP_Var* web_session_id) = - ((void (*)(PP_Instance instance, uint32_t promise_id, struct PP_Var* web_session_id))iface->RemoveSession); - temp_fp(instance, promise_id, &web_session_id); +static void Pnacl_M44_PPP_ContentDecryptor_Private_CloseSession(PP_Instance instance, uint32_t promise_id, struct PP_Var session_id) { + const struct PPP_ContentDecryptor_Private_0_15 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_15.real_iface; + void (*temp_fp)(PP_Instance instance, uint32_t promise_id, struct PP_Var* session_id) = + ((void (*)(PP_Instance instance, uint32_t promise_id, struct PP_Var* session_id))iface->CloseSession); + temp_fp(instance, promise_id, &session_id); } -static void Pnacl_M36_PPP_ContentDecryptor_Private_GetUsableKeyIds(PP_Instance instance, uint32_t promise_id, struct PP_Var web_session_id) { - const struct PPP_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_12.real_iface; - void (*temp_fp)(PP_Instance instance, uint32_t promise_id, struct PP_Var* web_session_id) = - ((void (*)(PP_Instance instance, uint32_t promise_id, struct PP_Var* web_session_id))iface->GetUsableKeyIds); - temp_fp(instance, promise_id, &web_session_id); +static void Pnacl_M44_PPP_ContentDecryptor_Private_RemoveSession(PP_Instance instance, uint32_t promise_id, struct PP_Var session_id) { + const struct PPP_ContentDecryptor_Private_0_15 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_15.real_iface; + void (*temp_fp)(PP_Instance instance, uint32_t promise_id, struct PP_Var* session_id) = + ((void (*)(PP_Instance instance, uint32_t promise_id, struct PP_Var* session_id))iface->RemoveSession); + temp_fp(instance, promise_id, &session_id); } -static void Pnacl_M36_PPP_ContentDecryptor_Private_Decrypt(PP_Instance instance, PP_Resource encrypted_block, const struct PP_EncryptedBlockInfo* encrypted_block_info) { - const struct PPP_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_12.real_iface; +static void Pnacl_M44_PPP_ContentDecryptor_Private_Decrypt(PP_Instance instance, PP_Resource encrypted_block, const struct PP_EncryptedBlockInfo* encrypted_block_info) { + const struct PPP_ContentDecryptor_Private_0_15 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_15.real_iface; void (*temp_fp)(PP_Instance instance, PP_Resource encrypted_block, const struct PP_EncryptedBlockInfo* encrypted_block_info) = ((void (*)(PP_Instance instance, PP_Resource encrypted_block, const struct PP_EncryptedBlockInfo* encrypted_block_info))iface->Decrypt); temp_fp(instance, encrypted_block, encrypted_block_info); } -static void Pnacl_M36_PPP_ContentDecryptor_Private_InitializeAudioDecoder(PP_Instance instance, const struct PP_AudioDecoderConfig* decoder_config, PP_Resource codec_extra_data) { - const struct PPP_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_12.real_iface; +static void Pnacl_M44_PPP_ContentDecryptor_Private_InitializeAudioDecoder(PP_Instance instance, const struct PP_AudioDecoderConfig* decoder_config, PP_Resource codec_extra_data) { + const struct PPP_ContentDecryptor_Private_0_15 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_15.real_iface; void (*temp_fp)(PP_Instance instance, const struct PP_AudioDecoderConfig* decoder_config, PP_Resource codec_extra_data) = ((void (*)(PP_Instance instance, const struct PP_AudioDecoderConfig* decoder_config, PP_Resource codec_extra_data))iface->InitializeAudioDecoder); temp_fp(instance, decoder_config, codec_extra_data); } -static void Pnacl_M36_PPP_ContentDecryptor_Private_InitializeVideoDecoder(PP_Instance instance, const struct PP_VideoDecoderConfig* decoder_config, PP_Resource codec_extra_data) { - const struct PPP_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_12.real_iface; +static void Pnacl_M44_PPP_ContentDecryptor_Private_InitializeVideoDecoder(PP_Instance instance, const struct PP_VideoDecoderConfig* decoder_config, PP_Resource codec_extra_data) { + const struct PPP_ContentDecryptor_Private_0_15 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_15.real_iface; void (*temp_fp)(PP_Instance instance, const struct PP_VideoDecoderConfig* decoder_config, PP_Resource codec_extra_data) = ((void (*)(PP_Instance instance, const struct PP_VideoDecoderConfig* decoder_config, PP_Resource codec_extra_data))iface->InitializeVideoDecoder); temp_fp(instance, decoder_config, codec_extra_data); } -static void Pnacl_M36_PPP_ContentDecryptor_Private_DeinitializeDecoder(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) { - const struct PPP_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_12.real_iface; +static void Pnacl_M44_PPP_ContentDecryptor_Private_DeinitializeDecoder(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) { + const struct PPP_ContentDecryptor_Private_0_15 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_15.real_iface; void (*temp_fp)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) = ((void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id))iface->DeinitializeDecoder); temp_fp(instance, decoder_type, request_id); } -static void Pnacl_M36_PPP_ContentDecryptor_Private_ResetDecoder(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) { - const struct PPP_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_12.real_iface; +static void Pnacl_M44_PPP_ContentDecryptor_Private_ResetDecoder(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) { + const struct PPP_ContentDecryptor_Private_0_15 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_15.real_iface; void (*temp_fp)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) = ((void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id))iface->ResetDecoder); temp_fp(instance, decoder_type, request_id); } -static void Pnacl_M36_PPP_ContentDecryptor_Private_DecryptAndDecode(PP_Instance instance, PP_DecryptorStreamType decoder_type, PP_Resource encrypted_buffer, const struct PP_EncryptedBlockInfo* encrypted_block_info) { - const struct PPP_ContentDecryptor_Private_0_12 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_12.real_iface; +static void Pnacl_M44_PPP_ContentDecryptor_Private_DecryptAndDecode(PP_Instance instance, PP_DecryptorStreamType decoder_type, PP_Resource encrypted_buffer, const struct PP_EncryptedBlockInfo* encrypted_block_info) { + const struct PPP_ContentDecryptor_Private_0_15 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_15.real_iface; void (*temp_fp)(PP_Instance instance, PP_DecryptorStreamType decoder_type, PP_Resource encrypted_buffer, const struct PP_EncryptedBlockInfo* encrypted_block_info) = ((void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, PP_Resource encrypted_buffer, const struct PP_EncryptedBlockInfo* encrypted_block_info))iface->DecryptAndDecode); temp_fp(instance, decoder_type, encrypted_buffer, encrypted_block_info); } -/* End wrapper methods for PPP_ContentDecryptor_Private_0_12 */ +/* End wrapper methods for PPP_ContentDecryptor_Private_0_15 */ /* Not generating wrapper methods for PPP_Find_Private_0_3 */ @@ -4647,12 +4676,6 @@ static const struct PPB_FileIO_1_1 Pnacl_Wrappers_PPB_FileIO_1_1 = { .ReadToArray = (int32_t (*)(PP_Resource file_io, int64_t offset, int32_t max_read_length, struct PP_ArrayOutput* output, struct PP_CompletionCallback callback))&Pnacl_M25_PPB_FileIO_ReadToArray }; -static const struct PPB_FileMapping_0_1 Pnacl_Wrappers_PPB_FileMapping_0_1 = { - .Map = (int32_t (*)(PP_Instance instance, PP_Resource file_io, int64_t length, uint32_t map_protection, uint32_t map_flags, int64_t offset, void** address, struct PP_CompletionCallback callback))&Pnacl_M34_PPB_FileMapping_Map, - .Unmap = (int32_t (*)(PP_Instance instance, const void* address, int64_t length, struct PP_CompletionCallback callback))&Pnacl_M34_PPB_FileMapping_Unmap, - .GetMapPageSize = (int64_t (*)(PP_Instance instance))&Pnacl_M34_PPB_FileMapping_GetMapPageSize -}; - static const struct PPB_FileRef_1_0 Pnacl_Wrappers_PPB_FileRef_1_0 = { .Create = (PP_Resource (*)(PP_Resource file_system, const char* path))&Pnacl_M14_PPB_FileRef_Create, .IsFileRef = (PP_Bool (*)(PP_Resource resource))&Pnacl_M14_PPB_FileRef_IsFileRef, @@ -4951,6 +4974,21 @@ static const struct PPB_TCPSocket_1_1 Pnacl_Wrappers_PPB_TCPSocket_1_1 = { .SetOption = (int32_t (*)(PP_Resource tcp_socket, PP_TCPSocket_Option name, struct PP_Var value, struct PP_CompletionCallback callback))&Pnacl_M31_PPB_TCPSocket_SetOption }; +static const struct PPB_TCPSocket_1_2 Pnacl_Wrappers_PPB_TCPSocket_1_2 = { + .Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M41_PPB_TCPSocket_Create, + .IsTCPSocket = (PP_Bool (*)(PP_Resource resource))&Pnacl_M41_PPB_TCPSocket_IsTCPSocket, + .Bind = (int32_t (*)(PP_Resource tcp_socket, PP_Resource addr, struct PP_CompletionCallback callback))&Pnacl_M41_PPB_TCPSocket_Bind, + .Connect = (int32_t (*)(PP_Resource tcp_socket, PP_Resource addr, struct PP_CompletionCallback callback))&Pnacl_M41_PPB_TCPSocket_Connect, + .GetLocalAddress = (PP_Resource (*)(PP_Resource tcp_socket))&Pnacl_M41_PPB_TCPSocket_GetLocalAddress, + .GetRemoteAddress = (PP_Resource (*)(PP_Resource tcp_socket))&Pnacl_M41_PPB_TCPSocket_GetRemoteAddress, + .Read = (int32_t (*)(PP_Resource tcp_socket, char* buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback))&Pnacl_M41_PPB_TCPSocket_Read, + .Write = (int32_t (*)(PP_Resource tcp_socket, const char* buffer, int32_t bytes_to_write, struct PP_CompletionCallback callback))&Pnacl_M41_PPB_TCPSocket_Write, + .Listen = (int32_t (*)(PP_Resource tcp_socket, int32_t backlog, struct PP_CompletionCallback callback))&Pnacl_M41_PPB_TCPSocket_Listen, + .Accept = (int32_t (*)(PP_Resource tcp_socket, PP_Resource* accepted_tcp_socket, struct PP_CompletionCallback callback))&Pnacl_M41_PPB_TCPSocket_Accept, + .Close = (void (*)(PP_Resource tcp_socket))&Pnacl_M41_PPB_TCPSocket_Close, + .SetOption = (int32_t (*)(PP_Resource tcp_socket, PP_TCPSocket_Option name, struct PP_Var value, struct PP_CompletionCallback callback))&Pnacl_M41_PPB_TCPSocket_SetOption +}; + static const struct PPB_TextInputController_1_0 Pnacl_Wrappers_PPB_TextInputController_1_0 = { .SetTextInputType = (void (*)(PP_Instance instance, PP_TextInput_Type type))&Pnacl_M30_PPB_TextInputController_SetTextInputType, .UpdateCaretPosition = (void (*)(PP_Instance instance, const struct PP_Rect* caret))&Pnacl_M30_PPB_TextInputController_UpdateCaretPosition, @@ -4969,6 +5007,30 @@ static const struct PPB_UDPSocket_1_0 Pnacl_Wrappers_PPB_UDPSocket_1_0 = { .SetOption = (int32_t (*)(PP_Resource udp_socket, PP_UDPSocket_Option name, struct PP_Var value, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_UDPSocket_SetOption }; +static const struct PPB_UDPSocket_1_1 Pnacl_Wrappers_PPB_UDPSocket_1_1 = { + .Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M41_PPB_UDPSocket_Create, + .IsUDPSocket = (PP_Bool (*)(PP_Resource resource))&Pnacl_M41_PPB_UDPSocket_IsUDPSocket, + .Bind = (int32_t (*)(PP_Resource udp_socket, PP_Resource addr, struct PP_CompletionCallback callback))&Pnacl_M41_PPB_UDPSocket_Bind, + .GetBoundAddress = (PP_Resource (*)(PP_Resource udp_socket))&Pnacl_M41_PPB_UDPSocket_GetBoundAddress, + .RecvFrom = (int32_t (*)(PP_Resource udp_socket, char* buffer, int32_t num_bytes, PP_Resource* addr, struct PP_CompletionCallback callback))&Pnacl_M41_PPB_UDPSocket_RecvFrom, + .SendTo = (int32_t (*)(PP_Resource udp_socket, const char* buffer, int32_t num_bytes, PP_Resource addr, struct PP_CompletionCallback callback))&Pnacl_M41_PPB_UDPSocket_SendTo, + .Close = (void (*)(PP_Resource udp_socket))&Pnacl_M41_PPB_UDPSocket_Close, + .SetOption = (int32_t (*)(PP_Resource udp_socket, PP_UDPSocket_Option name, struct PP_Var value, struct PP_CompletionCallback callback))&Pnacl_M41_PPB_UDPSocket_SetOption +}; + +static const struct PPB_UDPSocket_1_2 Pnacl_Wrappers_PPB_UDPSocket_1_2 = { + .Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M43_PPB_UDPSocket_Create, + .IsUDPSocket = (PP_Bool (*)(PP_Resource resource))&Pnacl_M43_PPB_UDPSocket_IsUDPSocket, + .Bind = (int32_t (*)(PP_Resource udp_socket, PP_Resource addr, struct PP_CompletionCallback callback))&Pnacl_M43_PPB_UDPSocket_Bind, + .GetBoundAddress = (PP_Resource (*)(PP_Resource udp_socket))&Pnacl_M43_PPB_UDPSocket_GetBoundAddress, + .RecvFrom = (int32_t (*)(PP_Resource udp_socket, char* buffer, int32_t num_bytes, PP_Resource* addr, struct PP_CompletionCallback callback))&Pnacl_M43_PPB_UDPSocket_RecvFrom, + .SendTo = (int32_t (*)(PP_Resource udp_socket, const char* buffer, int32_t num_bytes, PP_Resource addr, struct PP_CompletionCallback callback))&Pnacl_M43_PPB_UDPSocket_SendTo, + .Close = (void (*)(PP_Resource udp_socket))&Pnacl_M43_PPB_UDPSocket_Close, + .SetOption = (int32_t (*)(PP_Resource udp_socket, PP_UDPSocket_Option name, struct PP_Var value, struct PP_CompletionCallback callback))&Pnacl_M43_PPB_UDPSocket_SetOption, + .JoinGroup = (int32_t (*)(PP_Resource udp_socket, PP_Resource group, struct PP_CompletionCallback callback))&Pnacl_M43_PPB_UDPSocket_JoinGroup, + .LeaveGroup = (int32_t (*)(PP_Resource udp_socket, PP_Resource group, struct PP_CompletionCallback callback))&Pnacl_M43_PPB_UDPSocket_LeaveGroup +}; + static const struct PPB_URLLoader_1_0 Pnacl_Wrappers_PPB_URLLoader_1_0 = { .Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M14_PPB_URLLoader_Create, .IsURLLoader = (PP_Bool (*)(PP_Resource resource))&Pnacl_M14_PPB_URLLoader_IsURLLoader, @@ -5076,6 +5138,36 @@ static const struct PPB_VideoDecoder_1_0 Pnacl_Wrappers_PPB_VideoDecoder_1_0 = { .Reset = (int32_t (*)(PP_Resource video_decoder, struct PP_CompletionCallback callback))&Pnacl_M40_PPB_VideoDecoder_Reset }; +static const struct PPB_VideoEncoder_0_1 Pnacl_Wrappers_PPB_VideoEncoder_0_1 = { + .Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M42_PPB_VideoEncoder_Create, + .IsVideoEncoder = (PP_Bool (*)(PP_Resource resource))&Pnacl_M42_PPB_VideoEncoder_IsVideoEncoder, + .GetSupportedProfiles = (int32_t (*)(PP_Resource video_encoder, struct PP_ArrayOutput output, struct PP_CompletionCallback callback))&Pnacl_M42_PPB_VideoEncoder_GetSupportedProfiles, + .Initialize = (int32_t (*)(PP_Resource video_encoder, PP_VideoFrame_Format input_format, const struct PP_Size* input_visible_size, PP_VideoProfile output_profile, uint32_t initial_bitrate, PP_HardwareAcceleration acceleration, struct PP_CompletionCallback callback))&Pnacl_M42_PPB_VideoEncoder_Initialize, + .GetFramesRequired = (int32_t (*)(PP_Resource video_encoder))&Pnacl_M42_PPB_VideoEncoder_GetFramesRequired, + .GetFrameCodedSize = (int32_t (*)(PP_Resource video_encoder, struct PP_Size* coded_size))&Pnacl_M42_PPB_VideoEncoder_GetFrameCodedSize, + .GetVideoFrame = (int32_t (*)(PP_Resource video_encoder, PP_Resource* video_frame, struct PP_CompletionCallback callback))&Pnacl_M42_PPB_VideoEncoder_GetVideoFrame, + .Encode = (int32_t (*)(PP_Resource video_encoder, PP_Resource video_frame, PP_Bool force_keyframe, struct PP_CompletionCallback callback))&Pnacl_M42_PPB_VideoEncoder_Encode, + .GetBitstreamBuffer = (int32_t (*)(PP_Resource video_encoder, struct PP_BitstreamBuffer* bitstream_buffer, struct PP_CompletionCallback callback))&Pnacl_M42_PPB_VideoEncoder_GetBitstreamBuffer, + .RecycleBitstreamBuffer = (void (*)(PP_Resource video_encoder, const struct PP_BitstreamBuffer* bitstream_buffer))&Pnacl_M42_PPB_VideoEncoder_RecycleBitstreamBuffer, + .RequestEncodingParametersChange = (void (*)(PP_Resource video_encoder, uint32_t bitrate, uint32_t framerate))&Pnacl_M42_PPB_VideoEncoder_RequestEncodingParametersChange, + .Close = (void (*)(PP_Resource video_encoder))&Pnacl_M42_PPB_VideoEncoder_Close +}; + +static const struct PPB_VideoEncoder_0_2 Pnacl_Wrappers_PPB_VideoEncoder_0_2 = { + .Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M44_PPB_VideoEncoder_Create, + .IsVideoEncoder = (PP_Bool (*)(PP_Resource resource))&Pnacl_M44_PPB_VideoEncoder_IsVideoEncoder, + .GetSupportedProfiles = (int32_t (*)(PP_Resource video_encoder, struct PP_ArrayOutput output, struct PP_CompletionCallback callback))&Pnacl_M44_PPB_VideoEncoder_GetSupportedProfiles, + .Initialize = (int32_t (*)(PP_Resource video_encoder, PP_VideoFrame_Format input_format, const struct PP_Size* input_visible_size, PP_VideoProfile output_profile, uint32_t initial_bitrate, PP_HardwareAcceleration acceleration, struct PP_CompletionCallback callback))&Pnacl_M44_PPB_VideoEncoder_Initialize, + .GetFramesRequired = (int32_t (*)(PP_Resource video_encoder))&Pnacl_M44_PPB_VideoEncoder_GetFramesRequired, + .GetFrameCodedSize = (int32_t (*)(PP_Resource video_encoder, struct PP_Size* coded_size))&Pnacl_M44_PPB_VideoEncoder_GetFrameCodedSize, + .GetVideoFrame = (int32_t (*)(PP_Resource video_encoder, PP_Resource* video_frame, struct PP_CompletionCallback callback))&Pnacl_M44_PPB_VideoEncoder_GetVideoFrame, + .Encode = (int32_t (*)(PP_Resource video_encoder, PP_Resource video_frame, PP_Bool force_keyframe, struct PP_CompletionCallback callback))&Pnacl_M44_PPB_VideoEncoder_Encode, + .GetBitstreamBuffer = (int32_t (*)(PP_Resource video_encoder, struct PP_BitstreamBuffer* bitstream_buffer, struct PP_CompletionCallback callback))&Pnacl_M44_PPB_VideoEncoder_GetBitstreamBuffer, + .RecycleBitstreamBuffer = (void (*)(PP_Resource video_encoder, const struct PP_BitstreamBuffer* bitstream_buffer))&Pnacl_M44_PPB_VideoEncoder_RecycleBitstreamBuffer, + .RequestEncodingParametersChange = (void (*)(PP_Resource video_encoder, uint32_t bitrate, uint32_t framerate))&Pnacl_M44_PPB_VideoEncoder_RequestEncodingParametersChange, + .Close = (void (*)(PP_Resource video_encoder))&Pnacl_M44_PPB_VideoEncoder_Close +}; + /* Not generating wrapper interface for PPB_VideoFrame_0_1 */ /* Not generating wrapper interface for PPB_View_1_0 */ @@ -5317,23 +5409,29 @@ static const struct PPP_Selection_Dev_0_3 Pnacl_Wrappers_PPP_Selection_Dev_0_3 = /* Not generating wrapper interface for PPB_CameraCapabilities_Private_0_1 */ -static const struct PPB_ContentDecryptor_Private_0_12 Pnacl_Wrappers_PPB_ContentDecryptor_Private_0_12 = { - .PromiseResolved = (void (*)(PP_Instance instance, uint32_t promise_id))&Pnacl_M36_PPB_ContentDecryptor_Private_PromiseResolved, - .PromiseResolvedWithSession = (void (*)(PP_Instance instance, uint32_t promise_id, struct PP_Var web_session_id))&Pnacl_M36_PPB_ContentDecryptor_Private_PromiseResolvedWithSession, - .PromiseResolvedWithKeyIds = (void (*)(PP_Instance instance, uint32_t promise_id, struct PP_Var key_ids_array))&Pnacl_M36_PPB_ContentDecryptor_Private_PromiseResolvedWithKeyIds, - .PromiseRejected = (void (*)(PP_Instance instance, uint32_t promise_id, PP_CdmExceptionCode exception_code, uint32_t system_code, struct PP_Var error_description))&Pnacl_M36_PPB_ContentDecryptor_Private_PromiseRejected, - .SessionMessage = (void (*)(PP_Instance instance, struct PP_Var web_session_id, struct PP_Var message, struct PP_Var destination_url))&Pnacl_M36_PPB_ContentDecryptor_Private_SessionMessage, - .SessionKeysChange = (void (*)(PP_Instance instance, struct PP_Var web_session_id, PP_Bool has_additional_usable_key))&Pnacl_M36_PPB_ContentDecryptor_Private_SessionKeysChange, - .SessionExpirationChange = (void (*)(PP_Instance instance, struct PP_Var web_session_id, PP_Time new_expiry_time))&Pnacl_M36_PPB_ContentDecryptor_Private_SessionExpirationChange, - .SessionReady = (void (*)(PP_Instance instance, struct PP_Var web_session_id))&Pnacl_M36_PPB_ContentDecryptor_Private_SessionReady, - .SessionClosed = (void (*)(PP_Instance instance, struct PP_Var web_session_id))&Pnacl_M36_PPB_ContentDecryptor_Private_SessionClosed, - .SessionError = (void (*)(PP_Instance instance, struct PP_Var web_session_id, PP_CdmExceptionCode exception_code, uint32_t system_code, struct PP_Var error_description))&Pnacl_M36_PPB_ContentDecryptor_Private_SessionError, - .DeliverBlock = (void (*)(PP_Instance instance, PP_Resource decrypted_block, const struct PP_DecryptedBlockInfo* decrypted_block_info))&Pnacl_M36_PPB_ContentDecryptor_Private_DeliverBlock, - .DecoderInitializeDone = (void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id, PP_Bool success))&Pnacl_M36_PPB_ContentDecryptor_Private_DecoderInitializeDone, - .DecoderDeinitializeDone = (void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id))&Pnacl_M36_PPB_ContentDecryptor_Private_DecoderDeinitializeDone, - .DecoderResetDone = (void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id))&Pnacl_M36_PPB_ContentDecryptor_Private_DecoderResetDone, - .DeliverFrame = (void (*)(PP_Instance instance, PP_Resource decrypted_frame, const struct PP_DecryptedFrameInfo* decrypted_frame_info))&Pnacl_M36_PPB_ContentDecryptor_Private_DeliverFrame, - .DeliverSamples = (void (*)(PP_Instance instance, PP_Resource audio_frames, const struct PP_DecryptedSampleInfo* decrypted_sample_info))&Pnacl_M36_PPB_ContentDecryptor_Private_DeliverSamples +static const struct PPB_CameraDevice_Private_0_1 Pnacl_Wrappers_PPB_CameraDevice_Private_0_1 = { + .Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M42_PPB_CameraDevice_Private_Create, + .IsCameraDevice = (PP_Bool (*)(PP_Resource resource))&Pnacl_M42_PPB_CameraDevice_Private_IsCameraDevice, + .Open = (int32_t (*)(PP_Resource camera_device, struct PP_Var device_id, struct PP_CompletionCallback callback))&Pnacl_M42_PPB_CameraDevice_Private_Open, + .Close = (void (*)(PP_Resource camera_device))&Pnacl_M42_PPB_CameraDevice_Private_Close, + .GetCameraCapabilities = (int32_t (*)(PP_Resource camera_device, PP_Resource* capabilities, struct PP_CompletionCallback callback))&Pnacl_M42_PPB_CameraDevice_Private_GetCameraCapabilities +}; + +static const struct PPB_ContentDecryptor_Private_0_14 Pnacl_Wrappers_PPB_ContentDecryptor_Private_0_14 = { + .PromiseResolved = (void (*)(PP_Instance instance, uint32_t promise_id))&Pnacl_M44_PPB_ContentDecryptor_Private_PromiseResolved, + .PromiseResolvedWithSession = (void (*)(PP_Instance instance, uint32_t promise_id, struct PP_Var session_id))&Pnacl_M44_PPB_ContentDecryptor_Private_PromiseResolvedWithSession, + .PromiseRejected = (void (*)(PP_Instance instance, uint32_t promise_id, PP_CdmExceptionCode exception_code, uint32_t system_code, struct PP_Var error_description))&Pnacl_M44_PPB_ContentDecryptor_Private_PromiseRejected, + .SessionMessage = (void (*)(PP_Instance instance, struct PP_Var session_id, PP_CdmMessageType message_type, struct PP_Var message, struct PP_Var legacy_destination_url))&Pnacl_M44_PPB_ContentDecryptor_Private_SessionMessage, + .SessionKeysChange = (void (*)(PP_Instance instance, struct PP_Var session_id, PP_Bool has_additional_usable_key, uint32_t key_count, const struct PP_KeyInformation key_information[]))&Pnacl_M44_PPB_ContentDecryptor_Private_SessionKeysChange, + .SessionExpirationChange = (void (*)(PP_Instance instance, struct PP_Var session_id, PP_Time new_expiry_time))&Pnacl_M44_PPB_ContentDecryptor_Private_SessionExpirationChange, + .SessionClosed = (void (*)(PP_Instance instance, struct PP_Var session_id))&Pnacl_M44_PPB_ContentDecryptor_Private_SessionClosed, + .LegacySessionError = (void (*)(PP_Instance instance, struct PP_Var session_id, PP_CdmExceptionCode exception_code, uint32_t system_code, struct PP_Var error_description))&Pnacl_M44_PPB_ContentDecryptor_Private_LegacySessionError, + .DeliverBlock = (void (*)(PP_Instance instance, PP_Resource decrypted_block, const struct PP_DecryptedBlockInfo* decrypted_block_info))&Pnacl_M44_PPB_ContentDecryptor_Private_DeliverBlock, + .DecoderInitializeDone = (void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id, PP_Bool success))&Pnacl_M44_PPB_ContentDecryptor_Private_DecoderInitializeDone, + .DecoderDeinitializeDone = (void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id))&Pnacl_M44_PPB_ContentDecryptor_Private_DecoderDeinitializeDone, + .DecoderResetDone = (void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id))&Pnacl_M44_PPB_ContentDecryptor_Private_DecoderResetDone, + .DeliverFrame = (void (*)(PP_Instance instance, PP_Resource decrypted_frame, const struct PP_DecryptedFrameInfo* decrypted_frame_info))&Pnacl_M44_PPB_ContentDecryptor_Private_DeliverFrame, + .DeliverSamples = (void (*)(PP_Instance instance, PP_Resource audio_frames, const struct PP_DecryptedSampleInfo* decrypted_sample_info))&Pnacl_M44_PPB_ContentDecryptor_Private_DeliverSamples }; static const struct PPB_DisplayColorProfile_Private_0_1 Pnacl_Wrappers_PPB_DisplayColorProfile_Private_0_1 = { @@ -5495,18 +5593,6 @@ static const struct PPB_HostResolver_Private_0_1 Pnacl_Wrappers_PPB_HostResolver .GetNetAddress = (PP_Bool (*)(PP_Resource host_resolver, uint32_t index, struct PP_NetAddress_Private* addr))&Pnacl_M19_PPB_HostResolver_Private_GetNetAddress }; -/* Not generating wrapper interface for PPB_ImageCaptureConfig_Private_0_1 */ - -static const struct PPB_ImageCapture_Private_0_1 Pnacl_Wrappers_PPB_ImageCapture_Private_0_1 = { - .Create = (PP_Resource (*)(PP_Instance instance, struct PP_Var camera_source_id, PPB_ImageCapture_Private_ErrorCallback error_callback, void* user_data))&Pnacl_M39_PPB_ImageCapture_Private_Create, - .IsImageCapture = (PP_Bool (*)(PP_Resource resource))&Pnacl_M39_PPB_ImageCapture_Private_IsImageCapture, - .Close = (int32_t (*)(PP_Resource resource, struct PP_CompletionCallback callback))&Pnacl_M39_PPB_ImageCapture_Private_Close, - .SetConfig = (int32_t (*)(PP_Resource image_capture, PP_Resource config, struct PP_CompletionCallback callback))&Pnacl_M39_PPB_ImageCapture_Private_SetConfig, - .GetConfig = (int32_t (*)(PP_Resource image_capture, PP_Resource* config, struct PP_CompletionCallback callback))&Pnacl_M39_PPB_ImageCapture_Private_GetConfig, - .GetCameraCapabilities = (int32_t (*)(PP_Resource image_capture, PP_Resource* capabilities, struct PP_CompletionCallback callback))&Pnacl_M39_PPB_ImageCapture_Private_GetCameraCapabilities, - .CaptureStillImage = (int32_t (*)(PP_Resource image_capture, PPB_ImageCapture_Private_ShutterCallback shutter_callback, PPB_ImageCapture_Private_PreviewCallback preview_callback, PPB_ImageCapture_Private_JpegCallback jpeg_callback, int64_t* sequence_id))&Pnacl_M39_PPB_ImageCapture_Private_CaptureStillImage -}; - /* Not generating wrapper interface for PPB_InputEvent_Private_0_1 */ static const struct PPB_Instance_Private_0_1 Pnacl_Wrappers_PPB_Instance_Private_0_1 = { @@ -5519,45 +5605,6 @@ static const struct PPB_IsolatedFileSystem_Private_0_2 Pnacl_Wrappers_PPB_Isolat .Open = (int32_t (*)(PP_Instance instance, PP_IsolatedFileSystemType_Private type, PP_Resource* file_system, struct PP_CompletionCallback callback))&Pnacl_M33_PPB_IsolatedFileSystem_Private_Open }; -static const struct PPB_NaCl_Private_1_0 Pnacl_Wrappers_PPB_NaCl_Private_1_0 = { - .LaunchSelLdr = (void (*)(PP_Instance instance, PP_Bool main_service_runtime, const char* alleged_url, const struct PP_NaClFileInfo* nexe_file_info, PP_Bool uses_nonsfi_mode, PP_Bool enable_ppapi_dev, PP_NaClAppProcessType process_type, void* imc_handle, struct PP_CompletionCallback callback))&Pnacl_M25_PPB_NaCl_Private_LaunchSelLdr, - .StartPpapiProxy = (PP_Bool (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_StartPpapiProxy, - .UrandomFD = (int32_t (*)(void))&Pnacl_M25_PPB_NaCl_Private_UrandomFD, - .Are3DInterfacesDisabled = (PP_Bool (*)(void))&Pnacl_M25_PPB_NaCl_Private_Are3DInterfacesDisabled, - .BrokerDuplicateHandle = (int32_t (*)(PP_FileHandle source_handle, uint32_t process_id, PP_FileHandle* target_handle, uint32_t desired_access, uint32_t options))&Pnacl_M25_PPB_NaCl_Private_BrokerDuplicateHandle, - .GetReadExecPnaclFd = (void (*)(const char* url, struct PP_NaClFileInfo* out_file_info))&Pnacl_M25_PPB_NaCl_Private_GetReadExecPnaclFd, - .CreateTemporaryFile = (PP_FileHandle (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_CreateTemporaryFile, - .GetNumberOfProcessors = (int32_t (*)(void))&Pnacl_M25_PPB_NaCl_Private_GetNumberOfProcessors, - .IsNonSFIModeEnabled = (PP_Bool (*)(void))&Pnacl_M25_PPB_NaCl_Private_IsNonSFIModeEnabled, - .ReportTranslationFinished = (void (*)(PP_Instance instance, PP_Bool success, int32_t opt_level, int64_t pexe_size, int64_t compile_time_us))&Pnacl_M25_PPB_NaCl_Private_ReportTranslationFinished, - .DispatchEvent = (void (*)(PP_Instance instance, PP_NaClEventType event_type, const char* resource_url, PP_Bool length_is_computable, uint64_t loaded_bytes, uint64_t total_bytes))&Pnacl_M25_PPB_NaCl_Private_DispatchEvent, - .ReportLoadSuccess = (void (*)(PP_Instance instance, uint64_t loaded_bytes, uint64_t total_bytes))&Pnacl_M25_PPB_NaCl_Private_ReportLoadSuccess, - .ReportLoadError = (void (*)(PP_Instance instance, PP_NaClError error, const char* error_message))&Pnacl_M25_PPB_NaCl_Private_ReportLoadError, - .ReportLoadAbort = (void (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_ReportLoadAbort, - .InstanceCreated = (void (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_InstanceCreated, - .InstanceDestroyed = (void (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_InstanceDestroyed, - .NaClDebugEnabledForURL = (PP_Bool (*)(const char* alleged_nmf_url))&Pnacl_M25_PPB_NaCl_Private_NaClDebugEnabledForURL, - .GetSandboxArch = (const char* (*)(void))&Pnacl_M25_PPB_NaCl_Private_GetSandboxArch, - .LogToConsole = (void (*)(PP_Instance instance, const char* message))&Pnacl_M25_PPB_NaCl_Private_LogToConsole, - .GetNaClReadyState = (PP_NaClReadyState (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_GetNaClReadyState, - .Vlog = (void (*)(const char* message))&Pnacl_M25_PPB_NaCl_Private_Vlog, - .InitializePlugin = (void (*)(PP_Instance instance, uint32_t argc, const char* argn[], const char* argv[]))&Pnacl_M25_PPB_NaCl_Private_InitializePlugin, - .GetNexeSize = (int64_t (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_GetNexeSize, - .RequestNaClManifest = (void (*)(PP_Instance instance, struct PP_CompletionCallback callback))&Pnacl_M25_PPB_NaCl_Private_RequestNaClManifest, - .GetManifestBaseURL = (struct PP_Var (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_GetManifestBaseURL, - .ProcessNaClManifest = (void (*)(PP_Instance instance, const char* program_url))&Pnacl_M25_PPB_NaCl_Private_ProcessNaClManifest, - .DevInterfacesEnabled = (PP_Bool (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_DevInterfacesEnabled, - .GetManifestProgramURL = (PP_Bool (*)(PP_Instance instance, struct PP_Var* full_url, struct PP_PNaClOptions* pnacl_options, PP_Bool* uses_nonsfi_mode))&Pnacl_M25_PPB_NaCl_Private_GetManifestProgramURL, - .GetPnaclResourceInfo = (PP_Bool (*)(PP_Instance instance, struct PP_Var* llc_tool_name, struct PP_Var* ld_tool_name))&Pnacl_M25_PPB_NaCl_Private_GetPnaclResourceInfo, - .GetCpuFeatureAttrs = (struct PP_Var (*)(void))&Pnacl_M25_PPB_NaCl_Private_GetCpuFeatureAttrs, - .DownloadNexe = (void (*)(PP_Instance instance, const char* url, struct PP_NaClFileInfo* file_info, struct PP_CompletionCallback callback))&Pnacl_M25_PPB_NaCl_Private_DownloadNexe, - .ReportSelLdrStatus = (void (*)(PP_Instance instance, int32_t load_status, int32_t max_status))&Pnacl_M25_PPB_NaCl_Private_ReportSelLdrStatus, - .LogTranslateTime = (void (*)(const char* histogram_name, int64_t time_us))&Pnacl_M25_PPB_NaCl_Private_LogTranslateTime, - .OpenManifestEntry = (void (*)(PP_Instance instance, PP_Bool is_helper_process, const char* key, struct PP_NaClFileInfo* file_info, struct PP_CompletionCallback callback))&Pnacl_M25_PPB_NaCl_Private_OpenManifestEntry, - .SetPNaClStartTime = (void (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_SetPNaClStartTime, - .StreamPexe = (void (*)(PP_Instance instance, const char* pexe_url, int32_t opt_level, const struct PPP_PexeStreamHandler_1_0* stream_handler, void* stream_handler_user_data))&Pnacl_M25_PPB_NaCl_Private_StreamPexe -}; - static const struct PPB_NetAddress_Private_0_1 Pnacl_Wrappers_PPB_NetAddress_Private_0_1 = { .AreEqual = (PP_Bool (*)(const struct PP_NetAddress_Private* addr1, const struct PP_NetAddress_Private* addr2))&Pnacl_M17_PPB_NetAddress_Private_AreEqual, .AreHostsEqual = (PP_Bool (*)(const struct PP_NetAddress_Private* addr1, const struct PP_NetAddress_Private* addr2))&Pnacl_M17_PPB_NetAddress_Private_AreHostsEqual, @@ -5604,18 +5651,6 @@ static const struct PPB_PlatformVerification_Private_0_2 Pnacl_Wrappers_PPB_Plat .ChallengePlatform = (int32_t (*)(PP_Resource instance, struct PP_Var service_id, struct PP_Var challenge, struct PP_Var* signed_data, struct PP_Var* signed_data_signature, struct PP_Var* platform_key_certificate, struct PP_CompletionCallback callback))&Pnacl_M32_PPB_PlatformVerification_Private_ChallengePlatform }; -static const struct PPB_Talk_Private_1_0 Pnacl_Wrappers_PPB_Talk_Private_1_0 = { - .Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M19_PPB_Talk_Private_Create, - .GetPermission = (int32_t (*)(PP_Resource talk_resource, struct PP_CompletionCallback callback))&Pnacl_M19_PPB_Talk_Private_GetPermission -}; - -static const struct PPB_Talk_Private_2_0 Pnacl_Wrappers_PPB_Talk_Private_2_0 = { - .Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M29_PPB_Talk_Private_Create, - .RequestPermission = (int32_t (*)(PP_Resource talk_resource, PP_TalkPermission permission, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_Talk_Private_RequestPermission, - .StartRemoting = (int32_t (*)(PP_Resource talk_resource, PP_TalkEventCallback event_callback, void* user_data, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_Talk_Private_StartRemoting, - .StopRemoting = (int32_t (*)(PP_Resource talk_resource, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_Talk_Private_StopRemoting -}; - static const struct PPB_TCPServerSocket_Private_0_1 Pnacl_Wrappers_PPB_TCPServerSocket_Private_0_1 = { .Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M18_PPB_TCPServerSocket_Private_Create, .IsTCPServerSocket = (PP_Bool (*)(PP_Resource resource))&Pnacl_M18_PPB_TCPServerSocket_Private_IsTCPServerSocket, @@ -5683,6 +5718,8 @@ static const struct PPB_Testing_Private_1_0 Pnacl_Wrappers_PPB_Testing_Private_1 .QuitMessageLoop = (void (*)(PP_Instance instance))&Pnacl_M33_PPB_Testing_Private_QuitMessageLoop, .GetLiveObjectsForInstance = (uint32_t (*)(PP_Instance instance))&Pnacl_M33_PPB_Testing_Private_GetLiveObjectsForInstance, .IsOutOfProcess = (PP_Bool (*)(void))&Pnacl_M33_PPB_Testing_Private_IsOutOfProcess, + .PostPowerSaverStatus = (void (*)(PP_Instance instance))&Pnacl_M33_PPB_Testing_Private_PostPowerSaverStatus, + .SubscribeToPowerSaverNotifications = (void (*)(PP_Instance instance))&Pnacl_M33_PPB_Testing_Private_SubscribeToPowerSaverNotifications, .SimulateInputEvent = (void (*)(PP_Instance instance, PP_Resource input_event))&Pnacl_M33_PPB_Testing_Private_SimulateInputEvent, .GetDocumentURL = (struct PP_Var (*)(PP_Instance instance, struct PP_URLComponents_Dev* components))&Pnacl_M33_PPB_Testing_Private_GetDocumentURL, .GetLiveVars = (uint32_t (*)(struct PP_Var live_vars[], uint32_t array_size))&Pnacl_M33_PPB_Testing_Private_GetLiveVars, @@ -5753,21 +5790,20 @@ static const struct PPB_X509Certificate_Private_0_1 Pnacl_Wrappers_PPB_X509Certi .GetField = (struct PP_Var (*)(PP_Resource resource, PP_X509Certificate_Private_Field field))&Pnacl_M19_PPB_X509Certificate_Private_GetField }; -static const struct PPP_ContentDecryptor_Private_0_12 Pnacl_Wrappers_PPP_ContentDecryptor_Private_0_12 = { - .Initialize = &Pnacl_M36_PPP_ContentDecryptor_Private_Initialize, - .SetServerCertificate = &Pnacl_M36_PPP_ContentDecryptor_Private_SetServerCertificate, - .CreateSession = &Pnacl_M36_PPP_ContentDecryptor_Private_CreateSession, - .LoadSession = &Pnacl_M36_PPP_ContentDecryptor_Private_LoadSession, - .UpdateSession = &Pnacl_M36_PPP_ContentDecryptor_Private_UpdateSession, - .CloseSession = &Pnacl_M36_PPP_ContentDecryptor_Private_CloseSession, - .RemoveSession = &Pnacl_M36_PPP_ContentDecryptor_Private_RemoveSession, - .GetUsableKeyIds = &Pnacl_M36_PPP_ContentDecryptor_Private_GetUsableKeyIds, - .Decrypt = &Pnacl_M36_PPP_ContentDecryptor_Private_Decrypt, - .InitializeAudioDecoder = &Pnacl_M36_PPP_ContentDecryptor_Private_InitializeAudioDecoder, - .InitializeVideoDecoder = &Pnacl_M36_PPP_ContentDecryptor_Private_InitializeVideoDecoder, - .DeinitializeDecoder = &Pnacl_M36_PPP_ContentDecryptor_Private_DeinitializeDecoder, - .ResetDecoder = &Pnacl_M36_PPP_ContentDecryptor_Private_ResetDecoder, - .DecryptAndDecode = &Pnacl_M36_PPP_ContentDecryptor_Private_DecryptAndDecode +static const struct PPP_ContentDecryptor_Private_0_15 Pnacl_Wrappers_PPP_ContentDecryptor_Private_0_15 = { + .Initialize = &Pnacl_M44_PPP_ContentDecryptor_Private_Initialize, + .SetServerCertificate = &Pnacl_M44_PPP_ContentDecryptor_Private_SetServerCertificate, + .CreateSessionAndGenerateRequest = &Pnacl_M44_PPP_ContentDecryptor_Private_CreateSessionAndGenerateRequest, + .LoadSession = &Pnacl_M44_PPP_ContentDecryptor_Private_LoadSession, + .UpdateSession = &Pnacl_M44_PPP_ContentDecryptor_Private_UpdateSession, + .CloseSession = &Pnacl_M44_PPP_ContentDecryptor_Private_CloseSession, + .RemoveSession = &Pnacl_M44_PPP_ContentDecryptor_Private_RemoveSession, + .Decrypt = &Pnacl_M44_PPP_ContentDecryptor_Private_Decrypt, + .InitializeAudioDecoder = &Pnacl_M44_PPP_ContentDecryptor_Private_InitializeAudioDecoder, + .InitializeVideoDecoder = &Pnacl_M44_PPP_ContentDecryptor_Private_InitializeVideoDecoder, + .DeinitializeDecoder = &Pnacl_M44_PPP_ContentDecryptor_Private_DeinitializeDecoder, + .ResetDecoder = &Pnacl_M44_PPP_ContentDecryptor_Private_ResetDecoder, + .DecryptAndDecode = &Pnacl_M44_PPP_ContentDecryptor_Private_DecryptAndDecode }; /* Not generating wrapper interface for PPP_Find_Private_0_3 */ @@ -5826,12 +5862,6 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileIO_1_1 = { .real_iface = NULL }; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileMapping_0_1 = { - .iface_macro = PPB_FILEMAPPING_INTERFACE_0_1, - .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_FileMapping_0_1, - .real_iface = NULL -}; - static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileRef_1_0 = { .iface_macro = PPB_FILEREF_INTERFACE_1_0, .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_FileRef_1_0, @@ -6000,6 +6030,12 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TCPSocket_1_1 = { .real_iface = NULL }; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TCPSocket_1_2 = { + .iface_macro = PPB_TCPSOCKET_INTERFACE_1_2, + .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_TCPSocket_1_2, + .real_iface = NULL +}; + static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TextInputController_1_0 = { .iface_macro = PPB_TEXTINPUTCONTROLLER_INTERFACE_1_0, .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_TextInputController_1_0, @@ -6012,6 +6048,18 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_UDPSocket_1_0 = { .real_iface = NULL }; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_UDPSocket_1_1 = { + .iface_macro = PPB_UDPSOCKET_INTERFACE_1_1, + .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_UDPSocket_1_1, + .real_iface = NULL +}; + +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_UDPSocket_1_2 = { + .iface_macro = PPB_UDPSOCKET_INTERFACE_1_2, + .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_UDPSocket_1_2, + .real_iface = NULL +}; + static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_URLLoader_1_0 = { .iface_macro = PPB_URLLOADER_INTERFACE_1_0, .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_URLLoader_1_0, @@ -6084,6 +6132,18 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoDecoder_1_0 = { .real_iface = NULL }; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoEncoder_0_1 = { + .iface_macro = PPB_VIDEOENCODER_INTERFACE_0_1, + .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_VideoEncoder_0_1, + .real_iface = NULL +}; + +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoEncoder_0_2 = { + .iface_macro = PPB_VIDEOENCODER_INTERFACE_0_2, + .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_VideoEncoder_0_2, + .real_iface = NULL +}; + static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_WebSocket_1_0 = { .iface_macro = PPB_WEBSOCKET_INTERFACE_1_0, .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_WebSocket_1_0, @@ -6186,9 +6246,15 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Selection_Dev_0_3 = { .real_iface = NULL }; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_12 = { - .iface_macro = PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_12, - .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_ContentDecryptor_Private_0_12, +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_CameraDevice_Private_0_1 = { + .iface_macro = PPB_CAMERADEVICE_PRIVATE_INTERFACE_0_1, + .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_CameraDevice_Private_0_1, + .real_iface = NULL +}; + +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_14 = { + .iface_macro = PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_14, + .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_ContentDecryptor_Private_0_14, .real_iface = NULL }; @@ -6288,12 +6354,6 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_HostResolver_Private_0_1 .real_iface = NULL }; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_ImageCapture_Private_0_1 = { - .iface_macro = PPB_IMAGECAPTURE_PRIVATE_INTERFACE_0_1, - .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_ImageCapture_Private_0_1, - .real_iface = NULL -}; - static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Instance_Private_0_1 = { .iface_macro = PPB_INSTANCE_PRIVATE_INTERFACE_0_1, .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_Instance_Private_0_1, @@ -6306,12 +6366,6 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_IsolatedFileSystem_Privat .real_iface = NULL }; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NaCl_Private_1_0 = { - .iface_macro = PPB_NACL_PRIVATE_INTERFACE_1_0, - .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_NaCl_Private_1_0, - .real_iface = NULL -}; - static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetAddress_Private_0_1 = { .iface_macro = PPB_NETADDRESS_PRIVATE_INTERFACE_0_1, .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_NetAddress_Private_0_1, @@ -6342,18 +6396,6 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_PlatformVerification_Priv .real_iface = NULL }; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Talk_Private_1_0 = { - .iface_macro = PPB_TALK_PRIVATE_INTERFACE_1_0, - .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_Talk_Private_1_0, - .real_iface = NULL -}; - -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Talk_Private_2_0 = { - .iface_macro = PPB_TALK_PRIVATE_INTERFACE_2_0, - .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_Talk_Private_2_0, - .real_iface = NULL -}; - static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TCPServerSocket_Private_0_1 = { .iface_macro = PPB_TCPSERVERSOCKET_PRIVATE_INTERFACE_0_1, .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_TCPServerSocket_Private_0_1, @@ -6432,9 +6474,9 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_X509Certificate_Private_0 .real_iface = NULL }; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_12 = { - .iface_macro = PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_12, - .wrapped_iface = (const void *) &Pnacl_Wrappers_PPP_ContentDecryptor_Private_0_12, +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_15 = { + .iface_macro = PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_15, + .wrapped_iface = (const void *) &Pnacl_Wrappers_PPP_ContentDecryptor_Private_0_15, .real_iface = NULL }; @@ -6452,7 +6494,6 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = { &Pnacl_WrapperInfo_PPB_Core_1_0, &Pnacl_WrapperInfo_PPB_FileIO_1_0, &Pnacl_WrapperInfo_PPB_FileIO_1_1, - &Pnacl_WrapperInfo_PPB_FileMapping_0_1, &Pnacl_WrapperInfo_PPB_FileRef_1_0, &Pnacl_WrapperInfo_PPB_FileRef_1_1, &Pnacl_WrapperInfo_PPB_FileRef_1_2, @@ -6481,8 +6522,11 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = { &Pnacl_WrapperInfo_PPB_NetworkProxy_1_0, &Pnacl_WrapperInfo_PPB_TCPSocket_1_0, &Pnacl_WrapperInfo_PPB_TCPSocket_1_1, + &Pnacl_WrapperInfo_PPB_TCPSocket_1_2, &Pnacl_WrapperInfo_PPB_TextInputController_1_0, &Pnacl_WrapperInfo_PPB_UDPSocket_1_0, + &Pnacl_WrapperInfo_PPB_UDPSocket_1_1, + &Pnacl_WrapperInfo_PPB_UDPSocket_1_2, &Pnacl_WrapperInfo_PPB_URLLoader_1_0, &Pnacl_WrapperInfo_PPB_URLRequestInfo_1_0, &Pnacl_WrapperInfo_PPB_URLResponseInfo_1_0, @@ -6495,6 +6539,8 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = { &Pnacl_WrapperInfo_PPB_VideoDecoder_0_1, &Pnacl_WrapperInfo_PPB_VideoDecoder_0_2, &Pnacl_WrapperInfo_PPB_VideoDecoder_1_0, + &Pnacl_WrapperInfo_PPB_VideoEncoder_0_1, + &Pnacl_WrapperInfo_PPB_VideoEncoder_0_2, &Pnacl_WrapperInfo_PPB_WebSocket_1_0, &Pnacl_WrapperInfo_PPB_AudioInput_Dev_0_3, &Pnacl_WrapperInfo_PPB_AudioInput_Dev_0_4, @@ -6510,7 +6556,8 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = { &Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7, &Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_3, &Pnacl_WrapperInfo_PPB_VideoDecoder_Dev_0_16, - &Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_12, + &Pnacl_WrapperInfo_PPB_CameraDevice_Private_0_1, + &Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_14, &Pnacl_WrapperInfo_PPB_DisplayColorProfile_Private_0_1, &Pnacl_WrapperInfo_PPB_Ext_CrxFileSystem_Private_0_1, &Pnacl_WrapperInfo_PPB_FileIO_Private_0_1, @@ -6527,17 +6574,13 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = { &Pnacl_WrapperInfo_PPB_Flash_DRM_1_1, &Pnacl_WrapperInfo_PPB_Flash_Menu_0_2, &Pnacl_WrapperInfo_PPB_HostResolver_Private_0_1, - &Pnacl_WrapperInfo_PPB_ImageCapture_Private_0_1, &Pnacl_WrapperInfo_PPB_Instance_Private_0_1, &Pnacl_WrapperInfo_PPB_IsolatedFileSystem_Private_0_2, - &Pnacl_WrapperInfo_PPB_NaCl_Private_1_0, &Pnacl_WrapperInfo_PPB_NetAddress_Private_0_1, &Pnacl_WrapperInfo_PPB_NetAddress_Private_1_0, &Pnacl_WrapperInfo_PPB_NetAddress_Private_1_1, &Pnacl_WrapperInfo_PPB_OutputProtection_Private_0_1, &Pnacl_WrapperInfo_PPB_PlatformVerification_Private_0_2, - &Pnacl_WrapperInfo_PPB_Talk_Private_1_0, - &Pnacl_WrapperInfo_PPB_Talk_Private_2_0, &Pnacl_WrapperInfo_PPB_TCPServerSocket_Private_0_1, &Pnacl_WrapperInfo_PPB_TCPServerSocket_Private_0_2, &Pnacl_WrapperInfo_PPB_TCPSocket_Private_0_3, @@ -6557,7 +6600,7 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = { static struct __PnaclWrapperInfo *s_ppp_wrappers[] = { &Pnacl_WrapperInfo_PPP_Messaging_1_0, &Pnacl_WrapperInfo_PPP_Selection_Dev_0_3, - &Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_12, + &Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_15, &Pnacl_WrapperInfo_PPP_Instance_Private_0_1, NULL }; diff --git a/chromium/ppapi/native_client/src/untrusted/pnacl_support_extension/BUILD.gn b/chromium/ppapi/native_client/src/untrusted/pnacl_support_extension/BUILD.gn new file mode 100644 index 00000000000..50e9b7c5f2f --- /dev/null +++ b/chromium/ppapi/native_client/src/untrusted/pnacl_support_extension/BUILD.gn @@ -0,0 +1,11 @@ +# Copyright 2015 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. + +import("//build/config/features.gni") + +if (enable_nacl && enable_nacl_untrusted && enable_pnacl) { + group("pnacl_support_extension") { + # TODO(GYP): implement me ... + } +} diff --git a/chromium/ppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_component_crx_gen.py b/chromium/ppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_component_crx_gen.py index f3726c7f474..7ab46875b1f 100755 --- a/chromium/ppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_component_crx_gen.py +++ b/chromium/ppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_component_crx_gen.py @@ -120,16 +120,7 @@ class PnaclPackaging(object): 'getrevision', '--revision-package', PnaclPackaging.pnacl_package] - version = subprocess.check_output(pkg_ver_cmd).strip() - - # CWS happens to use version quads, so make it a quad too. - # However, each component of the quad is limited to 64K max. - # Try to handle a bit more. - max_version = 2 ** 16 - version = int(version) - version_more = version / max_version - version = version % max_version - return '0.1.%d.%d' % (version_more, version) + return subprocess.check_output(pkg_ver_cmd).strip() @staticmethod def GeneratePnaclInfo(target_dir, abi_version, arch): diff --git a/chromium/ppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_support_extension.gyp b/chromium/ppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_support_extension.gyp index dd58e1e83d6..573151df49a 100644 --- a/chromium/ppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_support_extension.gyp +++ b/chromium/ppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_support_extension.gyp @@ -8,66 +8,18 @@ 'includes': [ '../../../../../build/common_untrusted.gypi', ], - 'variables': { - 'pnacl_translator_dir%': "", - 'pnacl_translator_stamp%': "pnacl_translator.json", - }, 'targets': [ { - 'target_name': 'untar_pnacl_translator', - 'type': 'none', - 'conditions': [ - ['pnacl_translator_dir==""', { - 'actions': [{ - 'action_name': 'Untar pnacl_translator', - 'description': 'Untar pnacl_translator', - 'inputs': [ - '<(DEPTH)/native_client/build/package_version/package_version.py', - '<(DEPTH)/native_client/toolchain/.tars/<(TOOLCHAIN_OS)_x86/pnacl_translator.json', - ], - 'outputs': ['<(SHARED_INTERMEDIATE_DIR)/sdk/<(TOOLCHAIN_OS)_x86/pnacl_translator/<(pnacl_translator_stamp)'], - 'action': [ - 'python', - '<(DEPTH)/native_client/build/package_version/package_version.py', - '--quiet', - '--packages', 'pnacl_translator', - '--tar-dir', '<(DEPTH)/native_client/toolchain/.tars', - '--dest-dir', '<(SHARED_INTERMEDIATE_DIR)/sdk', - 'extract', - ], - }], - }, { - 'actions': [{ - 'action_name': 'Copy pnacl_translator', - 'description': 'Copy pnacl_translator', - 'inputs': [ - '<(DEPTH)/native_client/build/copy_directory.py', - '<(pnacl_translator_dir)/<(pnacl_translator_stamp)', - ], - 'outputs': [ - '<(SHARED_INTERMEDIATE_DIR)/sdk/<(TOOLCHAIN_OS)_x86/pnacl_translator/<(pnacl_translator_stamp)'], - 'action': [ - 'python', - '<(DEPTH)/native_client/build/copy_directory.py', - '--quiet', - '--stamp-arg', 'pnacl_translator_stamp', - '--stamp-file', '<(pnacl_translator_stamp)', - '<(pnacl_translator_dir)', - '<(SHARED_INTERMEDIATE_DIR)/sdk/<(TOOLCHAIN_OS)_x86/pnacl_translator', - ], - }], - }], - ], - }, - { 'target_name': 'pnacl_support_extension', 'type': 'none', + 'variables': { + 'pnacl_translator_dir%': "<(DEPTH)/native_client/toolchain/<(TOOLCHAIN_OS)_x86/pnacl_translator", + 'pnacl_translator_stamp%': "pnacl_translator.json", + }, 'conditions': [ ['disable_nacl==0 and disable_pnacl==0 and disable_nacl_untrusted==0', { 'dependencies': [ '../../../../../ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_irt_shim.gyp:browser', - '../../../../../native_client/tools.gyp:prep_toolchain', - 'untar_pnacl_translator', ], 'sources': [ 'pnacl_component_crx_gen.py', @@ -80,7 +32,7 @@ 'inputs': [ 'pnacl_component_crx_gen.py', # A stamp file representing the contents of pnacl_translator. - '<(SHARED_INTERMEDIATE_DIR)/sdk/<(TOOLCHAIN_OS)_x86/pnacl_translator/<(pnacl_translator_stamp)', + '<(pnacl_translator_dir)/<(pnacl_translator_stamp)', '<(DEPTH)/native_client/pnacl/driver/pnacl_info_template.json', '<(DEPTH)/native_client/toolchain_revisions/pnacl_newlib.json', ], @@ -93,14 +45,12 @@ '<(PRODUCT_DIR)/pnacl/pnacl_public_x86_32_ld_nexe', '<(PRODUCT_DIR)/pnacl/pnacl_public_x86_32_libcrt_platform_a', '<(PRODUCT_DIR)/pnacl/pnacl_public_x86_32_libgcc_a', - '<(PRODUCT_DIR)/pnacl/pnacl_public_x86_32_libgcc_eh_a', '<(PRODUCT_DIR)/pnacl/pnacl_public_x86_32_libpnacl_irt_shim_a', '<(PRODUCT_DIR)/pnacl/pnacl_public_x86_32_pnacl_llc_nexe', '<(PRODUCT_DIR)/pnacl/pnacl_public_x86_64_crtbegin_o', '<(PRODUCT_DIR)/pnacl/pnacl_public_x86_64_ld_nexe', '<(PRODUCT_DIR)/pnacl/pnacl_public_x86_64_libcrt_platform_a', '<(PRODUCT_DIR)/pnacl/pnacl_public_x86_64_libgcc_a', - '<(PRODUCT_DIR)/pnacl/pnacl_public_x86_64_libgcc_eh_a', '<(PRODUCT_DIR)/pnacl/pnacl_public_x86_64_libpnacl_irt_shim_a', '<(PRODUCT_DIR)/pnacl/pnacl_public_x86_64_pnacl_llc_nexe', ], @@ -126,7 +76,6 @@ '<(PRODUCT_DIR)/pnacl/pnacl_public_arm_ld_nexe', '<(PRODUCT_DIR)/pnacl/pnacl_public_arm_libcrt_platform_a', '<(PRODUCT_DIR)/pnacl/pnacl_public_arm_libgcc_a', - '<(PRODUCT_DIR)/pnacl/pnacl_public_arm_libgcc_eh_a', '<(PRODUCT_DIR)/pnacl/pnacl_public_arm_libpnacl_irt_shim_a', '<(PRODUCT_DIR)/pnacl/pnacl_public_arm_pnacl_llc_nexe', ], @@ -147,7 +96,6 @@ '<(PRODUCT_DIR)/pnacl/pnacl_public_mips32_ld_nexe', '<(PRODUCT_DIR)/pnacl/pnacl_public_mips32_libcrt_platform_a', '<(PRODUCT_DIR)/pnacl/pnacl_public_mips32_libgcc_a', - '<(PRODUCT_DIR)/pnacl/pnacl_public_mips32_libgcc_eh_a', '<(PRODUCT_DIR)/pnacl/pnacl_public_mips32_libpnacl_irt_shim_a', '<(PRODUCT_DIR)/pnacl/pnacl_public_mips32_llc_nexe', ], @@ -168,7 +116,6 @@ '<(PRODUCT_DIR)/pnacl/pnacl_public_x86_32_ld_nexe', '<(PRODUCT_DIR)/pnacl/pnacl_public_x86_32_libcrt_platform_a', '<(PRODUCT_DIR)/pnacl/pnacl_public_x86_32_libgcc_a', - '<(PRODUCT_DIR)/pnacl/pnacl_public_x86_32_libgcc_eh_a', '<(PRODUCT_DIR)/pnacl/pnacl_public_x86_32_libpnacl_irt_shim_a', '<(PRODUCT_DIR)/pnacl/pnacl_public_x86_32_pnacl_llc_nexe', ], @@ -189,7 +136,6 @@ '<(PRODUCT_DIR)/pnacl/pnacl_public_x86_64_ld_nexe', '<(PRODUCT_DIR)/pnacl/pnacl_public_x86_64_libcrt_platform_a', '<(PRODUCT_DIR)/pnacl/pnacl_public_x86_64_libgcc_a', - '<(PRODUCT_DIR)/pnacl/pnacl_public_x86_64_libgcc_eh_a', '<(PRODUCT_DIR)/pnacl/pnacl_public_x86_64_libpnacl_irt_shim_a', '<(PRODUCT_DIR)/pnacl/pnacl_public_x86_64_pnacl_llc_nexe', ], @@ -212,7 +158,7 @@ '<@(lib_overrides)', '--target_arch=<(target_arch)', '--info_template_path=<(DEPTH)/native_client/pnacl/driver/pnacl_info_template.json', - '--pnacl_translator_path=<(SHARED_INTERMEDIATE_DIR)/sdk/<(TOOLCHAIN_OS)_x86/pnacl_translator', + '--pnacl_translator_path=<(pnacl_translator_dir)', '--package_version_path=<(DEPTH)/native_client/build/package_version/package_version.py', '--pnacl_package_name=pnacl_newlib', # ABI Version Number. diff --git a/chromium/ppapi/native_client/tools/browser_tester/browser_tester.py b/chromium/ppapi/native_client/tools/browser_tester/browser_tester.py index 6c662910ea4..87cafe4a007 100755 --- a/chromium/ppapi/native_client/tools/browser_tester/browser_tester.py +++ b/chromium/ppapi/native_client/tools/browser_tester/browser_tester.py @@ -23,7 +23,6 @@ import browsertester.rpclistener import browsertester.server import memcheck_analyze -import tsan_analyze import test_env @@ -160,9 +159,6 @@ def ProcessToolLogs(options, logs_dir): if options.tool == 'memcheck': analyzer = memcheck_analyze.MemcheckAnalyzer('', use_gdb=True) logs_wildcard = 'xml.*' - elif options.tool == 'tsan': - analyzer = tsan_analyze.TsanAnalyzer(use_gdb=True) - logs_wildcard = 'log.*' files = glob.glob(os.path.join(logs_dir, logs_wildcard)) retcode = analyzer.Report(files, options.url) return retcode @@ -211,7 +207,7 @@ def RunTestsOnce(url, options): options.files.append(os.path.join(script_dir, 'browserdata', 'nacltest.js')) # Setup the environment with the setuid sandbox path. - os.environ.update(test_env.get_sandbox_env(sys.argv, os.environ)) + os.environ.update(test_env.get_sandbox_env(os.environ)) # Create server host = GetHostName() diff --git a/chromium/ppapi/native_client/tools/browser_tester/browserdata/nacltest.js b/chromium/ppapi/native_client/tools/browser_tester/browserdata/nacltest.js index 59a1340075d..f5e7c971daa 100644 --- a/chromium/ppapi/native_client/tools/browser_tester/browserdata/nacltest.js +++ b/chromium/ppapi/native_client/tools/browser_tester/browserdata/nacltest.js @@ -410,6 +410,14 @@ function assertArraysEqual(a, b, message, test_status) { } +function assertRegexMatches(str, re, message, test_status) { + if (!str.match(re)) { + fail(message, toString(str) + ' doesn\'t match ' + toString(re.toString()), + test_status); + } +} + + // Ideally there'd be some way to identify what exception was thrown, but JS // exceptions are fairly ad-hoc. // TODO(ncbray) allow manual validation of exception types? @@ -727,6 +735,10 @@ function TestStatus(tester, name, async) { assertEqual(a, b, message, this); } + this.assertRegexMatches = function(a, b, message) { + assertRegexMatches(a, b, message, this); + } + this.callbackWrapper = function(callback, args) { // A stale callback? if (!this.running) diff --git a/chromium/ppapi/ppapi_cpp.gypi b/chromium/ppapi/ppapi_cpp.gypi index bf4d2257ad8..0a07d53cbe8 100644 --- a/chromium/ppapi/ppapi_cpp.gypi +++ b/chromium/ppapi/ppapi_cpp.gypi @@ -11,7 +11,7 @@ ], 'targets': [ { - # GN version: //ppapi:ppapi_c + # GN version: //ppapi/c 'target_name': 'ppapi_c', 'type': 'none', 'all_dependent_settings': { @@ -24,7 +24,7 @@ ], }, { - # GN version: //ppapi:ppapi_cpp_objects + # GN version: //ppapi/cpp:objects 'target_name': 'ppapi_cpp_objects', 'type': 'static_library', 'dependencies': [ @@ -36,29 +36,9 @@ 'sources': [ '<@(cpp_source_files)', ], - 'conditions': [ - ['OS=="win"', { - 'msvs_settings': { - 'VCCLCompilerTool': { - 'AdditionalOptions': ['/we4244'], # implicit conversion, possible loss of data - }, - }, - 'msvs_disabled_warnings': [ - 4267, - ], - }], - ['OS=="linux"', { - 'cflags': ['-Wextra', '-pedantic'], - }], - ['OS=="mac"', { - 'xcode_settings': { - 'WARNING_CFLAGS': ['-Wextra', '-pedantic'], - }, - }], - ], }, { - # GN version: //ppapi:ppapi_cpp + # GN version: //ppapi/cpp 'target_name': 'ppapi_cpp', 'type': 'static_library', 'dependencies': [ @@ -72,19 +52,9 @@ 'cpp/module_embedder.h', 'cpp/ppp_entrypoints.cc', ], - 'conditions': [ - ['OS=="linux"', { - 'cflags': ['-Wextra', '-pedantic'], - }], - ['OS=="mac"', { - 'xcode_settings': { - 'WARNING_CFLAGS': ['-Wextra', '-pedantic'], - }, - }] - ], }, { - # GN version: //ppapi:ppapi_internal_module + # GN version: //ppapi/cpp/private:internal_module 'target_name': 'ppapi_internal_module', 'type': 'static_library', 'include_dirs+': [ diff --git a/chromium/ppapi/ppapi_gl.gypi b/chromium/ppapi/ppapi_gl.gypi index 69673fe4703..47a0a4cd493 100644 --- a/chromium/ppapi/ppapi_gl.gypi +++ b/chromium/ppapi/ppapi_gl.gypi @@ -5,7 +5,7 @@ { 'targets': [ { - # GN version: //ppapi:ppapi_gles2 + # GN version: //ppapi/lib/gl/gles2 'target_name': 'ppapi_gles2', 'type': 'static_library', 'dependencies': [ diff --git a/chromium/ppapi/ppapi_host.gypi b/chromium/ppapi/ppapi_host.gypi index eea53b42bca..3113ddf5c22 100644 --- a/chromium/ppapi/ppapi_host.gypi +++ b/chromium/ppapi/ppapi_host.gypi @@ -5,7 +5,7 @@ { 'targets': [ { - # GN version: //ppapi:ppapi_host + # GN version: //ppapi/host 'target_name': 'ppapi_host', 'type': '<(component)', 'dependencies': [ diff --git a/chromium/ppapi/ppapi_internal.gyp b/chromium/ppapi/ppapi_internal.gyp index 2240ba25e04..4efac4e02ba 100644 --- a/chromium/ppapi/ppapi_internal.gyp +++ b/chromium/ppapi/ppapi_internal.gyp @@ -33,7 +33,7 @@ ], 'targets': [ { - # GN version: //ppapi:ppapi_shared + # GN version: //ppapi/shared_impl and //ppapi/thunk 'target_name': 'ppapi_shared', 'type': '<(component)', 'variables': { @@ -69,24 +69,7 @@ ], }, }], - ['chrome_multiple_dll==1', { - 'dependencies': [ - '../third_party/WebKit/public/blink.gyp:blink_minimal', - ], - 'export_dependent_settings': [ - '../third_party/WebKit/public/blink.gyp:blink_minimal', - ], - }, { - 'dependencies': [ - '../third_party/WebKit/public/blink.gyp:blink', - ], - 'export_dependent_settings': [ - '../third_party/WebKit/public/blink.gyp:blink', - ], - }], ], - # Disable c4267 warnings until we fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], }, ], 'conditions': [ @@ -94,7 +77,7 @@ # In a static build, build ppapi_ipc separately. 'targets': [ { - # GN version: //ppapi:ppapi_ipc + # GN version: //ppapi/proxy:ipc 'target_name': 'ppapi_ipc', 'type': 'static_library', 'variables': { @@ -116,7 +99,7 @@ }, }, { - # GN version: //ppapi:ppapi_proxy + # GN version: //ppapi/proxy 'target_name': 'ppapi_proxy', 'type': 'static_library', 'variables': { @@ -125,6 +108,7 @@ 'dependencies': [ '../base/base.gyp:base', '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', + '../gin/gin.gyp:gin', '../gpu/gpu.gyp:gles2_implementation', '../gpu/gpu.gyp:gpu_ipc', '../media/media.gyp:shared_memory_support', @@ -143,8 +127,6 @@ '..', ], }, - # Disable c4267 warnings until we fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], 'conditions': [ ['chrome_multiple_dll==1', { 'dependencies': [ @@ -175,6 +157,7 @@ 'dependencies': [ '../base/base.gyp:base', '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', + '../gin/gin.gyp:gin', '../gpu/gpu.gyp:gles2_implementation', '../gpu/gpu.gyp:gpu_ipc', '../media/media.gyp:shared_memory_support', @@ -193,8 +176,6 @@ '..', ], }, - # Disable c4267 warnings until we fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], 'conditions': [ ['chrome_multiple_dll==1', { 'dependencies': [ diff --git a/chromium/ppapi/ppapi_ipc_nacl.gyp b/chromium/ppapi/ppapi_ipc_nacl.gyp index c82a4ec5155..3608f8042de 100644 --- a/chromium/ppapi/ppapi_ipc_nacl.gyp +++ b/chromium/ppapi/ppapi_ipc_nacl.gyp @@ -31,7 +31,6 @@ '..', ], 'dependencies': [ - '../native_client/tools.gyp:prep_toolchain', '../base/base_nacl.gyp:base_nacl', '../base/base_nacl.gyp:base_nacl_nonsfi', '../gpu/gpu_nacl.gyp:gpu_ipc_nacl', diff --git a/chromium/ppapi/ppapi_nacl.gyp b/chromium/ppapi/ppapi_nacl.gyp index 1d75eed8539..aa7b718bec8 100644 --- a/chromium/ppapi/ppapi_nacl.gyp +++ b/chromium/ppapi/ppapi_nacl.gyp @@ -27,9 +27,6 @@ 'cpp/ppp_entrypoints.cc', ], }, - 'dependencies': [ - '<(DEPTH)/native_client/tools.gyp:prep_toolchain', - ], }, { 'target_name': 'ppapi_gles2_lib', @@ -49,15 +46,11 @@ 'lib/gl/gles2/gles2.c', ], }, - 'dependencies': [ - '<(DEPTH)/native_client/tools.gyp:prep_toolchain', - ], }, { 'target_name': 'ppapi_nacl_tests', 'type': 'none', 'dependencies': [ - '<(DEPTH)/native_client/tools.gyp:prep_toolchain', '<(DEPTH)/native_client/src/untrusted/nacl/nacl.gyp:nacl_lib', '<(DEPTH)/native_client/src/untrusted/pthread/pthread.gyp:pthread_lib', 'ppapi_cpp_lib', @@ -139,6 +132,10 @@ '--strip-all', ], 'create_nmf': '<(DEPTH)/native_client_sdk/src/tools/create_nmf.py', + 'create_nmf_flags': [ + '--no-default-libpath', + '--objdump=>(nacl_glibc_tc_root)/bin/x86_64-nacl-objdump', + ], 'create_nonsfi_test_nmf': 'tests/create_nonsfi_test_nmf.py', }, 'conditions': [ @@ -149,7 +146,6 @@ # doesn't work on Windows. 'libdir_glibc64': '>(nacl_glibc_tc_root)/x86_64-nacl/lib', 'libdir_glibc32': '>(nacl_glibc_tc_root)/x86_64-nacl/lib32', - 'nacl_objdump': '>(nacl_glibc_tc_root)/bin/x86_64-nacl-objdump', 'nmf_glibc%': '<(PRODUCT_DIR)/>(nexe_target)_glibc.nmf', }, 'actions': [ @@ -165,7 +161,7 @@ 'action': [ 'python', '>@(_inputs)', - '--objdump=>(nacl_objdump)', + '>@(create_nmf_flags)', '--output=>(nmf_glibc)', '--stage-dependencies=<(PRODUCT_DIR)', ], @@ -218,6 +214,7 @@ 'action': [ 'python', '>@(_inputs)', + '>@(create_nmf_flags)', '--output=>(nmf_pnacl)', ], 'conditions': [ @@ -235,14 +232,26 @@ }, ], }], - ['disable_pnacl==0 and target_arch=="ia32" and OS=="linux"', { - # In addition to above configuration, build x86-32-nonsfi .nexe file - # by translating from .pexe binary, for non-SFI mode PPAPI testing. + ['disable_pnacl==0 and (target_arch=="ia32" or target_arch=="x64" or target_arch=="arm") and OS=="linux"', { + # In addition to above configuration, build x86-32 and arm nonsfi + # .nexe files by translating from .pexe binary, for non-SFI mode PPAPI + # testing. 'variables': { - 'enable_x86_32_nonsfi': 1, 'translate_pexe_with_build': 1, 'nmf_nonsfi%': '<(PRODUCT_DIR)/>(nexe_target)_pnacl_nonsfi.nmf', }, + 'conditions': [ + ['target_arch=="ia32" or target_arch=="x64"', { + 'variables': { + 'enable_x86_32_nonsfi': 1, + }, + }], + ['target_arch=="arm"', { + 'variables': { + 'enable_arm_nonsfi': 1, + }, + }], + ], # Shim is a dependency for the nexe because we pre-translate. 'dependencies': [ '<(DEPTH)/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_irt_shim.gyp:aot', @@ -256,7 +265,38 @@ 'python', '>(create_nonsfi_test_nmf)', '--output=>(nmf_nonsfi)', - '--program=>(out_pnacl_newlib_x86_32_nonsfi_nexe)', + ], + 'target_conditions': [ + ['enable_x86_32_nonsfi==1 and "<(target_arch)"=="ia32"', { + 'inputs': ['>(out_pnacl_newlib_x86_32_nonsfi_nexe)'], + 'action': [ + '--program=>(out_pnacl_newlib_x86_32_nonsfi_nexe)', + '--arch=x86-32', + ] + }], + ['enable_x86_32_nonsfi==1 and "<(target_arch)"=="x64"', { + 'inputs': ['>(out_pnacl_newlib_x86_32_nonsfi_nexe)'], + 'action': [ + '--program=>(out_pnacl_newlib_x86_32_nonsfi_nexe)', + # This should be used only for nacl_helper_nonsfi test. + # In theory this should be x86-32. However, currently + # fallback logic to x86-32-nonsfi is not implemented, + # and, moreover, it would break the tests for current + # nacl_helper in Non-SFI mode on x64 Chrome. + # So, here we introduce the hack to use "x86-64" in order + # to take the benefit to run nacl_helper_nonsfi tests on + # x64 Chrome. + # TODO(hidehiko): Remove this hack. + '--arch=x86-64', + ] + }], + ['enable_arm_nonsfi==1', { + 'inputs': ['>(out_pnacl_newlib_arm_nonsfi_nexe)'], + 'action': [ + '--program=>(out_pnacl_newlib_arm_nonsfi_nexe)', + '--arch=arm', + ] + }], ], }, ], @@ -281,6 +321,7 @@ 'action': [ 'python', '>@(_inputs)', + '>@(create_nmf_flags)', '--output=>(nmf_pnacl)', ], }, @@ -304,6 +345,7 @@ 'action': [ 'python', '>@(_inputs)', + '>@(create_nmf_flags)', '--output=>(nmf_pnacl)', ], }, diff --git a/chromium/ppapi/ppapi_nacl_test_common.gypi b/chromium/ppapi/ppapi_nacl_test_common.gypi index 3ebd8a0f851..50ea539f476 100644 --- a/chromium/ppapi/ppapi_nacl_test_common.gypi +++ b/chromium/ppapi/ppapi_nacl_test_common.gypi @@ -35,6 +35,7 @@ 'out_pnacl_newlib%': '>(nacl_pnacl_newlib_out_dir)/>(nexe_target)_newlib_pnacl.pexe', 'nmf_pnacl_newlib%': '>(nacl_pnacl_newlib_out_dir)/>(nexe_target).nmf', 'out_pnacl_newlib_x86_32_nonsfi_nexe': '>(nacl_pnacl_newlib_nonsfi_out_dir)/>(nexe_target)_pnacl_newlib_x32_nonsfi.nexe', + 'out_pnacl_newlib_arm_nonsfi_nexe': '>(nacl_pnacl_newlib_nonsfi_out_dir)/>(nexe_target)_pnacl_newlib_arm_nonsfi.nexe', 'nmf_pnacl_newlib_nonsfi%': '>(nacl_pnacl_newlib_nonsfi_out_dir)/>(nexe_target).nmf', }], ], @@ -77,7 +78,7 @@ }, ], }], - ['test_files!=[] and build_pnacl_newlib==1 and enable_x86_32_nonsfi==1', { + ['test_files!=[] and build_pnacl_newlib==1 and (enable_x86_32_nonsfi==1 or enable_arm_nonsfi==1)', { 'copies': [ { 'destination': '>(nacl_pnacl_newlib_nonsfi_out_dir)', @@ -109,6 +110,10 @@ 'create_nmf': '<(DEPTH)/native_client_sdk/src/tools/create_nmf.py', 'create_nmf_args_portable%': [], 'create_nonsfi_test_nmf': '<(DEPTH)/ppapi/tests/create_nonsfi_test_nmf.py', + 'create_nmf_args': [ + '--no-default-libpath', + '--objdump=>(nacl_glibc_tc_root)/bin/x86_64-nacl-objdump', + ], }, 'target_conditions': [ ['generate_nmf==1 and build_newlib==1', { @@ -120,6 +125,7 @@ 'action': [ 'python', '>(create_nmf)', + '>@(create_nmf_args)', '--output=>(nmf_newlib)', '>@(create_nmf_args_portable)', ], @@ -150,7 +156,6 @@ # doesn't work on Windows. 'libdir_glibc64': '>(nacl_glibc_tc_root)/x86_64-nacl/lib', 'libdir_glibc32': '>(nacl_glibc_tc_root)/x86_64-nacl/lib32', - 'nacl_objdump': '>(nacl_glibc_tc_root)/bin/x86_64-nacl-objdump', }, 'actions': [ { @@ -162,8 +167,8 @@ 'outputs': ['>(nmf_glibc)'], 'action': [ 'python', - '>(create_nmf)', - '--objdump=>(nacl_objdump)', + '>@(_inputs)', + '>@(create_nmf_args)', '--output=>(nmf_glibc)', '--path-prefix=>(nexe_target)_libs', '--stage-dependencies=<(nacl_glibc_out_dir)', @@ -173,7 +178,6 @@ ['enable_x86_64==1', { 'inputs': ['>(out_glibc64)'], 'action': [ - '>(out_glibc64)', '--library-path=>(libdir_glibc64)', '--library-path=>(tc_lib_dir_glibc64)', ], @@ -181,7 +185,6 @@ ['enable_x86_32==1', { 'inputs': ['>(out_glibc32)'], 'action': [ - '>(out_glibc32)', '--library-path=>(libdir_glibc32)', '--library-path=>(tc_lib_dir_glibc32)', ], @@ -202,6 +205,7 @@ 'action': [ 'python', '>(create_nmf)', + '>@(create_nmf_args)', '--output=>(nmf_pnacl_newlib)', '>(out_pnacl_newlib)', '>@(create_nmf_args_portable)', @@ -209,22 +213,49 @@ }, ], }], - ['generate_nmf==1 and build_pnacl_newlib==1 and disable_pnacl==0 and enable_x86_32_nonsfi==1', { + ['generate_nmf==1 and build_pnacl_newlib==1 and disable_pnacl==0 and (enable_x86_32_nonsfi==1 or enable_arm_nonsfi==1)', { 'actions': [ { 'action_name': 'Generate PNACL NEWLIB nonsfi NMF', - # If we add support for ARM, we should split the dependency on - # out_pnacl_newlib_x86_32_nonsfi_nexe to 'target_conditions', - # similar to build_newlib=1 config declared above. - 'inputs': ['>(create_nonsfi_test_nmf)', - '>(out_pnacl_newlib_x86_32_nonsfi_nexe)'], + 'inputs': ['>(create_nonsfi_test_nmf)'], 'outputs': ['>(nmf_pnacl_newlib_nonsfi)'], 'action': [ 'python', '>(create_nonsfi_test_nmf)', + '>@(create_nmf_args_portable)', '--output=>(nmf_pnacl_newlib_nonsfi)', - '--program=>(out_pnacl_newlib_x86_32_nonsfi_nexe)', - '>@(create_nmf_args_portable)' + ], + 'target_conditions': [ + ['enable_x86_32_nonsfi==1 and "<(target_arch)"=="ia32"', { + 'inputs': ['>(out_pnacl_newlib_x86_32_nonsfi_nexe)'], + 'action': [ + '--program=>(out_pnacl_newlib_x86_32_nonsfi_nexe)', + '--arch=x86-32', + ] + }], + ['enable_x86_32_nonsfi==1 and "<(target_arch)"=="x64"', { + 'inputs': ['>(out_pnacl_newlib_x86_32_nonsfi_nexe)'], + 'action': [ + '--program=>(out_pnacl_newlib_x86_32_nonsfi_nexe)', + # This should be used only for nacl_helper_nonsfi test. + # In theory this should be x86-32. However, currently + # fallback logic to x86-32-nonsfi is not implemented, + # and, moreover, it would break the tests for current + # nacl_helper in Non-SFI mode on x64 Chrome. + # So, here we introduce the hack to use "x86-64" in order + # to take the benefit to run nacl_helper_nonsfi tests on + # x64 Chrome. + # TODO(hidehiko): Remove this hack. + '--arch=x86-64', + ] + }], + ['enable_arm_nonsfi==1', { + 'inputs': ['>(out_pnacl_newlib_arm_nonsfi_nexe)'], + 'action': [ + '--program=>(out_pnacl_newlib_arm_nonsfi_nexe)', + '--arch=arm', + ] + }], ], }, ], diff --git a/chromium/ppapi/ppapi_proxy.gypi b/chromium/ppapi/ppapi_proxy.gypi index c775386e7cb..d099e0a6504 100644 --- a/chromium/ppapi/ppapi_proxy.gypi +++ b/chromium/ppapi/ppapi_proxy.gypi @@ -29,6 +29,10 @@ 'proxy/broker_resource.h', 'proxy/browser_font_singleton_resource.cc', 'proxy/browser_font_singleton_resource.h', + 'proxy/camera_capabilities_resource.cc', + 'proxy/camera_capabilities_resource.h', + 'proxy/camera_device_resource.cc', + 'proxy/camera_device_resource.h', 'proxy/compositor_layer_resource.cc', 'proxy/compositor_layer_resource.h', 'proxy/compositor_resource.cc', @@ -45,10 +49,6 @@ 'proxy/file_chooser_resource.h', 'proxy/file_io_resource.cc', 'proxy/file_io_resource.h', - 'proxy/file_mapping_resource.cc', - 'proxy/file_mapping_resource.h', - 'proxy/file_mapping_resource_posix.cc', - 'proxy/file_mapping_resource_win.cc', 'proxy/file_ref_resource.cc', 'proxy/file_ref_resource.h', 'proxy/file_system_resource.cc', @@ -130,8 +130,8 @@ 'proxy/plugin_var_tracker.h', 'proxy/ppapi_command_buffer_proxy.cc', 'proxy/ppapi_command_buffer_proxy.h', - 'proxy/ppapi_messages.h', 'proxy/ppapi_message_utils.h', + 'proxy/ppapi_messages.h', 'proxy/ppb_audio_proxy.cc', 'proxy/ppb_audio_proxy.h', 'proxy/ppb_broker_proxy.cc', @@ -197,10 +197,9 @@ 'proxy/proxy_object_var.h', 'proxy/resource_creation_proxy.cc', 'proxy/resource_creation_proxy.h', + 'proxy/resource_message_filter.h', 'proxy/resource_reply_thread_registrar.cc', 'proxy/resource_reply_thread_registrar.h', - 'proxy/talk_resource.cc', - 'proxy/talk_resource.h', 'proxy/tcp_server_socket_private_resource.cc', 'proxy/tcp_server_socket_private_resource.h', 'proxy/tcp_socket_private_resource.cc', @@ -213,6 +212,8 @@ 'proxy/truetype_font_resource.h', 'proxy/truetype_font_singleton_resource.cc', 'proxy/truetype_font_singleton_resource.h', + 'proxy/udp_socket_filter.cc', + 'proxy/udp_socket_filter.h', 'proxy/udp_socket_private_resource.cc', 'proxy/udp_socket_private_resource.h', 'proxy/udp_socket_resource.cc', @@ -234,6 +235,8 @@ 'proxy/video_decoder_resource.h', 'proxy/video_destination_resource.cc', 'proxy/video_destination_resource.h', + 'proxy/video_encoder_resource.cc', + 'proxy/video_encoder_resource.h', 'proxy/video_frame_resource.cc', 'proxy/video_frame_resource.h', 'proxy/video_source_resource.cc', @@ -284,14 +287,13 @@ 'proxy/ppb_flash_message_loop_proxy.cc', 'proxy/ppb_flash_proxy.cc', 'proxy/ppb_pdf_proxy.cc', - 'proxy/ppb_talk_private_proxy.cc', + 'proxy/ppb_var_deprecated_proxy.cc', 'proxy/ppb_video_capture_proxy.cc', 'proxy/ppb_video_decoder_proxy.cc', 'proxy/ppp_content_decryptor_private_proxy.cc', 'proxy/ppp_instance_private_proxy.cc', 'proxy/ppp_video_decoder_proxy.cc', 'proxy/serialized_flash_menu.cc', - 'proxy/talk_resource.cc', 'proxy/video_capture_resource.cc', ], }], diff --git a/chromium/ppapi/ppapi_proxy_nacl.gyp b/chromium/ppapi/ppapi_proxy_nacl.gyp index 8dd81e3b4ed..d015758d309 100644 --- a/chromium/ppapi/ppapi_proxy_nacl.gyp +++ b/chromium/ppapi/ppapi_proxy_nacl.gyp @@ -41,7 +41,6 @@ '../gpu/gpu_nacl.gyp:gpu_ipc_nacl', '../ipc/ipc_nacl.gyp:ipc_nacl', '../ipc/ipc_nacl.gyp:ipc_nacl_nonsfi', - '../native_client/tools.gyp:prep_toolchain', '../ppapi/ppapi_ipc_nacl.gyp:ppapi_ipc_nacl', '../ppapi/ppapi_shared_nacl.gyp:ppapi_shared_nacl', '../third_party/WebKit/public/blink_headers.gyp:blink_headers', diff --git a/chromium/ppapi/ppapi_shared.gypi b/chromium/ppapi/ppapi_shared.gypi index 9fe13752bbd..6e6f90b7bec 100644 --- a/chromium/ppapi/ppapi_shared.gypi +++ b/chromium/ppapi/ppapi_shared.gypi @@ -22,10 +22,10 @@ 'shared_impl/compositor_layer_data.h', 'shared_impl/dictionary_var.cc', 'shared_impl/dictionary_var.h', - 'shared_impl/file_io_state_manager.cc', - 'shared_impl/file_io_state_manager.h', 'shared_impl/file_growth.cc', 'shared_impl/file_growth.h', + 'shared_impl/file_io_state_manager.cc', + 'shared_impl/file_io_state_manager.h', 'shared_impl/file_path.cc', 'shared_impl/file_path.h', 'shared_impl/file_ref_create_info.cc', @@ -42,11 +42,11 @@ 'shared_impl/host_resource.h', 'shared_impl/id_assignment.cc', 'shared_impl/id_assignment.h', + 'shared_impl/media_stream_audio_track_shared.cc', + 'shared_impl/media_stream_audio_track_shared.h', 'shared_impl/media_stream_buffer.h', 'shared_impl/media_stream_buffer_manager.cc', 'shared_impl/media_stream_buffer_manager.h', - 'shared_impl/media_stream_audio_track_shared.cc', - 'shared_impl/media_stream_audio_track_shared.h', 'shared_impl/media_stream_video_track_shared.cc', 'shared_impl/media_stream_video_track_shared.h', 'shared_impl/platform_file.cc', @@ -99,6 +99,11 @@ 'shared_impl/ppp_flash_browser_operations_shared.h', 'shared_impl/ppp_instance_combined.cc', 'shared_impl/ppp_instance_combined.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', + 'shared_impl/private/net_address_private_impl_constants.cc', + 'shared_impl/proxy_lock.cc', 'shared_impl/proxy_lock.h', 'shared_impl/resource.cc', @@ -113,8 +118,6 @@ 'shared_impl/scoped_pp_var.h', 'shared_impl/socket_option_data.cc', 'shared_impl/socket_option_data.h', - 'shared_impl/test_harness_utils.cc', - 'shared_impl/test_harness_utils.h', 'shared_impl/thread_aware_callback.cc', 'shared_impl/thread_aware_callback.h', 'shared_impl/time_conversion.cc', @@ -129,10 +132,6 @@ 'shared_impl/var.h', 'shared_impl/var_tracker.cc', 'shared_impl/var_tracker.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_constants.cc', - 'shared_impl/private/net_address_private_impl.h', 'shared_impl/private/ppb_char_set_shared.cc', 'shared_impl/private/ppb_char_set_shared.h', @@ -142,10 +141,10 @@ 'thunk/enter.cc', 'thunk/enter.h', 'thunk/ppb_audio_api.h', - 'thunk/ppb_audio_config_api.h', - 'thunk/ppb_audio_config_thunk.cc', 'thunk/ppb_audio_buffer_api.h', 'thunk/ppb_audio_buffer_thunk.cc', + 'thunk/ppb_audio_config_api.h', + 'thunk/ppb_audio_config_thunk.cc', 'thunk/ppb_audio_input_api.h', 'thunk/ppb_audio_input_dev_thunk.cc', 'thunk/ppb_audio_thunk.cc', @@ -155,6 +154,10 @@ 'thunk/ppb_browser_font_trusted_thunk.cc', 'thunk/ppb_buffer_api.h', 'thunk/ppb_buffer_thunk.cc', + 'thunk/ppb_camera_capabilities_api.h', + 'thunk/ppb_camera_capabilities_private_thunk.cc', + 'thunk/ppb_camera_device_api.h', + 'thunk/ppb_camera_device_private_thunk.cc', 'thunk/ppb_char_set_thunk.cc', 'thunk/ppb_compositor_api.h', 'thunk/ppb_compositor_layer_api.h', @@ -172,7 +175,6 @@ 'thunk/ppb_file_io_api.h', 'thunk/ppb_file_io_private_thunk.cc', 'thunk/ppb_file_io_thunk.cc', - 'thunk/ppb_file_mapping_thunk.cc', 'thunk/ppb_file_ref_api.h', 'thunk/ppb_file_ref_thunk.cc', 'thunk/ppb_file_system_api.h', @@ -205,14 +207,14 @@ 'thunk/ppb_graphics_3d_api.h', 'thunk/ppb_graphics_3d_thunk.cc', 'thunk/ppb_host_resolver_api.h', - 'thunk/ppb_host_resolver_thunk.cc', 'thunk/ppb_host_resolver_private_api.h', 'thunk/ppb_host_resolver_private_thunk.cc', + 'thunk/ppb_host_resolver_thunk.cc', 'thunk/ppb_image_data_api.h', 'thunk/ppb_image_data_thunk.cc', 'thunk/ppb_input_event_api.h', - 'thunk/ppb_input_event_thunk.cc', 'thunk/ppb_input_event_private_thunk.cc', + 'thunk/ppb_input_event_thunk.cc', 'thunk/ppb_instance_api.h', 'thunk/ppb_instance_private_thunk.cc', 'thunk/ppb_instance_thunk.cc', @@ -244,8 +246,6 @@ 'thunk/ppb_printing_dev_thunk.cc', 'thunk/ppb_scrollbar_api.h', 'thunk/ppb_scrollbar_thunk.cc', - 'thunk/ppb_talk_private_api.h', - 'thunk/ppb_talk_private_thunk.cc', 'thunk/ppb_tcp_server_socket_private_api.h', 'thunk/ppb_tcp_server_socket_private_thunk.cc', 'thunk/ppb_tcp_socket_api.h', @@ -254,12 +254,12 @@ 'thunk/ppb_tcp_socket_thunk.cc', 'thunk/ppb_text_input_thunk.cc', 'thunk/ppb_truetype_font_api.h', - 'thunk/ppb_truetype_font_singleton_api.h', 'thunk/ppb_truetype_font_dev_thunk.cc', + 'thunk/ppb_truetype_font_singleton_api.h', 'thunk/ppb_udp_socket_api.h', - 'thunk/ppb_udp_socket_thunk.cc', 'thunk/ppb_udp_socket_private_api.h', 'thunk/ppb_udp_socket_private_thunk.cc', + 'thunk/ppb_udp_socket_thunk.cc', 'thunk/ppb_uma_private_thunk.cc', 'thunk/ppb_uma_singleton_api.h', 'thunk/ppb_url_loader_api.h', @@ -280,6 +280,8 @@ 'thunk/ppb_video_decoder_thunk.cc', 'thunk/ppb_video_destination_private_api.h', 'thunk/ppb_video_destination_private_thunk.cc', + 'thunk/ppb_video_encoder_api.h', + 'thunk/ppb_video_encoder_thunk.cc', 'thunk/ppb_video_frame_api.h', 'thunk/ppb_video_frame_thunk.cc', 'thunk/ppb_video_source_private_api.h', @@ -308,16 +310,16 @@ 'sources!': [ 'shared_impl/flash_clipboard_format_registry.cc', 'shared_impl/ppb_url_util_shared.cc', - 'shared_impl/ppb_video_decoder_shared.cc', 'shared_impl/ppb_video_capture_shared.cc', + 'shared_impl/ppb_video_decoder_shared.cc', 'shared_impl/private/ppb_browser_font_trusted_shared.cc', 'shared_impl/private/ppb_char_set_shared.cc', 'thunk/ppb_audio_input_dev_thunk.cc', 'thunk/ppb_broker_thunk.cc', 'thunk/ppb_browser_font_trusted_thunk.cc', 'thunk/ppb_buffer_thunk.cc', - 'thunk/ppb_content_decryptor_private_thunk.cc', 'thunk/ppb_char_set_thunk.cc', + 'thunk/ppb_content_decryptor_private_thunk.cc', 'thunk/ppb_flash_clipboard_thunk.cc', 'thunk/ppb_flash_device_id_thunk.cc', 'thunk/ppb_flash_drm_thunk.cc', @@ -327,13 +329,12 @@ 'thunk/ppb_flash_fullscreen_thunk.cc', 'thunk/ppb_flash_menu_thunk.cc', 'thunk/ppb_flash_message_loop_thunk.cc', - 'thunk/ppb_flash_thunk.cc', 'thunk/ppb_flash_message_loop_thunk.cc', + 'thunk/ppb_flash_thunk.cc', 'thunk/ppb_gles_chromium_texture_mapping_thunk.cc', 'thunk/ppb_pdf_thunk.cc', 'thunk/ppb_platform_verification_private_thunk.cc', 'thunk/ppb_scrollbar_thunk.cc', - 'thunk/ppb_talk_private_thunk.cc', 'thunk/ppb_transport_thunk.cc', 'thunk/ppb_url_util_thunk.cc', 'thunk/ppb_video_capture_thunk.cc', @@ -347,8 +348,8 @@ 'shared_impl/ppb_audio_shared.cc', 'shared_impl/ppb_graphics_3d_shared.cc', 'shared_impl/ppb_opengles2_shared.cc', - 'shared_impl/private/ppb_host_resolver_shared.cc', 'shared_impl/private/net_address_private_impl.cc', + 'shared_impl/private/ppb_host_resolver_shared.cc', 'thunk/ppb_graphics_3d_thunk.cc', 'thunk/ppb_host_resolver_private_thunk.cc', 'thunk/ppb_tcp_server_socket_private_thunk.cc', diff --git a/chromium/ppapi/ppapi_shared_nacl.gyp b/chromium/ppapi/ppapi_shared_nacl.gyp index 819acc7fde8..05e4acae480 100644 --- a/chromium/ppapi/ppapi_shared_nacl.gyp +++ b/chromium/ppapi/ppapi_shared_nacl.gyp @@ -31,7 +31,6 @@ '..', ], 'dependencies': [ - '../native_client/tools.gyp:prep_toolchain', '../base/base_nacl.gyp:base_nacl', '../base/base_nacl.gyp:base_nacl_nonsfi', '../gpu/command_buffer/command_buffer_nacl.gyp:gles2_utils_nacl', diff --git a/chromium/ppapi/ppapi_sources.gni b/chromium/ppapi/ppapi_sources.gni new file mode 100644 index 00000000000..dcee45c1d87 --- /dev/null +++ b/chromium/ppapi/ppapi_sources.gni @@ -0,0 +1,11 @@ +# Copyright 2015 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. + +# Import this file to get the ppapi_sources dictionary containing source files +# from GYP. This is a .gni file so it can be shared between different BUILD.gn +# files without having to re-run the script each time. +ppapi_sources = exec_script("//build/gypi_to_gn.py", + [ rebase_path("ppapi_sources.gypi") ], + "scope", + [ "ppapi_sources.gypi" ]) diff --git a/chromium/ppapi/ppapi_sources.gypi b/chromium/ppapi/ppapi_sources.gypi index 4407da75a24..add92ce26f0 100644 --- a/chromium/ppapi/ppapi_sources.gypi +++ b/chromium/ppapi/ppapi_sources.gypi @@ -32,7 +32,6 @@ 'c/ppb_console.h', 'c/ppb_core.h', 'c/ppb_file_io.h', - 'c/ppb_file_mapping.h', 'c/ppb_file_ref.h', 'c/ppb_file_system.h', 'c/ppb_fullscreen.h', @@ -106,6 +105,8 @@ 'c/private/pp_file_handle.h', 'c/private/pp_private_font_charset.h', 'c/private/pp_video_frame_private.h', + 'c/private/ppb_camera_capabilities_private.h', + 'c/private/ppb_camera_device_private.h', 'c/private/ppb_content_decryptor_private.h', 'c/private/ppb_ext_crx_file_system_private.h', 'c/private/ppb_find_private.h', @@ -120,15 +121,14 @@ 'c/private/ppb_input_event_private.h', 'c/private/ppb_instance_private.h', 'c/private/ppb_isolated_file_system_private.h', - 'c/private/ppb_nacl_private.h', 'c/private/ppb_net_address_private.h', 'c/private/ppb_output_protection_private.h', 'c/private/ppb_pdf.h', 'c/private/ppb_platform_verification_private.h', 'c/private/ppb_proxy_private.h', - 'c/private/ppb_testing_private.h', 'c/private/ppb_tcp_server_socket_private.h', 'c/private/ppb_tcp_socket_private.h', + 'c/private/ppb_testing_private.h', 'c/private/ppb_udp_socket_private.h', 'c/private/ppb_uma_private.h', 'c/private/ppb_video_destination_private.h', @@ -245,6 +245,8 @@ 'cpp/var_dictionary.h', 'cpp/video_decoder.cc', 'cpp/video_decoder.h', + 'cpp/video_encoder.cc', + 'cpp/video_encoder.h', 'cpp/video_frame.cc', 'cpp/video_frame.h', 'cpp/view.cc', @@ -301,10 +303,14 @@ 'cpp/dev/zoom_dev.h', # Deprecated interfaces. - 'cpp/dev/scriptable_object_deprecated.h', 'cpp/dev/scriptable_object_deprecated.cc', + 'cpp/dev/scriptable_object_deprecated.h', # Private interfaces. + 'cpp/private/camera_capabilities_private.cc', + 'cpp/private/camera_capabilities_private.h', + 'cpp/private/camera_device_private.cc', + 'cpp/private/camera_device_private.h', 'cpp/private/content_decryptor_private.cc', 'cpp/private/content_decryptor_private.h', 'cpp/private/ext_crx_file_system_private.cc', @@ -393,9 +399,9 @@ # 'test_common_source_files': [ # Common test files - 'lib/gl/gles2/gles2.c', 'lib/gl/gles2/gl2ext_ppapi.c', 'lib/gl/gles2/gl2ext_ppapi.h', + 'lib/gl/gles2/gles2.c', 'tests/all_c_includes.h', 'tests/all_cpp_includes.h', 'tests/arch_dependent_sizes_32.h', @@ -419,8 +425,6 @@ 'tests/test_empty.h', 'tests/test_file_io.cc', 'tests/test_file_io.h', - 'tests/test_file_mapping.cc', - 'tests/test_file_mapping.h', 'tests/test_file_ref.cc', 'tests/test_file_ref.h', 'tests/test_file_system.cc', @@ -506,6 +510,8 @@ 'tests/test_video_decoder.h', 'tests/test_video_destination.cc', 'tests/test_video_destination.h', + 'tests/test_video_encoder.cc', + 'tests/test_video_encoder.h', 'tests/test_video_source.cc', 'tests/test_video_source.h', 'tests/test_view.cc', @@ -564,8 +570,6 @@ 'tests/test_pdf.h', 'tests/test_platform_verification_private.cc', 'tests/test_platform_verification_private.h', - 'tests/test_talk_private.cc', - 'tests/test_talk_private.h', 'tests/test_tcp_socket_private_trusted.cc', 'tests/test_tcp_socket_private_trusted.h', 'tests/test_url_util.cc', diff --git a/chromium/ppapi/ppapi_tests.gypi b/chromium/ppapi/ppapi_tests.gypi index d7bf04766a0..830933ef834 100644 --- a/chromium/ppapi/ppapi_tests.gypi +++ b/chromium/ppapi/ppapi_tests.gypi @@ -5,6 +5,7 @@ { 'targets': [ { + # GN version: //ppapi:ppapi_tests 'target_name': 'ppapi_tests', 'type': 'loadable_module', 'include_dirs': [ @@ -29,6 +30,7 @@ 'tests/test_case.html', 'tests/test_case.html.mock-http-headers', 'tests/test_page.css', + 'tests/test_page.css.mock-http-headers', 'tests/ppapi_nacl_tests_newlib.nmf', ], }, @@ -55,8 +57,6 @@ '_CRT_NONSTDC_NO_DEPRECATE', '_SCL_SECURE_NO_DEPRECATE', ], - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], }], ['OS=="mac"', { 'mac_bundle': 1, @@ -64,8 +64,6 @@ 'product_extension': 'plugin', }], ], - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], # TODO(dmichael): Figure out what is wrong with the script on Windows and add # it as an automated action. # 'actions': [ @@ -83,7 +81,28 @@ # ], }, { - # GN version: //ppapi:ppapi_unittest_shared + # GN version: //ppapi:power_saver_test_plugin + 'target_name': 'power_saver_test_plugin', + 'type': 'loadable_module', + 'sources': [ + 'tests/power_saver_test_plugin.cc', + 'tests/test_utils.cc', + ], + 'dependencies': [ + 'ppapi.gyp:ppapi_cpp', + 'ppapi_internal.gyp:ppapi_shared', + ], + 'conditions': [ + ['OS=="mac"', { + 'mac_bundle': 1, + 'product_name': 'power_saver_test_plugin', + 'product_extension': 'plugin', + }], + ], + }, + { + # GN version: //ppapi/proxy:test_support + # //ppapi/shared_impl:test_support 'target_name': 'ppapi_unittest_shared', 'type': 'static_library', 'dependencies': [ @@ -103,12 +122,13 @@ 'proxy/resource_message_test_sink.h', 'shared_impl/test_globals.cc', 'shared_impl/test_globals.h', - 'shared_impl/unittest_utils.cc', - 'shared_impl/unittest_utils.h', + 'shared_impl/test_utils.cc', + 'shared_impl/test_utils.h', ], }, { + # GN version: //ppapi:ppapi_perftests 'target_name': 'ppapi_perftests', 'type': 'executable', 'variables': { @@ -135,6 +155,7 @@ ], }, { + # GN version: //ppapi:ppapi_unittests 'target_name': 'ppapi_unittests', 'type': 'executable', 'variables': { @@ -156,6 +177,7 @@ '../ui/surface/surface.gyp:surface', ], 'sources': [ + # Note: sources list duplicated in GN build. 'host/resource_message_filter_unittest.cc', 'proxy/device_enumeration_resource_helper_unittest.cc', 'proxy/file_chooser_resource_unittest.cc', @@ -176,8 +198,9 @@ 'proxy/printing_resource_unittest.cc', 'proxy/raw_var_data_unittest.cc', 'proxy/serialized_var_unittest.cc', - 'proxy/talk_resource_unittest.cc', + 'proxy/tracked_callback_unittest.cc', 'proxy/video_decoder_resource_unittest.cc', + 'proxy/video_encoder_resource_unittest.cc', 'proxy/websocket_resource_unittest.cc', 'shared_impl/media_stream_audio_track_shared_unittest.cc', 'shared_impl/media_stream_buffer_manager_unittest.cc', @@ -186,7 +209,6 @@ 'shared_impl/resource_tracker_unittest.cc', 'shared_impl/thread_aware_callback_unittest.cc', 'shared_impl/time_conversion_unittest.cc', - 'shared_impl/tracked_callback_unittest.cc', 'shared_impl/var_tracker_unittest.cc', ], 'conditions': [ @@ -200,8 +222,6 @@ ], }], ], - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], }, { 'target_name': 'ppapi_example_skeleton', @@ -233,6 +253,7 @@ }, }, { + # GN version: //ppapi/examples/mouse_cursor 'target_name': 'ppapi_example_mouse_cursor', 'dependencies': [ 'ppapi_example_skeleton', @@ -243,6 +264,7 @@ ], }, { + # GN version: //ppapi/examples/mouse_lock 'target_name': 'ppapi_example_mouse_lock', 'dependencies': [ 'ppapi_example_skeleton', @@ -254,6 +276,7 @@ }, { + # GN version: //ppapi/examples/gamepad 'target_name': 'ppapi_example_gamepad', 'dependencies': [ 'ppapi_example_skeleton', @@ -262,11 +285,10 @@ 'sources': [ 'examples/gamepad/gamepad.cc', ], - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], }, { + # GN version: //ppapi/examples/stub:c_stub 'target_name': 'ppapi_example_c_stub', 'dependencies': [ 'ppapi_example_skeleton', @@ -277,6 +299,7 @@ ], }, { + # GN version: //ppapi/examples/stub:cc_stub 'target_name': 'ppapi_example_cc_stub', 'dependencies': [ 'ppapi_example_skeleton', @@ -287,6 +310,7 @@ ], }, { + # GN version: //ppapi/examples/crxfs 'target_name': 'ppapi_example_crxfs', 'dependencies': [ 'ppapi_example_skeleton', @@ -297,6 +321,7 @@ ], }, { + # GN version: //ppapi/examples/audio 'target_name': 'ppapi_example_audio', 'dependencies': [ 'ppapi_example_skeleton', @@ -307,6 +332,7 @@ ], }, { + # GN version: //ppapi/examples/audio_input 'target_name': 'ppapi_example_audio_input', 'dependencies': [ 'ppapi_example_skeleton', @@ -317,6 +343,7 @@ ], }, { + # GN version: //ppapi/examples/file_chooser 'target_name': 'ppapi_example_file_chooser', 'dependencies': [ 'ppapi_example_skeleton', @@ -327,6 +354,7 @@ ], }, { + # GN version: //ppapi/examples/2d:graphics_2d 'target_name': 'ppapi_example_graphics_2d', 'dependencies': [ 'ppapi_example_skeleton', @@ -337,6 +365,7 @@ ], }, { + # GN version: //ppapi/examples/ime 'target_name': 'ppapi_example_ime', 'dependencies': [ 'ppapi_example_skeleton', @@ -345,10 +374,9 @@ 'sources': [ 'examples/ime/ime.cc', ], - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], }, { + # GN version: //ppapi/examples/2d:paint_manager 'target_name': 'ppapi_example_paint_manager', 'dependencies': [ 'ppapi_example_skeleton', @@ -359,6 +387,7 @@ ], }, { + # GN version: //ppapi/examples/input 'target_name': 'ppapi_example_input', 'dependencies': [ 'ppapi_example_skeleton', @@ -369,6 +398,7 @@ ], }, { + # GN version: //ppapi/examples/scripting 'target_name': 'ppapi_example_post_message', 'dependencies': [ 'ppapi_example_skeleton', @@ -379,6 +409,7 @@ ], }, { + # GN version: //ppapi/examples/scaling 'target_name': 'ppapi_example_scaling', 'dependencies': [ 'ppapi_example_skeleton', @@ -389,6 +420,7 @@ ], }, { + # GN version: //ppapi/examples/2d:scroll 'target_name': 'ppapi_example_scroll', 'dependencies': [ 'ppapi_example_skeleton', @@ -399,6 +431,7 @@ ], }, { + # GN version: //ppapi/examples/font 'target_name': 'ppapi_example_simple_font', 'dependencies': [ 'ppapi_example_skeleton', @@ -409,6 +442,18 @@ ], }, { + # GN version: //ppapi/examples/threading + 'target_name': 'ppapi_example_threading', + 'dependencies': [ + 'ppapi_example_skeleton', + 'ppapi.gyp:ppapi_cpp', + ], + 'sources': [ + 'examples/threading/threading.cc', + ], + }, + { + # GN version: //ppapi/examples/url_loader:streaming 'target_name': 'ppapi_example_url_loader', 'dependencies': [ 'ppapi_example_skeleton', @@ -419,6 +464,7 @@ ], }, { + # GN version: //ppapi/examples/url_loader:file 'target_name': 'ppapi_example_url_loader_file', 'dependencies': [ 'ppapi_example_skeleton', @@ -429,6 +475,7 @@ ], }, { + # GN version: //ppapi/examples/gles2 'target_name': 'ppapi_example_gles2', 'dependencies': [ 'ppapi_example_skeleton', @@ -443,6 +490,7 @@ ], }, { + # GN version: //ppapi/examples/video_decode:stable 'target_name': 'ppapi_example_video_decode', 'dependencies': [ 'ppapi_example_skeleton', @@ -453,13 +501,12 @@ 'lib/gl/include', ], 'sources': [ - 'examples/video_decode/video_decode.cc', 'examples/video_decode/testdata.h', + 'examples/video_decode/video_decode.cc', ], - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], }, { + # GN version: //ppapi/examples/video_decode:dev 'target_name': 'ppapi_example_video_decode_dev', 'dependencies': [ 'ppapi_example_skeleton', @@ -470,13 +517,22 @@ 'lib/gl/include', ], 'sources': [ - 'examples/video_decode/video_decode_dev.cc', 'examples/video_decode/testdata.h', + 'examples/video_decode/video_decode_dev.cc', + ], + }, + { + 'target_name': 'ppapi_example_video_encode', + 'dependencies': [ + 'ppapi_example_skeleton', + 'ppapi.gyp:ppapi_cpp', + ], + 'sources': [ + 'examples/video_encode/video_encode.cc', ], - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], }, { + # GN version: //ppapi/example/video_capture 'target_name': 'ppapi_example_vc', 'dependencies': [ 'ppapi_example_skeleton', @@ -491,6 +547,7 @@ ], }, { + # GN version: //ppapi/examples/video_effects 'target_name': 'ppapi_example_video_effects', 'dependencies': [ 'ppapi_example_skeleton', @@ -501,6 +558,7 @@ ], }, { + # GN version: //ppapi/examples/enumerate_devices 'target_name': 'ppapi_example_enumerate_devices', 'dependencies': [ 'ppapi_example_skeleton', @@ -511,6 +569,7 @@ ], }, { + # GN version: //ppapi/examples/flash_topmost 'target_name': 'ppapi_example_flash_topmost', 'dependencies': [ 'ppapi_example_skeleton', @@ -521,6 +580,7 @@ ], }, { + # GN version: //ppapi/examples/printing 'target_name': 'ppapi_example_printing', 'dependencies': [ 'ppapi_example_skeleton', @@ -529,10 +589,9 @@ 'sources': [ 'examples/printing/printing.cc', ], - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], }, { + # GN version: //ppapi/examples/media_stream_audio 'target_name': 'ppapi_example_media_stream_audio', 'dependencies': [ 'ppapi_example_skeleton', @@ -543,6 +602,7 @@ ], }, { + # GN version: //ppapi/examples/media_stream_video 'target_name': 'ppapi_example_media_stream_video', 'dependencies': [ 'ppapi_example_skeleton', @@ -557,6 +617,7 @@ ], }, { + # GN version: //ppapi/examples/gles2_spinning_cube 'target_name': 'ppapi_example_gles2_spinning_cube', 'dependencies': [ 'ppapi_example_skeleton', @@ -573,6 +634,7 @@ ], }, { + # GN version: //ppapi/examples/compositor 'target_name': 'ppapi_example_compositor', 'dependencies': [ 'ppapi_example_skeleton', @@ -588,5 +650,7 @@ 'examples/compositor/spinning_cube.h', ], }, + # Adding a new PPAPI example? Don't forget to update the GN build. + # See //ppapi/examples/BUILD.gn ], } diff --git a/chromium/ppapi/proxy/BUILD.gn b/chromium/ppapi/proxy/BUILD.gn new file mode 100644 index 00000000000..8e260088d8e --- /dev/null +++ b/chromium/ppapi/proxy/BUILD.gn @@ -0,0 +1,365 @@ +# Copyright 2015 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. + +config("proxy_implementation") { + defines = [ "PPAPI_PROXY_IMPLEMENTATION" ] +} + +component("proxy") { + output_name = "ppapi_proxy" + + sources = [ + # Take some standalone files from the C++ wrapper allowing us to more + # easily make async callbacks in the proxy. We can't depend on the + # full C++ wrappers at this layer since the C++ wrappers expect + # symbols defining the globals for "being a plugin" which we are not. + # These callback files are standalone. + "../cpp/completion_callback.h", + "../utility/completion_callback_factory.h", + "audio_buffer_resource.cc", + "audio_buffer_resource.h", + "broker_resource.cc", + "broker_resource.h", + "camera_capabilities_resource.cc", + "camera_capabilities_resource.h", + "camera_device_resource.cc", + "camera_device_resource.h", + "compositor_layer_resource.cc", + "compositor_layer_resource.h", + "compositor_resource.cc", + "compositor_resource.h", + "connection.h", + "dispatcher.cc", + "dispatcher.h", + "enter_proxy.h", + "error_conversion.cc", + "error_conversion.h", + "file_chooser_resource.cc", + "file_chooser_resource.h", + "file_io_resource.cc", + "file_io_resource.h", + "file_ref_resource.cc", + "file_ref_resource.h", + "file_system_resource.cc", + "file_system_resource.h", + "gamepad_resource.cc", + "gamepad_resource.h", + "graphics_2d_resource.cc", + "graphics_2d_resource.h", + "host_resolver_private_resource.cc", + "host_resolver_private_resource.h", + "host_resolver_resource.cc", + "host_resolver_resource.h", + "host_resolver_resource_base.cc", + "host_resolver_resource_base.h", + "interface_list.cc", + "interface_list.h", + "interface_proxy.cc", + "interface_proxy.h", + "isolated_file_system_private_resource.cc", + "isolated_file_system_private_resource.h", + "locking_resource_releaser.h", + "media_stream_audio_track_resource.cc", + "media_stream_audio_track_resource.h", + "media_stream_track_resource_base.cc", + "media_stream_track_resource_base.h", + "media_stream_video_track_resource.cc", + "media_stream_video_track_resource.h", + "message_handler.cc", + "message_handler.h", + "net_address_resource.cc", + "net_address_resource.h", + "network_list_resource.cc", + "network_list_resource.h", + "network_monitor_resource.cc", + "network_monitor_resource.h", + "network_proxy_resource.cc", + "network_proxy_resource.h", + "output_protection_resource.cc", + "output_protection_resource.h", + "plugin_array_buffer_var.cc", + "plugin_array_buffer_var.h", + "plugin_dispatcher.cc", + "plugin_dispatcher.h", + "plugin_globals.cc", + "plugin_globals.h", + "plugin_message_filter.cc", + "plugin_message_filter.h", + "plugin_resource.cc", + "plugin_resource.h", + "plugin_resource_tracker.cc", + "plugin_resource_tracker.h", + "plugin_resource_var.cc", + "plugin_resource_var.h", + "plugin_var_serialization_rules.cc", + "plugin_var_serialization_rules.h", + "plugin_var_tracker.cc", + "plugin_var_tracker.h", + "ppapi_command_buffer_proxy.cc", + "ppapi_command_buffer_proxy.h", + "ppapi_message_utils.h", + "ppapi_messages.h", + "ppb_audio_proxy.cc", + "ppb_audio_proxy.h", + "ppb_core_proxy.cc", + "ppb_core_proxy.h", + "ppb_graphics_3d_proxy.cc", + "ppb_graphics_3d_proxy.h", + "ppb_image_data_proxy.cc", + "ppb_image_data_proxy.h", + "ppb_instance_proxy.cc", + "ppb_instance_proxy.h", + "ppb_message_loop_proxy.cc", + "ppb_message_loop_proxy.h", + "ppb_testing_proxy.cc", + "ppb_testing_proxy.h", + "ppb_x509_certificate_private_proxy.cc", + "ppb_x509_certificate_private_proxy.h", + "ppp_class_proxy.cc", + "ppp_class_proxy.h", + "ppp_find_proxy.cc", + "ppp_find_proxy.h", + "ppp_graphics_3d_proxy.cc", + "ppp_graphics_3d_proxy.h", + "ppp_input_event_proxy.cc", + "ppp_input_event_proxy.h", + "ppp_instance_proxy.cc", + "ppp_instance_proxy.h", + "ppp_messaging_proxy.cc", + "ppp_messaging_proxy.h", + "ppp_mouse_lock_proxy.cc", + "ppp_mouse_lock_proxy.h", + "ppp_pdf_proxy.cc", + "ppp_pdf_proxy.h", + "ppp_printing_proxy.cc", + "ppp_printing_proxy.h", + "ppp_text_input_proxy.cc", + "ppp_text_input_proxy.h", + "printing_resource.cc", + "printing_resource.h", + "proxy_array_output.cc", + "proxy_array_output.h", + "proxy_channel.cc", + "proxy_channel.h", + "proxy_completion_callback_factory.h", + "proxy_module.cc", + "proxy_module.h", + "proxy_object_var.cc", + "proxy_object_var.h", + "resource_creation_proxy.cc", + "resource_creation_proxy.h", + "resource_reply_thread_registrar.cc", + "resource_reply_thread_registrar.h", + "tcp_server_socket_private_resource.cc", + "tcp_server_socket_private_resource.h", + "tcp_socket_private_resource.cc", + "tcp_socket_private_resource.h", + "tcp_socket_resource.cc", + "tcp_socket_resource.h", + "tcp_socket_resource_base.cc", + "tcp_socket_resource_base.h", + "truetype_font_resource.cc", + "truetype_font_resource.h", + "truetype_font_singleton_resource.cc", + "truetype_font_singleton_resource.h", + "udp_socket_filter.cc", + "udp_socket_filter.h", + "udp_socket_private_resource.cc", + "udp_socket_private_resource.h", + "udp_socket_resource.cc", + "udp_socket_resource.h", + "udp_socket_resource_base.cc", + "udp_socket_resource_base.h", + "uma_private_resource.cc", + "uma_private_resource.h", + "url_loader_resource.cc", + "url_loader_resource.h", + "url_request_info_resource.cc", + "url_request_info_resource.h", + "url_response_info_resource.cc", + "url_response_info_resource.h", + "var_serialization_rules.h", + "video_decoder_resource.cc", + "video_decoder_resource.h", + "video_destination_resource.cc", + "video_destination_resource.h", + "video_encoder_resource.cc", + "video_encoder_resource.h", + "video_frame_resource.cc", + "video_frame_resource.h", + "video_source_resource.cc", + "video_source_resource.h", + "websocket_resource.cc", + "websocket_resource.h", + ] + + if (is_nacl) { + sources += [ + "../nacl_irt/irt_ppapi.cc", + "../nacl_irt/irt_ppapi.h", + "../nacl_irt/irt_start.cc", + "../nacl_irt/manifest_service.cc", + "../nacl_irt/manifest_service.h", + "../nacl_irt/plugin_main.cc", + "../nacl_irt/plugin_main.h", + "../nacl_irt/plugin_startup.cc", + "../nacl_irt/plugin_startup.h", + "../nacl_irt/ppapi_dispatcher.cc", + "../nacl_irt/ppapi_dispatcher.h", + ] + } else { + sources += [ + "audio_input_resource.cc", + "audio_input_resource.h", + "broker_dispatcher.cc", + "broker_dispatcher.h", + "browser_font_singleton_resource.cc", + "browser_font_singleton_resource.h", + "device_enumeration_resource_helper.cc", + "device_enumeration_resource_helper.h", + "flash_clipboard_resource.cc", + "flash_clipboard_resource.h", + "flash_drm_resource.cc", + "flash_drm_resource.h", + "flash_file_resource.cc", + "flash_file_resource.h", + "flash_font_file_resource.cc", + "flash_font_file_resource.h", + "flash_fullscreen_resource.cc", + "flash_fullscreen_resource.h", + "flash_menu_resource.cc", + "flash_menu_resource.h", + "flash_resource.cc", + "flash_resource.h", + "host_dispatcher.cc", + "host_dispatcher.h", + "host_var_serialization_rules.cc", + "host_var_serialization_rules.h", + "pdf_resource.cc", + "pdf_resource.h", + "platform_verification_private_resource.cc", + "platform_verification_private_resource.h", + "ppb_broker_proxy.cc", + "ppb_broker_proxy.h", + "ppb_buffer_proxy.cc", + "ppb_buffer_proxy.h", + "ppb_flash_message_loop_proxy.cc", + "ppb_flash_message_loop_proxy.h", + "ppb_var_deprecated_proxy.cc", + "ppb_var_deprecated_proxy.h", + "ppb_video_decoder_proxy.cc", + "ppb_video_decoder_proxy.h", + "ppp_content_decryptor_private_proxy.cc", + "ppp_content_decryptor_private_proxy.h", + "ppp_instance_private_proxy.cc", + "ppp_instance_private_proxy.h", + "ppp_video_decoder_proxy.cc", + "ppp_video_decoder_proxy.h", + "video_capture_resource.cc", + "video_capture_resource.h", + ] + } + + configs += [ ":proxy_implementation" ] + + deps = [ + "//base", + "//gpu/command_buffer/client:gles2_implementation", + "//gpu/ipc", + "//ipc", + "//media:shared_memory_support", + "//ppapi/c", + "//ppapi/proxy:ipc_sources", + "//ppapi/shared_impl", + "//third_party/icu", + ] + + if (is_nacl) { + deps += [ "//ui/events:latency_info" ] + } else { + deps += [ + "//base/third_party/dynamic_annotations", + "//gin", + "//skia", + "//ui/events:events_base", + "//ui/surface", + ] + } +} + +group("ipc") { + if (is_component_build) { + public_deps = [ + "//ppapi/proxy", + ] + } else { + public_deps = [ + ":ipc_sources", + ] + } +} + +source_set("ipc_sources") { + sources = [ + "nacl_message_scanner.cc", + "nacl_message_scanner.h", + "ppapi_messages.cc", + "ppapi_messages.h", + "ppapi_param_traits.cc", + "ppapi_param_traits.h", + "raw_var_data.cc", + "raw_var_data.h", + "resource_message_params.cc", + "resource_message_params.h", + "serialized_flash_menu.cc", + "serialized_flash_menu.h", + "serialized_handle.cc", + "serialized_handle.h", + "serialized_structs.cc", + "serialized_structs.h", + "serialized_var.cc", + "serialized_var.h", + "var_serialization_rules.h", + ] + if (is_nacl) { + sources -= [ "serialized_flash_menu.cc" ] + } + + configs += [ ":proxy_implementation" ] + + deps = [ + "//base", + "//gpu/ipc", + "//ipc", + "//ppapi/c", + "//ppapi/shared_impl", + ] + if (!is_nacl) { + deps += [ + "//skia", + "//ui/events/ipc", + ] + } +} + +source_set("test_support") { + testonly = true + + sources = [ + "ppapi_proxy_test.cc", + "ppapi_proxy_test.h", + "resource_message_test_sink.cc", + "resource_message_test_sink.h", + ] + + deps = [ + "//base/test:test_support", + "//ipc", + "//ipc:test_support", + "//ppapi/proxy", + "//ppapi/shared_impl", + "//testing/gmock", + "//testing/gtest", + ] +} diff --git a/chromium/ppapi/proxy/DEPS b/chromium/ppapi/proxy/DEPS index 6183b609ef4..c1fd8e241f1 100644 --- a/chromium/ppapi/proxy/DEPS +++ b/chromium/ppapi/proxy/DEPS @@ -1,5 +1,6 @@ include_rules = [ "+base", + "+gin", "+gpu", "+ipc", "+media/audio", diff --git a/chromium/ppapi/proxy/audio_buffer_resource.h b/chromium/ppapi/proxy/audio_buffer_resource.h index ea5adec889a..8f1e22ff6ef 100644 --- a/chromium/ppapi/proxy/audio_buffer_resource.h +++ b/chromium/ppapi/proxy/audio_buffer_resource.h @@ -25,23 +25,23 @@ class PPAPI_PROXY_EXPORT AudioBufferResource int32_t index, MediaStreamBuffer* buffer); - virtual ~AudioBufferResource(); + ~AudioBufferResource() override; // PluginResource overrides: - virtual thunk::PPB_AudioBuffer_API* AsPPB_AudioBuffer_API() override; + thunk::PPB_AudioBuffer_API* AsPPB_AudioBuffer_API() override; // PPB_AudioBuffer_API overrides: - virtual PP_TimeDelta GetTimestamp() override; - virtual void SetTimestamp(PP_TimeDelta timestamp) override; - virtual PP_AudioBuffer_SampleRate GetSampleRate() override; - virtual PP_AudioBuffer_SampleSize GetSampleSize() override; - virtual uint32_t GetNumberOfChannels() override; - virtual uint32_t GetNumberOfSamples() override; - virtual void* GetDataBuffer() override; - virtual uint32_t GetDataBufferSize() override; - virtual MediaStreamBuffer* GetBuffer() override; - virtual int32_t GetBufferIndex() override; - virtual void Invalidate() override; + PP_TimeDelta GetTimestamp() override; + void SetTimestamp(PP_TimeDelta timestamp) override; + PP_AudioBuffer_SampleRate GetSampleRate() override; + PP_AudioBuffer_SampleSize GetSampleSize() override; + uint32_t GetNumberOfChannels() override; + uint32_t GetNumberOfSamples() override; + void* GetDataBuffer() override; + uint32_t GetDataBufferSize() override; + MediaStreamBuffer* GetBuffer() override; + int32_t GetBufferIndex() override; + void Invalidate() override; // Buffer index int32_t index_; diff --git a/chromium/ppapi/proxy/audio_input_resource.cc b/chromium/ppapi/proxy/audio_input_resource.cc index 7f1f81983e6..4a24255226f 100644 --- a/chromium/ppapi/proxy/audio_input_resource.cc +++ b/chromium/ppapi/proxy/audio_input_resource.cc @@ -6,6 +6,7 @@ #include "base/bind.h" #include "base/logging.h" +#include "base/numerics/safe_conversions.h" #include "ipc/ipc_platform_file.h" #include "media/audio/audio_parameters.h" #include "media/base/audio_bus.h" @@ -249,7 +250,8 @@ void AudioInputResource::Run() { media::AudioInputBuffer* buffer = static_cast<media::AudioInputBuffer*>(shared_memory_->memory()); const uint32_t audio_bus_size_bytes = - shared_memory_size_ - sizeof(media::AudioInputBufferParameters); + base::checked_cast<uint32_t>(shared_memory_size_ - + sizeof(media::AudioInputBufferParameters)); while (true) { int pending_data = 0; diff --git a/chromium/ppapi/proxy/audio_input_resource.h b/chromium/ppapi/proxy/audio_input_resource.h index 1d4fc06272c..a94ff9c5e3e 100644 --- a/chromium/ppapi/proxy/audio_input_resource.h +++ b/chromium/ppapi/proxy/audio_input_resource.h @@ -31,38 +31,36 @@ class AudioInputResource : public PluginResource, public base::DelegateSimpleThread::Delegate { public: AudioInputResource(Connection connection, PP_Instance instance); - virtual ~AudioInputResource(); + ~AudioInputResource() override; // Resource overrides. - virtual thunk::PPB_AudioInput_API* AsPPB_AudioInput_API() override; - virtual void OnReplyReceived(const ResourceMessageReplyParams& params, - const IPC::Message& msg) override; + thunk::PPB_AudioInput_API* AsPPB_AudioInput_API() override; + void OnReplyReceived(const ResourceMessageReplyParams& params, + const IPC::Message& msg) override; // PPB_AudioInput_API implementation. - virtual int32_t EnumerateDevices( - const PP_ArrayOutput& output, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t MonitorDeviceChange( - PP_MonitorDeviceChangeCallback callback, - void* user_data) override; - virtual int32_t Open0_3(PP_Resource device_ref, - PP_Resource config, - PPB_AudioInput_Callback_0_3 audio_input_callback_0_3, - void* user_data, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t Open(PP_Resource device_ref, - PP_Resource config, - PPB_AudioInput_Callback audio_input_callback, - void* user_data, - scoped_refptr<TrackedCallback> callback) override; - virtual PP_Resource GetCurrentConfig() override; - virtual PP_Bool StartCapture() override; - virtual PP_Bool StopCapture() override; - virtual void Close() override; + int32_t EnumerateDevices(const PP_ArrayOutput& output, + scoped_refptr<TrackedCallback> callback) override; + int32_t MonitorDeviceChange(PP_MonitorDeviceChangeCallback callback, + void* user_data) override; + int32_t Open0_3(PP_Resource device_ref, + PP_Resource config, + PPB_AudioInput_Callback_0_3 audio_input_callback_0_3, + void* user_data, + scoped_refptr<TrackedCallback> callback) override; + int32_t Open(PP_Resource device_ref, + PP_Resource config, + PPB_AudioInput_Callback audio_input_callback, + void* user_data, + scoped_refptr<TrackedCallback> callback) override; + PP_Resource GetCurrentConfig() override; + PP_Bool StartCapture() override; + PP_Bool StopCapture() override; + void Close() override; protected: // Resource override. - virtual void LastPluginRefWasDeleted() override; + void LastPluginRefWasDeleted() override; private: enum OpenState { @@ -87,7 +85,7 @@ class AudioInputResource : public PluginResource, // DelegateSimpleThread::Delegate implementation. // Run on the audio input thread. - virtual void Run() override; + void Run() override; int32_t CommonOpen(PP_Resource device_ref, PP_Resource config, diff --git a/chromium/ppapi/proxy/broker_dispatcher.h b/chromium/ppapi/proxy/broker_dispatcher.h index ea2b4770727..828dac63666 100644 --- a/chromium/ppapi/proxy/broker_dispatcher.h +++ b/chromium/ppapi/proxy/broker_dispatcher.h @@ -14,7 +14,7 @@ namespace proxy { class PPAPI_PROXY_EXPORT BrokerDispatcher : public ProxyChannel { public: - virtual ~BrokerDispatcher(); + ~BrokerDispatcher() override; // You must call this function before anything else. Returns true on success. // The delegate pointer must outlive this class, ownership is not @@ -25,7 +25,7 @@ class PPAPI_PROXY_EXPORT BrokerDispatcher : public ProxyChannel { bool is_client); // IPC::Listener implementation. - virtual bool OnMessageReceived(const IPC::Message& msg) override; + bool OnMessageReceived(const IPC::Message& msg) override; protected: // You must call InitBrokerWithChannel after the constructor. @@ -47,7 +47,7 @@ class PPAPI_PROXY_EXPORT BrokerHostDispatcher : public BrokerDispatcher { BrokerHostDispatcher(); // IPC::Listener implementation. - virtual void OnChannelError() override; + void OnChannelError() override; }; // The dispatcher for the broker side of the broker channel. @@ -56,7 +56,7 @@ class PPAPI_PROXY_EXPORT BrokerSideDispatcher : public BrokerDispatcher { explicit BrokerSideDispatcher(PP_ConnectInstance_Func connect_instance); // IPC::Listener implementation. - virtual void OnChannelError() override; + void OnChannelError() override; }; } // namespace proxy diff --git a/chromium/ppapi/proxy/broker_resource.h b/chromium/ppapi/proxy/broker_resource.h index b2fd437fbff..23310934545 100644 --- a/chromium/ppapi/proxy/broker_resource.h +++ b/chromium/ppapi/proxy/broker_resource.h @@ -17,13 +17,13 @@ class BrokerResource public thunk::PPB_Broker_Instance_API { public: BrokerResource(Connection connection, PP_Instance instance); - virtual ~BrokerResource(); + ~BrokerResource() override; // Resource override. - virtual thunk::PPB_Broker_Instance_API* AsPPB_Broker_Instance_API() override; + thunk::PPB_Broker_Instance_API* AsPPB_Broker_Instance_API() override; // thunk::PPB_Broker_Instance_API implementation. - virtual PP_Bool IsAllowed() override; + PP_Bool IsAllowed() override; private: DISALLOW_COPY_AND_ASSIGN(BrokerResource); diff --git a/chromium/ppapi/proxy/browser_font_singleton_resource.h b/chromium/ppapi/proxy/browser_font_singleton_resource.h index 85e2dc6edc7..ddbb690a638 100644 --- a/chromium/ppapi/proxy/browser_font_singleton_resource.h +++ b/chromium/ppapi/proxy/browser_font_singleton_resource.h @@ -19,14 +19,14 @@ class BrowserFontSingletonResource public thunk::PPB_BrowserFont_Singleton_API { public: BrowserFontSingletonResource(Connection connection, PP_Instance instance); - virtual ~BrowserFontSingletonResource(); + ~BrowserFontSingletonResource() override; // Resource override. - virtual thunk::PPB_BrowserFont_Singleton_API* + thunk::PPB_BrowserFont_Singleton_API* AsPPB_BrowserFont_Singleton_API() override; // thunk::PPB_BrowserFontSingleton_API implementation. - virtual PP_Var GetFontFamilies(PP_Instance instance) override; + PP_Var GetFontFamilies(PP_Instance instance) override; private: // Lazily-filled-in list of font families. diff --git a/chromium/ppapi/proxy/camera_capabilities_resource.cc b/chromium/ppapi/proxy/camera_capabilities_resource.cc new file mode 100644 index 00000000000..1236aa35a66 --- /dev/null +++ b/chromium/ppapi/proxy/camera_capabilities_resource.cc @@ -0,0 +1,38 @@ +// Copyright 2015 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/logging.h" +#include "base/numerics/safe_conversions.h" +#include "ppapi/proxy/camera_capabilities_resource.h" + +namespace ppapi { +namespace proxy { + +CameraCapabilitiesResource::CameraCapabilitiesResource( + PP_Instance instance, + const std::vector<PP_VideoCaptureFormat>& formats) + : Resource(OBJECT_IS_PROXY, instance), + num_video_capture_formats_(formats.size()), + video_capture_formats_( + new PP_VideoCaptureFormat[num_video_capture_formats_]) { + std::copy(formats.begin(), formats.end(), video_capture_formats_.get()); +} + +CameraCapabilitiesResource::~CameraCapabilitiesResource() { +} + +thunk::PPB_CameraCapabilities_API* +CameraCapabilitiesResource::AsPPB_CameraCapabilities_API() { + return this; +} + +void CameraCapabilitiesResource::GetSupportedVideoCaptureFormats( + uint32_t* array_size, + PP_VideoCaptureFormat** formats) { + *array_size = base::checked_cast<uint32_t>(num_video_capture_formats_); + *formats = video_capture_formats_.get(); +} + +} // namespace proxy +} // namespace ppapi diff --git a/chromium/ppapi/proxy/camera_capabilities_resource.h b/chromium/ppapi/proxy/camera_capabilities_resource.h new file mode 100644 index 00000000000..82e8df86275 --- /dev/null +++ b/chromium/ppapi/proxy/camera_capabilities_resource.h @@ -0,0 +1,46 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_PROXY_CAMERA_CAPABILITIES_RESOURCE_H_ +#define PPAPI_PROXY_CAMERA_CAPABILITIES_RESOURCE_H_ + +#include <vector> + +#include "base/basictypes.h" +#include "base/memory/scoped_ptr.h" +#include "ppapi/proxy/ppapi_proxy_export.h" +#include "ppapi/shared_impl/resource.h" +#include "ppapi/thunk/ppb_camera_capabilities_api.h" + +namespace ppapi { +namespace proxy { + +class PPAPI_PROXY_EXPORT CameraCapabilitiesResource + : public Resource, + public thunk::PPB_CameraCapabilities_API { + public: + CameraCapabilitiesResource(PP_Instance instance, + const std::vector<PP_VideoCaptureFormat>& formats); + + ~CameraCapabilitiesResource() override; + + // Resource overrides. + thunk::PPB_CameraCapabilities_API* AsPPB_CameraCapabilities_API() override; + + // PPB_CameraCapabilities_API implementation. + void GetSupportedVideoCaptureFormats( + uint32_t* array_size, + PP_VideoCaptureFormat** formats) override; + + private: + size_t num_video_capture_formats_; + scoped_ptr<PP_VideoCaptureFormat[]> video_capture_formats_; + + DISALLOW_COPY_AND_ASSIGN(CameraCapabilitiesResource); +}; + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_CAMERA_CAPABILITIES_RESOURCE_H_ diff --git a/chromium/ppapi/proxy/camera_device_resource.cc b/chromium/ppapi/proxy/camera_device_resource.cc new file mode 100644 index 00000000000..1ec5af2b662 --- /dev/null +++ b/chromium/ppapi/proxy/camera_device_resource.cc @@ -0,0 +1,120 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/proxy/camera_device_resource.h" + +#include "ppapi/proxy/camera_capabilities_resource.h" +#include "ppapi/proxy/plugin_resource_tracker.h" +#include "ppapi/proxy/ppapi_messages.h" +#include "ppapi/shared_impl/var.h" + +namespace ppapi { +namespace proxy { + +CameraDeviceResource::CameraDeviceResource(Connection connection, + PP_Instance instance) + : PluginResource(connection, instance), + open_state_(OpenState::BEFORE_OPEN) { + SendCreate(RENDERER, PpapiHostMsg_CameraDevice_Create()); +} + +CameraDeviceResource::~CameraDeviceResource() { +} + +int32_t CameraDeviceResource::Open( + PP_Var device_id, + const scoped_refptr<TrackedCallback>& callback) { + if (open_state_ != OpenState::BEFORE_OPEN) + return PP_ERROR_FAILED; + + if (TrackedCallback::IsPending(open_callback_)) + return PP_ERROR_INPROGRESS; + + scoped_refptr<StringVar> source_string_var(StringVar::FromPPVar(device_id)); + if (!source_string_var || source_string_var->value().empty()) + return PP_ERROR_BADARGUMENT; + + open_callback_ = callback; + + Call<PpapiPluginMsg_CameraDevice_OpenReply>( + RENDERER, PpapiHostMsg_CameraDevice_Open(source_string_var->value()), + base::Bind(&CameraDeviceResource::OnPluginMsgOpenReply, + base::Unretained(this))); + return PP_OK_COMPLETIONPENDING; +} + +void CameraDeviceResource::Close() { + if (open_state_ == OpenState::CLOSED) + return; + + if (TrackedCallback::IsPending(open_callback_)) { + open_callback_->PostAbort(); + open_callback_ = nullptr; + } + + if (TrackedCallback::IsPending(get_capabilities_callback_)) { + get_capabilities_callback_->PostAbort(); + get_capabilities_callback_ = nullptr; + } + + Post(RENDERER, PpapiHostMsg_CameraDevice_Close()); + + open_state_ = OpenState::CLOSED; +} + +int32_t CameraDeviceResource::GetCameraCapabilities( + PP_Resource* capabilities, + const scoped_refptr<TrackedCallback>& callback) { + if (!is_opened()) + return PP_ERROR_FAILED; + + if (TrackedCallback::IsPending(get_capabilities_callback_)) + return PP_ERROR_INPROGRESS; + + if (camera_capabilities_.get()) { + *capabilities = camera_capabilities_->GetReference(); + return PP_OK; + } + + get_capabilities_callback_ = callback; + Call<PpapiPluginMsg_CameraDevice_GetSupportedVideoCaptureFormatsReply>( + RENDERER, PpapiHostMsg_CameraDevice_GetSupportedVideoCaptureFormats(), + base::Bind(&CameraDeviceResource::OnPluginMsgGetVideoCaptureFormatsReply, + base::Unretained(this), capabilities)); + + return PP_OK_COMPLETIONPENDING; +} + +void CameraDeviceResource::OnPluginMsgOpenReply( + const ResourceMessageReplyParams& params) { + // The callback may have been aborted by Close(). + if (TrackedCallback::IsPending(open_callback_)) { + if (open_state_ == OpenState::BEFORE_OPEN && params.result() == PP_OK) + open_state_ = OpenState::OPENED; + + open_callback_->Run(params.result()); + } +} + +void CameraDeviceResource::OnPluginMsgGetVideoCaptureFormatsReply( + PP_Resource* capabilities_output, + const ResourceMessageReplyParams& params, + const std::vector<PP_VideoCaptureFormat>& formats) { + if (!TrackedCallback::IsPending(get_capabilities_callback_)) + return; + + // Return camera capabilities. + int32_t result = params.result(); + scoped_refptr<TrackedCallback> callback; + callback.swap(get_capabilities_callback_); + if (result == PP_OK) { + camera_capabilities_ = + new CameraCapabilitiesResource(pp_instance(), formats); + *capabilities_output = camera_capabilities_->GetReference(); + } + callback->Run(result == PP_OK ? PP_OK : PP_ERROR_FAILED); +} + +} // namespace proxy +} // namespace ppapi diff --git a/chromium/ppapi/proxy/camera_device_resource.h b/chromium/ppapi/proxy/camera_device_resource.h new file mode 100644 index 00000000000..93878fe37df --- /dev/null +++ b/chromium/ppapi/proxy/camera_device_resource.h @@ -0,0 +1,67 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_PROXY_CAMERA_DEVICE_RESOURCE_H_ +#define PPAPI_PROXY_CAMERA_DEVICE_RESOURCE_H_ + +#include "base/basictypes.h" +#include "ppapi/c/pp_size.h" +#include "ppapi/c/private/pp_video_capture_format.h" +#include "ppapi/proxy/connection.h" +#include "ppapi/proxy/plugin_resource.h" +#include "ppapi/proxy/ppapi_proxy_export.h" +#include "ppapi/shared_impl/resource.h" +#include "ppapi/thunk/ppb_camera_device_api.h" + +namespace ppapi { +namespace proxy { + +class CameraCapabilitiesResource; + +class PPAPI_PROXY_EXPORT CameraDeviceResource + : public PluginResource, + public thunk::PPB_CameraDevice_API { + public: + CameraDeviceResource(Connection connection, PP_Instance instance); + ~CameraDeviceResource() override; + + // Resource overrides: + thunk::PPB_CameraDevice_API* AsPPB_CameraDevice_API() override { + return this; + } + + // PPB_CameraDevice_API implementation. + int32_t Open(PP_Var device_id, + const scoped_refptr<TrackedCallback>& callback) override; + void Close() override; + int32_t GetCameraCapabilities( + PP_Resource* capabilities, + const scoped_refptr<TrackedCallback>& callback) override; + + private: + enum class OpenState { BEFORE_OPEN, OPENED, CLOSED }; + + void OnPluginMsgGetVideoCaptureFormatsReply( + PP_Resource* capabilities_output, + const ResourceMessageReplyParams& params, + const std::vector<PP_VideoCaptureFormat>& formats); + + void OnPluginMsgOpenReply(const ResourceMessageReplyParams& params); + + bool is_opened() const { return open_state_ == OpenState::OPENED; } + + // Holds a reference of the callback so that Close() can cancel it. + scoped_refptr<TrackedCallback> open_callback_; + OpenState open_state_; + + scoped_refptr<TrackedCallback> get_capabilities_callback_; + scoped_refptr<CameraCapabilitiesResource> camera_capabilities_; + + DISALLOW_COPY_AND_ASSIGN(CameraDeviceResource); +}; + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_CAMERA_DEVICE_RESOURCE_H_ diff --git a/chromium/ppapi/proxy/compositor_layer_resource.cc b/chromium/ppapi/proxy/compositor_layer_resource.cc index 09a63b18053..c42776eb293 100644 --- a/chromium/ppapi/proxy/compositor_layer_resource.cc +++ b/chromium/ppapi/proxy/compositor_layer_resource.cc @@ -4,6 +4,8 @@ #include "ppapi/proxy/compositor_layer_resource.h" +#include <limits> + #include "base/logging.h" #include "gpu/GLES2/gl2extchromium.h" #include "gpu/command_buffer/client/gles2_implementation.h" @@ -217,7 +219,7 @@ int32_t CompositorLayerResource::SetImage( if (desc.format != PP_IMAGEDATAFORMAT_RGBA_PREMUL) return PP_ERROR_BADARGUMENT; - if (!size || size->width <= 0 || size->height <= 0) + if (size && (size->width <= 0 || size->height <= 0)) return PP_ERROR_BADARGUMENT; // Set the source size to image's size. It will be used to verify @@ -301,11 +303,12 @@ int32_t CompositorLayerResource::SetSourceRect( if (compositor_->IsInProgress()) return PP_ERROR_INPROGRESS; + const float kEpsilon = std::numeric_limits<float>::epsilon(); if (!rect || - rect->point.x < 0.0f || - rect->point.y < 0.0f || - rect->point.x + rect->size.width > source_size_.width || - rect->point.y + rect->size.height > source_size_.height) { + rect->point.x < -kEpsilon || + rect->point.y < -kEpsilon || + rect->point.x + rect->size.width > source_size_.width + kEpsilon || + rect->point.y + rect->size.height > source_size_.height + kEpsilon) { return PP_ERROR_BADARGUMENT; } diff --git a/chromium/ppapi/proxy/compositor_layer_resource.h b/chromium/ppapi/proxy/compositor_layer_resource.h index 5609740902f..dc6024fe159 100644 --- a/chromium/ppapi/proxy/compositor_layer_resource.h +++ b/chromium/ppapi/proxy/compositor_layer_resource.h @@ -42,38 +42,38 @@ class PPAPI_PROXY_EXPORT CompositorLayerResource TYPE_IMAGE, }; - virtual ~CompositorLayerResource(); + ~CompositorLayerResource() override; // Resource overrides: - virtual thunk::PPB_CompositorLayer_API* AsPPB_CompositorLayer_API() override; + thunk::PPB_CompositorLayer_API* AsPPB_CompositorLayer_API() override; // thunk::PPB_Compositor_API overrides: - virtual int32_t SetColor(float red, - float green, - float blue, - float alpha, - const PP_Size* size) override; - virtual int32_t SetTexture0_1( + int32_t SetColor(float red, + float green, + float blue, + float alpha, + const PP_Size* size) override; + int32_t SetTexture0_1( PP_Resource context, uint32_t texture, const PP_Size* size, const scoped_refptr<ppapi::TrackedCallback>& callback) override; - virtual int32_t SetTexture( + int32_t SetTexture( PP_Resource context, uint32_t target, uint32_t texture, const PP_Size* size, const scoped_refptr<TrackedCallback>& callback) override; - virtual int32_t SetImage( + int32_t SetImage( PP_Resource image_data, const PP_Size* size, const scoped_refptr<TrackedCallback>& callback) override; - virtual int32_t SetClipRect(const PP_Rect* rect) override; - virtual int32_t SetTransform(const float matrix[16]) override; - virtual int32_t SetOpacity(float opacity) override; - virtual int32_t SetBlendMode(PP_BlendMode mode) override; - virtual int32_t SetSourceRect(const PP_FloatRect* rect) override; - virtual int32_t SetPremultipliedAlpha(PP_Bool premult) override; + int32_t SetClipRect(const PP_Rect* rect) override; + int32_t SetTransform(const float matrix[16]) override; + int32_t SetOpacity(float opacity) override; + int32_t SetBlendMode(PP_BlendMode mode) override; + int32_t SetSourceRect(const PP_FloatRect* rect) override; + int32_t SetPremultipliedAlpha(PP_Bool premult) override; bool SetType(LayerType type); int32_t CheckForSetTextureAndImage( diff --git a/chromium/ppapi/proxy/compositor_resource.h b/chromium/ppapi/proxy/compositor_resource.h index 82828d92d31..0d3161ddeda 100644 --- a/chromium/ppapi/proxy/compositor_resource.h +++ b/chromium/ppapi/proxy/compositor_resource.h @@ -28,20 +28,19 @@ class PPAPI_PROXY_EXPORT CompositorResource int32_t GenerateResourceId() const; private: - virtual ~CompositorResource(); + ~CompositorResource() override; // Resource overrides: - virtual thunk::PPB_Compositor_API* AsPPB_Compositor_API() override; + thunk::PPB_Compositor_API* AsPPB_Compositor_API() override; // PluginResource overrides: - virtual void OnReplyReceived(const ResourceMessageReplyParams& params, - const IPC::Message& msg) override; + void OnReplyReceived(const ResourceMessageReplyParams& params, + const IPC::Message& msg) override; // thunk::PPB_Compositor_API overrides: - virtual PP_Resource AddLayer() override; - virtual int32_t CommitLayers( - const scoped_refptr<TrackedCallback>& callback) override; - virtual int32_t ResetLayers() override; + PP_Resource AddLayer() override; + int32_t CommitLayers(const scoped_refptr<TrackedCallback>& callback) override; + int32_t ResetLayers() override; // IPC msg handlers: void OnPluginMsgCommitLayersReply(const ResourceMessageReplyParams& params); diff --git a/chromium/ppapi/proxy/device_enumeration_resource_helper.cc b/chromium/ppapi/proxy/device_enumeration_resource_helper.cc index 18b1939d5ba..32a4e1db984 100644 --- a/chromium/ppapi/proxy/device_enumeration_resource_helper.cc +++ b/chromium/ppapi/proxy/device_enumeration_resource_helper.cc @@ -146,7 +146,7 @@ void DeviceEnumerationResourceHelper::OnPluginMsgNotifyDeviceChange( CHECK(monitor_callback_.get()); scoped_ptr<PP_Resource[]> elements; - uint32_t size = devices.size(); + uint32_t size = static_cast<uint32_t>(devices.size()); if (size > 0) { elements.reset(new PP_Resource[size]); for (size_t index = 0; index < size; ++index) { diff --git a/chromium/ppapi/proxy/device_enumeration_resource_helper_unittest.cc b/chromium/ppapi/proxy/device_enumeration_resource_helper_unittest.cc index a8fa24c1ecf..32bc68a0dde 100644 --- a/chromium/ppapi/proxy/device_enumeration_resource_helper_unittest.cc +++ b/chromium/ppapi/proxy/device_enumeration_resource_helper_unittest.cc @@ -71,10 +71,10 @@ class TestResource : public PluginResource { device_enumeration_(this) { } - virtual ~TestResource() {} + ~TestResource() override {} - virtual void OnReplyReceived(const ResourceMessageReplyParams& params, - const IPC::Message& msg) override { + void OnReplyReceived(const ResourceMessageReplyParams& params, + const IPC::Message& msg) override { if (!device_enumeration_.HandleReply(params, msg)) PluginResource::OnReplyReceived(params, msg); } diff --git a/chromium/ppapi/proxy/dispatch_reply_message.h b/chromium/ppapi/proxy/dispatch_reply_message.h index bb4b7d7d931..3e8b74f4db8 100644 --- a/chromium/ppapi/proxy/dispatch_reply_message.h +++ b/chromium/ppapi/proxy/dispatch_reply_message.h @@ -22,43 +22,44 @@ class ResourceMessageReplyParams; template <class ObjT, class Method> inline void DispatchResourceReply(ObjT* obj, Method method, const ResourceMessageReplyParams& params, - const Tuple0& arg) { + const Tuple<>& arg) { (obj->*method)(params); } template <class ObjT, class Method, class A> inline void DispatchResourceReply(ObjT* obj, Method method, const ResourceMessageReplyParams& params, - const Tuple1<A>& arg) { - (obj->*method)(params, arg.a); + const Tuple<A>& arg) { + (obj->*method)(params, get<0>(arg)); } template<class ObjT, class Method, class A, class B> inline void DispatchResourceReply(ObjT* obj, Method method, const ResourceMessageReplyParams& params, - const Tuple2<A, B>& arg) { - (obj->*method)(params, arg.a, arg.b); + const Tuple<A, B>& arg) { + (obj->*method)(params, get<0>(arg), get<1>(arg)); } template<class ObjT, class Method, class A, class B, class C> inline void DispatchResourceReply(ObjT* obj, Method method, const ResourceMessageReplyParams& params, - const Tuple3<A, B, C>& arg) { - (obj->*method)(params, arg.a, arg.b, arg.c); + const Tuple<A, B, C>& arg) { + (obj->*method)(params, get<0>(arg), get<1>(arg), get<2>(arg)); } template<class ObjT, class Method, class A, class B, class C, class D> inline void DispatchResourceReply(ObjT* obj, Method method, const ResourceMessageReplyParams& params, - const Tuple4<A, B, C, D>& arg) { - (obj->*method)(params, arg.a, arg.b, arg.c, arg.d); + const Tuple<A, B, C, D>& arg) { + (obj->*method)(params, get<0>(arg), get<1>(arg), get<2>(arg), get<3>(arg)); } template<class ObjT, class Method, class A, class B, class C, class D, class E> inline void DispatchResourceReply(ObjT* obj, Method method, const ResourceMessageReplyParams& params, - const Tuple5<A, B, C, D, E>& arg) { - (obj->*method)(params, arg.a, arg.b, arg.c, arg.d, arg.e); + const Tuple<A, B, C, D, E>& arg) { + (obj->*method)(params, get<0>(arg), get<1>(arg), get<2>(arg), get<3>(arg), + get<4>(arg)); } // Used to dispatch resource replies. In most cases, you should not call this diff --git a/chromium/ppapi/proxy/dispatcher.h b/chromium/ppapi/proxy/dispatcher.h index 38ec51ceb00..302884150e4 100644 --- a/chromium/ppapi/proxy/dispatcher.h +++ b/chromium/ppapi/proxy/dispatcher.h @@ -48,7 +48,7 @@ class VarSerializationRules; // | class PPAPI_PROXY_EXPORT Dispatcher : public ProxyChannel { public: - virtual ~Dispatcher(); + ~Dispatcher() override; // Returns true if the dispatcher is on the plugin side, or false if it's the // browser side. @@ -67,7 +67,7 @@ class PPAPI_PROXY_EXPORT Dispatcher : public ProxyChannel { void AddIOThreadMessageFilter(scoped_refptr<IPC::MessageFilter> filter); // IPC::Listener implementation. - virtual bool OnMessageReceived(const IPC::Message& msg) override; + bool OnMessageReceived(const IPC::Message& msg) override; PP_GetInterface_Func local_get_interface() const { return local_get_interface_; diff --git a/chromium/ppapi/proxy/file_chooser_resource.h b/chromium/ppapi/proxy/file_chooser_resource.h index c60f99d94c2..0347fb07339 100644 --- a/chromium/ppapi/proxy/file_chooser_resource.h +++ b/chromium/ppapi/proxy/file_chooser_resource.h @@ -29,22 +29,22 @@ class PPAPI_PROXY_EXPORT FileChooserResource PP_Instance instance, PP_FileChooserMode_Dev mode, const std::string& accept_types); - virtual ~FileChooserResource(); + ~FileChooserResource() override; // Resource overrides. - virtual thunk::PPB_FileChooser_API* AsPPB_FileChooser_API() override; + thunk::PPB_FileChooser_API* AsPPB_FileChooser_API() override; // PPB_FileChooser_API. - virtual int32_t Show(const PP_ArrayOutput& output, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t ShowWithoutUserGesture( + int32_t Show(const PP_ArrayOutput& output, + scoped_refptr<TrackedCallback> callback) override; + int32_t ShowWithoutUserGesture( PP_Bool save_as, PP_Var suggested_file_name, const PP_ArrayOutput& output, scoped_refptr<TrackedCallback> callback) override; - virtual int32_t Show0_5(scoped_refptr<TrackedCallback> callback) override; - virtual PP_Resource GetNextChosenFile() override; - virtual int32_t ShowWithoutUserGesture0_5( + int32_t Show0_5(scoped_refptr<TrackedCallback> callback) override; + PP_Resource GetNextChosenFile() override; + int32_t ShowWithoutUserGesture0_5( PP_Bool save_as, PP_Var suggested_file_name, scoped_refptr<TrackedCallback> callback) override; diff --git a/chromium/ppapi/proxy/file_io_resource.h b/chromium/ppapi/proxy/file_io_resource.h index fed4cae70ac..f32879a43a7 100644 --- a/chromium/ppapi/proxy/file_io_resource.h +++ b/chromium/ppapi/proxy/file_io_resource.h @@ -30,44 +30,42 @@ class PPAPI_PROXY_EXPORT FileIOResource public thunk::PPB_FileIO_API { public: FileIOResource(Connection connection, PP_Instance instance); - virtual ~FileIOResource(); + ~FileIOResource() override; // Resource overrides. - virtual thunk::PPB_FileIO_API* AsPPB_FileIO_API() override; + thunk::PPB_FileIO_API* AsPPB_FileIO_API() override; // PPB_FileIO_API implementation. - virtual int32_t Open(PP_Resource file_ref, - int32_t open_flags, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t Query(PP_FileInfo* info, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t Touch(PP_Time last_access_time, - PP_Time last_modified_time, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t Read(int64_t offset, - char* buffer, - int32_t bytes_to_read, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t ReadToArray(int64_t offset, - int32_t max_read_length, - PP_ArrayOutput* array_output, + int32_t Open(PP_Resource file_ref, + int32_t open_flags, + scoped_refptr<TrackedCallback> callback) override; + int32_t Query(PP_FileInfo* info, + scoped_refptr<TrackedCallback> callback) override; + int32_t Touch(PP_Time last_access_time, + PP_Time last_modified_time, + scoped_refptr<TrackedCallback> callback) override; + int32_t Read(int64_t offset, + char* buffer, + int32_t bytes_to_read, + scoped_refptr<TrackedCallback> callback) override; + int32_t ReadToArray(int64_t offset, + int32_t max_read_length, + PP_ArrayOutput* array_output, + scoped_refptr<TrackedCallback> callback) override; + int32_t Write(int64_t offset, + const char* buffer, + int32_t bytes_to_write, + scoped_refptr<TrackedCallback> callback) override; + int32_t SetLength(int64_t length, + scoped_refptr<TrackedCallback> callback) override; + int64_t GetMaxWrittenOffset() const override; + int64_t GetAppendModeWriteAmount() const override; + void SetMaxWrittenOffset(int64_t max_written_offset) override; + void SetAppendModeWriteAmount(int64_t append_mode_write_amount) override; + int32_t Flush(scoped_refptr<TrackedCallback> callback) override; + void Close() override; + int32_t RequestOSFileHandle(PP_FileHandle* handle, scoped_refptr<TrackedCallback> callback) override; - virtual int32_t Write(int64_t offset, - const char* buffer, - int32_t bytes_to_write, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t SetLength(int64_t length, - scoped_refptr<TrackedCallback> callback) override; - virtual int64_t GetMaxWrittenOffset() const override; - virtual int64_t GetAppendModeWriteAmount() const override; - virtual void SetMaxWrittenOffset(int64_t max_written_offset) override; - virtual void SetAppendModeWriteAmount( - int64_t append_mode_write_amount) override; - virtual int32_t Flush(scoped_refptr<TrackedCallback> callback) override; - virtual void Close() override; - virtual int32_t RequestOSFileHandle( - PP_FileHandle* handle, - scoped_refptr<TrackedCallback> callback) override; // FileHolder is used to guarantee that file operations will have a valid FD // to operate on, even if they're in a different thread. diff --git a/chromium/ppapi/proxy/file_mapping_resource.cc b/chromium/ppapi/proxy/file_mapping_resource.cc deleted file mode 100644 index c620c06dd29..00000000000 --- a/chromium/ppapi/proxy/file_mapping_resource.cc +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/proxy/file_mapping_resource.h" - -#include "base/bind.h" -#include "base/numerics/safe_conversions.h" -#include "base/task_runner_util.h" -#include "ppapi/c/pp_errors.h" -#include "ppapi/shared_impl/tracked_callback.h" -#include "ppapi/shared_impl/var.h" -#include "ppapi/thunk/enter.h" -#include "ppapi/thunk/ppb_file_io_api.h" - -namespace ppapi { -namespace proxy { - -FileMappingResource::FileMappingResource(Connection connection, - PP_Instance instance) - : PluginResource(connection, instance) { -} - -FileMappingResource::~FileMappingResource() { -} - -thunk::PPB_FileMapping_API* FileMappingResource::AsPPB_FileMapping_API() { - return this; -} - -int32_t FileMappingResource::Map(PP_Instance /* instance */, - PP_Resource file_io, - int64_t length, - uint32_t protection, - uint32_t flags, - int64_t offset, - void** address, - scoped_refptr<TrackedCallback> callback) { - thunk::EnterResourceNoLock<thunk::PPB_FileIO_API> enter(file_io, true); - if (enter.failed()) - return PP_ERROR_BADARGUMENT; - FileIOResource* file_io_resource = - static_cast<FileIOResource*>(enter.object()); - scoped_refptr<FileIOResource::FileHolder> file_holder = - file_io_resource->file_holder(); - if (!FileIOResource::FileHolder::IsValid(file_holder)) - return PP_ERROR_FAILED; - if (length < 0 || offset < 0 || - !base::IsValueInRangeForNumericType<off_t>(offset)) { - return PP_ERROR_BADARGUMENT; - } - if (!base::IsValueInRangeForNumericType<size_t>(length)) { - return PP_ERROR_NOMEMORY; - } - - // Ensure any bits we don't recognize are zero. - if (protection & - ~(PP_FILEMAPPROTECTION_READ | PP_FILEMAPPROTECTION_WRITE)) { - return PP_ERROR_BADARGUMENT; - } - if (flags & - ~(PP_FILEMAPFLAG_SHARED | PP_FILEMAPFLAG_PRIVATE | - PP_FILEMAPFLAG_FIXED)) { - return PP_ERROR_BADARGUMENT; - } - // Ensure at least one of SHARED and PRIVATE is set. - if (!(flags & (PP_FILEMAPFLAG_SHARED | PP_FILEMAPFLAG_PRIVATE))) - return PP_ERROR_BADARGUMENT; - // Ensure at most one of SHARED and PRIVATE is set. - if ((flags & PP_FILEMAPFLAG_SHARED) && - (flags & PP_FILEMAPFLAG_PRIVATE)) { - return PP_ERROR_BADARGUMENT; - } - if (!address) - return PP_ERROR_BADARGUMENT; - - base::Callback<MapResult()> map_cb( - base::Bind(&FileMappingResource::DoMapBlocking, file_holder, *address, - length, protection, flags, offset)); - if (callback->is_blocking()) { - // The plugin could release its reference to this instance when we release - // the proxy lock below. - scoped_refptr<FileMappingResource> protect(this); - MapResult map_result; - { - // Release the proxy lock while making a potentially slow file call. - ProxyAutoUnlock unlock; - map_result = map_cb.Run(); - } - OnMapCompleted(address, length, callback, map_result); - return map_result.result; - } else { - base::PostTaskAndReplyWithResult( - PpapiGlobals::Get()->GetFileTaskRunner(), - FROM_HERE, - map_cb, - RunWhileLocked(Bind(&FileMappingResource::OnMapCompleted, - this, - base::Unretained(address), - length, - callback))); - return PP_OK_COMPLETIONPENDING; - } -} - -int32_t FileMappingResource::Unmap(PP_Instance /* instance */, - const void* address, - int64_t length, - scoped_refptr<TrackedCallback> callback) { - if (!address) - return PP_ERROR_BADARGUMENT; - if (!base::IsValueInRangeForNumericType<size_t>(length)) - return PP_ERROR_BADARGUMENT; - - base::Callback<int32_t()> unmap_cb( - base::Bind(&FileMappingResource::DoUnmapBlocking, address, length)); - if (callback->is_blocking()) { - // Release the proxy lock while making a potentially slow file call. - ProxyAutoUnlock unlock; - return unmap_cb.Run(); - } else { - base::PostTaskAndReplyWithResult( - PpapiGlobals::Get()->GetFileTaskRunner(), - FROM_HERE, - unmap_cb, - RunWhileLocked(Bind(&TrackedCallback::Run, callback))); - return PP_OK_COMPLETIONPENDING; - } -} - -int64_t FileMappingResource::GetMapPageSize(PP_Instance /* instance */) { - return DoGetMapPageSize(); -} - -void FileMappingResource::OnMapCompleted( - void** mapped_address_out_param, - int64_t length, - scoped_refptr<TrackedCallback> callback, - const MapResult& map_result) { - if (callback->aborted()) { - if (map_result.result == PP_OK) { - // If the Map operation was successful, we need to Unmap to avoid leaks. - // The plugin won't get the address, so doesn't have a chance to do the - // Unmap. - PpapiGlobals::Get()->GetFileTaskRunner()->PostTask( - FROM_HERE, - base::Bind(base::IgnoreResult(&FileMappingResource::DoUnmapBlocking), - map_result.address, - length)); - } - return; - } - if (map_result.result == PP_OK) - *mapped_address_out_param = map_result.address; - if (!callback->is_blocking()) - callback->Run(map_result.result); -} - -} // namespace proxy -} // namespace ppapi diff --git a/chromium/ppapi/proxy/file_mapping_resource.h b/chromium/ppapi/proxy/file_mapping_resource.h deleted file mode 100644 index c5014aed86b..00000000000 --- a/chromium/ppapi/proxy/file_mapping_resource.h +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef PPAPI_PROXY_FILE_MAPPING_RESOURCE_H_ -#define PPAPI_PROXY_FILE_MAPPING_RESOURCE_H_ - -#include "ppapi/proxy/file_io_resource.h" -#include "ppapi/proxy/plugin_resource.h" -#include "ppapi/proxy/ppapi_proxy_export.h" -#include "ppapi/thunk/ppb_file_mapping_api.h" - -namespace ppapi { -namespace proxy { - -// The proxy-side resource for PPB_FileMapping. -class PPAPI_PROXY_EXPORT FileMappingResource - : public PluginResource, - public thunk::PPB_FileMapping_API { - public: - FileMappingResource(Connection connection, PP_Instance instance); - - private: - virtual ~FileMappingResource(); - - // Resource implementation. - virtual thunk::PPB_FileMapping_API* AsPPB_FileMapping_API() override; - - // PPB_FileMapping_API implementation. - virtual int32_t Map(PP_Instance instance, - PP_Resource file_io, - int64_t length, - uint32_t protection, - uint32_t flags, - int64_t offset, - void** address, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t Unmap(PP_Instance instance, - const void* address, - int64_t length, - scoped_refptr<TrackedCallback> callback) override; - virtual int64_t GetMapPageSize(PP_Instance instance) override; - - struct MapResult { - MapResult() : result(PP_ERROR_FAILED), address(NULL) { - } - int32_t result; - void* address; - }; - void OnMapCompleted(void** mapped_address_out_param, - int64_t length, - scoped_refptr<TrackedCallback> callback, - const MapResult& map_result); - - // These functions perform potentially blocking operations so they should not - // be called on the main thread or while we hold the proxy lock. Their - // implementation is platform specific. See file_mapping_resource_posix.cc and - // file_mapping_resource_win.cc. - static MapResult DoMapBlocking( - scoped_refptr<FileIOResource::FileHolder> file_holder, - void* address_hint, - int64_t length, - uint32_t protection, - uint32_t flags, - int64_t offset); - static int32_t DoUnmapBlocking(const void* address, int64_t length); - // DoGetMapPageSize is platform-specific, but fast enough that we can call it - // on the main thread with the lock. - static int64_t DoGetMapPageSize(); - - DISALLOW_COPY_AND_ASSIGN(FileMappingResource); -}; - -} // namespace proxy -} // namespace ppapi - -#endif // PPAPI_PROXY_FILE_MAPPING_RESOURCE_H_ diff --git a/chromium/ppapi/proxy/file_mapping_resource_posix.cc b/chromium/ppapi/proxy/file_mapping_resource_posix.cc deleted file mode 100644 index 24ce546916c..00000000000 --- a/chromium/ppapi/proxy/file_mapping_resource_posix.cc +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/proxy/file_mapping_resource.h" - -#include <stdio.h> -#include <sys/mman.h> -#include <unistd.h> - -#include "ppapi/c/pp_errors.h" - -namespace ppapi { -namespace proxy { - -namespace { - -int32_t ErrnoToPPError(int error_code) { - switch (error_code) { - case EACCES: - return PP_ERROR_NOACCESS; - case EAGAIN: - return PP_ERROR_NOMEMORY; - case EINVAL: - return PP_ERROR_BADARGUMENT; - case ENFILE: - case ENOMEM: - return PP_ERROR_NOMEMORY; - default: - return PP_ERROR_FAILED; - } -} - -} // namespace - -// static -FileMappingResource::MapResult FileMappingResource::DoMapBlocking( - scoped_refptr<FileIOResource::FileHolder> file_holder, - void* address_hint, - int64_t length, - uint32_t map_protection, - uint32_t map_flags, - int64_t offset) { - int prot_for_mmap = 0; - if (map_protection & PP_FILEMAPPROTECTION_READ) - prot_for_mmap |= PROT_READ; - if (map_protection & PP_FILEMAPPROTECTION_WRITE) - prot_for_mmap |= PROT_WRITE; - if (prot_for_mmap == 0) - prot_for_mmap = PROT_NONE; - - int flags_for_mmap = 0; - if (map_flags & PP_FILEMAPFLAG_SHARED) - flags_for_mmap |= MAP_SHARED; - if (map_flags & PP_FILEMAPFLAG_PRIVATE) - flags_for_mmap |= MAP_PRIVATE; - if (map_flags & PP_FILEMAPFLAG_FIXED) - flags_for_mmap |= MAP_FIXED; - - MapResult map_result; - map_result.address = - mmap(address_hint, - static_cast<size_t>(length), - prot_for_mmap, - flags_for_mmap, - file_holder->file()->GetPlatformFile(), - static_cast<off_t>(offset)); - if (map_result.address != MAP_FAILED) - map_result.result = PP_OK; - else - map_result.result = ErrnoToPPError(errno); - return map_result; -} - -// static -int32_t FileMappingResource::DoUnmapBlocking(const void* address, - int64_t length) { - if (munmap(const_cast<void*>(address), static_cast<size_t>(length))) - return ErrnoToPPError(errno); - return PP_OK; -} - -// static -int64_t FileMappingResource::DoGetMapPageSize() { - return getpagesize(); -} - -} // namespace proxy -} // namespace ppapi diff --git a/chromium/ppapi/proxy/file_mapping_resource_win.cc b/chromium/ppapi/proxy/file_mapping_resource_win.cc deleted file mode 100644 index c5d9353f3d4..00000000000 --- a/chromium/ppapi/proxy/file_mapping_resource_win.cc +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/proxy/file_mapping_resource.h" - -#include "ppapi/c/pp_errors.h" - -namespace ppapi { -namespace proxy { - -// static -FileMappingResource::MapResult FileMappingResource::DoMapBlocking( - scoped_refptr<FileIOResource::FileHolder> file_holder, - void* address_hint, - int64_t length, - uint32_t map_protection, - uint32_t map_flags, - int64_t offset) { - // TODO(dmichael): Implement for Windows (crbug.com/83774). - MapResult map_result; - map_result.result = PP_ERROR_NOTSUPPORTED; - return map_result; -} - -// static -int32_t FileMappingResource::DoUnmapBlocking(const void* address, - int64_t length) { - // TODO(dmichael): Implement for Windows (crbug.com/83774). - return PP_ERROR_NOTSUPPORTED; -} - -// static -int64_t FileMappingResource::DoGetMapPageSize() { - // TODO(dmichael): Implement for Windows (crbug.com/83774). - return 0; -} - -} // namespace proxy -} // namespace ppapi diff --git a/chromium/ppapi/proxy/file_ref_resource.cc b/chromium/ppapi/proxy/file_ref_resource.cc index 098ef5f336a..ee56969cd82 100644 --- a/chromium/ppapi/proxy/file_ref_resource.cc +++ b/chromium/ppapi/proxy/file_ref_resource.cc @@ -4,6 +4,7 @@ #include "ppapi/proxy/file_ref_resource.h" +#include "base/numerics/safe_conversions.h" #include "ppapi/c/pp_directory_entry.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" @@ -29,7 +30,7 @@ FileRefResource::FileRefResource( if (uses_internal_paths()) { // If path ends with a slash, then normalize it away unless path is // the root path. - int path_size = create_info_.internal_path.size(); + int path_size = base::checked_cast<int>(create_info_.internal_path.size()); if (path_size > 1 && create_info_.internal_path.at(path_size - 1) == '/') create_info_.internal_path.erase(path_size - 1, 1); diff --git a/chromium/ppapi/proxy/file_ref_resource.h b/chromium/ppapi/proxy/file_ref_resource.h index 6db04accabc..59e7b7c9684 100644 --- a/chromium/ppapi/proxy/file_ref_resource.h +++ b/chromium/ppapi/proxy/file_ref_resource.h @@ -31,34 +31,33 @@ class PPAPI_PROXY_EXPORT FileRefResource PP_Instance instance, const FileRefCreateInfo& info); - virtual ~FileRefResource(); + ~FileRefResource() override; // Resource implementation. - virtual thunk::PPB_FileRef_API* AsPPB_FileRef_API() override; + thunk::PPB_FileRef_API* AsPPB_FileRef_API() override; // PPB_FileRef_API implementation. - virtual PP_FileSystemType GetFileSystemType() const override; - virtual PP_Var GetName() const override; - virtual PP_Var GetPath() const override; - virtual PP_Resource GetParent() override; - virtual int32_t MakeDirectory( - int32_t make_directory_flags, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t Touch(PP_Time last_access_time, - PP_Time last_modified_time, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t Delete(scoped_refptr<TrackedCallback> callback) override; - virtual int32_t Rename(PP_Resource new_file_ref, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t Query(PP_FileInfo* info, + PP_FileSystemType GetFileSystemType() const override; + PP_Var GetName() const override; + PP_Var GetPath() const override; + PP_Resource GetParent() override; + int32_t MakeDirectory(int32_t make_directory_flags, scoped_refptr<TrackedCallback> callback) override; - virtual int32_t ReadDirectoryEntries( + int32_t Touch(PP_Time last_access_time, + PP_Time last_modified_time, + scoped_refptr<TrackedCallback> callback) override; + int32_t Delete(scoped_refptr<TrackedCallback> callback) override; + int32_t Rename(PP_Resource new_file_ref, + scoped_refptr<TrackedCallback> callback) override; + int32_t Query(PP_FileInfo* info, + scoped_refptr<TrackedCallback> callback) override; + int32_t ReadDirectoryEntries( const PP_ArrayOutput& output, scoped_refptr<TrackedCallback> callback) override; - virtual const FileRefCreateInfo& GetCreateInfo() const override; + const FileRefCreateInfo& GetCreateInfo() const override; // Private API - virtual PP_Var GetAbsolutePath() override; + PP_Var GetAbsolutePath() override; private: FileRefResource(Connection connection, diff --git a/chromium/ppapi/proxy/file_system_resource.h b/chromium/ppapi/proxy/file_system_resource.h index fef6b0b2a59..5b35f86d7bd 100644 --- a/chromium/ppapi/proxy/file_system_resource.h +++ b/chromium/ppapi/proxy/file_system_resource.h @@ -42,20 +42,20 @@ class PPAPI_PROXY_EXPORT FileSystemResource int pending_renderer_id, int pending_browser_id, PP_FileSystemType type); - virtual ~FileSystemResource(); + ~FileSystemResource() override; // Resource overrides. - virtual thunk::PPB_FileSystem_API* AsPPB_FileSystem_API() override; + thunk::PPB_FileSystem_API* AsPPB_FileSystem_API() override; // PPB_FileSystem_API implementation. - virtual int32_t Open(int64_t expected_size, - scoped_refptr<TrackedCallback> callback) override; - virtual PP_FileSystemType GetType() override; - virtual void OpenQuotaFile(PP_Resource file_io) override; - virtual void CloseQuotaFile(PP_Resource file_io) override; + int32_t Open(int64_t expected_size, + scoped_refptr<TrackedCallback> callback) override; + PP_FileSystemType GetType() override; + void OpenQuotaFile(PP_Resource file_io) override; + void CloseQuotaFile(PP_Resource file_io) override; typedef base::Callback<void(int64_t)> RequestQuotaCallback; - virtual int64_t RequestQuota(int64_t amount, - const RequestQuotaCallback& callback) override; + int64_t RequestQuota(int64_t amount, + const RequestQuotaCallback& callback) override; int32_t InitIsolatedFileSystem(const std::string& fsid, PP_IsolatedFileSystemType_Private type, diff --git a/chromium/ppapi/proxy/flash_clipboard_resource.cc b/chromium/ppapi/proxy/flash_clipboard_resource.cc index 2b665bfa059..28df94cddf8 100644 --- a/chromium/ppapi/proxy/flash_clipboard_resource.cc +++ b/chromium/ppapi/proxy/flash_clipboard_resource.cc @@ -4,6 +4,7 @@ #include "ppapi/proxy/flash_clipboard_resource.h" +#include "base/numerics/safe_conversions.h" #include "ipc/ipc_message.h" #include "ppapi/c/pp_errors.h" #include "ppapi/proxy/ppapi_messages.h" @@ -53,7 +54,7 @@ PP_Var ClipboardStringToPPVar(int32_t format, } else { // All other formats are expected to be array buffers. return PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( - string.size(), string.data()); + base::checked_cast<uint32_t>(string.size()), string.data()); } } } // namespace diff --git a/chromium/ppapi/proxy/flash_clipboard_resource.h b/chromium/ppapi/proxy/flash_clipboard_resource.h index 85181bc0246..cd607d62abd 100644 --- a/chromium/ppapi/proxy/flash_clipboard_resource.h +++ b/chromium/ppapi/proxy/flash_clipboard_resource.h @@ -18,26 +18,26 @@ class FlashClipboardResource public NON_EXPORTED_BASE(thunk::PPB_Flash_Clipboard_API) { public: FlashClipboardResource(Connection connection, PP_Instance instance); - virtual ~FlashClipboardResource(); + ~FlashClipboardResource() override; // Resource implementation. - virtual thunk::PPB_Flash_Clipboard_API* AsPPB_Flash_Clipboard_API() override; + thunk::PPB_Flash_Clipboard_API* AsPPB_Flash_Clipboard_API() override; // PPB_Flash_Clipboard_API implementation. - virtual uint32_t RegisterCustomFormat(PP_Instance instance, - const char* format_name) override; - virtual PP_Bool IsFormatAvailable(PP_Instance instance, - PP_Flash_Clipboard_Type clipboard_type, - uint32_t format) override; - virtual PP_Var ReadData(PP_Instance instance, - PP_Flash_Clipboard_Type clipboard_type, - uint32_t format) override; - virtual int32_t WriteData(PP_Instance instance, + uint32_t RegisterCustomFormat(PP_Instance instance, + const char* format_name) override; + PP_Bool IsFormatAvailable(PP_Instance instance, PP_Flash_Clipboard_Type clipboard_type, - uint32_t data_item_count, - const uint32_t formats[], - const PP_Var data_items[]) override; - virtual PP_Bool GetSequenceNumber( + uint32_t format) override; + PP_Var ReadData(PP_Instance instance, + PP_Flash_Clipboard_Type clipboard_type, + uint32_t format) override; + int32_t WriteData(PP_Instance instance, + PP_Flash_Clipboard_Type clipboard_type, + uint32_t data_item_count, + const uint32_t formats[], + const PP_Var data_items[]) override; + PP_Bool GetSequenceNumber( PP_Instance instance, PP_Flash_Clipboard_Type clipboard_type, uint64_t* sequence_number) override; diff --git a/chromium/ppapi/proxy/flash_drm_resource.h b/chromium/ppapi/proxy/flash_drm_resource.h index 53a661192db..fc773c42a6c 100644 --- a/chromium/ppapi/proxy/flash_drm_resource.h +++ b/chromium/ppapi/proxy/flash_drm_resource.h @@ -23,19 +23,19 @@ class FlashDRMResource public: FlashDRMResource(Connection connection, PP_Instance instance); - virtual ~FlashDRMResource(); + ~FlashDRMResource() override; // Resource override. - virtual thunk::PPB_Flash_DRM_API* AsPPB_Flash_DRM_API() override; + thunk::PPB_Flash_DRM_API* AsPPB_Flash_DRM_API() override; // PPB_Flash_DRM_API implementation. - virtual int32_t GetDeviceID(PP_Var* id, - scoped_refptr<TrackedCallback> callback) override; - virtual PP_Bool GetHmonitor(int64_t* hmonitor) override; - virtual int32_t GetVoucherFile( + int32_t GetDeviceID(PP_Var* id, + scoped_refptr<TrackedCallback> callback) override; + PP_Bool GetHmonitor(int64_t* hmonitor) override; + int32_t GetVoucherFile( PP_Resource* file_ref, scoped_refptr<TrackedCallback> callback) override; - virtual int32_t MonitorIsExternal( + int32_t MonitorIsExternal( PP_Bool* is_external, scoped_refptr<TrackedCallback> callback) override; diff --git a/chromium/ppapi/proxy/flash_file_resource.h b/chromium/ppapi/proxy/flash_file_resource.h index 04d6ed9bfec..ea35152c8f6 100644 --- a/chromium/ppapi/proxy/flash_file_resource.h +++ b/chromium/ppapi/proxy/flash_file_resource.h @@ -20,40 +20,40 @@ class FlashFileResource public thunk::PPB_Flash_File_API { public: FlashFileResource(Connection connection, PP_Instance instance); - virtual ~FlashFileResource(); + ~FlashFileResource() override; // Resource overrides. - virtual thunk::PPB_Flash_File_API* AsPPB_Flash_File_API() override; + thunk::PPB_Flash_File_API* AsPPB_Flash_File_API() override; // PPB_Flash_Functions_API. - virtual int32_t OpenFile(PP_Instance instance, - const char* path, - int32_t mode, - PP_FileHandle* file) override; - virtual int32_t RenameFile(PP_Instance instance, - const char* path_from, - const char* path_to) override; - virtual int32_t DeleteFileOrDir(PP_Instance instance, - const char* path, - PP_Bool recursive) override; - virtual int32_t CreateDir(PP_Instance instance, const char* path) override; - virtual int32_t QueryFile(PP_Instance instance, - const char* path, - PP_FileInfo* info) override; - virtual int32_t GetDirContents(PP_Instance instance, - const char* path, - PP_DirContents_Dev** contents) override; - virtual void FreeDirContents(PP_Instance instance, - PP_DirContents_Dev* contents) override; - virtual int32_t CreateTemporaryFile(PP_Instance instance, - PP_FileHandle* file) override; - virtual int32_t OpenFileRef(PP_Instance instance, - PP_Resource file_ref, - int32_t mode, + int32_t OpenFile(PP_Instance instance, + const char* path, + int32_t mode, + PP_FileHandle* file) override; + int32_t RenameFile(PP_Instance instance, + const char* path_from, + const char* path_to) override; + int32_t DeleteFileOrDir(PP_Instance instance, + const char* path, + PP_Bool recursive) override; + int32_t CreateDir(PP_Instance instance, const char* path) override; + int32_t QueryFile(PP_Instance instance, + const char* path, + PP_FileInfo* info) override; + int32_t GetDirContents(PP_Instance instance, + const char* path, + PP_DirContents_Dev** contents) override; + void FreeDirContents(PP_Instance instance, + PP_DirContents_Dev* contents) override; + int32_t CreateTemporaryFile(PP_Instance instance, PP_FileHandle* file) override; - virtual int32_t QueryFileRef(PP_Instance instance, - PP_Resource file_ref, - PP_FileInfo* info) override; + int32_t OpenFileRef(PP_Instance instance, + PP_Resource file_ref, + int32_t mode, + PP_FileHandle* file) override; + int32_t QueryFileRef(PP_Instance instance, + PP_Resource file_ref, + PP_FileInfo* info) override; private: int32_t OpenFileHelper(const std::string& path, diff --git a/chromium/ppapi/proxy/flash_font_file_resource.h b/chromium/ppapi/proxy/flash_font_file_resource.h index b4713072e5f..e1b32d58f66 100644 --- a/chromium/ppapi/proxy/flash_font_file_resource.h +++ b/chromium/ppapi/proxy/flash_font_file_resource.h @@ -29,15 +29,15 @@ class FlashFontFileResource : public PluginResource, PP_Instance instance, const PP_BrowserFont_Trusted_Description* description, PP_PrivateFontCharset charset); - virtual ~FlashFontFileResource(); + ~FlashFontFileResource() override; // Resource overrides. - virtual thunk::PPB_Flash_FontFile_API* AsPPB_Flash_FontFile_API() override; + thunk::PPB_Flash_FontFile_API* AsPPB_Flash_FontFile_API() override; // PPB_Flash_FontFile_API. - virtual PP_Bool GetFontTable(uint32_t table, - void* output, - uint32_t* output_length) override; + PP_Bool GetFontTable(uint32_t table, + void* output, + uint32_t* output_length) override; private: // Sees if we have a cache of the font table and returns a pointer to it. diff --git a/chromium/ppapi/proxy/flash_fullscreen_resource.h b/chromium/ppapi/proxy/flash_fullscreen_resource.h index 06b2722f6f6..b193e303b47 100644 --- a/chromium/ppapi/proxy/flash_fullscreen_resource.h +++ b/chromium/ppapi/proxy/flash_fullscreen_resource.h @@ -18,18 +18,16 @@ class FlashFullscreenResource public: FlashFullscreenResource(Connection connection, PP_Instance instance); - virtual ~FlashFullscreenResource(); + ~FlashFullscreenResource() override; // Resource overrides. - virtual thunk::PPB_Flash_Fullscreen_API* - AsPPB_Flash_Fullscreen_API() override; + thunk::PPB_Flash_Fullscreen_API* AsPPB_Flash_Fullscreen_API() override; // PPB_Flash_Fullscreen_API implementation. - virtual PP_Bool IsFullscreen(PP_Instance instance) override; - virtual PP_Bool SetFullscreen(PP_Instance instance, - PP_Bool fullscreen) override; - virtual void SetLocalIsFullscreen(PP_Instance instance, - PP_Bool is_fullscreen) override; + PP_Bool IsFullscreen(PP_Instance instance) override; + PP_Bool SetFullscreen(PP_Instance instance, PP_Bool fullscreen) override; + void SetLocalIsFullscreen(PP_Instance instance, + PP_Bool is_fullscreen) override; private: PP_Bool is_fullscreen_; diff --git a/chromium/ppapi/proxy/flash_menu_resource.h b/chromium/ppapi/proxy/flash_menu_resource.h index 337e95332e8..23b74876236 100644 --- a/chromium/ppapi/proxy/flash_menu_resource.h +++ b/chromium/ppapi/proxy/flash_menu_resource.h @@ -22,7 +22,7 @@ class FlashMenuResource public: // You must call Initialize after construction. FlashMenuResource(Connection connection, PP_Instance instance); - virtual ~FlashMenuResource(); + ~FlashMenuResource() override; // Returns true on success. False means that this object can not be used. // This has to be separate from the constructor because the menu data could @@ -30,16 +30,16 @@ class FlashMenuResource bool Initialize(const PP_Flash_Menu* menu_data); // Resource overrides. - virtual thunk::PPB_Flash_Menu_API* AsPPB_Flash_Menu_API() override; + thunk::PPB_Flash_Menu_API* AsPPB_Flash_Menu_API() override; // PPB_Flash_Menu_API. - virtual int32_t Show(const PP_Point* location, - int32_t* selected_id, - scoped_refptr<TrackedCallback> callback) override; + int32_t Show(const PP_Point* location, + int32_t* selected_id, + scoped_refptr<TrackedCallback> callback) override; private: - virtual void OnReplyReceived(const proxy::ResourceMessageReplyParams& params, - const IPC::Message& msg) override; + void OnReplyReceived(const proxy::ResourceMessageReplyParams& params, + const IPC::Message& msg) override; void OnShowReply( const proxy::ResourceMessageReplyParams& params, diff --git a/chromium/ppapi/proxy/flash_resource.h b/chromium/ppapi/proxy/flash_resource.h index 891de4c1a87..21cdbb73bce 100644 --- a/chromium/ppapi/proxy/flash_resource.h +++ b/chromium/ppapi/proxy/flash_resource.h @@ -24,25 +24,21 @@ class FlashResource FlashResource(Connection connection, PP_Instance instance, PluginDispatcher* plugin_dispatcher); - virtual ~FlashResource(); + ~FlashResource() override; // Resource override. - virtual thunk::PPB_Flash_Functions_API* AsPPB_Flash_Functions_API() override; + thunk::PPB_Flash_Functions_API* AsPPB_Flash_Functions_API() override; // PPB_Flash_Functions_API implementation. - virtual PP_Var GetProxyForURL(PP_Instance instance, - const std::string& url) override; - virtual void UpdateActivity(PP_Instance instance) override; - virtual PP_Bool SetCrashData(PP_Instance instance, - PP_FlashCrashKey key, - PP_Var value) override; - virtual double GetLocalTimeZoneOffset(PP_Instance instance, - PP_Time t) override; - virtual PP_Var GetSetting(PP_Instance instance, - PP_FlashSetting setting) override; - virtual void SetInstanceAlwaysOnTop(PP_Instance instance, - PP_Bool on_top) override; - virtual PP_Bool DrawGlyphs( + PP_Var GetProxyForURL(PP_Instance instance, const std::string& url) override; + void UpdateActivity(PP_Instance instance) override; + PP_Bool SetCrashData(PP_Instance instance, + PP_FlashCrashKey key, + PP_Var value) override; + double GetLocalTimeZoneOffset(PP_Instance instance, PP_Time t) override; + PP_Var GetSetting(PP_Instance instance, PP_FlashSetting setting) override; + void SetInstanceAlwaysOnTop(PP_Instance instance, PP_Bool on_top) override; + PP_Bool DrawGlyphs( PP_Instance instance, PP_Resource pp_image_data, const PP_BrowserFont_Trusted_Description* font_desc, @@ -54,13 +50,12 @@ class FlashResource uint32_t glyph_count, const uint16_t glyph_indices[], const PP_Point glyph_advances[]) override; - virtual int32_t Navigate(PP_Instance instance, - PP_Resource request_info, - const char* target, - PP_Bool from_user_action) override; - virtual PP_Bool IsRectTopmost(PP_Instance instance, - const PP_Rect* rect) override; - virtual void InvokePrinting(PP_Instance instance) override; + int32_t Navigate(PP_Instance instance, + PP_Resource request_info, + const char* target, + PP_Bool from_user_action) override; + PP_Bool IsRectTopmost(PP_Instance instance, const PP_Rect* rect) override; + void InvokePrinting(PP_Instance instance) override; private: // Non-owning pointer to the PluginDispatcher that owns this object. diff --git a/chromium/ppapi/proxy/gamepad_resource.h b/chromium/ppapi/proxy/gamepad_resource.h index 807cc5c69e1..4851d69cd8e 100644 --- a/chromium/ppapi/proxy/gamepad_resource.h +++ b/chromium/ppapi/proxy/gamepad_resource.h @@ -33,14 +33,13 @@ class PPAPI_PROXY_EXPORT GamepadResource public thunk::PPB_Gamepad_API { public: GamepadResource(Connection connection, PP_Instance instance); - virtual ~GamepadResource(); + ~GamepadResource() override; // Resource implementation. - virtual thunk::PPB_Gamepad_API* AsPPB_Gamepad_API() override; + thunk::PPB_Gamepad_API* AsPPB_Gamepad_API() override; // PPB_Gamepad_API. - virtual void Sample(PP_Instance instance, - PP_GamepadsSampleData* data) override; + void Sample(PP_Instance instance, PP_GamepadsSampleData* data) override; private: void OnPluginMsgSendMemory(const ResourceMessageReplyParams& params); diff --git a/chromium/ppapi/proxy/graphics_2d_resource.h b/chromium/ppapi/proxy/graphics_2d_resource.h index e8f4e993e71..efd7d760877 100644 --- a/chromium/ppapi/proxy/graphics_2d_resource.h +++ b/chromium/ppapi/proxy/graphics_2d_resource.h @@ -25,24 +25,22 @@ class PPAPI_PROXY_EXPORT Graphics2DResource const PP_Size& size, PP_Bool is_always_opaque); - virtual ~Graphics2DResource(); + ~Graphics2DResource() override; // Resource overrides. - virtual thunk::PPB_Graphics2D_API* AsPPB_Graphics2D_API() override; + thunk::PPB_Graphics2D_API* AsPPB_Graphics2D_API() override; // PPB_Graphics2D_API overrides. - virtual PP_Bool Describe(PP_Size* size, PP_Bool* is_always_opaque) override; - virtual void PaintImageData(PP_Resource image_data, - const PP_Point* top_left, - const PP_Rect* src_rect) override; - virtual void Scroll(const PP_Rect* clip_rect, - const PP_Point* amount) override; - virtual void ReplaceContents(PP_Resource image_data) override; - virtual PP_Bool SetScale(float scale) override; - virtual float GetScale() override; - virtual int32_t Flush(scoped_refptr<TrackedCallback> callback) override; - virtual bool ReadImageData(PP_Resource image, - const PP_Point* top_left) override; + PP_Bool Describe(PP_Size* size, PP_Bool* is_always_opaque) override; + void PaintImageData(PP_Resource image_data, + const PP_Point* top_left, + const PP_Rect* src_rect) override; + void Scroll(const PP_Rect* clip_rect, const PP_Point* amount) override; + void ReplaceContents(PP_Resource image_data) override; + PP_Bool SetScale(float scale) override; + float GetScale() override; + int32_t Flush(scoped_refptr<TrackedCallback> callback) override; + bool ReadImageData(PP_Resource image, const PP_Point* top_left) override; private: void OnPluginMsgFlushACK(const ResourceMessageReplyParams& params); diff --git a/chromium/ppapi/proxy/host_dispatcher.cc b/chromium/ppapi/proxy/host_dispatcher.cc index ee7e91905b1..eb9f7ee48d7 100644 --- a/chromium/ppapi/proxy/host_dispatcher.cc +++ b/chromium/ppapi/proxy/host_dispatcher.cc @@ -4,8 +4,8 @@ #include "ppapi/proxy/host_dispatcher.h" -#include "base/debug/trace_event.h" #include "base/logging.h" +#include "base/trace_event/trace_event.h" #include "ppapi/c/private/ppb_proxy_private.h" #include "ppapi/c/ppb_var.h" #include "ppapi/proxy/host_var_serialization_rules.h" @@ -224,10 +224,7 @@ const void* HostDispatcher::GetProxiedInterface(const std::string& iface_name) { // Need to query. Cache the result so we only do this once. bool supported = false; - bool previous_reentrancy_value = allow_plugin_reentrancy_; - allow_plugin_reentrancy_ = true; Send(new PpapiMsg_SupportsInterface(iface_name, &supported)); - allow_plugin_reentrancy_ = previous_reentrancy_value; std::pair<PluginSupportedMap::iterator, bool> iter_success_pair; iter_success_pair = plugin_supported_.insert( diff --git a/chromium/ppapi/proxy/host_dispatcher.h b/chromium/ppapi/proxy/host_dispatcher.h index 345f8eab687..89be7ed7bc1 100644 --- a/chromium/ppapi/proxy/host_dispatcher.h +++ b/chromium/ppapi/proxy/host_dispatcher.h @@ -81,12 +81,12 @@ class PPAPI_PROXY_EXPORT HostDispatcher : public Dispatcher { PP_Module pp_module() const { return pp_module_; } // Dispatcher overrides. - virtual bool IsPlugin() const; - virtual bool Send(IPC::Message* msg); + bool IsPlugin() const override; + bool Send(IPC::Message* msg) override; // IPC::Listener. - virtual bool OnMessageReceived(const IPC::Message& msg) override; - virtual void OnChannelError() override; + bool OnMessageReceived(const IPC::Message& msg) override; + void OnChannelError() override; // Proxied version of calling GetInterface on the plugin. This will check // if the plugin supports the given interface (with caching) and returns the @@ -115,7 +115,7 @@ class PPAPI_PROXY_EXPORT HostDispatcher : public Dispatcher { protected: // Overridden from Dispatcher. - virtual void OnInvalidMessageReceived(); + void OnInvalidMessageReceived() override; private: void OnHostMsgLogWithSource(PP_Instance instance, diff --git a/chromium/ppapi/proxy/host_resolver_private_resource.h b/chromium/ppapi/proxy/host_resolver_private_resource.h index 6af6a2db07b..d83b707bc65 100644 --- a/chromium/ppapi/proxy/host_resolver_private_resource.h +++ b/chromium/ppapi/proxy/host_resolver_private_resource.h @@ -20,21 +20,20 @@ class PPAPI_PROXY_EXPORT HostResolverPrivateResource public: HostResolverPrivateResource(Connection connection, PP_Instance instance); - virtual ~HostResolverPrivateResource(); + ~HostResolverPrivateResource() override; // PluginResource overrides. - virtual thunk::PPB_HostResolver_Private_API* - AsPPB_HostResolver_Private_API() override; + thunk::PPB_HostResolver_Private_API* AsPPB_HostResolver_Private_API() + override; // PPB_HostResolver_Private_API implementation. - virtual int32_t Resolve(const char* host, - uint16_t port, - const PP_HostResolver_Private_Hint* hint, - scoped_refptr<TrackedCallback> callback) override; - virtual PP_Var GetCanonicalName() override; - virtual uint32_t GetSize() override; - virtual bool GetNetAddress(uint32_t index, - PP_NetAddress_Private* address) override; + int32_t Resolve(const char* host, + uint16_t port, + const PP_HostResolver_Private_Hint* hint, + scoped_refptr<TrackedCallback> callback) override; + PP_Var GetCanonicalName() override; + uint32_t GetSize() override; + bool GetNetAddress(uint32_t index, PP_NetAddress_Private* address) override; private: DISALLOW_COPY_AND_ASSIGN(HostResolverPrivateResource); diff --git a/chromium/ppapi/proxy/host_resolver_resource.h b/chromium/ppapi/proxy/host_resolver_resource.h index d6e41b30496..ae6c524d3c5 100644 --- a/chromium/ppapi/proxy/host_resolver_resource.h +++ b/chromium/ppapi/proxy/host_resolver_resource.h @@ -19,19 +19,19 @@ class PPAPI_PROXY_EXPORT HostResolverResource public thunk::PPB_HostResolver_API { public: HostResolverResource(Connection connection, PP_Instance instance); - virtual ~HostResolverResource(); + ~HostResolverResource() override; // PluginResource overrides. - virtual thunk::PPB_HostResolver_API* AsPPB_HostResolver_API() override; + thunk::PPB_HostResolver_API* AsPPB_HostResolver_API() override; // thunk::PPB_HostResolver_API implementation. - virtual int32_t Resolve(const char* host, - uint16_t port, - const PP_HostResolver_Hint* hint, - scoped_refptr<TrackedCallback> callback) override; - virtual PP_Var GetCanonicalName() override; - virtual uint32_t GetNetAddressCount() override; - virtual PP_Resource GetNetAddress(uint32_t index) override; + int32_t Resolve(const char* host, + uint16_t port, + const PP_HostResolver_Hint* hint, + scoped_refptr<TrackedCallback> callback) override; + PP_Var GetCanonicalName() override; + uint32_t GetNetAddressCount() override; + PP_Resource GetNetAddress(uint32_t index) override; private: DISALLOW_COPY_AND_ASSIGN(HostResolverResource); diff --git a/chromium/ppapi/proxy/host_var_serialization_rules.cc b/chromium/ppapi/proxy/host_var_serialization_rules.cc index dcc965bd691..35faace5dd3 100644 --- a/chromium/ppapi/proxy/host_var_serialization_rules.cc +++ b/chromium/ppapi/proxy/host_var_serialization_rules.cc @@ -45,9 +45,18 @@ PP_Var HostVarSerializationRules::BeginSendPassRef(const PP_Var& var) { return var; } -void HostVarSerializationRules::EndSendPassRef(const PP_Var& /* var */) { - // See PluginVarSerialization::ReceivePassRef for an example. We don't need - // to do anything here. +void HostVarSerializationRules::EndSendPassRef(const PP_Var& var) { + // See PluginVarSerializationRules::ReceivePassRef for an example. We don't + // need to do anything here for "Object" vars; we continue holding one ref on + // behalf of the plugin. + if (var.type != PP_VARTYPE_OBJECT) { + // But for other ref-counted types (like String, Array, and Dictionary), + // the value will be re-constituted on the other side as a new Var with no + // connection to the host-side reference counting. We must therefore release + // our reference count; this is roughly equivalent to passing the ref to the + // plugin. + PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(var); + } } void HostVarSerializationRules::ReleaseObjectRef(const PP_Var& var) { diff --git a/chromium/ppapi/proxy/interface_list.cc b/chromium/ppapi/proxy/interface_list.cc index f2ed19a61b2..52b6a3d959b 100644 --- a/chromium/ppapi/proxy/interface_list.cc +++ b/chromium/ppapi/proxy/interface_list.cc @@ -17,7 +17,6 @@ #include "ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h" #include "ppapi/c/dev/ppb_ime_input_event_dev.h" #include "ppapi/c/dev/ppb_memory_dev.h" -#include "ppapi/c/dev/ppb_messaging_deprecated.h" #include "ppapi/c/dev/ppb_opengles2ext_dev.h" #include "ppapi/c/dev/ppb_printing_dev.h" #include "ppapi/c/dev/ppb_scrollbar_dev.h" @@ -38,7 +37,6 @@ #include "ppapi/c/ppb_console.h" #include "ppapi/c/ppb_core.h" #include "ppapi/c/ppb_file_io.h" -#include "ppapi/c/ppb_file_mapping.h" #include "ppapi/c/ppb_file_ref.h" #include "ppapi/c/ppb_file_system.h" #include "ppapi/c/ppb_fullscreen.h" @@ -68,10 +66,13 @@ #include "ppapi/c/ppb_var_array_buffer.h" #include "ppapi/c/ppb_var_dictionary.h" #include "ppapi/c/ppb_video_decoder.h" +#include "ppapi/c/ppb_video_encoder.h" #include "ppapi/c/ppb_video_frame.h" #include "ppapi/c/ppb_view.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/ppp_instance.h" +#include "ppapi/c/private/ppb_camera_capabilities_private.h" +#include "ppapi/c/private/ppb_camera_device_private.h" #include "ppapi/c/private/ppb_content_decryptor_private.h" #include "ppapi/c/private/ppb_ext_crx_file_system_private.h" #include "ppapi/c/private/ppb_file_io_private.h" @@ -94,7 +95,6 @@ #include "ppapi/c/private/ppb_output_protection_private.h" #include "ppapi/c/private/ppb_pdf.h" #include "ppapi/c/private/ppb_platform_verification_private.h" -#include "ppapi/c/private/ppb_talk_private.h" #include "ppapi/c/private/ppb_tcp_server_socket_private.h" #include "ppapi/c/private/ppb_tcp_socket_private.h" #include "ppapi/c/private/ppb_testing_private.h" @@ -333,7 +333,7 @@ void InterfaceList::SetProcessGlobalPermissions( InterfaceProxy::Factory InterfaceList::GetFactoryForID(ApiID id) const { int index = static_cast<int>(id); - COMPILE_ASSERT(API_ID_NONE == 0, none_must_be_zero); + static_assert(API_ID_NONE == 0, "none must be zero"); if (id <= 0 || id >= API_ID_COUNT) return NULL; return id_to_factory_[index]; diff --git a/chromium/ppapi/proxy/interface_list.h b/chromium/ppapi/proxy/interface_list.h index dc109e5c5af..2fec61f4926 100644 --- a/chromium/ppapi/proxy/interface_list.h +++ b/chromium/ppapi/proxy/interface_list.h @@ -80,7 +80,7 @@ class PPAPI_PROXY_EXPORT InterfaceList { // Give friendship for HashInterfaceName. friend class InterfaceInfo; - typedef base::ScopedPtrHashMap<std::string, InterfaceInfo> + typedef base::ScopedPtrHashMap<std::string, scoped_ptr<InterfaceInfo>> NameToInterfaceInfoMap; void AddProxy(ApiID id, InterfaceProxy::Factory factory); diff --git a/chromium/ppapi/proxy/isolated_file_system_private_resource.h b/chromium/ppapi/proxy/isolated_file_system_private_resource.h index 4f826fe7302..55ff23e9af7 100644 --- a/chromium/ppapi/proxy/isolated_file_system_private_resource.h +++ b/chromium/ppapi/proxy/isolated_file_system_private_resource.h @@ -41,17 +41,17 @@ class PPAPI_PROXY_EXPORT IsolatedFileSystemPrivateResource public: IsolatedFileSystemPrivateResource( Connection connection, PP_Instance instance); - virtual ~IsolatedFileSystemPrivateResource(); + ~IsolatedFileSystemPrivateResource() override; // Resource overrides. - virtual thunk::PPB_IsolatedFileSystem_Private_API* + thunk::PPB_IsolatedFileSystem_Private_API* AsPPB_IsolatedFileSystem_Private_API() override; // PPB_IsolatedFileSystem_Private_API implementation. - virtual int32_t Open(PP_Instance instance, - PP_IsolatedFileSystemType_Private type, - PP_Resource* file_system_resource, - scoped_refptr<TrackedCallback> callback) override; + int32_t Open(PP_Instance instance, + PP_IsolatedFileSystemType_Private type, + PP_Resource* file_system_resource, + scoped_refptr<TrackedCallback> callback) override; private: void OnBrowserOpenComplete(PP_IsolatedFileSystemType_Private type, diff --git a/chromium/ppapi/proxy/media_stream_audio_track_resource.h b/chromium/ppapi/proxy/media_stream_audio_track_resource.h index 3dece832030..566f42d96ca 100644 --- a/chromium/ppapi/proxy/media_stream_audio_track_resource.h +++ b/chromium/ppapi/proxy/media_stream_audio_track_resource.h @@ -27,27 +27,26 @@ class PPAPI_PROXY_EXPORT MediaStreamAudioTrackResource int pending_renderer_id, const std::string& id); - virtual ~MediaStreamAudioTrackResource(); + ~MediaStreamAudioTrackResource() override; // Resource overrides: - virtual thunk::PPB_MediaStreamAudioTrack_API* - AsPPB_MediaStreamAudioTrack_API() override; + thunk::PPB_MediaStreamAudioTrack_API* AsPPB_MediaStreamAudioTrack_API() + override; // PPB_MediaStreamAudioTrack_API overrides: - virtual PP_Var GetId() override; - virtual PP_Bool HasEnded() override; - virtual int32_t Configure(const int32_t attrib_list[], - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t GetAttrib(PP_MediaStreamAudioTrack_Attrib attrib, - int32_t* value) override; - virtual int32_t GetBuffer( - PP_Resource* buffer, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t RecycleBuffer(PP_Resource buffer) override; - virtual void Close() override; + PP_Var GetId() override; + PP_Bool HasEnded() override; + int32_t Configure(const int32_t attrib_list[], + scoped_refptr<TrackedCallback> callback) override; + int32_t GetAttrib(PP_MediaStreamAudioTrack_Attrib attrib, + int32_t* value) override; + int32_t GetBuffer(PP_Resource* buffer, + scoped_refptr<TrackedCallback> callback) override; + int32_t RecycleBuffer(PP_Resource buffer) override; + void Close() override; // MediaStreamBufferManager::Delegate overrides: - virtual void OnNewBufferEnqueued() override; + void OnNewBufferEnqueued() override; private: PP_Resource GetAudioBuffer(); diff --git a/chromium/ppapi/proxy/media_stream_track_resource_base.h b/chromium/ppapi/proxy/media_stream_track_resource_base.h index 2dc2e36d111..0e7e9cc2854 100644 --- a/chromium/ppapi/proxy/media_stream_track_resource_base.h +++ b/chromium/ppapi/proxy/media_stream_track_resource_base.h @@ -23,7 +23,7 @@ class PPAPI_PROXY_EXPORT MediaStreamTrackResourceBase MediaStreamTrackResourceBase(Connection connection, PP_Instance instance); - virtual ~MediaStreamTrackResourceBase(); + ~MediaStreamTrackResourceBase() override; std::string id() const { return id_; } @@ -42,8 +42,8 @@ class PPAPI_PROXY_EXPORT MediaStreamTrackResourceBase void SendEnqueueBufferMessageToHost(int32_t index); // PluginResource overrides: - virtual void OnReplyReceived(const ResourceMessageReplyParams& params, - const IPC::Message& msg) override; + void OnReplyReceived(const ResourceMessageReplyParams& params, + const IPC::Message& msg) override; private: // Message handlers: diff --git a/chromium/ppapi/proxy/media_stream_video_track_resource.h b/chromium/ppapi/proxy/media_stream_video_track_resource.h index 2bdbb72b24b..b6102ecdb50 100644 --- a/chromium/ppapi/proxy/media_stream_video_track_resource.h +++ b/chromium/ppapi/proxy/media_stream_video_track_resource.h @@ -28,29 +28,29 @@ class PPAPI_PROXY_EXPORT MediaStreamVideoTrackResource MediaStreamVideoTrackResource(Connection connection, PP_Instance instance); - virtual ~MediaStreamVideoTrackResource(); + ~MediaStreamVideoTrackResource() override; // Resource overrides: - virtual thunk::PPB_MediaStreamVideoTrack_API* - AsPPB_MediaStreamVideoTrack_API() override; + thunk::PPB_MediaStreamVideoTrack_API* AsPPB_MediaStreamVideoTrack_API() + override; // PPB_MediaStreamVideoTrack_API overrides: - virtual PP_Var GetId() override; - virtual PP_Bool HasEnded() override; - virtual int32_t Configure(const int32_t attrib_list[], - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t GetAttrib(PP_MediaStreamVideoTrack_Attrib attrib, - int32_t* value) override; - virtual int32_t GetFrame(PP_Resource* frame, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t RecycleFrame(PP_Resource frame) override; - virtual void Close() override; - virtual int32_t GetEmptyFrame( - PP_Resource* frame, scoped_refptr<TrackedCallback> callback) override; - virtual int32_t PutFrame(PP_Resource frame) override; + PP_Var GetId() override; + PP_Bool HasEnded() override; + int32_t Configure(const int32_t attrib_list[], + scoped_refptr<TrackedCallback> callback) override; + int32_t GetAttrib(PP_MediaStreamVideoTrack_Attrib attrib, + int32_t* value) override; + int32_t GetFrame(PP_Resource* frame, + scoped_refptr<TrackedCallback> callback) override; + int32_t RecycleFrame(PP_Resource frame) override; + void Close() override; + int32_t GetEmptyFrame(PP_Resource* frame, + scoped_refptr<TrackedCallback> callback) override; + int32_t PutFrame(PP_Resource frame) override; // MediaStreamBufferManager::Delegate overrides: - virtual void OnNewBufferEnqueued() override; + void OnNewBufferEnqueued() override; private: PP_Resource GetVideoFrame(); diff --git a/chromium/ppapi/proxy/message_handler.cc b/chromium/ppapi/proxy/message_handler.cc index a0f5cccb183..af9a45f8380 100644 --- a/chromium/ppapi/proxy/message_handler.cc +++ b/chromium/ppapi/proxy/message_handler.cc @@ -19,8 +19,6 @@ namespace { typedef void (*HandleMessageFunc)(PP_Instance, void*, const PP_Var*); typedef void (*HandleBlockingMessageFunc)( PP_Instance, void*, const PP_Var*, PP_Var*); -typedef void (*HandleMessageFunc_0_1)(PP_Instance, void*, PP_Var); -typedef PP_Var (*HandleBlockingMessageFunc_0_1)(PP_Instance, void*, PP_Var); void HandleMessageWrapper(HandleMessageFunc function, PP_Instance instance, @@ -52,37 +50,6 @@ void HandleBlockingMessageWrapper(HandleBlockingMessageFunc function, dispatcher->Send(reply_msg.release()); } -// TODO(dmichael): Remove the 0_1 verions; crbug.com/414398 -void HandleMessageWrapper_0_1(HandleMessageFunc_0_1 function, - PP_Instance instance, - void* user_data, - ScopedPPVar message_data) { - CallWhileUnlocked(function, instance, user_data, message_data.get()); -} - -void HandleBlockingMessageWrapper_0_1(HandleBlockingMessageFunc_0_1 function, - PP_Instance instance, - void* user_data, - ScopedPPVar message_data, - scoped_ptr<IPC::Message> reply_msg) { - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); - if (!dispatcher) - return; - MessageLoopResource::GetCurrent()-> - set_currently_handling_blocking_message(true); - PP_Var return_value = CallWhileUnlocked(function, - instance, - user_data, - message_data.get()); - MessageLoopResource::GetCurrent()-> - set_currently_handling_blocking_message(false); - PpapiMsg_PPPMessageHandler_HandleBlockingMessage::WriteReplyParams( - reply_msg.get(), - SerializedVarReturnValue::Convert(dispatcher, return_value), - true /* was_handled */); - dispatcher->Send(reply_msg.release()); -} - } // namespace // static @@ -120,57 +87,12 @@ scoped_ptr<MessageHandler> MessageHandler::Create( return result.Pass(); } -// CreateDeprecated is a near-exact copy of Create, but we'll just delete it -// when 0.1 is deprecated, so need to get fancy to avoid code duplication. -// TODO(dmichael) crbug.com/414398 -// static -scoped_ptr<MessageHandler> MessageHandler::CreateDeprecated( - PP_Instance instance, - const PPP_MessageHandler_0_1_Deprecated* handler_if, - void* user_data, - PP_Resource message_loop, - int32_t* error) { - scoped_ptr<MessageHandler> result; - // The interface and all function pointers must be valid. - if (!handler_if || - !handler_if->HandleMessage || - !handler_if->HandleBlockingMessage || - !handler_if->Destroy) { - *error = PP_ERROR_BADARGUMENT; - return result.Pass(); - } - thunk::EnterResourceNoLock<thunk::PPB_MessageLoop_API> - enter_loop(message_loop, true); - if (enter_loop.failed()) { - *error = PP_ERROR_BADRESOURCE; - return result.Pass(); - } - scoped_refptr<MessageLoopResource> message_loop_resource( - static_cast<MessageLoopResource*>(enter_loop.object())); - if (message_loop_resource->is_main_thread_loop()) { - *error = PP_ERROR_WRONG_THREAD; - return result.Pass(); - } - - result.reset(new MessageHandler( - instance, handler_if, user_data, message_loop_resource)); - *error = PP_OK; - return result.Pass(); -} - MessageHandler::~MessageHandler() { // It's possible the message_loop_proxy is NULL if that loop has been quit. // In that case, we unfortunately just can't call Destroy. if (message_loop_->message_loop_proxy().get()) { // The posted task won't have the proxy lock, but that's OK, it doesn't // touch any internal state; it's a direct call on the plugin's function. - if (handler_if_0_1_) { - message_loop_->message_loop_proxy()->PostTask(FROM_HERE, - base::Bind(handler_if_0_1_->Destroy, - instance_, - user_data_)); - return; - } message_loop_->message_loop_proxy()->PostTask(FROM_HERE, base::Bind(handler_if_->Destroy, instance_, @@ -183,16 +105,6 @@ bool MessageHandler::LoopIsValid() const { } void MessageHandler::HandleMessage(ScopedPPVar var) { - if (handler_if_0_1_) { - // TODO(dmichael): Remove this code path. crbug.com/414398 - message_loop_->message_loop_proxy()->PostTask(FROM_HERE, - RunWhileLocked(base::Bind(&HandleMessageWrapper_0_1, - handler_if_0_1_->HandleMessage, - instance_, - user_data_, - var))); - return; - } message_loop_->message_loop_proxy()->PostTask(FROM_HERE, RunWhileLocked(base::Bind(&HandleMessageWrapper, handler_if_->HandleMessage, @@ -203,17 +115,6 @@ void MessageHandler::HandleMessage(ScopedPPVar var) { void MessageHandler::HandleBlockingMessage(ScopedPPVar var, scoped_ptr<IPC::Message> reply_msg) { - if (handler_if_0_1_) { - // TODO(dmichael): Remove this code path. crbug.com/414398 - message_loop_->message_loop_proxy()->PostTask(FROM_HERE, - RunWhileLocked(base::Bind(&HandleBlockingMessageWrapper_0_1, - handler_if_0_1_->HandleBlockingMessage, - instance_, - user_data_, - var, - base::Passed(reply_msg.Pass())))); - return; - } message_loop_->message_loop_proxy()->PostTask(FROM_HERE, RunWhileLocked(base::Bind(&HandleBlockingMessageWrapper, handler_if_->HandleBlockingMessage, @@ -230,19 +131,6 @@ MessageHandler::MessageHandler( scoped_refptr<MessageLoopResource> message_loop) : instance_(instance), handler_if_(handler_if), - handler_if_0_1_(NULL), - user_data_(user_data), - message_loop_(message_loop) { -} - -MessageHandler::MessageHandler( - PP_Instance instance, - const PPP_MessageHandler_0_1_Deprecated* handler_if, - void* user_data, - scoped_refptr<MessageLoopResource> message_loop) - : instance_(instance), - handler_if_(NULL), - handler_if_0_1_(handler_if), user_data_(user_data), message_loop_(message_loop) { } diff --git a/chromium/ppapi/proxy/message_handler.h b/chromium/ppapi/proxy/message_handler.h index 1d047bb3d13..cb3c6ab8257 100644 --- a/chromium/ppapi/proxy/message_handler.h +++ b/chromium/ppapi/proxy/message_handler.h @@ -7,7 +7,6 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "ppapi/c/dev/ppb_messaging_deprecated.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/ppp_message_handler.h" #include "ppapi/proxy/ppapi_proxy_export.h" @@ -48,15 +47,6 @@ class PPAPI_PROXY_EXPORT MessageHandler { void* user_data, PP_Resource message_loop, int32_t* error); - // Provide temporary backwards compatibility. TODO(dmichael): Remove all - // references to PPB_Messaging_1_1 and PPP_MessageHandler_0_1. - // crbug.com/414398 - static scoped_ptr<MessageHandler> CreateDeprecated( - PP_Instance instance, - const PPP_MessageHandler_0_1_Deprecated* handler_if, - void* user_data, - PP_Resource message_loop, - int32_t* error); ~MessageHandler(); bool LoopIsValid() const; @@ -70,15 +60,8 @@ class PPAPI_PROXY_EXPORT MessageHandler { const PPP_MessageHandler_0_2* handler_if, void* user_data, scoped_refptr<MessageLoopResource> message_loop); - MessageHandler(PP_Instance instance, - const PPP_MessageHandler_0_1_Deprecated* handler_if, - void* user_data, - scoped_refptr<MessageLoopResource> message_loop); - - PP_Instance instance_; const PPP_MessageHandler_0_2* handler_if_; - const PPP_MessageHandler_0_1_Deprecated* handler_if_0_1_; void* user_data_; scoped_refptr<MessageLoopResource> message_loop_; diff --git a/chromium/ppapi/proxy/nacl_message_scanner.cc b/chromium/ppapi/proxy/nacl_message_scanner.cc index 4120beb7457..a31ba624872 100644 --- a/chromium/ppapi/proxy/nacl_message_scanner.cc +++ b/chromium/ppapi/proxy/nacl_message_scanner.cc @@ -149,26 +149,26 @@ void ScanParam(const T& param, ScanningResults* results) { // The idea is to scan elements in the tuple which require special handling, // and write them into the |results| struct. template <class A> -void ScanTuple(const Tuple1<A>& t1, ScanningResults* results) { - ScanParam(t1.a, results); +void ScanTuple(const Tuple<A>& t1, ScanningResults* results) { + ScanParam(get<0>(t1), results); } template <class A, class B> -void ScanTuple(const Tuple2<A, B>& t1, ScanningResults* results) { - ScanParam(t1.a, results); - ScanParam(t1.b, results); +void ScanTuple(const Tuple<A, B>& t1, ScanningResults* results) { + ScanParam(get<0>(t1), results); + ScanParam(get<1>(t1), results); } template <class A, class B, class C> -void ScanTuple(const Tuple3<A, B, C>& t1, ScanningResults* results) { - ScanParam(t1.a, results); - ScanParam(t1.b, results); - ScanParam(t1.c, results); +void ScanTuple(const Tuple<A, B, C>& t1, ScanningResults* results) { + ScanParam(get<0>(t1), results); + ScanParam(get<1>(t1), results); + ScanParam(get<2>(t1), results); } template <class A, class B, class C, class D> -void ScanTuple(const Tuple4<A, B, C, D>& t1, ScanningResults* results) { - ScanParam(t1.a, results); - ScanParam(t1.b, results); - ScanParam(t1.c, results); - ScanParam(t1.d, results); +void ScanTuple(const Tuple<A, B, C, D>& t1, ScanningResults* results) { + ScanParam(get<0>(t1), results); + ScanParam(get<1>(t1), results); + ScanParam(get<2>(t1), results); + ScanParam(get<3>(t1), results); } template <class MessageType> diff --git a/chromium/ppapi/proxy/net_address_resource.h b/chromium/ppapi/proxy/net_address_resource.h index c9375216a19..fe17ec6b6f0 100644 --- a/chromium/ppapi/proxy/net_address_resource.h +++ b/chromium/ppapi/proxy/net_address_resource.h @@ -28,19 +28,17 @@ class PPAPI_PROXY_EXPORT NetAddressResource : public PluginResource, PP_Instance instance, const PP_NetAddress_Private& private_addr); - virtual ~NetAddressResource(); + ~NetAddressResource() override; // PluginResource implementation. - virtual thunk::PPB_NetAddress_API* AsPPB_NetAddress_API() override; + thunk::PPB_NetAddress_API* AsPPB_NetAddress_API() override; // PPB_NetAddress_API implementation. - virtual PP_NetAddress_Family GetFamily() override; - virtual PP_Var DescribeAsString(PP_Bool include_port) override; - virtual PP_Bool DescribeAsIPv4Address( - PP_NetAddress_IPv4* ipv4_addr) override; - virtual PP_Bool DescribeAsIPv6Address( - PP_NetAddress_IPv6* ipv6_addr) override; - virtual const PP_NetAddress_Private& GetNetAddressPrivate() override; + PP_NetAddress_Family GetFamily() override; + PP_Var DescribeAsString(PP_Bool include_port) override; + PP_Bool DescribeAsIPv4Address(PP_NetAddress_IPv4* ipv4_addr) override; + PP_Bool DescribeAsIPv6Address(PP_NetAddress_IPv6* ipv6_addr) override; + const PP_NetAddress_Private& GetNetAddressPrivate() override; private: // TODO(yzshen): Refactor the code so that PPB_NetAddress resource doesn't diff --git a/chromium/ppapi/proxy/network_list_resource.h b/chromium/ppapi/proxy/network_list_resource.h index 71fb856d383..005b752bec0 100644 --- a/chromium/ppapi/proxy/network_list_resource.h +++ b/chromium/ppapi/proxy/network_list_resource.h @@ -25,20 +25,19 @@ class NetworkListResource public: NetworkListResource(PP_Instance instance, const SerializedNetworkList& list); - virtual ~NetworkListResource(); + ~NetworkListResource() override; // Resource override. - virtual thunk::PPB_NetworkList_API* AsPPB_NetworkList_API() override; + thunk::PPB_NetworkList_API* AsPPB_NetworkList_API() override; // PPB_NetworkList_API implementation. - virtual uint32_t GetCount() override; - virtual PP_Var GetName(uint32_t index) override; - virtual PP_NetworkList_Type GetType(uint32_t index) override; - virtual PP_NetworkList_State GetState(uint32_t index) override; - virtual int32_t GetIpAddresses(uint32_t index, - const PP_ArrayOutput& output) override; - virtual PP_Var GetDisplayName(uint32_t index) override; - virtual uint32_t GetMTU(uint32_t index) override; + uint32_t GetCount() override; + PP_Var GetName(uint32_t index) override; + PP_NetworkList_Type GetType(uint32_t index) override; + PP_NetworkList_State GetState(uint32_t index) override; + int32_t GetIpAddresses(uint32_t index, const PP_ArrayOutput& output) override; + PP_Var GetDisplayName(uint32_t index) override; + uint32_t GetMTU(uint32_t index) override; private: SerializedNetworkList list_; diff --git a/chromium/ppapi/proxy/network_monitor_resource.h b/chromium/ppapi/proxy/network_monitor_resource.h index 529dd6e1e39..e63ae390fa7 100644 --- a/chromium/ppapi/proxy/network_monitor_resource.h +++ b/chromium/ppapi/proxy/network_monitor_resource.h @@ -24,15 +24,15 @@ class NetworkMonitorResource : public PluginResource, public: explicit NetworkMonitorResource(Connection connection, PP_Instance instance); - virtual ~NetworkMonitorResource(); + ~NetworkMonitorResource() override; // PluginResource overrides. ppapi::thunk::PPB_NetworkMonitor_API* AsPPB_NetworkMonitor_API() override; - virtual void OnReplyReceived(const ResourceMessageReplyParams& params, - const IPC::Message& msg) override; + void OnReplyReceived(const ResourceMessageReplyParams& params, + const IPC::Message& msg) override; // thunk::PPB_NetworkMonitor_API interface - virtual int32_t UpdateNetworkList( + int32_t UpdateNetworkList( PP_Resource* network_list, scoped_refptr<TrackedCallback> callback) override; diff --git a/chromium/ppapi/proxy/network_proxy_resource.h b/chromium/ppapi/proxy/network_proxy_resource.h index ba1236e553a..b48089d08ec 100644 --- a/chromium/ppapi/proxy/network_proxy_resource.h +++ b/chromium/ppapi/proxy/network_proxy_resource.h @@ -18,14 +18,14 @@ class PPAPI_PROXY_EXPORT NetworkProxyResource public thunk::PPB_NetworkProxy_API { public: NetworkProxyResource(Connection connection, PP_Instance instance); - virtual ~NetworkProxyResource(); + ~NetworkProxyResource() override; private: // Resource implementation. - virtual thunk::PPB_NetworkProxy_API* AsPPB_NetworkProxy_API() override; + thunk::PPB_NetworkProxy_API* AsPPB_NetworkProxy_API() override; // PPB_NetworkProxy_API implementation. - virtual int32_t GetProxyForURL( + int32_t GetProxyForURL( PP_Instance instance, PP_Var url, PP_Var* proxy_string, diff --git a/chromium/ppapi/proxy/output_protection_resource.h b/chromium/ppapi/proxy/output_protection_resource.h index 6b80b910808..25dcc53e0c0 100644 --- a/chromium/ppapi/proxy/output_protection_resource.h +++ b/chromium/ppapi/proxy/output_protection_resource.h @@ -22,18 +22,17 @@ class OutputProtectionResource PP_Instance instance); private: - virtual ~OutputProtectionResource(); + ~OutputProtectionResource() override; // PluginResource overrides. - virtual thunk::PPB_OutputProtection_API* AsPPB_OutputProtection_API() - override; + thunk::PPB_OutputProtection_API* AsPPB_OutputProtection_API() override; // PPB_OutputProtection_API implementation. - virtual int32_t QueryStatus( + int32_t QueryStatus( uint32_t* link_mask, uint32_t* protection_mask, const scoped_refptr<TrackedCallback>& callback) override; - virtual int32_t EnableProtection( + int32_t EnableProtection( uint32_t desired_method_mask, const scoped_refptr<TrackedCallback>& callback) override; diff --git a/chromium/ppapi/proxy/pdf_resource.cc b/chromium/ppapi/proxy/pdf_resource.cc index 1398866e924..384fdc90a35 100644 --- a/chromium/ppapi/proxy/pdf_resource.cc +++ b/chromium/ppapi/proxy/pdf_resource.cc @@ -10,6 +10,7 @@ #include "base/command_line.h" #include "base/metrics/histogram.h" #include "base/strings/utf_string_conversions.h" +#include "gin/v8_initializer.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/private/ppb_pdf.h" #include "ppapi/proxy/ppapi_messages.h" @@ -27,7 +28,8 @@ namespace { std::string GetLocale() { // The browser process should have passed the locale to the plugin via the // --lang command line flag. - const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); + const base::CommandLine& parsed_command_line = + *base::CommandLine::ForCurrentProcess(); const std::string& lang = parsed_command_line.GetSwitchValueASCII("lang"); DCHECK(!lang.empty()); return lang; @@ -87,7 +89,7 @@ void PDFResource::SearchString(const unsigned short* input_string, std::vector<PP_PrivateFindResult> pp_results; while (match_start != USEARCH_DONE) { - size_t matched_length = usearch_getMatchedLength(searcher); + int32_t matched_length = usearch_getMatchedLength(searcher); PP_PrivateFindResult result; result.start_index = match_start; result.length = matched_length; @@ -96,7 +98,7 @@ void PDFResource::SearchString(const unsigned short* input_string, DCHECK(status == U_ZERO_ERROR); } - *count = pp_results.size(); + *count = static_cast<uint32_t>(pp_results.size()); if (*count) { *results = reinterpret_cast<PP_PrivateFindResult*>(malloc( *count * sizeof(PP_PrivateFindResult))); @@ -204,5 +206,13 @@ void PDFResource::SetLinkUnderCursor(const char* url) { Post(RENDERER, PpapiHostMsg_PDF_SetLinkUnderCursor(url)); } +void PDFResource::GetV8ExternalSnapshotData(const char** natives_data_out, + int* natives_size_out, + const char** snapshot_data_out, + int* snapshot_size_out) { + gin::V8Initializer::GetV8ExternalSnapshotData( + natives_data_out, natives_size_out, snapshot_data_out, snapshot_size_out); +} + } // namespace proxy } // namespace ppapi diff --git a/chromium/ppapi/proxy/pdf_resource.h b/chromium/ppapi/proxy/pdf_resource.h index c15d73808f9..f68c1a2d895 100644 --- a/chromium/ppapi/proxy/pdf_resource.h +++ b/chromium/ppapi/proxy/pdf_resource.h @@ -25,7 +25,7 @@ class PPAPI_PROXY_EXPORT PDFResource public thunk::PPB_PDF_API { public: PDFResource(Connection connection, PP_Instance instance); - virtual ~PDFResource(); + ~PDFResource() override; // For unittesting with a given locale. void SetLocaleForTest(const std::string& locale) { @@ -33,30 +33,34 @@ class PPAPI_PROXY_EXPORT PDFResource } // Resource override. - virtual thunk::PPB_PDF_API* AsPPB_PDF_API() override; + thunk::PPB_PDF_API* AsPPB_PDF_API() override; // PPB_PDF_API implementation. PP_Var GetLocalizedString(PP_ResourceString string_id) override; - virtual void SearchString(const unsigned short* input_string, - const unsigned short* input_term, - bool case_sensitive, - PP_PrivateFindResult** results, - int* count) override; - virtual void DidStartLoading() override; - virtual void DidStopLoading() override; - virtual void SetContentRestriction(int restrictions) override; - virtual void HistogramPDFPageCount(int count) override; - virtual void UserMetricsRecordAction(const PP_Var& action) override; - virtual void HasUnsupportedFeature() override; - virtual void Print() override; - virtual void SaveAs() override; - virtual PP_Bool IsFeatureEnabled(PP_PDFFeature feature) override; - virtual PP_Resource GetResourceImageForScale(PP_ResourceImage image_id, - float scale) override; - virtual PP_Resource GetResourceImage(PP_ResourceImage image_id) override; - virtual PP_Bool IsOutOfProcess() override; - virtual void SetSelectedText(const char* selected_text) override; - virtual void SetLinkUnderCursor(const char* url) override; + void SearchString(const unsigned short* input_string, + const unsigned short* input_term, + bool case_sensitive, + PP_PrivateFindResult** results, + int* count) override; + void DidStartLoading() override; + void DidStopLoading() override; + void SetContentRestriction(int restrictions) override; + void HistogramPDFPageCount(int count) override; + void UserMetricsRecordAction(const PP_Var& action) override; + void HasUnsupportedFeature() override; + void Print() override; + void SaveAs() override; + PP_Bool IsFeatureEnabled(PP_PDFFeature feature) override; + PP_Resource GetResourceImageForScale(PP_ResourceImage image_id, + float scale) override; + PP_Resource GetResourceImage(PP_ResourceImage image_id) override; + PP_Bool IsOutOfProcess() override; + void SetSelectedText(const char* selected_text) override; + void SetLinkUnderCursor(const char* url) override; + void GetV8ExternalSnapshotData(const char** natives_data_out, + int* natives_size_out, + const char** snapshot_data_out, + int* snapshot_size_out) override; private: std::string locale_; diff --git a/chromium/ppapi/proxy/platform_verification_private_resource.cc b/chromium/ppapi/proxy/platform_verification_private_resource.cc index 76d514871d0..27804d36dc9 100644 --- a/chromium/ppapi/proxy/platform_verification_private_resource.cc +++ b/chromium/ppapi/proxy/platform_verification_private_resource.cc @@ -88,10 +88,11 @@ void PlatformVerificationPrivateResource::OnChallengePlatformReply( if (params.result() == PP_OK) { *(output_params.signed_data) = (PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferVar( - raw_signed_data.size(), &raw_signed_data.front()))->GetPPVar(); + static_cast<uint32_t>(raw_signed_data.size()), + &raw_signed_data.front()))->GetPPVar(); *(output_params.signed_data_signature) = (PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferVar( - raw_signed_data_signature.size(), + static_cast<uint32_t>(raw_signed_data_signature.size()), &raw_signed_data_signature.front()))->GetPPVar(); *(output_params.platform_key_certificate) = (new StringVar(raw_platform_key_certificate))->GetPPVar(); diff --git a/chromium/ppapi/proxy/platform_verification_private_resource.h b/chromium/ppapi/proxy/platform_verification_private_resource.h index 424b30d6e00..072b3f8dd05 100644 --- a/chromium/ppapi/proxy/platform_verification_private_resource.h +++ b/chromium/ppapi/proxy/platform_verification_private_resource.h @@ -27,14 +27,14 @@ class PPAPI_PROXY_EXPORT PlatformVerificationPrivateResource scoped_refptr<TrackedCallback> callback; }; - virtual ~PlatformVerificationPrivateResource(); + ~PlatformVerificationPrivateResource() override; // PluginResource overrides. - virtual thunk::PPB_PlatformVerification_API* - AsPPB_PlatformVerification_API() override; + thunk::PPB_PlatformVerification_API* AsPPB_PlatformVerification_API() + override; // PPB_PlatformVerification_API implementation. - virtual int32_t ChallengePlatform( + int32_t ChallengePlatform( const PP_Var& service_id, const PP_Var& challenge, PP_Var* signed_data, diff --git a/chromium/ppapi/proxy/plugin_array_buffer_var.h b/chromium/ppapi/proxy/plugin_array_buffer_var.h index efe90403286..ee9b9306457 100644 --- a/chromium/ppapi/proxy/plugin_array_buffer_var.h +++ b/chromium/ppapi/proxy/plugin_array_buffer_var.h @@ -23,13 +23,13 @@ class PluginArrayBufferVar : public ArrayBufferVar { explicit PluginArrayBufferVar(uint32 size_in_bytes); PluginArrayBufferVar(uint32 size_in_bytes, base::SharedMemoryHandle plugin_handle); - virtual ~PluginArrayBufferVar(); + ~PluginArrayBufferVar() override; // ArrayBufferVar implementation. - virtual void* Map() override; - virtual void Unmap() override; - virtual uint32 ByteLength() override; - virtual bool CopyToNewShmem( + void* Map() override; + void Unmap() override; + uint32 ByteLength() override; + bool CopyToNewShmem( PP_Instance instance, int* host_handle, base::SharedMemoryHandle* plugin_handle) override; diff --git a/chromium/ppapi/proxy/plugin_dispatcher.cc b/chromium/ppapi/proxy/plugin_dispatcher.cc index ad3e7a06642..fb3c23e9e50 100644 --- a/chromium/ppapi/proxy/plugin_dispatcher.cc +++ b/chromium/ppapi/proxy/plugin_dispatcher.cc @@ -7,9 +7,10 @@ #include <map> #include "base/compiler_specific.h" -#include "base/debug/trace_event.h" #include "base/logging.h" #include "base/message_loop/message_loop.h" +#include "base/metrics/histogram_macros.h" +#include "base/trace_event/trace_event.h" #include "ipc/ipc_message.h" #include "ipc/ipc_sync_channel.h" #include "ipc/ipc_sync_message_filter.h" @@ -206,11 +207,21 @@ bool PluginDispatcher::Send(IPC::Message* msg) { if (msg->is_sync()) { // Synchronous messages might be re-entrant, so we need to drop the lock. ProxyAutoUnlock unlock; + SCOPED_UMA_HISTOGRAM_TIMER("Plugin.PpapiSyncIPCTime"); return SendMessage(msg); } return SendMessage(msg); } +bool PluginDispatcher::SendAndStayLocked(IPC::Message* msg) { + TRACE_EVENT2("ppapi proxy", "PluginDispatcher::SendAndStayLocked", + "Class", IPC_MESSAGE_ID_CLASS(msg->type()), + "Line", IPC_MESSAGE_ID_LINE(msg->type())); + if (!msg->is_reply()) + msg->set_unblock(true); + return SendMessage(msg); +} + bool PluginDispatcher::OnMessageReceived(const IPC::Message& msg) { // We need to grab the proxy lock to ensure that we don't collide with the // plugin making pepper calls on a different thread. diff --git a/chromium/ppapi/proxy/plugin_dispatcher.h b/chromium/ppapi/proxy/plugin_dispatcher.h index f8e22f6ebde..03d09e80f7a 100644 --- a/chromium/ppapi/proxy/plugin_dispatcher.h +++ b/chromium/ppapi/proxy/plugin_dispatcher.h @@ -140,12 +140,19 @@ class PPAPI_PROXY_EXPORT PluginDispatcher bool is_client); // Dispatcher overrides. - virtual bool IsPlugin() const; - virtual bool Send(IPC::Message* msg); + bool IsPlugin() const override; + // Send the message to the renderer. If |msg| is a synchronous message, we + // will unlock the ProxyLock so that we can handle incoming messages from the + // renderer. + bool Send(IPC::Message* msg) override; + + // Unlike |Send()|, this function continues to hold the Pepper proxy lock + // until we are finished sending |msg|, even if it is a synchronous message. + bool SendAndStayLocked(IPC::Message* msg); // IPC::Listener implementation. - virtual bool OnMessageReceived(const IPC::Message& msg); - virtual void OnChannelError(); + bool OnMessageReceived(const IPC::Message& msg) override; + void OnChannelError() override; // Keeps track of which dispatcher to use for each instance, active instances // and tracks associated data like the current size. @@ -189,7 +196,8 @@ class PPAPI_PROXY_EXPORT PluginDispatcher typedef base::hash_map<std::string, const void*> InterfaceMap; InterfaceMap plugin_interfaces_; - typedef base::ScopedPtrHashMap<PP_Instance, InstanceData> InstanceDataMap; + typedef base::ScopedPtrHashMap<PP_Instance, scoped_ptr<InstanceData>> + InstanceDataMap; InstanceDataMap instance_map_; // The preferences sent from the host. We only want to set this once, which diff --git a/chromium/ppapi/proxy/plugin_globals.cc b/chromium/ppapi/proxy/plugin_globals.cc index 6bb9c75860a..060aa71d482 100644 --- a/chromium/ppapi/proxy/plugin_globals.cc +++ b/chromium/ppapi/proxy/plugin_globals.cc @@ -9,10 +9,12 @@ #include "ipc/ipc_message.h" #include "ipc/ipc_sender.h" #include "ppapi/proxy/plugin_dispatcher.h" +#include "ppapi/proxy/plugin_message_filter.h" #include "ppapi/proxy/plugin_proxy_delegate.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/ppb_message_loop_proxy.h" #include "ppapi/proxy/resource_reply_thread_registrar.h" +#include "ppapi/proxy/udp_socket_filter.h" #include "ppapi/shared_impl/ppapi_constants.h" #include "ppapi/shared_impl/proxy_lock.h" #include "ppapi/thunk/enter.h" @@ -29,10 +31,10 @@ class PluginGlobals::BrowserSender : public IPC::Sender { : underlying_sender_(underlying_sender) { } - virtual ~BrowserSender() {} + ~BrowserSender() override {} // IPC::Sender implementation. - virtual bool Send(IPC::Message* msg) override { + bool Send(IPC::Message* msg) override { if (msg->is_sync()) { // Synchronous messages might be re-entrant, so we need to drop the lock. ProxyAutoUnlock unlock; @@ -51,12 +53,15 @@ class PluginGlobals::BrowserSender : public IPC::Sender { PluginGlobals* PluginGlobals::plugin_globals_ = NULL; -PluginGlobals::PluginGlobals() +PluginGlobals::PluginGlobals( + const scoped_refptr<base::TaskRunner>& ipc_task_runner) : ppapi::PpapiGlobals(), plugin_proxy_delegate_(NULL), callback_tracker_(new CallbackTracker), + ipc_task_runner_(ipc_task_runner), resource_reply_thread_registrar_( new ResourceReplyThreadRegistrar(GetMainThreadMessageLoop())), + udp_socket_filter_(new UDPSocketFilter()), plugin_recently_active_(false), keepalive_throttle_interval_milliseconds_( ppapi::kKeepaliveThrottleIntervalDefaultMilliseconds), @@ -72,10 +77,13 @@ PluginGlobals::PluginGlobals() new MessageLoopResource(MessageLoopResource::ForMainThread()); } -PluginGlobals::PluginGlobals(PerThreadForTest per_thread_for_test) +PluginGlobals::PluginGlobals( + PerThreadForTest per_thread_for_test, + const scoped_refptr<base::TaskRunner>& ipc_task_runner) : ppapi::PpapiGlobals(per_thread_for_test), plugin_proxy_delegate_(NULL), callback_tracker_(new CallbackTracker), + ipc_task_runner_(ipc_task_runner), resource_reply_thread_registrar_( new ResourceReplyThreadRegistrar(GetMainThreadMessageLoop())), plugin_recently_active_(false), @@ -236,6 +244,11 @@ MessageLoopResource* PluginGlobals::loop_for_main_thread() { return loop_for_main_thread_.get(); } +void PluginGlobals::RegisterResourceMessageFilters( + ppapi::proxy::PluginMessageFilter* plugin_filter) { + plugin_filter->AddResourceMessageFilter(udp_socket_filter_.get()); +} + void PluginGlobals::set_keepalive_throttle_interval_milliseconds(unsigned i) { keepalive_throttle_interval_milliseconds_ = i; } diff --git a/chromium/ppapi/proxy/plugin_globals.h b/chromium/ppapi/proxy/plugin_globals.h index 2aaf15770ac..28cfe486dad 100644 --- a/chromium/ppapi/proxy/plugin_globals.h +++ b/chromium/ppapi/proxy/plugin_globals.h @@ -8,6 +8,7 @@ #include <string> #include "base/compiler_specific.h" +#include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/threading/thread_local_storage.h" #include "ppapi/proxy/connection.h" @@ -33,14 +34,17 @@ struct Preferences; namespace proxy { class MessageLoopResource; +class PluginMessageFilter; class PluginProxyDelegate; class ResourceReplyThreadRegistrar; +class UDPSocketFilter; class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals { public: - PluginGlobals(); - explicit PluginGlobals(PpapiGlobals::PerThreadForTest); - virtual ~PluginGlobals(); + explicit PluginGlobals(const scoped_refptr<base::TaskRunner>& task_runner); + PluginGlobals(PpapiGlobals::PerThreadForTest, + const scoped_refptr<base::TaskRunner>& task_runner); + ~PluginGlobals() override; // Getter for the global singleton. Generally, you should use // PpapiGlobals::Get() when possible. Use this only when you need some @@ -53,32 +57,32 @@ class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals { } // PpapiGlobals implementation. - virtual ResourceTracker* GetResourceTracker() override; - virtual VarTracker* GetVarTracker() override; - virtual CallbackTracker* GetCallbackTrackerForInstance( + ResourceTracker* GetResourceTracker() override; + VarTracker* GetVarTracker() override; + CallbackTracker* GetCallbackTrackerForInstance(PP_Instance instance) override; + thunk::PPB_Instance_API* GetInstanceAPI(PP_Instance instance) override; + thunk::ResourceCreationAPI* GetResourceCreationAPI( PP_Instance instance) override; - virtual thunk::PPB_Instance_API* GetInstanceAPI( - PP_Instance instance) override; - virtual thunk::ResourceCreationAPI* GetResourceCreationAPI( - PP_Instance instance) override; - virtual PP_Module GetModuleForInstance(PP_Instance instance) override; - virtual std::string GetCmdLine() override; - virtual void PreCacheFontForFlash(const void* logfontw) override; - virtual void LogWithSource(PP_Instance instance, - PP_LogLevel level, - const std::string& source, - const std::string& value) override; - virtual void BroadcastLogWithSource(PP_Module module, - PP_LogLevel level, - const std::string& source, - const std::string& value) override; - virtual MessageLoopShared* GetCurrentMessageLoop() override; + PP_Module GetModuleForInstance(PP_Instance instance) override; + std::string GetCmdLine() override; + void PreCacheFontForFlash(const void* logfontw) override; + void LogWithSource(PP_Instance instance, + PP_LogLevel level, + const std::string& source, + const std::string& value) override; + void BroadcastLogWithSource(PP_Module module, + PP_LogLevel level, + const std::string& source, + const std::string& value) override; + MessageLoopShared* GetCurrentMessageLoop() override; base::TaskRunner* GetFileTaskRunner() override; - virtual void MarkPluginIsActive() override; + void MarkPluginIsActive() override; // Returns the channel for sending to the browser. IPC::Sender* GetBrowserSender(); + base::TaskRunner* ipc_task_runner() { return ipc_task_runner_.get(); } + // Returns the language code of the current UI language. std::string GetUILanguage(); @@ -136,6 +140,14 @@ class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals { return resource_reply_thread_registrar_.get(); } + UDPSocketFilter* udp_socket_filter() const { + return udp_socket_filter_.get(); + } + // Add any necessary ResourceMessageFilters to the PluginMessageFilter so + // that they can receive and handle appropriate messages on the IO thread. + void RegisterResourceMessageFilters( + ppapi::proxy::PluginMessageFilter* plugin_filter); + // Interval to limit how many IPC messages are sent indicating that the plugin // is active and should be kept alive. The value must be smaller than any // threshold used to kill inactive plugins by the embedder host. @@ -145,7 +157,7 @@ class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals { class BrowserSender; // PpapiGlobals overrides. - virtual bool IsPluginGlobals() const override; + bool IsPluginGlobals() const override; // Locks the proxy lock and releases the throttle on keepalive IPC messages. void OnReleaseKeepaliveThrottle(); @@ -172,12 +184,16 @@ class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals { scoped_ptr<BrowserSender> browser_sender_; + scoped_refptr<base::TaskRunner> ipc_task_runner_; + // Thread for performing potentially blocking file operations. It's created // lazily, since it might not be needed. scoped_ptr<base::Thread> file_thread_; scoped_refptr<ResourceReplyThreadRegistrar> resource_reply_thread_registrar_; + scoped_refptr<UDPSocketFilter> udp_socket_filter_; + // Indicates activity by the plugin. Used to monitor when a plugin can be // shutdown due to idleness. Current needs do not require differentiating // between idle state between multiple instances, if any are active they are diff --git a/chromium/ppapi/proxy/plugin_message_filter.cc b/chromium/ppapi/proxy/plugin_message_filter.cc index f2f1cbeef14..d9dadc37f58 100644 --- a/chromium/ppapi/proxy/plugin_message_filter.cc +++ b/chromium/ppapi/proxy/plugin_message_filter.cc @@ -54,6 +54,11 @@ bool PluginMessageFilter::Send(IPC::Message* msg) { return false; } +void PluginMessageFilter::AddResourceMessageFilter( + const scoped_refptr<ResourceMessageFilter>& filter) { + resource_filters_.push_back(filter); +} + // static void PluginMessageFilter::DispatchResourceReplyForTest( const ResourceMessageReplyParams& reply_params, @@ -82,17 +87,15 @@ void PluginMessageFilter::OnMsgReserveInstanceId(PP_Instance instance, void PluginMessageFilter::OnMsgResourceReply( const ResourceMessageReplyParams& reply_params, const IPC::Message& nested_msg) { + for (const auto& filter_ptr : resource_filters_) { + if (filter_ptr->OnResourceReplyReceived(reply_params, nested_msg)) + return; + } scoped_refptr<base::MessageLoopProxy> target = resource_reply_thread_registrar_->GetTargetThread(reply_params, nested_msg); - - if (!target.get()) { - DispatchResourceReply(reply_params, nested_msg); - } else { - target->PostTask( - FROM_HERE, - base::Bind(&DispatchResourceReply, reply_params, nested_msg)); - } + target->PostTask( + FROM_HERE, base::Bind(&DispatchResourceReply, reply_params, nested_msg)); } // static diff --git a/chromium/ppapi/proxy/plugin_message_filter.h b/chromium/ppapi/proxy/plugin_message_filter.h index 2e239a2e409..b41a71dbd5d 100644 --- a/chromium/ppapi/proxy/plugin_message_filter.h +++ b/chromium/ppapi/proxy/plugin_message_filter.h @@ -6,6 +6,7 @@ #define PPAPI_PROXY_PLUGIN_MESSAGE_FILTER_H_ #include <set> +#include <vector> #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" @@ -13,6 +14,7 @@ #include "ipc/message_filter.h" #include "ppapi/c/pp_instance.h" #include "ppapi/proxy/ppapi_proxy_export.h" +#include "ppapi/proxy/resource_message_filter.h" namespace ppapi { namespace proxy { @@ -38,15 +40,18 @@ class PPAPI_PROXY_EXPORT PluginMessageFilter : public IPC::MessageFilter, PluginMessageFilter( std::set<PP_Instance>* seen_instance_ids, scoped_refptr<ResourceReplyThreadRegistrar> thread_registrar); - virtual ~PluginMessageFilter(); + ~PluginMessageFilter() override; // MessageFilter implementation. - virtual void OnFilterAdded(IPC::Sender* sender) override; - virtual void OnFilterRemoved() override; - virtual bool OnMessageReceived(const IPC::Message& message) override; + void OnFilterAdded(IPC::Sender* sender) override; + void OnFilterRemoved() override; + bool OnMessageReceived(const IPC::Message& message) override; // IPC::Sender implementation. - virtual bool Send(IPC::Message* msg) override; + bool Send(IPC::Message* msg) override; + + void AddResourceMessageFilter( + const scoped_refptr<ResourceMessageFilter>& filter); // Simulates an incoming resource reply that is handled on the calling thread. // For testing only. @@ -72,6 +77,8 @@ class PPAPI_PROXY_EXPORT PluginMessageFilter : public IPC::MessageFilter, scoped_refptr<ResourceReplyThreadRegistrar> resource_reply_thread_registrar_; + std::vector<scoped_refptr<ResourceMessageFilter>> resource_filters_; + // The IPC sender to the renderer. May be NULL if we're not currently // attached as a filter. IPC::Sender* sender_; diff --git a/chromium/ppapi/proxy/plugin_resource.h b/chromium/ppapi/proxy/plugin_resource.h index fd905cfe75a..0f2124035bc 100644 --- a/chromium/ppapi/proxy/plugin_resource.h +++ b/chromium/ppapi/proxy/plugin_resource.h @@ -34,7 +34,7 @@ class PPAPI_PROXY_EXPORT PluginResource : public Resource { }; PluginResource(Connection connection, PP_Instance instance); - virtual ~PluginResource(); + ~PluginResource() override; // Returns true if we've previously sent a create message to the browser // or renderer. Generally resources will use these to tell if they should @@ -45,16 +45,15 @@ class PPAPI_PROXY_EXPORT PluginResource : public Resource { // This handles a reply to a resource call. It works by looking up the // callback that was registered when CallBrowser/CallRenderer was called // and calling it with |params| and |msg|. - virtual void OnReplyReceived(const proxy::ResourceMessageReplyParams& params, - const IPC::Message& msg) override; + void OnReplyReceived(const proxy::ResourceMessageReplyParams& params, + const IPC::Message& msg) override; // Resource overrides. // Note: Subclasses shouldn't override these methods directly. Instead, they // should implement LastPluginRefWasDeleted() or InstanceWasDeleted() to get // notified. - virtual void NotifyLastPluginRefWasDeleted() override; - virtual void NotifyInstanceWasDeleted() override; - + void NotifyLastPluginRefWasDeleted() override; + void NotifyInstanceWasDeleted() override; // Sends a create message to the browser or renderer for the current resource. void SendCreate(Destination dest, const IPC::Message& msg); diff --git a/chromium/ppapi/proxy/plugin_resource_callback.h b/chromium/ppapi/proxy/plugin_resource_callback.h index 9c443d8ae39..ecde1c2cd82 100644 --- a/chromium/ppapi/proxy/plugin_resource_callback.h +++ b/chromium/ppapi/proxy/plugin_resource_callback.h @@ -33,7 +33,7 @@ class PluginResourceCallback : public PluginResourceCallbackBase { explicit PluginResourceCallback(const CallbackType& callback) : callback_(callback) {} - virtual void Run( + void Run( const ResourceMessageReplyParams& reply_params, const IPC::Message& msg) override { DispatchResourceReplyOrDefaultParams<MsgClass>( @@ -41,7 +41,7 @@ class PluginResourceCallback : public PluginResourceCallbackBase { } private: - virtual ~PluginResourceCallback() {} + ~PluginResourceCallback() override {} CallbackType callback_; }; diff --git a/chromium/ppapi/proxy/plugin_resource_tracker.cc b/chromium/ppapi/proxy/plugin_resource_tracker.cc index 86cbf7cee43..7cf7caf6546 100644 --- a/chromium/ppapi/proxy/plugin_resource_tracker.cc +++ b/chromium/ppapi/proxy/plugin_resource_tracker.cc @@ -32,6 +32,14 @@ PP_Resource PluginResourceTracker::PluginResourceForHostResource( return found->second; } +void PluginResourceTracker::AbandonResource(PP_Resource res) { + DCHECK(GetResource(res)); + bool inserted = abandoned_resources_.insert(res).second; + DCHECK(inserted); + + ReleaseResource(res); +} + PP_Resource PluginResourceTracker::AddResource(Resource* object) { // If there's a HostResource, it must not be added twice. DCHECK(!object->host_resource().host_resource() || @@ -56,9 +64,16 @@ void PluginResourceTracker::RemoveResource(Resource* object) { host_resource_map_.end()); host_resource_map_.erase(object->host_resource()); + bool abandoned = false; + auto it = abandoned_resources_.find(object->pp_resource()); + if (it != abandoned_resources_.end()) { + abandoned = true; + abandoned_resources_.erase(it); + } + PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(object->pp_instance()); - if (dispatcher) { + if (dispatcher && !abandoned) { // The dispatcher can be NULL if the plugin held on to a resource after // the instance was destroyed. In that case the browser-side resource has // already been freed correctly on the browser side. diff --git a/chromium/ppapi/proxy/plugin_resource_tracker.h b/chromium/ppapi/proxy/plugin_resource_tracker.h index 21c7fc531b2..e806645e92c 100644 --- a/chromium/ppapi/proxy/plugin_resource_tracker.h +++ b/chromium/ppapi/proxy/plugin_resource_tracker.h @@ -9,6 +9,7 @@ #include <utility> #include "base/compiler_specific.h" +#include "base/containers/hash_tables.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_stdint.h" @@ -27,23 +28,38 @@ namespace proxy { class PPAPI_PROXY_EXPORT PluginResourceTracker : public ResourceTracker { public: PluginResourceTracker(); - virtual ~PluginResourceTracker(); + ~PluginResourceTracker() override; // Given a host resource, maps it to an existing plugin resource ID if it // exists, or returns 0 on failure. PP_Resource PluginResourceForHostResource( const HostResource& resource) const; + // "Abandons" a PP_Resource on the plugin side. This releases a reference to + // the resource and allows the plugin side of the resource (the proxy + // resource) to be destroyed without sending a message to the renderer + // notifing it that the plugin has released the resource. This is useful when + // the plugin sends a resource to the renderer in reply to a sync IPC. The + // plugin would want to release its reference to the reply resource straight + // away but doing so can sometimes cause the resource to be deleted in the + // renderer before the sync IPC reply has been received giving the renderer a + // chance to add a ref to it. (see e.g. crbug.com/490611). Instead the + // renderer assumes responsibility for the ref that the plugin created and + // this function can be called. + void AbandonResource(PP_Resource res); + protected: // ResourceTracker overrides. - virtual PP_Resource AddResource(Resource* object) override; - virtual void RemoveResource(Resource* object) override; + PP_Resource AddResource(Resource* object) override; + void RemoveResource(Resource* object) override; private: // Map of host instance/resource pairs to a plugin resource ID. typedef std::map<HostResource, PP_Resource> HostResourceMap; HostResourceMap host_resource_map_; + base::hash_set<PP_Resource> abandoned_resources_; + DISALLOW_COPY_AND_ASSIGN(PluginResourceTracker); }; diff --git a/chromium/ppapi/proxy/plugin_resource_var.h b/chromium/ppapi/proxy/plugin_resource_var.h index edfe47b4ede..461dbfddb78 100644 --- a/chromium/ppapi/proxy/plugin_resource_var.h +++ b/chromium/ppapi/proxy/plugin_resource_var.h @@ -22,13 +22,13 @@ class PPAPI_PROXY_EXPORT PluginResourceVar : public ppapi::ResourceVar { explicit PluginResourceVar(ppapi::Resource* resource); // ResourceVar override. - virtual PP_Resource GetPPResource() const override; - virtual bool IsPending() const override; + PP_Resource GetPPResource() const override; + bool IsPending() const override; scoped_refptr<ppapi::Resource> resource() const { return resource_; } protected: - virtual ~PluginResourceVar(); + ~PluginResourceVar() override; private: // If NULL, this represents the PP_Resource 0. diff --git a/chromium/ppapi/proxy/plugin_var_tracker.h b/chromium/ppapi/proxy/plugin_var_tracker.h index 24be5a2012b..671dffe619f 100644 --- a/chromium/ppapi/proxy/plugin_var_tracker.h +++ b/chromium/ppapi/proxy/plugin_var_tracker.h @@ -32,7 +32,7 @@ class PluginDispatcher; class PPAPI_PROXY_EXPORT PluginVarTracker : public VarTracker { public: PluginVarTracker(); - ~PluginVarTracker(); + ~PluginVarTracker() override; // Manages tracking for receiving a VARTYPE_OBJECT from the remote side // (either the plugin or the renderer) that has already had its reference @@ -59,20 +59,19 @@ class PPAPI_PROXY_EXPORT PluginVarTracker : public VarTracker { const PP_Var& host_object); // VarTracker public overrides. - virtual PP_Var MakeResourcePPVarFromMessage( - PP_Instance instance, - const IPC::Message& creation_message, - int pending_renderer_id, - int pending_browser_id) override; - virtual ResourceVar* MakeResourceVar(PP_Resource pp_resource) override; - virtual void DidDeleteInstance(PP_Instance instance) override; - virtual int TrackSharedMemoryHandle(PP_Instance instance, - base::SharedMemoryHandle file, - uint32 size_in_bytes) override; - virtual bool StopTrackingSharedMemoryHandle(int id, - PP_Instance instance, - base::SharedMemoryHandle* handle, - uint32* size_in_bytes) override; + PP_Var MakeResourcePPVarFromMessage(PP_Instance instance, + const IPC::Message& creation_message, + int pending_renderer_id, + int pending_browser_id) override; + ResourceVar* MakeResourceVar(PP_Resource pp_resource) override; + void DidDeleteInstance(PP_Instance instance) override; + int TrackSharedMemoryHandle(PP_Instance instance, + base::SharedMemoryHandle file, + uint32 size_in_bytes) override; + bool StopTrackingSharedMemoryHandle(int id, + PP_Instance instance, + base::SharedMemoryHandle* handle, + uint32* size_in_bytes) override; // Notification that a plugin-implemented object (PPP_Class) was created by // the plugin or deallocated by WebKit over IPC. @@ -97,12 +96,12 @@ class PPAPI_PROXY_EXPORT PluginVarTracker : public VarTracker { private: // VarTracker protected overrides. - virtual int32 AddVarInternal(Var* var, AddVarRefMode mode) override; - virtual void TrackedObjectGettingOneRef(VarMap::const_iterator iter) override; - virtual void ObjectGettingZeroRef(VarMap::iterator iter) override; - virtual bool DeleteObjectInfoIfNecessary(VarMap::iterator iter) override; - virtual ArrayBufferVar* CreateArrayBuffer(uint32 size_in_bytes) override; - virtual ArrayBufferVar* CreateShmArrayBuffer( + int32 AddVarInternal(Var* var, AddVarRefMode mode) override; + void TrackedObjectGettingOneRef(VarMap::const_iterator iter) override; + void ObjectGettingZeroRef(VarMap::iterator iter) override; + bool DeleteObjectInfoIfNecessary(VarMap::iterator iter) override; + ArrayBufferVar* CreateArrayBuffer(uint32 size_in_bytes) override; + ArrayBufferVar* CreateShmArrayBuffer( uint32 size_in_bytes, base::SharedMemoryHandle handle) override; diff --git a/chromium/ppapi/proxy/plugin_var_tracker_unittest.cc b/chromium/ppapi/proxy/plugin_var_tracker_unittest.cc index f43d7a8d4da..fe0a82dd9b6 100644 --- a/chromium/ppapi/proxy/plugin_var_tracker_unittest.cc +++ b/chromium/ppapi/proxy/plugin_var_tracker_unittest.cc @@ -56,9 +56,9 @@ class PluginVarTrackerTest : public PluginProxyTest { if (!release_msg) return -1; - Tuple1<int64> id; + Tuple<int64> id; PpapiHostMsg_PPBVar_ReleaseObject::Read(release_msg, &id); - return id.a; + return get<0>(id); } }; diff --git a/chromium/ppapi/proxy/ppapi_command_buffer_proxy.cc b/chromium/ppapi/proxy/ppapi_command_buffer_proxy.cc index 95500b4a1ec..73f6dfcef94 100644 --- a/chromium/ppapi/proxy/ppapi_command_buffer_proxy.cc +++ b/chromium/ppapi/proxy/ppapi_command_buffer_proxy.cc @@ -4,8 +4,9 @@ #include "ppapi/proxy/ppapi_command_buffer_proxy.h" +#include "base/numerics/safe_conversions.h" +#include "ppapi/proxy/plugin_dispatcher.h" #include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/proxy/proxy_channel.h" #include "ppapi/shared_impl/api_id.h" #include "ppapi/shared_impl/host_resource.h" #include "ppapi/shared_impl/proxy_lock.h" @@ -15,12 +16,12 @@ namespace proxy { PpapiCommandBufferProxy::PpapiCommandBufferProxy( const ppapi::HostResource& resource, - ProxyChannel* channel, + PluginDispatcher* dispatcher, const gpu::Capabilities& capabilities, const SerializedHandle& shared_state) : capabilities_(capabilities), resource_(resource), - channel_(channel) { + dispatcher_(dispatcher) { shared_state_shm_.reset( new base::SharedMemory(shared_state.shmem(), false)); shared_state_shm_->Map(shared_state.size()); @@ -60,6 +61,10 @@ void PpapiCommandBufferProxy::Flush(int32 put_offset) { Send(message); } +void PpapiCommandBufferProxy::OrderingBarrier(int32 put_offset) { + Flush(put_offset); +} + void PpapiCommandBufferProxy::WaitForTokenInRange(int32 start, int32 end) { TryUpdateState(); if (!InRange(start, end, last_state_.token) && @@ -118,7 +123,8 @@ scoped_refptr<gpu::Buffer> PpapiCommandBufferProxy::CreateTransferBuffer( ppapi::proxy::SerializedHandle handle( ppapi::proxy::SerializedHandle::SHARED_MEMORY); if (!Send(new PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer( - ppapi::API_ID_PPB_GRAPHICS_3D, resource_, size, id, &handle))) { + ppapi::API_ID_PPB_GRAPHICS_3D, resource_, + base::checked_cast<uint32_t>(size), id, &handle))) { return NULL; } @@ -152,6 +158,10 @@ uint32 PpapiCommandBufferProxy::CreateStreamTexture(uint32 texture_id) { return 0; } +void PpapiCommandBufferProxy::SetLock(base::Lock*) { + NOTIMPLEMENTED(); +} + uint32 PpapiCommandBufferProxy::InsertSyncPoint() { uint32 sync_point = 0; if (last_state_.error == gpu::error::kNoError) { @@ -219,7 +229,11 @@ int32 PpapiCommandBufferProxy::CreateGpuMemoryBufferImage( bool PpapiCommandBufferProxy::Send(IPC::Message* msg) { DCHECK(last_state_.error == gpu::error::kNoError); - if (channel_->Send(msg)) + // We need to hold the Pepper proxy lock for sync IPC, because the GPU command + // buffer may use a sync IPC with another lock held which could lead to lock + // and deadlock if we dropped the proxy lock here. + // http://crbug.com/418651 + if (dispatcher_->SendAndStayLocked(msg)) return true; last_state_.error = gpu::error::kLostContext; diff --git a/chromium/ppapi/proxy/ppapi_command_buffer_proxy.h b/chromium/ppapi/proxy/ppapi_command_buffer_proxy.h index b277baff9c3..62f77a4f341 100644 --- a/chromium/ppapi/proxy/ppapi_command_buffer_proxy.h +++ b/chromium/ppapi/proxy/ppapi_command_buffer_proxy.h @@ -21,50 +21,51 @@ class Message; namespace ppapi { namespace proxy { -class ProxyChannel; +class PluginDispatcher; class SerializedHandle; class PPAPI_PROXY_EXPORT PpapiCommandBufferProxy : public gpu::CommandBuffer, public gpu::GpuControl { public: PpapiCommandBufferProxy(const HostResource& resource, - ProxyChannel* channel, + PluginDispatcher* dispatcher, const gpu::Capabilities& capabilities, const SerializedHandle& shared_state); - virtual ~PpapiCommandBufferProxy(); + ~PpapiCommandBufferProxy() override; // gpu::CommandBuffer implementation: - virtual bool Initialize() override; - virtual State GetLastState() override; - virtual int32 GetLastToken() override; - virtual void Flush(int32 put_offset) override; - virtual void WaitForTokenInRange(int32 start, int32 end) override; - virtual void WaitForGetOffsetInRange(int32 start, int32 end) override; - virtual void SetGetBuffer(int32 transfer_buffer_id) override; - virtual scoped_refptr<gpu::Buffer> CreateTransferBuffer(size_t size, - int32* id) override; - virtual void DestroyTransferBuffer(int32 id) override; + bool Initialize() override; + State GetLastState() override; + int32 GetLastToken() override; + void Flush(int32 put_offset) override; + void OrderingBarrier(int32 put_offset) override; + void WaitForTokenInRange(int32 start, int32 end) override; + void WaitForGetOffsetInRange(int32 start, int32 end) override; + void SetGetBuffer(int32 transfer_buffer_id) override; + scoped_refptr<gpu::Buffer> CreateTransferBuffer(size_t size, + int32* id) override; + void DestroyTransferBuffer(int32 id) override; // gpu::GpuControl implementation: - virtual gpu::Capabilities GetCapabilities() override; - virtual int32 CreateImage(ClientBuffer buffer, - size_t width, - size_t height, - unsigned internalformat) override; - virtual void DestroyImage(int32 id) override; - virtual int32 CreateGpuMemoryBufferImage(size_t width, - size_t height, - unsigned internalformat, - unsigned usage) override; - virtual uint32 InsertSyncPoint() override; - virtual uint32 InsertFutureSyncPoint() override; - virtual void RetireSyncPoint(uint32 sync_point) override; - virtual void SignalSyncPoint(uint32 sync_point, - const base::Closure& callback) override; - virtual void SignalQuery(uint32 query, - const base::Closure& callback) override; - virtual void SetSurfaceVisible(bool visible) override; - virtual uint32 CreateStreamTexture(uint32 texture_id) override; + gpu::Capabilities GetCapabilities() override; + int32 CreateImage(ClientBuffer buffer, + size_t width, + size_t height, + unsigned internalformat) override; + void DestroyImage(int32 id) override; + int32 CreateGpuMemoryBufferImage(size_t width, + size_t height, + unsigned internalformat, + unsigned usage) override; + uint32 InsertSyncPoint() override; + uint32 InsertFutureSyncPoint() override; + void RetireSyncPoint(uint32 sync_point) override; + void SignalSyncPoint(uint32 sync_point, + const base::Closure& callback) override; + void SignalQuery(uint32 query, const base::Closure& callback) override; + void SetSurfaceVisible(bool visible) override; + uint32 CreateStreamTexture(uint32 texture_id) override; + void SetLock(base::Lock*) override; private: bool Send(IPC::Message* msg); @@ -81,7 +82,7 @@ class PPAPI_PROXY_EXPORT PpapiCommandBufferProxy : public gpu::CommandBuffer, scoped_ptr<base::SharedMemory> shared_state_shm_; HostResource resource_; - ProxyChannel* channel_; + PluginDispatcher* dispatcher_; base::Closure channel_error_callback_; diff --git a/chromium/ppapi/proxy/ppapi_message_utils.h b/chromium/ppapi/proxy/ppapi_message_utils.h index 68667ddebd5..7c4fc0ce7d1 100644 --- a/chromium/ppapi/proxy/ppapi_message_utils.h +++ b/chromium/ppapi/proxy/ppapi_message_utils.h @@ -23,7 +23,7 @@ struct TupleTypeMatch1 { static const bool kValue = false; }; template <class A> -struct TupleTypeMatch1<Tuple1<A>, A> { +struct TupleTypeMatch1<Tuple<A>, A> { static const bool kValue = true; }; @@ -32,7 +32,7 @@ struct TupleTypeMatch2 { static const bool kValue = false; }; template <class A, class B> -struct TupleTypeMatch2<Tuple2<A, B>, A, B> { +struct TupleTypeMatch2<Tuple<A, B>, A, B> { static const bool kValue = true; }; @@ -41,7 +41,7 @@ struct TupleTypeMatch3 { static const bool kValue = false; }; template <class A, class B, class C> -struct TupleTypeMatch3<Tuple3<A, B, C>, A, B, C> { +struct TupleTypeMatch3<Tuple<A, B, C>, A, B, C> { static const bool kValue = true; }; @@ -50,7 +50,7 @@ struct TupleTypeMatch4 { static const bool kValue = false; }; template <class A, class B, class C, class D> -struct TupleTypeMatch4<Tuple4<A, B, C, D>, A, B, C, D> { +struct TupleTypeMatch4<Tuple<A, B, C, D>, A, B, C, D> { static const bool kValue = true; }; @@ -59,7 +59,7 @@ struct TupleTypeMatch5 { static const bool kValue = false; }; template <class A, class B, class C, class D, class E> -struct TupleTypeMatch5<Tuple5<A, B, C, D, E>, A, B, C, D, E> { +struct TupleTypeMatch5<Tuple<A, B, C, D, E>, A, B, C, D, E> { static const bool kValue = true; }; @@ -67,9 +67,9 @@ struct TupleTypeMatch5<Tuple5<A, B, C, D, E>, A, B, C, D, E> { template <class MsgClass, class A> bool UnpackMessage(const IPC::Message& msg, A* a) { - COMPILE_ASSERT( + static_assert( (internal::TupleTypeMatch1<typename MsgClass::Param, A>::kValue), - tuple_types_dont_match); + "tuple types should match"); PickleIterator iter(msg); return IPC::ReadParam(&msg, &iter, a); @@ -77,9 +77,9 @@ bool UnpackMessage(const IPC::Message& msg, A* a) { template <class MsgClass, class A, class B> bool UnpackMessage(const IPC::Message& msg, A* a, B* b) { - COMPILE_ASSERT( + static_assert( (internal::TupleTypeMatch2<typename MsgClass::Param, A, B>::kValue), - tuple_types_dont_match); + "tuple types should match"); PickleIterator iter(msg); return IPC::ReadParam(&msg, &iter, a) && IPC::ReadParam(&msg, &iter, b); @@ -87,9 +87,9 @@ bool UnpackMessage(const IPC::Message& msg, A* a, B* b) { template <class MsgClass, class A, class B, class C> bool UnpackMessage(const IPC::Message& msg, A* a, B* b, C* c) { - COMPILE_ASSERT( + static_assert( (internal::TupleTypeMatch3<typename MsgClass::Param, A, B, C>::kValue), - tuple_types_dont_match); + "tuple types should match"); PickleIterator iter(msg); return IPC::ReadParam(&msg, &iter, a) && @@ -99,9 +99,9 @@ bool UnpackMessage(const IPC::Message& msg, A* a, B* b, C* c) { template <class MsgClass, class A, class B, class C, class D> bool UnpackMessage(const IPC::Message& msg, A* a, B* b, C* c, D* d) { - COMPILE_ASSERT( + static_assert( (internal::TupleTypeMatch4<typename MsgClass::Param, A, B, C, D>::kValue), - tuple_types_dont_match); + "tuple types should match"); PickleIterator iter(msg); return IPC::ReadParam(&msg, &iter, a) && @@ -112,10 +112,10 @@ bool UnpackMessage(const IPC::Message& msg, A* a, B* b, C* c, D* d) { template <class MsgClass, class A, class B, class C, class D, class E> bool UnpackMessage(const IPC::Message& msg, A* a, B* b, C* c, D* d, E* e) { - COMPILE_ASSERT( + static_assert( (internal::TupleTypeMatch5< typename MsgClass::Param, A, B, C, D, E>::kValue), - tuple_types_dont_match); + "tuple types should match"); PickleIterator iter(msg); return IPC::ReadParam(&msg, &iter, a) && @@ -128,4 +128,3 @@ bool UnpackMessage(const IPC::Message& msg, A* a, B* b, C* c, D* d, E* e) { } // namespace ppapi #endif // PPAPI_PROXY_PPAPI_MESSAGE_UTILS_H_ - diff --git a/chromium/ppapi/proxy/ppapi_messages.h b/chromium/ppapi/proxy/ppapi_messages.h index 484e6c74a2d..8a2aeeaca1c 100644 --- a/chromium/ppapi/proxy/ppapi_messages.h +++ b/chromium/ppapi/proxy/ppapi_messages.h @@ -41,15 +41,17 @@ #include "ppapi/c/ppb_tcp_socket.h" #include "ppapi/c/ppb_text_input_controller.h" #include "ppapi/c/ppb_udp_socket.h" +#include "ppapi/c/ppb_video_encoder.h" #include "ppapi/c/private/pp_content_decryptor.h" #include "ppapi/c/private/pp_private_font_charset.h" +#include "ppapi/c/private/pp_video_capture_format.h" #include "ppapi/c/private/ppb_flash.h" #include "ppapi/c/private/ppb_host_resolver_private.h" #include "ppapi/c/private/ppb_isolated_file_system_private.h" #include "ppapi/c/private/ppb_net_address_private.h" #include "ppapi/c/private/ppb_pdf.h" -#include "ppapi/c/private/ppb_talk_private.h" #include "ppapi/c/private/ppp_flash_browser_operations.h" +#include "ppapi/c/private/ppp_pdf.h" #include "ppapi/proxy/host_resolver_private_resource.h" #include "ppapi/proxy/network_list_resource.h" #include "ppapi/proxy/ppapi_param_traits.h" @@ -88,16 +90,18 @@ IPC_ENUM_TRAITS_MAX_VALUE(ppapi::TCPSocketVersion, ppapi::TCP_SOCKET_VERSION_1_1_OR_ABOVE) IPC_ENUM_TRAITS(PP_AudioSampleRate) IPC_ENUM_TRAITS_MAX_VALUE(PP_BlendMode, PP_BLENDMODE_LAST) +IPC_ENUM_TRAITS_MAX_VALUE(PP_CdmExceptionCode, PP_CDMEXCEPTIONCODE_OUTPUTERROR) +IPC_ENUM_TRAITS_MAX_VALUE(PP_CdmKeyStatus, PP_CDMKEYSTATUS_STATUSPENDING) +IPC_ENUM_TRAITS_MAX_VALUE(PP_CdmMessageType, PP_CDMMESSAGETYPE_LICENSE_RELEASE) IPC_ENUM_TRAITS(PP_DeviceType_Dev) IPC_ENUM_TRAITS(PP_DecryptorStreamType) -IPC_ENUM_TRAITS(PP_SessionType) -IPC_ENUM_TRAITS(PP_CdmExceptionCode) IPC_ENUM_TRAITS_MAX_VALUE(PP_FileSystemType, PP_FILESYSTEMTYPE_ISOLATED) IPC_ENUM_TRAITS_MAX_VALUE(PP_FileType, PP_FILETYPE_OTHER) IPC_ENUM_TRAITS(PP_Flash_BrowserOperations_Permission) IPC_ENUM_TRAITS(PP_Flash_BrowserOperations_SettingType) IPC_ENUM_TRAITS(PP_FlashSetting) IPC_ENUM_TRAITS(PP_ImageDataFormat) +IPC_ENUM_TRAITS_MAX_VALUE(PP_InitDataType, PP_INITDATATYPE_WEBM) IPC_ENUM_TRAITS(PP_InputEvent_MouseButton) IPC_ENUM_TRAITS(PP_InputEvent_Type) IPC_ENUM_TRAITS_MAX_VALUE(PP_IsolatedFileSystemType_Private, @@ -109,12 +113,11 @@ IPC_ENUM_TRAITS_MAX_VALUE(PP_NetworkList_Type, PP_NETWORKLIST_TYPE_CELLULAR) IPC_ENUM_TRAITS(PP_PrintOrientation_Dev) IPC_ENUM_TRAITS(PP_PrintOutputFormat_Dev) IPC_ENUM_TRAITS(PP_PrintScalingOption_Dev) +IPC_ENUM_TRAITS_MAX_VALUE(PP_PrivateDuplexMode_Dev, PP_PRIVATEDUPLEXMODE_LAST) IPC_ENUM_TRAITS(PP_PrivateFontCharset) IPC_ENUM_TRAITS(PP_ResourceImage) IPC_ENUM_TRAITS(PP_ResourceString) -IPC_ENUM_TRAITS_MAX_VALUE(PP_TalkEvent, PP_TALKEVENT_NUM_EVENTS - 1) -IPC_ENUM_TRAITS_MAX_VALUE(PP_TalkPermission, - PP_TALKPERMISSION_NUM_PERMISSIONS - 1) +IPC_ENUM_TRAITS_MAX_VALUE(PP_SessionType, PP_SESSIONTYPE_PERSISTENT_RELEASE) IPC_ENUM_TRAITS_MAX_VALUE(PP_TCPSocket_Option, PP_TCPSOCKET_OPTION_RECV_BUFFER_SIZE) IPC_ENUM_TRAITS(PP_TextInput_Type) @@ -124,7 +127,7 @@ IPC_ENUM_TRAITS(PP_TrueTypeFontWeight_Dev) IPC_ENUM_TRAITS(PP_TrueTypeFontWidth_Dev) IPC_ENUM_TRAITS(PP_TrueTypeFontCharset_Dev) IPC_ENUM_TRAITS_MAX_VALUE(PP_UDPSocket_Option, - PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE) + PP_UDPSOCKET_OPTION_MULTICAST_TTL) IPC_ENUM_TRAITS(PP_VideoDecodeError_Dev) IPC_ENUM_TRAITS(PP_VideoDecoder_Profile) IPC_ENUM_TRAITS_MAX_VALUE(PP_VideoFrame_Format, PP_VIDEOFRAME_FORMAT_LAST) @@ -205,6 +208,14 @@ IPC_STRUCT_TRAITS_BEGIN(PP_PrintSettings_Dev) IPC_STRUCT_TRAITS_MEMBER(format) IPC_STRUCT_TRAITS_END() +IPC_STRUCT_TRAITS_BEGIN(PP_PdfPrintPresetOptions_Dev) + IPC_STRUCT_TRAITS_MEMBER(is_scaling_disabled) + IPC_STRUCT_TRAITS_MEMBER(copies) + IPC_STRUCT_TRAITS_MEMBER(duplex) + IPC_STRUCT_TRAITS_MEMBER(is_page_size_uniform) + IPC_STRUCT_TRAITS_MEMBER(uniform_page_size) +IPC_STRUCT_TRAITS_END() + IPC_STRUCT_TRAITS_BEGIN(PP_URLComponent_Dev) IPC_STRUCT_TRAITS_MEMBER(begin) IPC_STRUCT_TRAITS_MEMBER(len) @@ -221,6 +232,11 @@ IPC_STRUCT_TRAITS_BEGIN(PP_URLComponents_Dev) IPC_STRUCT_TRAITS_MEMBER(ref) IPC_STRUCT_TRAITS_END() +IPC_STRUCT_TRAITS_BEGIN(PP_VideoCaptureFormat) + IPC_STRUCT_TRAITS_MEMBER(frame_size) + IPC_STRUCT_TRAITS_MEMBER(frame_rate) +IPC_STRUCT_TRAITS_END() + IPC_STRUCT_TRAITS_BEGIN(PP_FileInfo) IPC_STRUCT_TRAITS_MEMBER(size) IPC_STRUCT_TRAITS_MEMBER(type) @@ -429,6 +445,14 @@ IPC_STRUCT_TRAITS_BEGIN(ppapi::PpapiNaClPluginArgs) IPC_STRUCT_TRAITS_MEMBER(switch_values) IPC_STRUCT_TRAITS_END() +IPC_STRUCT_TRAITS_BEGIN(PP_VideoProfileDescription) +IPC_STRUCT_TRAITS_MEMBER(profile) +IPC_STRUCT_TRAITS_MEMBER(max_resolution) +IPC_STRUCT_TRAITS_MEMBER(max_framerate_numerator) +IPC_STRUCT_TRAITS_MEMBER(max_framerate_denominator) +IPC_STRUCT_TRAITS_MEMBER(hardware_accelerated) +IPC_STRUCT_TRAITS_END() + #if !defined(OS_NACL) && !defined(NACL_WIN64) IPC_STRUCT_TRAITS_BEGIN(ppapi::proxy::PPPDecryptor_Buffer) @@ -698,6 +722,11 @@ IPC_MESSAGE_ROUTED1(PpapiMsg_PPPMouseLock_MouseLockLost, IPC_MESSAGE_ROUTED2(PpapiMsg_PPPPdf_Rotate, PP_Instance /* instance */, bool /* clockwise */) +IPC_SYNC_MESSAGE_ROUTED1_2( + PpapiMsg_PPPPdf_PrintPresetOptions, + PP_Instance /* instance */, + PP_PdfPrintPresetOptions_Dev /* print preset options */, + PP_Bool /* result */) // Find IPC_MESSAGE_ROUTED2(PpapiPluginMsg_PPPFind_StartFind, @@ -754,40 +783,41 @@ IPC_MESSAGE_ROUTED3( int32_t /* result */) // PPP_ContentDecryptor_Dev -IPC_MESSAGE_ROUTED2(PpapiMsg_PPPContentDecryptor_Initialize, +IPC_MESSAGE_ROUTED5(PpapiMsg_PPPContentDecryptor_Initialize, PP_Instance /* instance */, - ppapi::proxy::SerializedVar /* key_system, String */) + uint32_t /* promise_id */, + ppapi::proxy::SerializedVar /* key_system, String */, + PP_Bool /* allow_distinctive_identifier */, + PP_Bool /* allow_persistent_state */) IPC_MESSAGE_ROUTED3(PpapiMsg_PPPContentDecryptor_SetServerCertificate, PP_Instance /* instance */, uint32_t /* promise_id */, std::vector<uint8_t> /* certificate */) -IPC_MESSAGE_ROUTED5(PpapiMsg_PPPContentDecryptor_CreateSession, - PP_Instance /* instance */, - uint32_t /* promise_id */, - ppapi::proxy::SerializedVar /* init_data_type, String */, - ppapi::proxy::SerializedVar /* init_data, ArrayBuffer */, - PP_SessionType /* session_type */) -IPC_MESSAGE_ROUTED3(PpapiMsg_PPPContentDecryptor_LoadSession, +IPC_MESSAGE_ROUTED5( + PpapiMsg_PPPContentDecryptor_CreateSessionAndGenerateRequest, + PP_Instance /* instance */, + uint32_t /* promise_id */, + PP_SessionType /* session_type */, + PP_InitDataType /* init_data_type */, + ppapi::proxy::SerializedVar /* init_data, ArrayBuffer */) +IPC_MESSAGE_ROUTED4(PpapiMsg_PPPContentDecryptor_LoadSession, PP_Instance /* instance */, uint32_t /* promise_id */, - ppapi::proxy::SerializedVar /* web_session_id, String */) + PP_SessionType /* session_type */, + ppapi::proxy::SerializedVar /* session_id, String */) IPC_MESSAGE_ROUTED4(PpapiMsg_PPPContentDecryptor_UpdateSession, PP_Instance /* instance */, uint32_t /* promise_id */, - ppapi::proxy::SerializedVar /* web_session_id, String */, + ppapi::proxy::SerializedVar /* session_id, String */, ppapi::proxy::SerializedVar /* response, ArrayBuffer */) IPC_MESSAGE_ROUTED3(PpapiMsg_PPPContentDecryptor_CloseSession, PP_Instance /* instance */, uint32_t /* promise_id */, - std::string /* web_session_id */) + std::string /* session_id */) IPC_MESSAGE_ROUTED3(PpapiMsg_PPPContentDecryptor_RemoveSession, PP_Instance /* instance */, uint32_t /* promise_id */, - std::string /* web_session_id */) -IPC_MESSAGE_ROUTED3(PpapiMsg_PPPContentDecryptor_GetUsableKeyIds, - PP_Instance /* instance */, - uint32_t /* promise_id */, - std::string /* web_session_id */) + std::string /* session_id */) IPC_MESSAGE_ROUTED3(PpapiMsg_PPPContentDecryptor_Decrypt, PP_Instance /* instance */, ppapi::proxy::PPPDecryptor_Buffer /* buffer */, @@ -1107,39 +1137,34 @@ IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBInstance_PromiseResolved, IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBInstance_PromiseResolvedWithSession, PP_Instance /* instance */, uint32_t /* promise_id */, - ppapi::proxy::SerializedVar /* web_session_id, String */) -IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBInstance_PromiseResolvedWithKeyIds, - PP_Instance /* instance */, - uint32_t /* promise_id */, - std::vector<std::vector<uint8_t> > /* key_ids */) + ppapi::proxy::SerializedVar /* session_id, String */) IPC_MESSAGE_ROUTED5(PpapiHostMsg_PPBInstance_PromiseRejected, PP_Instance /* instance */, uint32_t /* promise_id */, PP_CdmExceptionCode /* exception_code */, int32_t /* system_code */, ppapi::proxy::SerializedVar /* error_description, String */) -IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBInstance_SessionMessage, +IPC_MESSAGE_ROUTED5(PpapiHostMsg_PPBInstance_SessionMessage, PP_Instance /* instance */, - ppapi::proxy::SerializedVar /* web_session_id, String */, + ppapi::proxy::SerializedVar /* session_id, String */, + PP_CdmMessageType /* message_type */, ppapi::proxy::SerializedVar /* message, ArrayBuffer */, ppapi::proxy::SerializedVar /* destination_url, String */) -IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBInstance_SessionKeysChange, +IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBInstance_SessionKeysChange, PP_Instance /* instance */, - std::string /* web_session_id */, - PP_Bool /* has_additional_usable_key */) + std::string /* session_id */, + PP_Bool /* has_additional_usable_key */, + std::vector<PP_KeyInformation> /* key_information */) IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBInstance_SessionExpirationChange, PP_Instance /* instance */, - std::string /* web_session_id */, + std::string /* session_id */, PP_Time /* new_expiry_time */) -IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBInstance_SessionReady, - PP_Instance /* instance */, - ppapi::proxy::SerializedVar /* web_session_id, String */) IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBInstance_SessionClosed, PP_Instance /* instance */, - ppapi::proxy::SerializedVar /* web_session_id, String */) -IPC_MESSAGE_ROUTED5(PpapiHostMsg_PPBInstance_SessionError, + ppapi::proxy::SerializedVar /* session_id, String */) +IPC_MESSAGE_ROUTED5(PpapiHostMsg_PPBInstance_LegacySessionError, PP_Instance /* instance */, - ppapi::proxy::SerializedVar /* web_session_id, String */, + ppapi::proxy::SerializedVar /* session_id, String */, PP_CdmExceptionCode /* exception_code */, int32_t /* system_code */, ppapi::proxy::SerializedVar /* error_description, String */) @@ -1180,9 +1205,14 @@ IPC_SYNC_MESSAGE_ROUTED3_1( IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance, PP_Instance /* instance */, uint32 /* result */) -IPC_SYNC_MESSAGE_ROUTED2_0(PpapiHostMsg_PPBTesting_SimulateInputEvent, - PP_Instance /* instance */, - ppapi::InputEventData /* input_event */) +IPC_SYNC_MESSAGE_ROUTED1_0(PpapiHostMsg_PPBTesting_PostPowerSaverStatus, + PP_Instance /* instance */) +IPC_SYNC_MESSAGE_ROUTED1_0( + PpapiHostMsg_PPBTesting_SubscribeToPowerSaverNotifications, + PP_Instance /* instance */) +IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBTesting_SimulateInputEvent, + PP_Instance /* instance */, + ppapi::InputEventData /* input_event */) IPC_SYNC_MESSAGE_ROUTED1_0( PpapiHostMsg_PPBTesting_SetMinimumArrayBufferSizeForShmem, uint32_t /* threshold */) @@ -1535,7 +1565,21 @@ IPC_MESSAGE_CONTROL2(PpapiHostMsg_Graphics2D_ReadImageData, PP_Point /* top_left */) IPC_MESSAGE_CONTROL0(PpapiPluginMsg_Graphics2D_ReadImageDataAck) -// IsolatedFileSystem +// CameraDevice ---------------------------------------------------------------- +IPC_MESSAGE_CONTROL0(PpapiHostMsg_CameraDevice_Create) +IPC_MESSAGE_CONTROL0(PpapiHostMsg_CameraDevice_Close) + +IPC_MESSAGE_CONTROL1(PpapiHostMsg_CameraDevice_Open, + std::string /* camera_source_id */) +IPC_MESSAGE_CONTROL0(PpapiPluginMsg_CameraDevice_OpenReply) + +IPC_MESSAGE_CONTROL0( + PpapiHostMsg_CameraDevice_GetSupportedVideoCaptureFormats) +IPC_MESSAGE_CONTROL1( + PpapiPluginMsg_CameraDevice_GetSupportedVideoCaptureFormatsReply, + std::vector<PP_VideoCaptureFormat> /* video_capture_formats */) + +// IsolatedFileSystem ---------------------------------------------------------- IPC_MESSAGE_CONTROL0(PpapiHostMsg_IsolatedFileSystem_Create) IPC_MESSAGE_CONTROL1(PpapiHostMsg_IsolatedFileSystem_BrowserOpen, PP_IsolatedFileSystemType_Private /* type */) @@ -1740,6 +1784,12 @@ IPC_MESSAGE_CONTROL2(PpapiHostMsg_UDPSocket_SendTo, IPC_MESSAGE_CONTROL1(PpapiPluginMsg_UDPSocket_SendToReply, int32_t /* bytes_written */) IPC_MESSAGE_CONTROL0(PpapiHostMsg_UDPSocket_Close) +IPC_MESSAGE_CONTROL1(PpapiHostMsg_UDPSocket_JoinGroup, + PP_NetAddress_Private /* net_addr */) +IPC_MESSAGE_CONTROL0(PpapiPluginMsg_UDPSocket_JoinGroupReply) +IPC_MESSAGE_CONTROL1(PpapiHostMsg_UDPSocket_LeaveGroup, + PP_NetAddress_Private /* net_addr */) +IPC_MESSAGE_CONTROL0(PpapiPluginMsg_UDPSocket_LeaveGroupReply) // URLLoader ------------------------------------------------------------------ @@ -1966,6 +2016,46 @@ IPC_MESSAGE_CONTROL0(PpapiPluginMsg_VideoDecoder_ResetReply) IPC_MESSAGE_CONTROL1(PpapiPluginMsg_VideoDecoder_NotifyError, int32_t /* error */) +// VideoEncoder ------------------------------------------------------ + +IPC_MESSAGE_CONTROL0(PpapiHostMsg_VideoEncoder_Create) +IPC_MESSAGE_CONTROL0(PpapiHostMsg_VideoEncoder_GetSupportedProfiles) +IPC_MESSAGE_CONTROL1(PpapiPluginMsg_VideoEncoder_GetSupportedProfilesReply, + std::vector<PP_VideoProfileDescription> /* results */) +IPC_MESSAGE_CONTROL5(PpapiHostMsg_VideoEncoder_Initialize, + PP_VideoFrame_Format /* input_format */, + PP_Size /* input_visible_size */, + PP_VideoProfile /* output_profile */, + uint32_t /* initial_bitrate */, + PP_HardwareAcceleration /* acceleration */) +IPC_MESSAGE_CONTROL2(PpapiPluginMsg_VideoEncoder_InitializeReply, + uint32_t /* input_frame_count */, + PP_Size /* input_coded_size */) +IPC_MESSAGE_CONTROL1(PpapiPluginMsg_VideoEncoder_BitstreamBuffers, + uint32_t /* buffer_length */) +IPC_MESSAGE_CONTROL0(PpapiHostMsg_VideoEncoder_GetVideoFrames) +IPC_MESSAGE_CONTROL3(PpapiPluginMsg_VideoEncoder_GetVideoFramesReply, + uint32_t /* frame_count */, + uint32_t /* frame_length */, + PP_Size /* frame_size */) +IPC_MESSAGE_CONTROL2(PpapiHostMsg_VideoEncoder_Encode, + uint32_t /* frame_id */, + bool /* force_keyframe */) +IPC_MESSAGE_CONTROL1(PpapiPluginMsg_VideoEncoder_EncodeReply, + uint32_t /* frame_id */) +IPC_MESSAGE_CONTROL3(PpapiPluginMsg_VideoEncoder_BitstreamBufferReady, + uint32_t /* buffer_id */, + uint32_t /* buffer_size */, + bool /* key_frame */) +IPC_MESSAGE_CONTROL1(PpapiHostMsg_VideoEncoder_RecycleBitstreamBuffer, + uint32_t /* buffer_id */) +IPC_MESSAGE_CONTROL2(PpapiHostMsg_VideoEncoder_RequestEncodingParametersChange, + uint32_t /* bitrate */, + uint32_t /* framerate */) +IPC_MESSAGE_CONTROL1(PpapiPluginMsg_VideoEncoder_NotifyError, + int32_t /* error */) +IPC_MESSAGE_CONTROL0(PpapiHostMsg_VideoEncoder_Close) + #if !defined(OS_NACL) && !defined(NACL_WIN64) // Audio input. @@ -2237,6 +2327,8 @@ IPC_MESSAGE_CONTROL1(PpapiHostMsg_PDF_SetSelectedText, IPC_MESSAGE_CONTROL1(PpapiHostMsg_PDF_SetLinkUnderCursor, std::string /* url */) +// VideoCapture ---------------------------------------------------------------- + // VideoCapture_Dev, plugin -> host IPC_MESSAGE_CONTROL0(PpapiHostMsg_VideoCapture_Create) IPC_MESSAGE_CONTROL0(PpapiHostMsg_VideoCapture_StartCapture) @@ -2264,16 +2356,4 @@ IPC_MESSAGE_CONTROL1(PpapiPluginMsg_VideoCapture_OnError, IPC_MESSAGE_CONTROL1(PpapiPluginMsg_VideoCapture_OnBufferReady, uint32_t /* buffer */) -// Talk ------------------------------------------------------------------------ - -IPC_MESSAGE_CONTROL0(PpapiHostMsg_Talk_Create) -IPC_MESSAGE_CONTROL1(PpapiHostMsg_Talk_RequestPermission, - PP_TalkPermission /* permission */) -IPC_MESSAGE_CONTROL0(PpapiPluginMsg_Talk_RequestPermissionReply) -IPC_MESSAGE_CONTROL0(PpapiHostMsg_Talk_StartRemoting) -IPC_MESSAGE_CONTROL0(PpapiPluginMsg_Talk_StartRemotingReply) -IPC_MESSAGE_CONTROL0(PpapiHostMsg_Talk_StopRemoting) -IPC_MESSAGE_CONTROL0(PpapiPluginMsg_Talk_StopRemotingReply) -IPC_MESSAGE_CONTROL1(PpapiPluginMsg_Talk_NotifyEvent, PP_TalkEvent /* event */) - #endif // !defined(OS_NACL) && !defined(NACL_WIN64) diff --git a/chromium/ppapi/proxy/ppapi_param_traits.cc b/chromium/ppapi/proxy/ppapi_param_traits.cc index 1623395924e..c3e5af17503 100644 --- a/chromium/ppapi/proxy/ppapi_param_traits.cc +++ b/chromium/ppapi/proxy/ppapi_param_traits.cc @@ -43,7 +43,7 @@ bool ReadVectorWithoutCopy(const Message* m, // This part is just a copy of the the default ParamTraits vector Read(). int size; // ReadLength() checks for < 0 itself. - if (!m->ReadLength(iter, &size)) + if (!iter->ReadLength(&size)) return false; // Resizing beforehand is not safe, see BUG 1006367 for details. if (INT_MAX / sizeof(T) <= static_cast<size_t>(size)) @@ -97,6 +97,52 @@ bool ParamTraits<PP_Bool>::Read(const Message* m, void ParamTraits<PP_Bool>::Log(const param_type& p, std::string* l) { } +// PP_KeyInformation ------------------------------------------------------- + +// static +void ParamTraits<PP_KeyInformation>::Write(Message* m, const param_type& p) { + WriteParam(m, p.key_id_size); + m->WriteBytes(p.key_id, static_cast<int>(p.key_id_size)); + WriteParam(m, p.key_status); + WriteParam(m, p.system_code); +} + +// static +bool ParamTraits<PP_KeyInformation>::Read(const Message* m, + PickleIterator* iter, + param_type* p) { + uint32_t size; + if (!ReadParam(m, iter, &size)) + return false; + if (size > sizeof(p->key_id)) + return false; + p->key_id_size = size; + + const char* data; + if (!iter->ReadBytes(&data, size)) + return false; + memcpy(p->key_id, data, size); + + PP_CdmKeyStatus key_status; + if (!ReadParam(m, iter, &key_status)) + return false; + p->key_status = key_status; + + uint32_t system_code; + if (!ReadParam(m, iter, &system_code)) + return false; + p->system_code = system_code; + + return true; +} + +// static +void ParamTraits<PP_KeyInformation>::Log(const param_type& p, std::string* l) { + l->append("<PP_KeyInformation ("); + LogParam(p.key_id_size, l); + l->append(" bytes)>"); +} + // PP_NetAddress_Private ------------------------------------------------------- // static @@ -118,7 +164,7 @@ bool ParamTraits<PP_NetAddress_Private>::Read(const Message* m, p->size = size; const char* data; - if (!m->ReadBytes(iter, &data, size)) + if (!iter->ReadBytes(&data, size)) return false; memcpy(p->data, data, size); return true; diff --git a/chromium/ppapi/proxy/ppapi_param_traits.h b/chromium/ppapi/proxy/ppapi_param_traits.h index 76dd10df6f8..d2d47629720 100644 --- a/chromium/ppapi/proxy/ppapi_param_traits.h +++ b/chromium/ppapi/proxy/ppapi_param_traits.h @@ -21,6 +21,7 @@ #include "ppapi/shared_impl/ppapi_permissions.h" #include "ppapi/shared_impl/socket_option_data.h" +struct PP_KeyInformation; struct PP_NetAddress_Private; namespace ppapi { @@ -60,6 +61,14 @@ struct PPAPI_PROXY_EXPORT ParamTraits<PP_NetAddress_Private> { static void Log(const param_type& p, std::string* l); }; +template <> +struct PPAPI_PROXY_EXPORT ParamTraits<PP_KeyInformation> { + typedef PP_KeyInformation param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, PickleIterator* iter, param_type* p); + static void Log(const param_type& p, std::string* l); +}; + template<> struct PPAPI_PROXY_EXPORT ParamTraits< ppapi::proxy::PPBFlash_DrawGlyphs_Params> { diff --git a/chromium/ppapi/proxy/ppapi_proxy_test.cc b/chromium/ppapi/proxy/ppapi_proxy_test.cc index 2c0b1365d35..fdd16043515 100644 --- a/chromium/ppapi/proxy/ppapi_proxy_test.cc +++ b/chromium/ppapi/proxy/ppapi_proxy_test.cc @@ -18,7 +18,6 @@ #include "ppapi/c/private/ppb_proxy_private.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/ppb_message_loop_proxy.h" -#include "ppapi/shared_impl/proxy_lock.h" namespace ppapi { namespace proxy { @@ -66,8 +65,7 @@ PPB_Proxy_Private ppb_proxy_private = { ObserverList<ProxyTestHarnessBase> get_interface_handlers_; const void* MockGetInterface(const char* name) { - ObserverList<ProxyTestHarnessBase>::Iterator it = - get_interface_handlers_; + ObserverList<ProxyTestHarnessBase>::Iterator it(&get_interface_handlers_); while (ProxyTestHarnessBase* observer = it.GetNext()) { const void* interface = observer->GetInterface(name); if (interface) @@ -142,7 +140,7 @@ bool ProxyTestHarnessBase::SupportsInterface(const char* name) { reply_msg, &reply_data)); sink().ClearMessages(); - return reply_data.a; + return get<0>(reply_data); } // PluginProxyTestHarness ------------------------------------------------------ @@ -165,7 +163,7 @@ Dispatcher* PluginProxyTestHarness::GetDispatcher() { void PluginProxyTestHarness::SetUpHarness() { // These must be first since the dispatcher set-up uses them. - CreatePluginGlobals(); + CreatePluginGlobals(nullptr /* ipc_task_runner */); // Some of the methods called during set-up check that the lock is held. ProxyAutoLock lock; @@ -192,7 +190,8 @@ void PluginProxyTestHarness::SetUpHarnessWithChannel( base::WaitableEvent* shutdown_event, bool is_client) { // These must be first since the dispatcher set-up uses them. - CreatePluginGlobals(); + scoped_refptr<base::TaskRunner> ipc_task_runner(ipc_message_loop); + CreatePluginGlobals(ipc_message_loop); // Some of the methods called during set-up check that the lock is held. ProxyAutoLock lock; @@ -225,16 +224,14 @@ void PluginProxyTestHarness::TearDownHarness() { plugin_globals_.reset(); } -void PluginProxyTestHarness::CreatePluginGlobals() { +void PluginProxyTestHarness::CreatePluginGlobals( + const scoped_refptr<base::TaskRunner>& ipc_task_runner) { if (globals_config_ == PER_THREAD_GLOBALS) { - plugin_globals_.reset(new PluginGlobals(PpapiGlobals::PerThreadForTest())); + plugin_globals_.reset(new PluginGlobals(PpapiGlobals::PerThreadForTest(), + ipc_task_runner)); PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); - // Enable locking in case some other unit test ran before us and disabled - // locking. - ProxyLock::EnableLockingOnThreadForTest(); } else { - plugin_globals_.reset(new PluginGlobals()); - ProxyLock::EnableLockingOnThreadForTest(); + plugin_globals_.reset(new PluginGlobals(ipc_task_runner)); } } @@ -464,13 +461,11 @@ void HostProxyTestHarness::TearDownHarness() { } void HostProxyTestHarness::CreateHostGlobals() { + disable_locking_.reset(new ProxyLock::LockingDisablerForTest); if (globals_config_ == PER_THREAD_GLOBALS) { host_globals_.reset(new TestGlobals(PpapiGlobals::PerThreadForTest())); PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); - // The host side of the proxy does not lock. - ProxyLock::DisableLockingOnThreadForTest(); } else { - ProxyLock::DisableLockingOnThreadForTest(); host_globals_.reset(new TestGlobals()); } } diff --git a/chromium/ppapi/proxy/ppapi_proxy_test.h b/chromium/ppapi/proxy/ppapi_proxy_test.h index ce9ec655f72..ab6c8b2c819 100644 --- a/chromium/ppapi/proxy/ppapi_proxy_test.h +++ b/chromium/ppapi/proxy/ppapi_proxy_test.h @@ -10,6 +10,7 @@ #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "base/synchronization/waitable_event.h" +#include "base/task_runner.h" #include "base/threading/simple_thread.h" #include "base/threading/thread.h" #include "ppapi/c/pp_instance.h" @@ -20,6 +21,7 @@ #include "ppapi/proxy/plugin_resource_tracker.h" #include "ppapi/proxy/plugin_var_tracker.h" #include "ppapi/proxy/resource_message_test_sink.h" +#include "ppapi/shared_impl/proxy_lock.h" #include "ppapi/shared_impl/test_globals.h" #include "testing/gtest/include/gtest/gtest.h" @@ -118,7 +120,7 @@ class PluginProxyTestHarness : public ProxyTestHarnessBase { public PluginProxyDelegate { public: PluginDelegateMock() : ipc_message_loop_(NULL), shutdown_event_() {} - virtual ~PluginDelegateMock() {} + ~PluginDelegateMock() override {} void Init(base::MessageLoopProxy* ipc_message_loop, base::WaitableEvent* shutdown_event) { @@ -131,24 +133,24 @@ class PluginProxyTestHarness : public ProxyTestHarnessBase { } // ProxyChannel::Delegate implementation. - virtual base::MessageLoopProxy* GetIPCMessageLoop() override; - virtual base::WaitableEvent* GetShutdownEvent() override; - virtual IPC::PlatformFileForTransit ShareHandleWithRemote( + base::MessageLoopProxy* GetIPCMessageLoop() override; + base::WaitableEvent* GetShutdownEvent() override; + IPC::PlatformFileForTransit ShareHandleWithRemote( base::PlatformFile handle, base::ProcessId remote_pid, bool should_close_source) override; // PluginDispatcher::PluginDelegate implementation. - virtual std::set<PP_Instance>* GetGloballySeenInstanceIDSet() override; - virtual uint32 Register(PluginDispatcher* plugin_dispatcher) override; - virtual void Unregister(uint32 plugin_dispatcher_id) override; + std::set<PP_Instance>* GetGloballySeenInstanceIDSet() override; + uint32 Register(PluginDispatcher* plugin_dispatcher) override; + void Unregister(uint32 plugin_dispatcher_id) override; // PluginProxyDelegate implementation. - virtual IPC::Sender* GetBrowserSender() override; - virtual std::string GetUILanguage() override; - virtual void PreCacheFont(const void* logfontw) override; - virtual void SetActiveURL(const std::string& url) override; - virtual PP_Resource CreateBrowserFont( + IPC::Sender* GetBrowserSender() override; + std::string GetUILanguage() override; + void PreCacheFont(const void* logfontw) override; + void SetActiveURL(const std::string& url) override; + PP_Resource CreateBrowserFont( Connection connection, PP_Instance instance, const PP_BrowserFont_Trusted_Description& desc, @@ -164,7 +166,8 @@ class PluginProxyTestHarness : public ProxyTestHarnessBase { }; private: - void CreatePluginGlobals(); + void CreatePluginGlobals( + const scoped_refptr<base::TaskRunner>& ipc_task_runner); GlobalsConfiguration globals_config_; scoped_ptr<PluginGlobals> plugin_globals_; @@ -195,7 +198,7 @@ class PluginProxyMultiThreadTest public base::DelegateSimpleThread::Delegate { public: PluginProxyMultiThreadTest(); - virtual ~PluginProxyMultiThreadTest(); + ~PluginProxyMultiThreadTest() override; // Called before the secondary thread is started, but after all the member // variables, including |secondary_thread_| and @@ -223,7 +226,7 @@ class PluginProxyMultiThreadTest private: // base::DelegateSimpleThread::Delegate implementation. - virtual void Run() override; + void Run() override; void QuitNestedLoop(); @@ -261,7 +264,7 @@ class HostProxyTestHarness : public ProxyTestHarnessBase { public: DelegateMock() : ipc_message_loop_(NULL), shutdown_event_(NULL) { } - virtual ~DelegateMock() {} + ~DelegateMock() override {} void Init(base::MessageLoopProxy* ipc_message_loop, base::WaitableEvent* shutdown_event) { @@ -270,9 +273,9 @@ class HostProxyTestHarness : public ProxyTestHarnessBase { } // ProxyChannel::Delegate implementation. - virtual base::MessageLoopProxy* GetIPCMessageLoop(); - virtual base::WaitableEvent* GetShutdownEvent(); - virtual IPC::PlatformFileForTransit ShareHandleWithRemote( + base::MessageLoopProxy* GetIPCMessageLoop() override; + base::WaitableEvent* GetShutdownEvent() override; + IPC::PlatformFileForTransit ShareHandleWithRemote( base::PlatformFile handle, base::ProcessId remote_pid, bool should_close_source) override; @@ -290,6 +293,9 @@ class HostProxyTestHarness : public ProxyTestHarnessBase { GlobalsConfiguration globals_config_; scoped_ptr<ppapi::TestGlobals> host_globals_; scoped_ptr<HostDispatcher> host_dispatcher_; + // The host side of the real proxy doesn't lock, so this disables locking for + // the thread the host side of the test runs on. + scoped_ptr<ProxyLock::LockingDisablerForTest> disable_locking_; DelegateMock delegate_mock_; }; diff --git a/chromium/ppapi/proxy/ppb_audio_proxy.cc b/chromium/ppapi/proxy/ppb_audio_proxy.cc index 616b04bda14..ca714355b83 100644 --- a/chromium/ppapi/proxy/ppb_audio_proxy.cc +++ b/chromium/ppapi/proxy/ppb_audio_proxy.cc @@ -38,20 +38,19 @@ class Audio : public Resource, public PPB_Audio_Shared { PP_Resource config_id, const AudioCallbackCombined& callback, void* user_data); - virtual ~Audio(); + ~Audio() override; // Resource overrides. - virtual PPB_Audio_API* AsPPB_Audio_API(); + PPB_Audio_API* AsPPB_Audio_API() override; // PPB_Audio_API implementation. - virtual PP_Resource GetCurrentConfig() override; - virtual PP_Bool StartPlayback() override; - virtual PP_Bool StopPlayback() override; - virtual int32_t Open( - PP_Resource config_id, - scoped_refptr<TrackedCallback> create_callback) override; - virtual int32_t GetSyncSocket(int* sync_socket) override; - virtual int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size) override; + PP_Resource GetCurrentConfig() override; + PP_Bool StartPlayback() override; + PP_Bool StopPlayback() override; + int32_t Open(PP_Resource config_id, + scoped_refptr<TrackedCallback> create_callback) override; + int32_t GetSyncSocket(int* sync_socket) override; + int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size) override; private: // Owning reference to the current config object. This isn't actually used, diff --git a/chromium/ppapi/proxy/ppb_broker_proxy.cc b/chromium/ppapi/proxy/ppb_broker_proxy.cc index ed7ed425203..e1d38ead671 100644 --- a/chromium/ppapi/proxy/ppb_broker_proxy.cc +++ b/chromium/ppapi/proxy/ppb_broker_proxy.cc @@ -27,15 +27,14 @@ namespace proxy { class Broker : public PPB_Broker_API, public Resource { public: explicit Broker(const HostResource& resource); - virtual ~Broker(); + ~Broker() override; // Resource overrides. - virtual PPB_Broker_API* AsPPB_Broker_API() override; + PPB_Broker_API* AsPPB_Broker_API() override; // PPB_Broker_API implementation. - virtual int32_t Connect( - scoped_refptr<TrackedCallback> connect_callback) override; - virtual int32_t GetHandle(int32_t* handle) override; + int32_t Connect(scoped_refptr<TrackedCallback> connect_callback) override; + int32_t GetHandle(int32_t* handle) override; // Called by the proxy when the host side has completed the request. void ConnectComplete(IPC::PlatformFileForTransit socket_handle, diff --git a/chromium/ppapi/proxy/ppb_buffer_proxy.h b/chromium/ppapi/proxy/ppb_buffer_proxy.h index 7566c08cf1a..b1484947ecb 100644 --- a/chromium/ppapi/proxy/ppb_buffer_proxy.h +++ b/chromium/ppapi/proxy/ppb_buffer_proxy.h @@ -24,19 +24,19 @@ class Buffer : public thunk::PPB_Buffer_API, public Resource { Buffer(const HostResource& resource, const base::SharedMemoryHandle& shm_handle, uint32_t size); - virtual ~Buffer(); + ~Buffer() override; // Resource overrides. - virtual thunk::PPB_Buffer_API* AsPPB_Buffer_API() override; + thunk::PPB_Buffer_API* AsPPB_Buffer_API() override; // PPB_Buffer_API implementation. - virtual PP_Bool Describe(uint32_t* size_in_bytes) override; - virtual PP_Bool IsMapped() override; - virtual void* Map() override; - virtual void Unmap() override; + PP_Bool Describe(uint32_t* size_in_bytes) override; + PP_Bool IsMapped() override; + void* Map() override; + void Unmap() override; // Trusted - virtual int32_t GetSharedMemory(int* handle) override; + int32_t GetSharedMemory(int* handle) override; private: base::SharedMemory shm_; diff --git a/chromium/ppapi/proxy/ppb_core_proxy.cc b/chromium/ppapi/proxy/ppb_core_proxy.cc index 52f965c1245..0cf2a95ed29 100644 --- a/chromium/ppapi/proxy/ppb_core_proxy.cc +++ b/chromium/ppapi/proxy/ppb_core_proxy.cc @@ -7,9 +7,9 @@ #include <stdlib.h> // For malloc #include "base/bind.h" -#include "base/debug/trace_event.h" #include "base/logging.h" #include "base/time/time.h" +#include "base/trace_event/trace_event.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/ppb_core.h" @@ -63,6 +63,13 @@ void CallOnMainThread(int delay_in_ms, if (!callback.func) return; ProxyAutoLock lock; + + // If the plugin attempts to call CallOnMainThread from a background thread + // at shutdown, it's possible that the PpapiGlobals object or the main loop + // has been destroyed. + if (!PpapiGlobals::Get() || !PpapiGlobals::Get()->GetMainThreadMessageLoop()) + return; + PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostDelayedTask( FROM_HERE, RunWhileLocked(base::Bind(&CallbackWrapper, callback, result)), diff --git a/chromium/ppapi/proxy/ppb_flash_message_loop_proxy.cc b/chromium/ppapi/proxy/ppb_flash_message_loop_proxy.cc index e4e92e9d3e7..1b332185293 100644 --- a/chromium/ppapi/proxy/ppb_flash_message_loop_proxy.cc +++ b/chromium/ppapi/proxy/ppb_flash_message_loop_proxy.cc @@ -24,16 +24,15 @@ namespace { class FlashMessageLoop : public PPB_Flash_MessageLoop_API, public Resource { public: explicit FlashMessageLoop(const HostResource& resource); - virtual ~FlashMessageLoop(); + ~FlashMessageLoop() override; // Resource overrides. - virtual PPB_Flash_MessageLoop_API* AsPPB_Flash_MessageLoop_API() override; + PPB_Flash_MessageLoop_API* AsPPB_Flash_MessageLoop_API() override; // PPB_Flash_MesssageLoop_API implementation. - virtual int32_t Run() override; - virtual void Quit() override; - virtual void RunFromHostProxy( - const RunFromHostProxyCallback& callback) override; + int32_t Run() override; + void Quit() override; + void RunFromHostProxy(const RunFromHostProxyCallback& callback) override; private: DISALLOW_COPY_AND_ASSIGN(FlashMessageLoop); diff --git a/chromium/ppapi/proxy/ppb_flash_message_loop_proxy.h b/chromium/ppapi/proxy/ppb_flash_message_loop_proxy.h index 9dfcca99c9d..a28bbda0613 100644 --- a/chromium/ppapi/proxy/ppb_flash_message_loop_proxy.h +++ b/chromium/ppapi/proxy/ppb_flash_message_loop_proxy.h @@ -28,12 +28,12 @@ class PPB_Flash_MessageLoop_Proxy public base::SupportsWeakPtr<PPB_Flash_MessageLoop_Proxy> { public: explicit PPB_Flash_MessageLoop_Proxy(Dispatcher* dispatcher); - virtual ~PPB_Flash_MessageLoop_Proxy(); + ~PPB_Flash_MessageLoop_Proxy() override; static PP_Resource CreateProxyResource(PP_Instance instance); // InterfaceProxy implementation. - virtual bool OnMessageReceived(const IPC::Message& msg) override; + bool OnMessageReceived(const IPC::Message& msg) override; static const ApiID kApiID = API_ID_PPB_FLASH_MESSAGELOOP; diff --git a/chromium/ppapi/proxy/ppb_graphics_3d_proxy.cc b/chromium/ppapi/proxy/ppb_graphics_3d_proxy.cc index e55e9ca3696..6b49914c272 100644 --- a/chromium/ppapi/proxy/ppb_graphics_3d_proxy.cc +++ b/chromium/ppapi/proxy/ppb_graphics_3d_proxy.cc @@ -4,6 +4,7 @@ #include "ppapi/proxy/ppb_graphics_3d_proxy.h" +#include "base/numerics/safe_conversions.h" #include "gpu/command_buffer/client/gles2_implementation.h" #include "gpu/command_buffer/common/command_buffer.h" #include "ppapi/c/pp_errors.h" @@ -28,6 +29,7 @@ namespace { const int32 kCommandBufferSize = 1024 * 1024; const int32 kTransferBufferSize = 1024 * 1024; +#if !defined(OS_NACL) base::SharedMemoryHandle TransportSHMHandle( Dispatcher* dispatcher, const base::SharedMemoryHandle& handle) { @@ -35,6 +37,7 @@ base::SharedMemoryHandle TransportSHMHandle( // Don't close the handle, it doesn't belong to us. return dispatcher->ShareHandleWithRemote(source, false); } +#endif // !defined(OS_NACL) gpu::CommandBuffer::State GetErrorState() { gpu::CommandBuffer::State error_state; @@ -313,7 +316,7 @@ void PPB_Graphics3D_Proxy::OnMsgCreateTransferBuffer( DCHECK(backing && backing->shared_memory()); transfer_buffer->set_shmem( TransportSHMHandle(dispatcher(), backing->shared_memory()->handle()), - buffer->size()); + base::checked_cast<uint32_t>(buffer->size())); } else { *id = -1; } @@ -378,4 +381,3 @@ void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( } // namespace proxy } // namespace ppapi - diff --git a/chromium/ppapi/proxy/ppb_graphics_3d_proxy.h b/chromium/ppapi/proxy/ppb_graphics_3d_proxy.h index 848281e0280..98e7d3c3175 100644 --- a/chromium/ppapi/proxy/ppb_graphics_3d_proxy.h +++ b/chromium/ppapi/proxy/ppb_graphics_3d_proxy.h @@ -34,32 +34,31 @@ class PpapiCommandBufferProxy; class PPAPI_PROXY_EXPORT Graphics3D : public PPB_Graphics3D_Shared { public: explicit Graphics3D(const HostResource& resource); - virtual ~Graphics3D(); + ~Graphics3D() override; bool Init(gpu::gles2::GLES2Implementation* share_gles2, const gpu::Capabilities& capabilities, const SerializedHandle& shared_state); // Graphics3DTrusted API. These are not implemented in the proxy. - virtual PP_Bool SetGetBuffer(int32_t shm_id) override; - virtual PP_Bool Flush(int32_t put_offset) override; - virtual scoped_refptr<gpu::Buffer> CreateTransferBuffer(uint32_t size, - int32* id) override; - virtual PP_Bool DestroyTransferBuffer(int32_t id) override; - virtual gpu::CommandBuffer::State WaitForTokenInRange(int32_t start, - int32_t end) override; - virtual gpu::CommandBuffer::State WaitForGetOffsetInRange(int32_t start, - int32_t end) - override; - virtual uint32_t InsertSyncPoint() override; - virtual uint32_t InsertFutureSyncPoint() override; - virtual void RetireSyncPoint(uint32_t sync_point) override; + PP_Bool SetGetBuffer(int32_t shm_id) override; + PP_Bool Flush(int32_t put_offset) override; + scoped_refptr<gpu::Buffer> CreateTransferBuffer(uint32_t size, + int32* id) override; + PP_Bool DestroyTransferBuffer(int32_t id) override; + gpu::CommandBuffer::State WaitForTokenInRange(int32_t start, + int32_t end) override; + gpu::CommandBuffer::State WaitForGetOffsetInRange(int32_t start, + int32_t end) override; + uint32_t InsertSyncPoint() override; + uint32_t InsertFutureSyncPoint() override; + void RetireSyncPoint(uint32_t sync_point) override; private: // PPB_Graphics3D_Shared overrides. - virtual gpu::CommandBuffer* GetCommandBuffer() override; - virtual gpu::GpuControl* GetGpuControl() override; - virtual int32 DoSwapBuffers() override; + gpu::CommandBuffer* GetCommandBuffer() override; + gpu::GpuControl* GetGpuControl() override; + int32 DoSwapBuffers() override; scoped_ptr<PpapiCommandBufferProxy> command_buffer_; @@ -69,7 +68,7 @@ class PPAPI_PROXY_EXPORT Graphics3D : public PPB_Graphics3D_Shared { class PPB_Graphics3D_Proxy : public InterfaceProxy { public: PPB_Graphics3D_Proxy(Dispatcher* dispatcher); - virtual ~PPB_Graphics3D_Proxy(); + ~PPB_Graphics3D_Proxy(); static PP_Resource CreateProxyResource( PP_Instance instance, @@ -77,7 +76,7 @@ class PPB_Graphics3D_Proxy : public InterfaceProxy { const int32_t* attrib_list); // InterfaceProxy implementation. - virtual bool OnMessageReceived(const IPC::Message& msg); + bool OnMessageReceived(const IPC::Message& msg) override; static const ApiID kApiID = API_ID_PPB_GRAPHICS_3D; diff --git a/chromium/ppapi/proxy/ppb_image_data_proxy.cc b/chromium/ppapi/proxy/ppb_image_data_proxy.cc index 4ed4442ceb4..d1c040cf250 100644 --- a/chromium/ppapi/proxy/ppb_image_data_proxy.cc +++ b/chromium/ppapi/proxy/ppb_image_data_proxy.cc @@ -282,7 +282,7 @@ void ImageDataCache::Add(ImageData* image_data) { cache_[image_data->pp_instance()].Add(image_data); // Schedule a timer to invalidate this entry. - base::MessageLoop::current()->PostDelayedTask( + PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostDelayedTask( FROM_HERE, RunWhileLocked(base::Bind(&ImageDataCache::OnTimer, weak_factory_.GetWeakPtr(), diff --git a/chromium/ppapi/proxy/ppb_image_data_proxy.h b/chromium/ppapi/proxy/ppb_image_data_proxy.h index c321e452f50..6cd8ba31434 100644 --- a/chromium/ppapi/proxy/ppb_image_data_proxy.h +++ b/chromium/ppapi/proxy/ppb_image_data_proxy.h @@ -39,17 +39,17 @@ class PPAPI_PROXY_EXPORT ImageData public NON_EXPORTED_BASE(ppapi::thunk::PPB_ImageData_API), public ppapi::PPB_ImageData_Shared { public: - virtual ~ImageData(); + ~ImageData() override; // Resource overrides. - virtual ppapi::thunk::PPB_ImageData_API* AsPPB_ImageData_API() override; - virtual void LastPluginRefWasDeleted() override; - virtual void InstanceWasDeleted() override; + ppapi::thunk::PPB_ImageData_API* AsPPB_ImageData_API() override; + void LastPluginRefWasDeleted() override; + void InstanceWasDeleted() override; // PPB_ImageData API. - virtual PP_Bool Describe(PP_ImageDataDesc* desc) override; - virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) override; - virtual void SetIsCandidateForReuse() override; + PP_Bool Describe(PP_ImageDataDesc* desc) override; + int32_t GetSharedMemory(int* handle, uint32_t* byte_count) override; + void SetIsCandidateForReuse() override; PPB_ImageData_Shared::ImageDataType type() const { return type_; } const PP_ImageDataDesc& desc() const { return desc_; } @@ -81,13 +81,13 @@ class PPAPI_PROXY_EXPORT PlatformImageData : public ImageData { PlatformImageData(const ppapi::HostResource& resource, const PP_ImageDataDesc& desc, ImageHandle handle); - virtual ~PlatformImageData(); + ~PlatformImageData() override; // PPB_ImageData API. - virtual void* Map() override; - virtual void Unmap() override; - virtual SkCanvas* GetPlatformCanvas() override; - virtual SkCanvas* GetCanvas() override; + void* Map() override; + void Unmap() override; + SkCanvas* GetPlatformCanvas() override; + SkCanvas* GetCanvas() override; static ImageHandle NullHandle(); static ImageHandle HandleFromInt(int32_t i); @@ -110,13 +110,13 @@ class PPAPI_PROXY_EXPORT SimpleImageData : public ImageData { SimpleImageData(const ppapi::HostResource& resource, const PP_ImageDataDesc& desc, const base::SharedMemoryHandle& handle); - virtual ~SimpleImageData(); + ~SimpleImageData() override; // PPB_ImageData API. - virtual void* Map() override; - virtual void Unmap() override; - virtual SkCanvas* GetPlatformCanvas() override; - virtual SkCanvas* GetCanvas() override; + void* Map() override; + void Unmap() override; + SkCanvas* GetPlatformCanvas() override; + SkCanvas* GetCanvas() override; private: base::SharedMemory shm_; @@ -129,7 +129,7 @@ class PPAPI_PROXY_EXPORT SimpleImageData : public ImageData { class PPB_ImageData_Proxy : public InterfaceProxy { public: PPB_ImageData_Proxy(Dispatcher* dispatcher); - virtual ~PPB_ImageData_Proxy(); + ~PPB_ImageData_Proxy() override; static PP_Resource CreateProxyResource( PP_Instance instance, @@ -139,7 +139,7 @@ class PPB_ImageData_Proxy : public InterfaceProxy { PP_Bool init_to_zero); // InterfaceProxy implementation. - virtual bool OnMessageReceived(const IPC::Message& msg); + bool OnMessageReceived(const IPC::Message& msg) override; // Utility for creating ImageData resources. // This can only be called on the host side of the proxy. diff --git a/chromium/ppapi/proxy/ppb_instance_proxy.cc b/chromium/ppapi/proxy/ppb_instance_proxy.cc index 1dfb897ca68..6f0042d066a 100644 --- a/chromium/ppapi/proxy/ppb_instance_proxy.cc +++ b/chromium/ppapi/proxy/ppb_instance_proxy.cc @@ -5,6 +5,8 @@ #include "ppapi/proxy/ppb_instance_proxy.h" #include "base/memory/ref_counted.h" +#include "base/numerics/safe_conversions.h" +#include "base/stl_util.h" #include "build/build_config.h" #include "media/base/limits.h" #include "ppapi/c/pp_errors.h" @@ -19,7 +21,6 @@ #include "ppapi/proxy/browser_font_singleton_resource.h" #include "ppapi/proxy/content_decryptor_private_serializer.h" #include "ppapi/proxy/enter_proxy.h" -#include "ppapi/proxy/file_mapping_resource.h" #include "ppapi/proxy/flash_clipboard_resource.h" #include "ppapi/proxy/flash_file_resource.h" #include "ppapi/proxy/flash_fullscreen_resource.h" @@ -182,8 +183,6 @@ bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { OnHostMsgPromiseResolved) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_PromiseResolvedWithSession, OnHostMsgPromiseResolvedWithSession) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_PromiseResolvedWithKeyIds, - OnHostMsgPromiseResolvedWithKeyIds) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_PromiseRejected, OnHostMsgPromiseRejected) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionMessage, @@ -192,12 +191,10 @@ bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { OnHostMsgSessionKeysChange) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionExpirationChange, OnHostMsgSessionExpirationChange) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionReady, - OnHostMsgSessionReady) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionClosed, OnHostMsgSessionClosed) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionError, - OnHostMsgSessionError) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_LegacySessionError, + OnHostMsgLegacySessionError) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DeliverBlock, OnHostMsgDeliverBlock) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DecoderInitializeDone, @@ -395,9 +392,6 @@ Resource* PPB_Instance_Proxy::GetSingletonResource(PP_Instance instance, case BROKER_SINGLETON_ID: new_singleton = new BrokerResource(connection, instance); break; - case FILE_MAPPING_SINGLETON_ID: - new_singleton = new FileMappingResource(connection, instance); - break; case GAMEPAD_SINGLETON_ID: new_singleton = new GamepadResource(connection, instance); break; @@ -578,41 +572,10 @@ void PPB_Instance_Proxy::PromiseResolved(PP_Instance instance, void PPB_Instance_Proxy::PromiseResolvedWithSession(PP_Instance instance, uint32 promise_id, - PP_Var web_session_id_var) { + PP_Var session_id_var) { dispatcher()->Send(new PpapiHostMsg_PPBInstance_PromiseResolvedWithSession( - API_ID_PPB_INSTANCE, - instance, - promise_id, - SerializedVarSendInput(dispatcher(), web_session_id_var))); -} - -void PPB_Instance_Proxy::PromiseResolvedWithKeyIds(PP_Instance instance, - uint32 promise_id, - PP_Var key_ids_var) { - ArrayVar* key_ids_array = ArrayVar::FromPPVar(key_ids_var); - if (!key_ids_array || - key_ids_array->GetLength() > media::limits::kMaxKeyIds) { - NOTREACHED(); - return; - } - - std::vector<std::vector<uint8_t> > key_ids; - for (size_t i = 0; i < key_ids_array->GetLength(); ++i) { - ArrayBufferVar* key_id = ArrayBufferVar::FromPPVar(key_ids_array->Get(i)); - if (!key_id || key_id->ByteLength() < media::limits::kMinKeyIdLength || - key_id->ByteLength() > media::limits::kMaxKeyIdLength) { - NOTREACHED(); - continue; - } - - const uint8_t* key_id_ptr = static_cast<const uint8_t*>(key_id->Map()); - const uint32_t key_id_size = key_id->ByteLength(); - std::vector<uint8_t> key_id_vector(key_id_ptr, key_id_ptr + key_id_size); - key_ids.push_back(key_id_vector); - } - - dispatcher()->Send(new PpapiHostMsg_PPBInstance_PromiseResolvedWithKeyIds( - API_ID_PPB_INSTANCE, instance, promise_id, key_ids)); + API_ID_PPB_INSTANCE, instance, promise_id, + SerializedVarSendInput(dispatcher(), session_id_var))); } void PPB_Instance_Proxy::PromiseRejected(PP_Instance instance, @@ -630,40 +593,48 @@ void PPB_Instance_Proxy::PromiseRejected(PP_Instance instance, } void PPB_Instance_Proxy::SessionMessage(PP_Instance instance, - PP_Var web_session_id_var, + PP_Var session_id_var, + PP_CdmMessageType message_type, PP_Var message_var, - PP_Var destination_url_var) { + PP_Var legacy_destination_url_var) { dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionMessage( - API_ID_PPB_INSTANCE, - instance, - SerializedVarSendInput(dispatcher(), web_session_id_var), + API_ID_PPB_INSTANCE, instance, + SerializedVarSendInput(dispatcher(), session_id_var), message_type, SerializedVarSendInput(dispatcher(), message_var), - SerializedVarSendInput(dispatcher(), destination_url_var))); + SerializedVarSendInput(dispatcher(), legacy_destination_url_var))); } -void PPB_Instance_Proxy::SessionKeysChange(PP_Instance instance, - PP_Var web_session_id_var, - PP_Bool has_additional_usable_key) { - StringVar* session_id = StringVar::FromPPVar(web_session_id_var); +void PPB_Instance_Proxy::SessionKeysChange( + PP_Instance instance, + PP_Var session_id_var, + PP_Bool has_additional_usable_key, + uint32_t key_count, + const struct PP_KeyInformation key_information[]) { + StringVar* session_id = StringVar::FromPPVar(session_id_var); if (!session_id || - session_id->value().length() > media::limits::kMaxWebSessionIdLength) { + session_id->value().length() > media::limits::kMaxSessionIdLength) { + NOTREACHED(); + return; + } + + if (key_count > media::limits::kMaxKeyIds) { NOTREACHED(); return; } dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionKeysChange( - API_ID_PPB_INSTANCE, - instance, - session_id->value(), - has_additional_usable_key)); + API_ID_PPB_INSTANCE, instance, session_id->value(), + has_additional_usable_key, + std::vector<PP_KeyInformation>(key_information, + key_information + key_count))); } void PPB_Instance_Proxy::SessionExpirationChange(PP_Instance instance, - PP_Var web_session_id_var, + PP_Var session_id_var, PP_Time new_expiry_time) { - StringVar* session_id = StringVar::FromPPVar(web_session_id_var); + StringVar* session_id = StringVar::FromPPVar(session_id_var); if (!session_id || - session_id->value().length() > media::limits::kMaxWebSessionIdLength) { + session_id->value().length() > media::limits::kMaxSessionIdLength) { NOTREACHED(); return; } @@ -672,32 +643,21 @@ void PPB_Instance_Proxy::SessionExpirationChange(PP_Instance instance, API_ID_PPB_INSTANCE, instance, session_id->value(), new_expiry_time)); } -void PPB_Instance_Proxy::SessionReady(PP_Instance instance, - PP_Var web_session_id_var) { - dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionReady( - API_ID_PPB_INSTANCE, - instance, - SerializedVarSendInput(dispatcher(), web_session_id_var))); -} - void PPB_Instance_Proxy::SessionClosed(PP_Instance instance, - PP_Var web_session_id_var) { + PP_Var session_id_var) { dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionClosed( - API_ID_PPB_INSTANCE, - instance, - SerializedVarSendInput(dispatcher(), web_session_id_var))); + API_ID_PPB_INSTANCE, instance, + SerializedVarSendInput(dispatcher(), session_id_var))); } -void PPB_Instance_Proxy::SessionError(PP_Instance instance, - PP_Var web_session_id_var, - PP_CdmExceptionCode exception_code, - uint32 system_code, - PP_Var error_description_var) { - dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionError( - API_ID_PPB_INSTANCE, - instance, - SerializedVarSendInput(dispatcher(), web_session_id_var), - exception_code, +void PPB_Instance_Proxy::LegacySessionError(PP_Instance instance, + PP_Var session_id_var, + PP_CdmExceptionCode exception_code, + uint32 system_code, + PP_Var error_description_var) { + dispatcher()->Send(new PpapiHostMsg_PPBInstance_LegacySessionError( + API_ID_PPB_INSTANCE, instance, + SerializedVarSendInput(dispatcher(), session_id_var), exception_code, system_code, SerializedVarSendInput(dispatcher(), error_description_var))); } @@ -853,25 +813,6 @@ int32_t PPB_Instance_Proxy::RegisterMessageHandler( return result; } -// TODO(dmichael): Remove this. crbug.com/414398 -int32_t PPB_Instance_Proxy::RegisterMessageHandler_1_1_Deprecated( - PP_Instance instance, - void* user_data, - const PPP_MessageHandler_0_1_Deprecated* handler, - PP_Resource message_loop) { - InstanceData* data = - static_cast<PluginDispatcher*>(dispatcher())->GetInstanceData(instance); - if (!data) - return PP_ERROR_BADARGUMENT; - - int32_t result = PP_ERROR_FAILED; - scoped_ptr<MessageHandler> message_handler = MessageHandler::CreateDeprecated( - instance, handler, user_data, message_loop, &result); - if (message_handler) - data->message_handler = message_handler.Pass(); - return result; -} - void PPB_Instance_Proxy::UnregisterMessageHandler(PP_Instance instance) { InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())->GetInstanceData(instance); @@ -966,7 +907,7 @@ void PPB_Instance_Proxy::SelectionChanged(PP_Instance instance) { data->should_do_request_surrounding_text = true; if (!data->is_request_surrounding_text_pending) { - base::MessageLoop::current()->PostTask( + PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( FROM_HERE, RunWhileLocked(base::Bind(&RequestSurroundingText, instance))); data->is_request_surrounding_text_pending = true; @@ -1276,47 +1217,13 @@ void PPB_Instance_Proxy::OnHostMsgPromiseResolved(PP_Instance instance, void PPB_Instance_Proxy::OnHostMsgPromiseResolvedWithSession( PP_Instance instance, uint32_t promise_id, - SerializedVarReceiveInput web_session_id) { + SerializedVarReceiveInput session_id) { if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) return; EnterInstanceNoLock enter(instance); if (enter.succeeded()) { - enter.functions()->PromiseResolvedWithSession( - instance, promise_id, web_session_id.Get(dispatcher())); - } -} - -void PPB_Instance_Proxy::OnHostMsgPromiseResolvedWithKeyIds( - PP_Instance instance, - uint32_t promise_id, - const std::vector<std::vector<uint8_t> >& key_ids) { - if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) - return; - if (key_ids.size() > media::limits::kMaxKeyIds) { - NOTREACHED(); - return; - } - - scoped_refptr<ArrayVar> key_ids_array = new ArrayVar(); - key_ids_array->SetLength(key_ids.size()); - for (size_t i = 0; i < key_ids.size(); ++i) { - const std::vector<uint8_t>& entry = key_ids[i]; - if (entry.size() < media::limits::kMinKeyIdLength || - entry.size() > media::limits::kMaxKeyIdLength) { - NOTREACHED(); - continue; - } - key_ids_array->Set( - i, - PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar(entry.size(), - &entry[0])); - } - - EnterInstanceNoLock enter(instance); - if (enter.succeeded()) { - ScopedPPVar key_ids_var(ScopedPPVar::PassRef(), key_ids_array->GetPPVar()); - enter.functions()->PromiseResolvedWithKeyIds( - instance, promise_id, key_ids_var.get()); + enter.functions()->PromiseResolvedWithSession(instance, promise_id, + session_id.Get(dispatcher())); } } @@ -1340,76 +1247,73 @@ void PPB_Instance_Proxy::OnHostMsgPromiseRejected( void PPB_Instance_Proxy::OnHostMsgSessionMessage( PP_Instance instance, - SerializedVarReceiveInput web_session_id, + SerializedVarReceiveInput session_id, + PP_CdmMessageType message_type, SerializedVarReceiveInput message, - SerializedVarReceiveInput destination_url) { + SerializedVarReceiveInput legacy_destination_url) { if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) return; EnterInstanceNoLock enter(instance); if (enter.succeeded()) { - enter.functions()->SessionMessage(instance, - web_session_id.Get(dispatcher()), - message.Get(dispatcher()), - destination_url.Get(dispatcher())); + enter.functions()->SessionMessage(instance, session_id.Get(dispatcher()), + message_type, message.Get(dispatcher()), + legacy_destination_url.Get(dispatcher())); } } void PPB_Instance_Proxy::OnHostMsgSessionKeysChange( PP_Instance instance, - const std::string& web_session_id, - PP_Bool has_additional_usable_key) { + const std::string& session_id, + PP_Bool has_additional_usable_key, + const std::vector<PP_KeyInformation>& key_information) { if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) return; + + if (key_information.size() > media::limits::kMaxKeyIds) { + NOTREACHED(); + return; + } + EnterInstanceNoLock enter(instance); if (enter.succeeded()) { - ScopedPPVar web_session_id_var(ScopedPPVar::PassRef(), - StringVar::StringToPPVar(web_session_id)); + ScopedPPVar session_id_var(ScopedPPVar::PassRef(), + StringVar::StringToPPVar(session_id)); enter.functions()->SessionKeysChange( - instance, web_session_id_var.get(), has_additional_usable_key); + instance, session_id_var.get(), has_additional_usable_key, + base::checked_cast<uint32_t>(key_information.size()), + vector_as_array(&key_information)); } } void PPB_Instance_Proxy::OnHostMsgSessionExpirationChange( PP_Instance instance, - const std::string& web_session_id, + const std::string& session_id, PP_Time new_expiry_time) { if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) return; EnterInstanceNoLock enter(instance); if (enter.succeeded()) { - ScopedPPVar web_session_id_var(ScopedPPVar::PassRef(), - StringVar::StringToPPVar(web_session_id)); - enter.functions()->SessionExpirationChange( - instance, web_session_id_var.get(), new_expiry_time); - } -} - -void PPB_Instance_Proxy::OnHostMsgSessionReady( - PP_Instance instance, - SerializedVarReceiveInput web_session_id) { - if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) - return; - EnterInstanceNoLock enter(instance); - if (enter.succeeded()) { - enter.functions()->SessionReady(instance, web_session_id.Get(dispatcher())); + ScopedPPVar session_id_var(ScopedPPVar::PassRef(), + StringVar::StringToPPVar(session_id)); + enter.functions()->SessionExpirationChange(instance, session_id_var.get(), + new_expiry_time); } } void PPB_Instance_Proxy::OnHostMsgSessionClosed( PP_Instance instance, - SerializedVarReceiveInput web_session_id) { + SerializedVarReceiveInput session_id) { if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) return; EnterInstanceNoLock enter(instance); if (enter.succeeded()) { - enter.functions()->SessionClosed(instance, - web_session_id.Get(dispatcher())); + enter.functions()->SessionClosed(instance, session_id.Get(dispatcher())); } } -void PPB_Instance_Proxy::OnHostMsgSessionError( +void PPB_Instance_Proxy::OnHostMsgLegacySessionError( PP_Instance instance, - SerializedVarReceiveInput web_session_id, + SerializedVarReceiveInput session_id, PP_CdmExceptionCode exception_code, uint32_t system_code, SerializedVarReceiveInput error_description) { @@ -1417,11 +1321,9 @@ void PPB_Instance_Proxy::OnHostMsgSessionError( return; EnterInstanceNoLock enter(instance); if (enter.succeeded()) { - enter.functions()->SessionError(instance, - web_session_id.Get(dispatcher()), - exception_code, - system_code, - error_description.Get(dispatcher())); + enter.functions()->LegacySessionError( + instance, session_id.Get(dispatcher()), exception_code, system_code, + error_description.Get(dispatcher())); } } diff --git a/chromium/ppapi/proxy/ppb_instance_proxy.h b/chromium/ppapi/proxy/ppb_instance_proxy.h index e45bccc93ed..f7a715944ba 100644 --- a/chromium/ppapi/proxy/ppb_instance_proxy.h +++ b/chromium/ppapi/proxy/ppb_instance_proxy.h @@ -38,151 +38,132 @@ class PPB_Instance_Proxy : public InterfaceProxy, public PPB_Instance_Shared { public: PPB_Instance_Proxy(Dispatcher* dispatcher); - virtual ~PPB_Instance_Proxy(); + ~PPB_Instance_Proxy() override; // InterfaceProxy implementation. - virtual bool OnMessageReceived(const IPC::Message& msg); + bool OnMessageReceived(const IPC::Message& msg) override; // PPB_Instance_API implementation. - virtual PP_Bool BindGraphics(PP_Instance instance, - PP_Resource device) override; - virtual PP_Bool IsFullFrame(PP_Instance instance) override; - virtual const ViewData* GetViewData(PP_Instance instance) override; - virtual PP_Bool FlashIsFullscreen(PP_Instance instance) override; - virtual PP_Var GetWindowObject(PP_Instance instance) override; - virtual PP_Var GetOwnerElementObject(PP_Instance instance) override; - virtual PP_Var ExecuteScript(PP_Instance instance, - PP_Var script, - PP_Var* exception) override; - virtual uint32_t GetAudioHardwareOutputSampleRate(PP_Instance instance) - override; - virtual uint32_t GetAudioHardwareOutputBufferSize(PP_Instance instance) - override; - virtual PP_Var GetDefaultCharSet(PP_Instance instance) override; - virtual void SetPluginToHandleFindRequests(PP_Instance instance) override; - virtual void NumberOfFindResultsChanged(PP_Instance instance, - int32_t total, - PP_Bool final_result) override; - virtual void SelectedFindResultChanged(PP_Instance instance, - int32_t index) override; - virtual void SetTickmarks(PP_Instance instance, - const PP_Rect* tickmarks, - uint32_t count) override; - virtual PP_Bool IsFullscreen(PP_Instance instance) override; - virtual PP_Bool SetFullscreen(PP_Instance instance, - PP_Bool fullscreen) override; - virtual PP_Bool GetScreenSize(PP_Instance instance, - PP_Size* size) override; - virtual Resource* GetSingletonResource(PP_Instance instance, - SingletonResourceID id) override; - virtual int32_t RequestInputEvents(PP_Instance instance, - uint32_t event_classes) override; - virtual int32_t RequestFilteringInputEvents(PP_Instance instance, - uint32_t event_classes) override; - virtual void StartTrackingLatency(PP_Instance instance) override; - virtual void ClearInputEventRequest(PP_Instance instance, + PP_Bool BindGraphics(PP_Instance instance, PP_Resource device) override; + PP_Bool IsFullFrame(PP_Instance instance) override; + const ViewData* GetViewData(PP_Instance instance) override; + PP_Bool FlashIsFullscreen(PP_Instance instance) override; + PP_Var GetWindowObject(PP_Instance instance) override; + PP_Var GetOwnerElementObject(PP_Instance instance) override; + PP_Var ExecuteScript(PP_Instance instance, + PP_Var script, + PP_Var* exception) override; + uint32_t GetAudioHardwareOutputSampleRate(PP_Instance instance) override; + uint32_t GetAudioHardwareOutputBufferSize(PP_Instance instance) override; + PP_Var GetDefaultCharSet(PP_Instance instance) override; + void SetPluginToHandleFindRequests(PP_Instance instance) override; + void NumberOfFindResultsChanged(PP_Instance instance, + int32_t total, + PP_Bool final_result) override; + void SelectedFindResultChanged(PP_Instance instance, int32_t index) override; + void SetTickmarks(PP_Instance instance, + const PP_Rect* tickmarks, + uint32_t count) override; + PP_Bool IsFullscreen(PP_Instance instance) override; + PP_Bool SetFullscreen(PP_Instance instance, PP_Bool fullscreen) override; + PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) override; + Resource* GetSingletonResource(PP_Instance instance, + SingletonResourceID id) override; + int32_t RequestInputEvents(PP_Instance instance, + uint32_t event_classes) override; + int32_t RequestFilteringInputEvents(PP_Instance instance, uint32_t event_classes) override; - virtual void ZoomChanged(PP_Instance instance, double factor) override; - virtual void ZoomLimitsChanged(PP_Instance instance, - double minimum_factor, - double maximium_factor) override; - virtual void PostMessage(PP_Instance instance, PP_Var message) override; - virtual int32_t RegisterMessageHandler(PP_Instance instance, - void* user_data, - const PPP_MessageHandler_0_2* handler, - PP_Resource message_loop) override; - virtual int32_t RegisterMessageHandler_1_1_Deprecated( - PP_Instance instance, - void* user_data, - const PPP_MessageHandler_0_1_Deprecated* handler, - PP_Resource message_loop) override; - virtual void UnregisterMessageHandler(PP_Instance instance) override; - virtual PP_Bool SetCursor(PP_Instance instance, - PP_MouseCursor_Type type, - PP_Resource image, - const PP_Point* hot_spot) override; - virtual int32_t LockMouse(PP_Instance instance, - scoped_refptr<TrackedCallback> callback) override; - virtual void UnlockMouse(PP_Instance instance) override; - virtual void SetTextInputType(PP_Instance instance, - PP_TextInput_Type type) override; - virtual void UpdateCaretPosition(PP_Instance instance, - const PP_Rect& caret, - const PP_Rect& bounding_box) override; - virtual void CancelCompositionText(PP_Instance instance) override; - virtual void SelectionChanged(PP_Instance instance) override; - virtual void UpdateSurroundingText(PP_Instance instance, - const char* text, - uint32_t caret, - uint32_t anchor) override; - virtual PP_Var GetDocumentURL(PP_Instance instance, - PP_URLComponents_Dev* components) override; + void StartTrackingLatency(PP_Instance instance) override; + void ClearInputEventRequest(PP_Instance instance, + uint32_t event_classes) override; + void ZoomChanged(PP_Instance instance, double factor) override; + void ZoomLimitsChanged(PP_Instance instance, + double minimum_factor, + double maximium_factor) override; + void PostMessage(PP_Instance instance, PP_Var message) override; + int32_t RegisterMessageHandler(PP_Instance instance, + void* user_data, + const PPP_MessageHandler_0_2* handler, + PP_Resource message_loop) override; + void UnregisterMessageHandler(PP_Instance instance) override; + PP_Bool SetCursor(PP_Instance instance, + PP_MouseCursor_Type type, + PP_Resource image, + const PP_Point* hot_spot) override; + int32_t LockMouse(PP_Instance instance, + scoped_refptr<TrackedCallback> callback) override; + void UnlockMouse(PP_Instance instance) override; + void SetTextInputType(PP_Instance instance, PP_TextInput_Type type) override; + void UpdateCaretPosition(PP_Instance instance, + const PP_Rect& caret, + const PP_Rect& bounding_box) override; + void CancelCompositionText(PP_Instance instance) override; + void SelectionChanged(PP_Instance instance) override; + void UpdateSurroundingText(PP_Instance instance, + const char* text, + uint32_t caret, + uint32_t anchor) override; + PP_Var GetDocumentURL(PP_Instance instance, + PP_URLComponents_Dev* components) override; #if !defined(OS_NACL) - virtual PP_Var ResolveRelativeToDocument( - PP_Instance instance, - PP_Var relative, - PP_URLComponents_Dev* components) override; - virtual PP_Bool DocumentCanRequest(PP_Instance instance, PP_Var url) override; - virtual PP_Bool DocumentCanAccessDocument(PP_Instance instance, - PP_Instance target) override; - virtual PP_Var GetPluginInstanceURL( - PP_Instance instance, - PP_URLComponents_Dev* components) override; - virtual PP_Var GetPluginReferrerURL( - PP_Instance instance, - PP_URLComponents_Dev* components) override; - virtual void PromiseResolved(PP_Instance instance, - uint32 promise_id) override; - virtual void PromiseResolvedWithSession(PP_Instance instance, - uint32 promise_id, - PP_Var web_session_id_var) override; - virtual void PromiseResolvedWithKeyIds(PP_Instance instance, - uint32 promise_id, - PP_Var key_ids_var) override; - virtual void PromiseRejected(PP_Instance instance, - uint32 promise_id, - PP_CdmExceptionCode exception_code, - uint32 system_code, - PP_Var error_description_var) override; - virtual void SessionMessage(PP_Instance instance, - PP_Var web_session_id_var, - PP_Var message_var, - PP_Var destination_url_var) override; - virtual void SessionKeysChange(PP_Instance instance, - PP_Var web_session_id_var, - PP_Bool has_additional_usable_key) override; - virtual void SessionExpirationChange(PP_Instance instance, - PP_Var web_session_id_var, - PP_Time new_expiry_time) override; - virtual void SessionReady(PP_Instance instance, - PP_Var web_session_id_var) override; - virtual void SessionClosed(PP_Instance instance, - PP_Var web_session_id_var) override; - virtual void SessionError(PP_Instance instance, - PP_Var web_session_id_var, - PP_CdmExceptionCode exception_code, - uint32 system_code, - PP_Var error_description_var) override; - virtual void DeliverBlock(PP_Instance instance, - PP_Resource decrypted_block, - const PP_DecryptedBlockInfo* block_info) override; - virtual void DecoderInitializeDone(PP_Instance instance, - PP_DecryptorStreamType decoder_type, - uint32_t request_id, - PP_Bool success) override; - virtual void DecoderDeinitializeDone(PP_Instance instance, - PP_DecryptorStreamType decoder_type, - uint32_t request_id) override; - virtual void DecoderResetDone(PP_Instance instance, - PP_DecryptorStreamType decoder_type, - uint32_t request_id) override; - virtual void DeliverFrame(PP_Instance instance, - PP_Resource decrypted_frame, - const PP_DecryptedFrameInfo* frame_info) override; - virtual void DeliverSamples( + PP_Var ResolveRelativeToDocument(PP_Instance instance, + PP_Var relative, + PP_URLComponents_Dev* components) override; + PP_Bool DocumentCanRequest(PP_Instance instance, PP_Var url) override; + PP_Bool DocumentCanAccessDocument(PP_Instance instance, + PP_Instance target) override; + PP_Var GetPluginInstanceURL(PP_Instance instance, + PP_URLComponents_Dev* components) override; + PP_Var GetPluginReferrerURL(PP_Instance instance, + PP_URLComponents_Dev* components) override; + void PromiseResolved(PP_Instance instance, uint32 promise_id) override; + void PromiseResolvedWithSession(PP_Instance instance, + uint32 promise_id, + PP_Var session_id_var) override; + void PromiseRejected(PP_Instance instance, + uint32 promise_id, + PP_CdmExceptionCode exception_code, + uint32 system_code, + PP_Var error_description_var) override; + void SessionMessage(PP_Instance instance, + PP_Var session_id_var, + PP_CdmMessageType message_type, + PP_Var message_var, + PP_Var legacy_destination_url_var) override; + void SessionKeysChange( PP_Instance instance, - PP_Resource audio_frames, - const PP_DecryptedSampleInfo* sample_info) override; + PP_Var session_id_var, + PP_Bool has_additional_usable_key, + uint32_t key_count, + const struct PP_KeyInformation key_information[]) override; + void SessionExpirationChange(PP_Instance instance, + PP_Var session_id_var, + PP_Time new_expiry_time) override; + void SessionClosed(PP_Instance instance, PP_Var session_id_var) override; + void LegacySessionError(PP_Instance instance, + PP_Var session_id_var, + PP_CdmExceptionCode exception_code, + uint32 system_code, + PP_Var error_description_var) override; + void DeliverBlock(PP_Instance instance, + PP_Resource decrypted_block, + const PP_DecryptedBlockInfo* block_info) override; + void DecoderInitializeDone(PP_Instance instance, + PP_DecryptorStreamType decoder_type, + uint32_t request_id, + PP_Bool success) override; + void DecoderDeinitializeDone(PP_Instance instance, + PP_DecryptorStreamType decoder_type, + uint32_t request_id) override; + void DecoderResetDone(PP_Instance instance, + PP_DecryptorStreamType decoder_type, + uint32_t request_id) override; + void DeliverFrame(PP_Instance instance, + PP_Resource decrypted_frame, + const PP_DecryptedFrameInfo* frame_info) override; + void DeliverSamples(PP_Instance instance, + PP_Resource audio_frames, + const PP_DecryptedSampleInfo* sample_info) override; #endif // !defined(OS_NACL) static const ApiID kApiID = API_ID_PPB_INSTANCE; @@ -268,11 +249,7 @@ class PPB_Instance_Proxy : public InterfaceProxy, virtual void OnHostMsgPromiseResolvedWithSession( PP_Instance instance, uint32_t promise_id, - SerializedVarReceiveInput web_session_id); - virtual void OnHostMsgPromiseResolvedWithKeyIds( - PP_Instance instance, - uint32 promise_id, - const std::vector<std::vector<uint8_t> >& key_ids); + SerializedVarReceiveInput session_id); virtual void OnHostMsgPromiseRejected( PP_Instance instance, uint32_t promise_id, @@ -281,23 +258,24 @@ class PPB_Instance_Proxy : public InterfaceProxy, SerializedVarReceiveInput error_description); virtual void OnHostMsgSessionMessage( PP_Instance instance, - SerializedVarReceiveInput web_session_id, + SerializedVarReceiveInput session_id, + PP_CdmMessageType message_type, SerializedVarReceiveInput message, - SerializedVarReceiveInput destination_url); - virtual void OnHostMsgSessionKeysChange(PP_Instance instance, - const std::string& web_session_id, - PP_Bool has_additional_usable_key); + SerializedVarReceiveInput legacy_destination_url); + virtual void OnHostMsgSessionKeysChange( + PP_Instance instance, + const std::string& session_id, + PP_Bool has_additional_usable_key, + const std::vector<PP_KeyInformation>& key_information); virtual void OnHostMsgSessionExpirationChange( PP_Instance instance, - const std::string& web_session_id, + const std::string& session_id, PP_Time new_expiry_time); - virtual void OnHostMsgSessionReady(PP_Instance instance, - SerializedVarReceiveInput web_session_id); virtual void OnHostMsgSessionClosed(PP_Instance instance, - SerializedVarReceiveInput web_session_id); - virtual void OnHostMsgSessionError( + SerializedVarReceiveInput session_id); + virtual void OnHostMsgLegacySessionError( PP_Instance instance, - SerializedVarReceiveInput web_session_id, + SerializedVarReceiveInput session_id, PP_CdmExceptionCode exception_code, uint32_t system_code, SerializedVarReceiveInput error_description); diff --git a/chromium/ppapi/proxy/ppb_message_loop_proxy.h b/chromium/ppapi/proxy/ppb_message_loop_proxy.h index 73df5f1cb28..0aa07fe3b5f 100644 --- a/chromium/ppapi/proxy/ppb_message_loop_proxy.h +++ b/chromium/ppapi/proxy/ppb_message_loop_proxy.h @@ -26,17 +26,16 @@ class PPAPI_PROXY_EXPORT MessageLoopResource : public MessageLoopShared { // Construct the one MessageLoopResource for the main thread. This must be // invoked on the main thread. explicit MessageLoopResource(ForMainThread); - virtual ~MessageLoopResource(); + ~MessageLoopResource() override; // Resource overrides. - virtual thunk::PPB_MessageLoop_API* AsPPB_MessageLoop_API() override; + thunk::PPB_MessageLoop_API* AsPPB_MessageLoop_API() override; // PPB_MessageLoop_API implementation. - virtual int32_t AttachToCurrentThread() override; - virtual int32_t Run() override; - virtual int32_t PostWork(PP_CompletionCallback callback, - int64_t delay_ms) override; - virtual int32_t PostQuit(PP_Bool should_destroy) override; + int32_t AttachToCurrentThread() override; + int32_t Run() override; + int32_t PostWork(PP_CompletionCallback callback, int64_t delay_ms) override; + int32_t PostQuit(PP_Bool should_destroy) override; static MessageLoopResource* GetCurrent(); void DetachFromThread(); @@ -69,11 +68,11 @@ class PPAPI_PROXY_EXPORT MessageLoopResource : public MessageLoopShared { // NOTE: The given closure will be run *WITHOUT* acquiring the Proxy lock. // This only makes sense for user code and completely thread-safe // proxy operations (e.g., MessageLoop::QuitClosure). - virtual void PostClosure(const tracked_objects::Location& from_here, - const base::Closure& closure, - int64 delay_ms) override; - virtual base::MessageLoopProxy* GetMessageLoopProxy() override; - virtual bool CurrentlyHandlingBlockingMessage() override; + void PostClosure(const tracked_objects::Location& from_here, + const base::Closure& closure, + int64 delay_ms) override; + base::MessageLoopProxy* GetMessageLoopProxy() override; + bool CurrentlyHandlingBlockingMessage() override; // TLS destructor function. static void ReleaseMessageLoop(void* value); diff --git a/chromium/ppapi/proxy/ppb_testing_proxy.cc b/chromium/ppapi/proxy/ppb_testing_proxy.cc index 0dbab0be063..438179854b8 100644 --- a/chromium/ppapi/proxy/ppb_testing_proxy.cc +++ b/chromium/ppapi/proxy/ppb_testing_proxy.cc @@ -80,6 +80,27 @@ PP_Bool IsOutOfProcess() { return PP_TRUE; } +void PostPowerSaverStatus(PP_Instance instance_id) { + ProxyAutoLock lock; + PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); + if (!dispatcher) + return; + + dispatcher->Send(new PpapiHostMsg_PPBTesting_PostPowerSaverStatus( + API_ID_PPB_TESTING, instance_id)); +} + +void SubscribeToPowerSaverNotifications(PP_Instance instance_id) { + ProxyAutoLock lock; + PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); + if (!dispatcher) + return; + + dispatcher->Send( + new PpapiHostMsg_PPBTesting_SubscribeToPowerSaverNotifications( + API_ID_PPB_TESTING, instance_id)); +} + void SimulateInputEvent(PP_Instance instance_id, PP_Resource input_event) { ProxyAutoLock lock; PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); @@ -112,7 +133,7 @@ uint32_t GetLiveVars(PP_Var live_vars[], uint32_t array_size) { i < std::min(static_cast<size_t>(array_size), vars.size()); ++i) live_vars[i] = vars[i]; - return vars.size(); + return static_cast<uint32_t>(vars.size()); } void SetMinimumArrayBufferSizeForShmem(PP_Instance instance, @@ -133,17 +154,18 @@ void RunV8GC(PP_Instance instance) { } const PPB_Testing_Private testing_interface = { - &ReadImageData, - &RunMessageLoop, - &QuitMessageLoop, - &GetLiveObjectsForInstance, - &IsOutOfProcess, - &SimulateInputEvent, - &GetDocumentURL, - &GetLiveVars, - &SetMinimumArrayBufferSizeForShmem, - &RunV8GC -}; + &ReadImageData, + &RunMessageLoop, + &QuitMessageLoop, + &GetLiveObjectsForInstance, + &IsOutOfProcess, + &PostPowerSaverStatus, + &SubscribeToPowerSaverNotifications, + &SimulateInputEvent, + &GetDocumentURL, + &GetLiveVars, + &SetMinimumArrayBufferSizeForShmem, + &RunV8GC}; } // namespace @@ -174,6 +196,11 @@ bool PPB_Testing_Proxy::OnMessageReceived(const IPC::Message& msg) { OnMsgReadImageData) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance, OnMsgGetLiveObjectsForInstance) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_PostPowerSaverStatus, + OnMsgPostPowerSaverStatus) + IPC_MESSAGE_HANDLER( + PpapiHostMsg_PPBTesting_SubscribeToPowerSaverNotifications, + OnMsgSubscribeToPowerSaverNotifications) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_SimulateInputEvent, OnMsgSimulateInputEvent) IPC_MESSAGE_HANDLER( @@ -206,6 +233,15 @@ void PPB_Testing_Proxy::OnMsgGetLiveObjectsForInstance(PP_Instance instance, *result = ppb_testing_impl_->GetLiveObjectsForInstance(instance); } +void PPB_Testing_Proxy::OnMsgPostPowerSaverStatus(PP_Instance instance) { + ppb_testing_impl_->PostPowerSaverStatus(instance); +} + +void PPB_Testing_Proxy::OnMsgSubscribeToPowerSaverNotifications( + PP_Instance instance) { + ppb_testing_impl_->SubscribeToPowerSaverNotifications(instance); +} + void PPB_Testing_Proxy::OnMsgSimulateInputEvent( PP_Instance instance, const InputEventData& input_event) { diff --git a/chromium/ppapi/proxy/ppb_testing_proxy.h b/chromium/ppapi/proxy/ppb_testing_proxy.h index bcdb53b4d70..7640291bfb8 100644 --- a/chromium/ppapi/proxy/ppb_testing_proxy.h +++ b/chromium/ppapi/proxy/ppb_testing_proxy.h @@ -39,6 +39,8 @@ class PPB_Testing_Proxy : public InterfaceProxy { void OnMsgRunMessageLoop(PP_Instance instance); void OnMsgQuitMessageLoop(PP_Instance instance); void OnMsgGetLiveObjectsForInstance(PP_Instance instance, uint32_t* result); + void OnMsgPostPowerSaverStatus(PP_Instance instance); + void OnMsgSubscribeToPowerSaverNotifications(PP_Instance instance); void OnMsgSimulateInputEvent(PP_Instance instance, const ppapi::InputEventData& input_event); void OnMsgSetMinimumArrayBufferSizeForShmem(uint32_t threshold); diff --git a/chromium/ppapi/proxy/ppb_var_deprecated_proxy.cc b/chromium/ppapi/proxy/ppb_var_deprecated_proxy.cc index 723fb941186..7adda60381b 100644 --- a/chromium/ppapi/proxy/ppb_var_deprecated_proxy.cc +++ b/chromium/ppapi/proxy/ppb_var_deprecated_proxy.cc @@ -22,6 +22,7 @@ #include "ppapi/proxy/ppp_class_proxy.h" #include "ppapi/proxy/proxy_object_var.h" #include "ppapi/proxy/serialized_var.h" +#include "ppapi/shared_impl/ppapi_globals.h" #include "ppapi/shared_impl/ppb_var_shared.h" #include "ppapi/shared_impl/proxy_lock.h" #include "ppapi/shared_impl/var.h" @@ -379,7 +380,7 @@ void PPB_Var_Deprecated_Proxy::OnMsgReleaseObject(int64 object_id) { // spurious warning). // TODO(piman): See if we can fix the IPC code to enforce strict ordering, and // then remove this. - base::MessageLoop::current()->PostNonNestableTask( + PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostNonNestableTask( FROM_HERE, RunWhileLocked(base::Bind(&PPB_Var_Deprecated_Proxy::DoReleaseObject, task_factory_.GetWeakPtr(), diff --git a/chromium/ppapi/proxy/ppb_var_unittest.cc b/chromium/ppapi/proxy/ppb_var_unittest.cc index 5e25379eeb0..98b64283221 100644 --- a/chromium/ppapi/proxy/ppb_var_unittest.cc +++ b/chromium/ppapi/proxy/ppb_var_unittest.cc @@ -33,7 +33,7 @@ class PPB_VarTest : public PluginProxyTest { ppb_var_(ppapi::PPB_Var_Shared::GetVarInterface1_2()) { // Set the value of test_strings_[i] to "i". for (size_t i = 0; i < kNumStrings; ++i) - test_strings_[i] = base::IntToString(i); + test_strings_[i] = base::IntToString(static_cast<int>(i)); } protected: std::vector<std::string> test_strings_; @@ -44,8 +44,9 @@ class PPB_VarTest : public PluginProxyTest { // Test basic String operations. TEST_F(PPB_VarTest, Strings) { for (size_t i = 0; i < kNumStrings; ++i) { - vars_[i] = ppb_var_->VarFromUtf8(test_strings_[i].c_str(), - test_strings_[i].length()); + vars_[i] = ppb_var_->VarFromUtf8( + test_strings_[i].c_str(), + static_cast<uint32_t>(test_strings_[i].length())); EXPECT_EQ(test_strings_[i], VarToString(vars_[i], ppb_var_)); } // At this point, they should each have a ref count of 1. Add some more. @@ -104,8 +105,9 @@ class CreateVarThreadDelegate : public base::PlatformThread::Delegate { virtual void ThreadMain() { const PPB_Var* ppb_var = ppapi::PPB_Var_Shared::GetVarInterface1_2(); for (size_t i = 0; i < size_; ++i) { - vars_out_[i] = ppb_var->VarFromUtf8(strings_in_[i].c_str(), - strings_in_[i].length()); + vars_out_[i] = ppb_var->VarFromUtf8( + strings_in_[i].c_str(), + static_cast<uint32_t>(strings_in_[i].length())); strings_out_[i] = VarToString(vars_out_[i], ppb_var); } } diff --git a/chromium/ppapi/proxy/ppb_video_decoder_proxy.cc b/chromium/ppapi/proxy/ppb_video_decoder_proxy.cc index 7699c84ecaa..e63423d6460 100644 --- a/chromium/ppapi/proxy/ppb_video_decoder_proxy.cc +++ b/chromium/ppapi/proxy/ppb_video_decoder_proxy.cc @@ -5,6 +5,7 @@ #include "ppapi/proxy/ppb_video_decoder_proxy.h" #include "base/logging.h" +#include "base/numerics/safe_conversions.h" #include "gpu/command_buffer/client/gles2_implementation.h" #include "ppapi/proxy/enter_proxy.h" #include "ppapi/proxy/plugin_dispatcher.h" @@ -27,21 +28,21 @@ class VideoDecoder : public PPB_VideoDecoder_Shared { public: // You must call Init() before using this class. explicit VideoDecoder(const HostResource& resource); - virtual ~VideoDecoder(); + ~VideoDecoder() override; static VideoDecoder* Create(const HostResource& resource, PP_Resource graphics_context, PP_VideoDecoder_Profile profile); // PPB_VideoDecoder_Dev_API implementation. - virtual int32_t Decode(const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, - scoped_refptr<TrackedCallback> callback) override; - virtual void AssignPictureBuffers( - uint32_t no_of_buffers, const PP_PictureBuffer_Dev* buffers) override; - virtual void ReusePictureBuffer(int32_t picture_buffer_id) override; - virtual int32_t Flush(scoped_refptr<TrackedCallback> callback) override; - virtual int32_t Reset(scoped_refptr<TrackedCallback> callback) override; - virtual void Destroy() override; + int32_t Decode(const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, + scoped_refptr<TrackedCallback> callback) override; + void AssignPictureBuffers(uint32_t no_of_buffers, + const PP_PictureBuffer_Dev* buffers) override; + void ReusePictureBuffer(int32_t picture_buffer_id) override; + int32_t Flush(scoped_refptr<TrackedCallback> callback) override; + int32_t Reset(scoped_refptr<TrackedCallback> callback) override; + void Destroy() override; private: friend class PPB_VideoDecoder_Proxy; @@ -247,7 +248,8 @@ void PPB_VideoDecoder_Proxy::OnMsgAssignPictureBuffers( EnterHostFromHostResource<PPB_VideoDecoder_Dev_API> enter(decoder); if (enter.succeeded() && !buffers.empty()) { const PP_PictureBuffer_Dev* buffer_array = &buffers.front(); - enter.object()->AssignPictureBuffers(buffers.size(), buffer_array); + enter.object()->AssignPictureBuffers( + base::checked_cast<uint32_t>(buffers.size()), buffer_array); } } diff --git a/chromium/ppapi/proxy/ppb_x509_certificate_private_proxy.cc b/chromium/ppapi/proxy/ppb_x509_certificate_private_proxy.cc index bebea910710..df58f43a6bd 100644 --- a/chromium/ppapi/proxy/ppb_x509_certificate_private_proxy.cc +++ b/chromium/ppapi/proxy/ppb_x509_certificate_private_proxy.cc @@ -17,10 +17,10 @@ namespace { class X509CertificatePrivate : public PPB_X509Certificate_Private_Shared { public: X509CertificatePrivate(PP_Instance instance); - virtual ~X509CertificatePrivate(); + ~X509CertificatePrivate() override; - virtual bool ParseDER(const std::vector<char>& der, - PPB_X509Certificate_Fields* result) override; + bool ParseDER(const std::vector<char>& der, + PPB_X509Certificate_Fields* result) override; private: void SendToBrowser(IPC::Message* msg); diff --git a/chromium/ppapi/proxy/ppb_x509_certificate_private_proxy.h b/chromium/ppapi/proxy/ppb_x509_certificate_private_proxy.h index b9ad5dfdf3d..95d8f2cdc64 100644 --- a/chromium/ppapi/proxy/ppb_x509_certificate_private_proxy.h +++ b/chromium/ppapi/proxy/ppb_x509_certificate_private_proxy.h @@ -18,11 +18,11 @@ class PPB_X509Certificate_Private_Proxy : public InterfaceProxy { public: explicit PPB_X509Certificate_Private_Proxy(Dispatcher* dispatcher); - virtual ~PPB_X509Certificate_Private_Proxy(); + ~PPB_X509Certificate_Private_Proxy() override; static PP_Resource CreateProxyResource(PP_Instance instance); // InterfaceProxy implementation. - virtual bool OnMessageReceived(const IPC::Message& msg) override; + bool OnMessageReceived(const IPC::Message& msg) override; static const ApiID kApiID = API_ID_PPB_X509_CERTIFICATE_PRIVATE; diff --git a/chromium/ppapi/proxy/ppp_content_decryptor_private_proxy.cc b/chromium/ppapi/proxy/ppp_content_decryptor_private_proxy.cc index e956d12e526..3f6315f0794 100644 --- a/chromium/ppapi/proxy/ppp_content_decryptor_private_proxy.cc +++ b/chromium/ppapi/proxy/ppp_content_decryptor_private_proxy.cc @@ -112,18 +112,20 @@ bool InitializePppDecryptorBuffer(PP_Instance instance, } void Initialize(PP_Instance instance, - PP_Var key_system) { + uint32_t promise_id, + PP_Var key_system, + PP_Bool allow_distinctive_identifier, + PP_Bool allow_persistent_state) { HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); if (!dispatcher) { NOTREACHED(); return; } - dispatcher->Send( - new PpapiMsg_PPPContentDecryptor_Initialize( - API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, - instance, - SerializedVarSendInput(dispatcher, key_system))); + dispatcher->Send(new PpapiMsg_PPPContentDecryptor_Initialize( + API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, instance, promise_id, + SerializedVarSendInput(dispatcher, key_system), + allow_distinctive_identifier, allow_persistent_state)); } void SetServerCertificate(PP_Instance instance, @@ -160,29 +162,28 @@ void SetServerCertificate(PP_Instance instance, server_certificate_vector)); } -void CreateSession(PP_Instance instance, - uint32_t promise_id, - PP_Var init_data_type, - PP_Var init_data, - PP_SessionType session_type) { +void CreateSessionAndGenerateRequest(PP_Instance instance, + uint32_t promise_id, + PP_SessionType session_type, + PP_InitDataType init_data_type, + PP_Var init_data) { HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); if (!dispatcher) { NOTREACHED(); return; } - dispatcher->Send(new PpapiMsg_PPPContentDecryptor_CreateSession( - API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, - instance, - promise_id, - SerializedVarSendInput(dispatcher, init_data_type), - SerializedVarSendInput(dispatcher, init_data), - session_type)); + dispatcher->Send( + new PpapiMsg_PPPContentDecryptor_CreateSessionAndGenerateRequest( + API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, instance, promise_id, + session_type, init_data_type, + SerializedVarSendInput(dispatcher, init_data))); } void LoadSession(PP_Instance instance, uint32_t promise_id, - PP_Var web_session_id) { + PP_SessionType session_type, + PP_Var session_id) { HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); if (!dispatcher) { NOTREACHED(); @@ -190,15 +191,13 @@ void LoadSession(PP_Instance instance, } dispatcher->Send(new PpapiMsg_PPPContentDecryptor_LoadSession( - API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, - instance, - promise_id, - SerializedVarSendInput(dispatcher, web_session_id))); + API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, instance, promise_id, session_type, + SerializedVarSendInput(dispatcher, session_id))); } void UpdateSession(PP_Instance instance, uint32_t promise_id, - PP_Var web_session_id, + PP_Var session_id, PP_Var response) { HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); if (!dispatcher) { @@ -207,80 +206,53 @@ void UpdateSession(PP_Instance instance, } dispatcher->Send(new PpapiMsg_PPPContentDecryptor_UpdateSession( - API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, - instance, - promise_id, - SerializedVarSendInput(dispatcher, web_session_id), + API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, instance, promise_id, + SerializedVarSendInput(dispatcher, session_id), SerializedVarSendInput(dispatcher, response))); } void CloseSession(PP_Instance instance, uint32_t promise_id, - PP_Var web_session_id) { + PP_Var session_id) { HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); if (!dispatcher) { NOTREACHED(); return; } - StringVar* session_id = StringVar::FromPPVar(web_session_id); - if (!session_id || - session_id->value().length() > media::limits::kMaxWebSessionIdLength) { + StringVar* session_id_string = StringVar::FromPPVar(session_id); + if (!session_id_string || + session_id_string->value().length() > + media::limits::kMaxSessionIdLength) { NOTREACHED(); return; } dispatcher->Send(new PpapiMsg_PPPContentDecryptor_CloseSession( - API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, - instance, - promise_id, - session_id->value())); + API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, instance, promise_id, + session_id_string->value())); } void RemoveSession(PP_Instance instance, uint32_t promise_id, - PP_Var web_session_id) { + PP_Var session_id) { HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); if (!dispatcher) { NOTREACHED(); return; } - StringVar* session_id = StringVar::FromPPVar(web_session_id); - if (!session_id || - session_id->value().length() > media::limits::kMaxWebSessionIdLength) { + StringVar* session_id_string = StringVar::FromPPVar(session_id); + if (!session_id_string || + session_id_string->value().length() > + media::limits::kMaxSessionIdLength) { NOTREACHED(); return; } dispatcher->Send(new PpapiMsg_PPPContentDecryptor_RemoveSession( - API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, - instance, - promise_id, - session_id->value())); -} - -void GetUsableKeyIds(PP_Instance instance, - uint32_t promise_id, - PP_Var web_session_id) { - HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); - if (!dispatcher) { - NOTREACHED(); - return; - } - - StringVar* session_id = StringVar::FromPPVar(web_session_id); - if (!session_id || - session_id->value().length() > media::limits::kMaxWebSessionIdLength) { - NOTREACHED(); - return; - } - - dispatcher->Send(new PpapiMsg_PPPContentDecryptor_GetUsableKeyIds( - API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, - instance, - promise_id, - session_id->value())); + API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, instance, promise_id, + session_id_string->value())); } void Decrypt(PP_Instance instance, @@ -473,12 +445,11 @@ void DecryptAndDecode(PP_Instance instance, static const PPP_ContentDecryptor_Private content_decryptor_interface = { &Initialize, &SetServerCertificate, - &CreateSession, + &CreateSessionAndGenerateRequest, &LoadSession, &UpdateSession, &CloseSession, &RemoveSession, - &GetUsableKeyIds, &Decrypt, &InitializeAudioDecoder, &InitializeVideoDecoder, @@ -520,8 +491,9 @@ bool PPP_ContentDecryptor_Private_Proxy::OnMessageReceived( OnMsgInitialize) IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_SetServerCertificate, OnMsgSetServerCertificate) - IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CreateSession, - OnMsgCreateSession) + IPC_MESSAGE_HANDLER( + PpapiMsg_PPPContentDecryptor_CreateSessionAndGenerateRequest, + OnMsgCreateSessionAndGenerateRequest) IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_LoadSession, OnMsgLoadSession) IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_UpdateSession, @@ -530,8 +502,6 @@ bool PPP_ContentDecryptor_Private_Proxy::OnMessageReceived( OnMsgCloseSession) IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_RemoveSession, OnMsgRemoveSession) - IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_GetUsableKeyIds, - OnMsgGetUsableKeyIds) IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Decrypt, OnMsgDecrypt) IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_InitializeAudioDecoder, @@ -552,12 +522,14 @@ bool PPP_ContentDecryptor_Private_Proxy::OnMessageReceived( void PPP_ContentDecryptor_Private_Proxy::OnMsgInitialize( PP_Instance instance, - SerializedVarReceiveInput key_system) { + uint32_t promise_id, + SerializedVarReceiveInput key_system, + PP_Bool allow_distinctive_identifier, + PP_Bool allow_persistent_state) { if (ppp_decryptor_impl_) { - CallWhileUnlocked( - ppp_decryptor_impl_->Initialize, - instance, - ExtractReceivedVarAndAddRef(dispatcher(), &key_system)); + CallWhileUnlocked(ppp_decryptor_impl_->Initialize, instance, promise_id, + ExtractReceivedVarAndAddRef(dispatcher(), &key_system), + allow_distinctive_identifier, allow_persistent_state); } } @@ -576,8 +548,9 @@ void PPP_ContentDecryptor_Private_Proxy::OnMsgSetServerCertificate( ScopedPPVar::PassRef(), PpapiGlobals::Get() ->GetVarTracker() - ->MakeArrayBufferPPVar(server_certificate.size(), - &server_certificate[0])); + ->MakeArrayBufferPPVar( + static_cast<uint32_t>(server_certificate.size()), + &server_certificate[0])); CallWhileUnlocked(ppp_decryptor_impl_->SetServerCertificate, instance, promise_id, @@ -585,90 +558,64 @@ void PPP_ContentDecryptor_Private_Proxy::OnMsgSetServerCertificate( } } -void PPP_ContentDecryptor_Private_Proxy::OnMsgCreateSession( +void PPP_ContentDecryptor_Private_Proxy::OnMsgCreateSessionAndGenerateRequest( PP_Instance instance, uint32_t promise_id, - SerializedVarReceiveInput init_data_type, - SerializedVarReceiveInput init_data, - PP_SessionType session_type) { + PP_SessionType session_type, + PP_InitDataType init_data_type, + SerializedVarReceiveInput init_data) { if (ppp_decryptor_impl_) { - CallWhileUnlocked( - ppp_decryptor_impl_->CreateSession, - instance, - promise_id, - ExtractReceivedVarAndAddRef(dispatcher(), &init_data_type), - ExtractReceivedVarAndAddRef(dispatcher(), &init_data), - session_type); + CallWhileUnlocked(ppp_decryptor_impl_->CreateSessionAndGenerateRequest, + instance, promise_id, session_type, init_data_type, + ExtractReceivedVarAndAddRef(dispatcher(), &init_data)); } } void PPP_ContentDecryptor_Private_Proxy::OnMsgLoadSession( PP_Instance instance, uint32_t promise_id, - SerializedVarReceiveInput web_session_id) { + PP_SessionType session_type, + SerializedVarReceiveInput session_id) { if (ppp_decryptor_impl_) { - CallWhileUnlocked( - ppp_decryptor_impl_->LoadSession, - instance, - promise_id, - ExtractReceivedVarAndAddRef(dispatcher(), &web_session_id)); + CallWhileUnlocked(ppp_decryptor_impl_->LoadSession, instance, promise_id, + session_type, + ExtractReceivedVarAndAddRef(dispatcher(), &session_id)); } } void PPP_ContentDecryptor_Private_Proxy::OnMsgUpdateSession( PP_Instance instance, uint32_t promise_id, - SerializedVarReceiveInput web_session_id, + SerializedVarReceiveInput session_id, SerializedVarReceiveInput response) { if (ppp_decryptor_impl_) { - CallWhileUnlocked( - ppp_decryptor_impl_->UpdateSession, - instance, - promise_id, - ExtractReceivedVarAndAddRef(dispatcher(), &web_session_id), - ExtractReceivedVarAndAddRef(dispatcher(), &response)); + CallWhileUnlocked(ppp_decryptor_impl_->UpdateSession, instance, promise_id, + ExtractReceivedVarAndAddRef(dispatcher(), &session_id), + ExtractReceivedVarAndAddRef(dispatcher(), &response)); } } void PPP_ContentDecryptor_Private_Proxy::OnMsgCloseSession( PP_Instance instance, uint32_t promise_id, - const std::string& web_session_id) { + const std::string& session_id) { if (ppp_decryptor_impl_) { - ScopedPPVar web_session_id_var(ScopedPPVar::PassRef(), - StringVar::StringToPPVar(web_session_id)); - CallWhileUnlocked(ppp_decryptor_impl_->CloseSession, - instance, - promise_id, - web_session_id_var.get()); + ScopedPPVar session_id_var(ScopedPPVar::PassRef(), + StringVar::StringToPPVar(session_id)); + CallWhileUnlocked(ppp_decryptor_impl_->CloseSession, instance, promise_id, + session_id_var.get()); } } void PPP_ContentDecryptor_Private_Proxy::OnMsgRemoveSession( PP_Instance instance, uint32_t promise_id, - const std::string& web_session_id) { - if (ppp_decryptor_impl_) { - ScopedPPVar web_session_id_var(ScopedPPVar::PassRef(), - StringVar::StringToPPVar(web_session_id)); - CallWhileUnlocked(ppp_decryptor_impl_->RemoveSession, - instance, - promise_id, - web_session_id_var.get()); - } -} - -void PPP_ContentDecryptor_Private_Proxy::OnMsgGetUsableKeyIds( - PP_Instance instance, - uint32_t promise_id, - const std::string& web_session_id) { + const std::string& session_id) { if (ppp_decryptor_impl_) { - ScopedPPVar web_session_id_var(ScopedPPVar::PassRef(), - StringVar::StringToPPVar(web_session_id)); - CallWhileUnlocked(ppp_decryptor_impl_->GetUsableKeyIds, - instance, - promise_id, - web_session_id_var.get()); + ScopedPPVar session_id_var(ScopedPPVar::PassRef(), + StringVar::StringToPPVar(session_id)); + CallWhileUnlocked(ppp_decryptor_impl_->RemoveSession, instance, promise_id, + session_id_var.get()); } } diff --git a/chromium/ppapi/proxy/ppp_content_decryptor_private_proxy.h b/chromium/ppapi/proxy/ppp_content_decryptor_private_proxy.h index 217a9b9ed52..0df8734ca24 100644 --- a/chromium/ppapi/proxy/ppp_content_decryptor_private_proxy.h +++ b/chromium/ppapi/proxy/ppp_content_decryptor_private_proxy.h @@ -32,31 +32,33 @@ class PPP_ContentDecryptor_Private_Proxy : public InterfaceProxy { // Message handlers. void OnMsgInitialize(PP_Instance instance, - SerializedVarReceiveInput key_system); + uint32_t promise_id, + SerializedVarReceiveInput key_system, + PP_Bool allow_distinctive_identifier, + PP_Bool allow_persistent_state); void OnMsgSetServerCertificate(PP_Instance instance, uint32_t promise_id, std::vector<uint8_t> server_certificate); - void OnMsgCreateSession(PP_Instance instance, - uint32_t promise_id, - SerializedVarReceiveInput init_data_type, - SerializedVarReceiveInput init_data, - PP_SessionType session_type); + void OnMsgCreateSessionAndGenerateRequest( + PP_Instance instance, + uint32_t promise_id, + PP_SessionType session_type, + PP_InitDataType init_data_type, + SerializedVarReceiveInput init_data); void OnMsgLoadSession(PP_Instance instance, uint32_t promise_id, - SerializedVarReceiveInput web_session_id); + PP_SessionType session_type, + SerializedVarReceiveInput session_id); void OnMsgUpdateSession(PP_Instance instance, uint32_t promise_id, - SerializedVarReceiveInput web_session_id, + SerializedVarReceiveInput session_id, SerializedVarReceiveInput response); void OnMsgCloseSession(PP_Instance instance, uint32_t promise_id, - const std::string& web_session_id); + const std::string& session_id); void OnMsgRemoveSession(PP_Instance instance, uint32_t promise_id, - const std::string& web_session_id); - void OnMsgGetUsableKeyIds(PP_Instance instance, - uint32_t promise_id, - const std::string& web_session_id); + const std::string& session_id); void OnMsgDecrypt(PP_Instance instance, const PPPDecryptor_Buffer& encrypted_buffer, const std::string& serialized_encrypted_block_info); diff --git a/chromium/ppapi/proxy/ppp_instance_private_proxy_unittest.cc b/chromium/ppapi/proxy/ppp_instance_private_proxy_unittest.cc index e373c48d2e8..8b758d9084f 100644 --- a/chromium/ppapi/proxy/ppp_instance_private_proxy_unittest.cc +++ b/chromium/ppapi/proxy/ppp_instance_private_proxy_unittest.cc @@ -25,11 +25,11 @@ namespace ppapi { class V8ObjectVar : public ppapi::Var { public: V8ObjectVar() {} - virtual ~V8ObjectVar() {} + ~V8ObjectVar() override {} // Var overrides. - virtual V8ObjectVar* AsV8ObjectVar() override { return this; } - virtual PP_VarType GetType() const override { return PP_VARTYPE_OBJECT; } + V8ObjectVar* AsV8ObjectVar() override { return this; } + PP_VarType GetType() const override { return PP_VARTYPE_OBJECT; } }; namespace proxy { diff --git a/chromium/ppapi/proxy/ppp_instance_proxy_unittest.cc b/chromium/ppapi/proxy/ppp_instance_proxy_unittest.cc index e2df26e250f..18ec91993e5 100644 --- a/chromium/ppapi/proxy/ppp_instance_proxy_unittest.cc +++ b/chromium/ppapi/proxy/ppp_instance_proxy_unittest.cc @@ -140,7 +140,7 @@ TEST_F(PPP_Instance_ProxyTest, PPPInstance1_0) { argn_to_pass.push_back(expected_argn[i].c_str()); argv_to_pass.push_back(expected_argv[i].c_str()); } - uint32_t expected_argc = expected_argn.size(); + uint32_t expected_argc = static_cast<uint32_t>(expected_argn.size()); bool_to_return = PP_TRUE; ResetReceived(); // Tell the host resource tracker about the instance. diff --git a/chromium/ppapi/proxy/ppp_messaging_proxy.h b/chromium/ppapi/proxy/ppp_messaging_proxy.h index 90b674c453a..f232c6ba528 100644 --- a/chromium/ppapi/proxy/ppp_messaging_proxy.h +++ b/chromium/ppapi/proxy/ppp_messaging_proxy.h @@ -18,10 +18,10 @@ class SerializedVarReceiveInput; class PPP_Messaging_Proxy : public InterfaceProxy { public: PPP_Messaging_Proxy(Dispatcher* dispatcher); - virtual ~PPP_Messaging_Proxy(); + ~PPP_Messaging_Proxy() override; // InterfaceProxy implementation. - virtual bool OnMessageReceived(const IPC::Message& msg) override; + bool OnMessageReceived(const IPC::Message& msg) override; private: // Message handlers. diff --git a/chromium/ppapi/proxy/ppp_messaging_proxy_perftest.cc b/chromium/ppapi/proxy/ppp_messaging_proxy_perftest.cc index c5265145949..b64434341a2 100644 --- a/chromium/ppapi/proxy/ppp_messaging_proxy_perftest.cc +++ b/chromium/ppapi/proxy/ppp_messaging_proxy_perftest.cc @@ -56,7 +56,7 @@ TEST_F(PppMessagingPerfTest, StringPerformance) { int seed = 123; int string_count = 1000; int max_string_size = 1000000; - CommandLine* command_line = CommandLine::ForCurrentProcess(); + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); if (command_line) { if (command_line->HasSwitch("seed")) { base::StringToInt(command_line->GetSwitchValueASCII("seed"), diff --git a/chromium/ppapi/proxy/ppp_mouse_lock_proxy.h b/chromium/ppapi/proxy/ppp_mouse_lock_proxy.h index 3685e82af02..f04d7f359a4 100644 --- a/chromium/ppapi/proxy/ppp_mouse_lock_proxy.h +++ b/chromium/ppapi/proxy/ppp_mouse_lock_proxy.h @@ -16,12 +16,12 @@ namespace proxy { class PPP_MouseLock_Proxy : public InterfaceProxy { public: PPP_MouseLock_Proxy(Dispatcher* dispatcher); - virtual ~PPP_MouseLock_Proxy(); + ~PPP_MouseLock_Proxy() override; static const PPP_MouseLock* GetProxyInterface(); // InterfaceProxy implementation. - virtual bool OnMessageReceived(const IPC::Message& msg) override; + bool OnMessageReceived(const IPC::Message& msg) override; private: // Message handlers. diff --git a/chromium/ppapi/proxy/ppp_pdf_proxy.cc b/chromium/ppapi/proxy/ppp_pdf_proxy.cc index 356b42f0ebd..4b16dd6b66a 100644 --- a/chromium/ppapi/proxy/ppp_pdf_proxy.cc +++ b/chromium/ppapi/proxy/ppp_pdf_proxy.cc @@ -25,9 +25,20 @@ void Transform(PP_Instance instance, PP_PrivatePageTransformType type) { new PpapiMsg_PPPPdf_Rotate(API_ID_PPP_PDF, instance, clockwise)); } +PP_Bool GetPrintPresetOptionsFromDocument( + PP_Instance instance, + PP_PdfPrintPresetOptions_Dev* options) { + PP_Bool ret = PP_FALSE; + HostDispatcher::GetForInstance(instance) + ->Send(new PpapiMsg_PPPPdf_PrintPresetOptions( + API_ID_PPP_PDF, instance, options, &ret)); + return ret; +} + const PPP_Pdf ppp_pdf_interface = { &GetLinkAtPosition, &Transform, + &GetPrintPresetOptionsFromDocument }; #else // The NaCl plugin doesn't need the host side interface - stub it out. @@ -60,6 +71,8 @@ bool PPP_Pdf_Proxy::OnMessageReceived(const IPC::Message& msg) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(PPP_Pdf_Proxy, msg) IPC_MESSAGE_HANDLER(PpapiMsg_PPPPdf_Rotate, OnPluginMsgRotate) + IPC_MESSAGE_HANDLER(PpapiMsg_PPPPdf_PrintPresetOptions, + OnPluginMsgPrintPresetOptions) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; @@ -73,5 +86,15 @@ void PPP_Pdf_Proxy::OnPluginMsgRotate(PP_Instance instance, bool clockwise) { CallWhileUnlocked(ppp_pdf_->Transform, instance, type); } +void PPP_Pdf_Proxy::OnPluginMsgPrintPresetOptions( + PP_Instance instance, + PP_PdfPrintPresetOptions_Dev* options, + PP_Bool* result) { + if (ppp_pdf_) { + *result = CallWhileUnlocked( + ppp_pdf_->GetPrintPresetOptionsFromDocument, instance, options); + } +} + } // namespace proxy } // namespace ppapi diff --git a/chromium/ppapi/proxy/ppp_pdf_proxy.h b/chromium/ppapi/proxy/ppp_pdf_proxy.h index 992b2248811..2544c0f5230 100644 --- a/chromium/ppapi/proxy/ppp_pdf_proxy.h +++ b/chromium/ppapi/proxy/ppp_pdf_proxy.h @@ -25,6 +25,9 @@ class PPP_Pdf_Proxy : public InterfaceProxy { private: // Message handlers. void OnPluginMsgRotate(PP_Instance instance, bool clockwise); + void OnPluginMsgPrintPresetOptions(PP_Instance instance, + PP_PdfPrintPresetOptions_Dev* options, + PP_Bool* result); // When this proxy is in the plugin side, this value caches the interface // pointer so we don't have to retrieve it from the dispatcher each time. diff --git a/chromium/ppapi/proxy/ppp_printing_proxy.cc b/chromium/ppapi/proxy/ppp_printing_proxy.cc index 7b2ae55d927..81710efcc5f 100644 --- a/chromium/ppapi/proxy/ppp_printing_proxy.cc +++ b/chromium/ppapi/proxy/ppp_printing_proxy.cc @@ -6,9 +6,11 @@ #include <string.h> +#include "base/numerics/safe_conversions.h" #include "ppapi/c/dev/ppp_printing_dev.h" #include "ppapi/proxy/host_dispatcher.h" #include "ppapi/proxy/plugin_dispatcher.h" +#include "ppapi/proxy/plugin_resource_tracker.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/shared_impl/ppapi_globals.h" #include "ppapi/shared_impl/proxy_lock.h" @@ -66,15 +68,11 @@ PP_Resource PrintPages(PP_Instance instance, new PpapiMsg_PPPPrinting_PrintPages(API_ID_PPP_PRINTING, instance, pages, &result)); - // How refcounting works when returning a resource: - // - // The plugin in the plugin process makes a resource that it returns to the - // browser. The plugin proxy code returns that ref to us and asynchronously - // releases it. Before any release message associated with that operation - // comes, we'll get this reply. We need to add one ref since our caller - // expects us to add one ref for it to consume. - PpapiGlobals::Get()->GetResourceTracker()->AddRefResource( - result.host_resource()); + // Explicilty don't add a reference to the received resource here. The plugin + // adds a ref during creation of the resource and it will "abandon" the + // resource to release it, which ensures that the initial ref won't be + // decremented. See the comment below in OnPluginMsgPrintPages. + return result.host_resource(); } @@ -180,7 +178,7 @@ void PPP_Printing_Proxy::OnPluginMsgPrintPages( PP_Resource plugin_resource = CallWhileUnlocked( ppp_printing_impl_->PrintPages, - instance, &pages[0], pages.size()); + instance, &pages[0], base::checked_cast<uint32_t>(pages.size())); ResourceTracker* resource_tracker = PpapiGlobals::Get()->GetResourceTracker(); Resource* resource_object = resource_tracker->GetResource(plugin_resource); if (!resource_object) @@ -188,8 +186,17 @@ void PPP_Printing_Proxy::OnPluginMsgPrintPages( *result = resource_object->host_resource(); - // See PrintPages above for how refcounting works. - resource_tracker->ReleaseResourceSoon(plugin_resource); + // Abandon the resource on the plugin side. This releases a reference to the + // resource and allows the plugin side of the resource (the proxy resource) to + // be destroyed without sending a message to the renderer notifing it that the + // plugin has released the resource. This used to call + // ResourceTracker::ReleaseResource directly which would trigger an IPC to be + // sent to the renderer to remove a ref to the resource. However due to + // arbitrary ordering of received sync/async IPCs in the renderer, this + // sometimes resulted in the resource being destroyed in the renderer before + // the renderer had a chance to add a reference to it. See crbug.com/490611. + static_cast<PluginResourceTracker*>(resource_tracker) + ->AbandonResource(plugin_resource); } void PPP_Printing_Proxy::OnPluginMsgEnd(PP_Instance instance) { diff --git a/chromium/ppapi/proxy/ppp_text_input_proxy.h b/chromium/ppapi/proxy/ppp_text_input_proxy.h index 59c7a9d8076..0ae023c71e9 100644 --- a/chromium/ppapi/proxy/ppp_text_input_proxy.h +++ b/chromium/ppapi/proxy/ppp_text_input_proxy.h @@ -16,12 +16,12 @@ namespace proxy { class PPP_TextInput_Proxy : public InterfaceProxy { public: PPP_TextInput_Proxy(Dispatcher* dispatcher); - virtual ~PPP_TextInput_Proxy(); + ~PPP_TextInput_Proxy() override; static const PPP_TextInput_Dev* GetProxyInterface(); // InterfaceProxy implementation. - virtual bool OnMessageReceived(const IPC::Message& msg) override; + bool OnMessageReceived(const IPC::Message& msg) override; private: // Message handlers. diff --git a/chromium/ppapi/proxy/printing_resource.h b/chromium/ppapi/proxy/printing_resource.h index 0ea677544df..deaa1f5cb78 100644 --- a/chromium/ppapi/proxy/printing_resource.h +++ b/chromium/ppapi/proxy/printing_resource.h @@ -20,13 +20,13 @@ class PPAPI_PROXY_EXPORT PrintingResource public: PrintingResource(Connection connection, PP_Instance instance); - virtual ~PrintingResource(); + ~PrintingResource() override; // Resource overrides. - virtual thunk::PPB_Printing_API* AsPPB_Printing_API() override; + thunk::PPB_Printing_API* AsPPB_Printing_API() override; // PPB_Printing_API. - virtual int32_t GetDefaultPrintSettings( + int32_t GetDefaultPrintSettings( PP_PrintSettings_Dev* print_settings, scoped_refptr<TrackedCallback> callback) override; diff --git a/chromium/ppapi/proxy/proxy_channel.h b/chromium/ppapi/proxy/proxy_channel.h index 97069beb367..ffa906ee3e6 100644 --- a/chromium/ppapi/proxy/proxy_channel.h +++ b/chromium/ppapi/proxy/proxy_channel.h @@ -52,7 +52,7 @@ class PPAPI_PROXY_EXPORT ProxyChannel bool should_close_source) = 0; }; - virtual ~ProxyChannel(); + ~ProxyChannel() override; // Alternative to InitWithChannel() for unit tests that want to send all // messages sent via this channel to the given test sink. The test sink @@ -71,10 +71,10 @@ class PPAPI_PROXY_EXPORT ProxyChannel bool should_close_source); // IPC::Sender implementation. - virtual bool Send(IPC::Message* msg) override; + bool Send(IPC::Message* msg) override; // IPC::Listener implementation. - virtual void OnChannelError() override; + void OnChannelError() override; // Will be NULL in some unit tests and if the remote side has crashed. IPC::SyncChannel* channel() const { diff --git a/chromium/ppapi/proxy/proxy_object_var.h b/chromium/ppapi/proxy/proxy_object_var.h index e90b29f3b2b..a3ba1533944 100644 --- a/chromium/ppapi/proxy/proxy_object_var.h +++ b/chromium/ppapi/proxy/proxy_object_var.h @@ -23,11 +23,11 @@ class PPAPI_PROXY_EXPORT ProxyObjectVar : public Var { ProxyObjectVar(proxy::PluginDispatcher* dispatcher, int32 host_var_id); - virtual ~ProxyObjectVar(); + ~ProxyObjectVar() override; // Var overrides. - virtual ProxyObjectVar* AsProxyObjectVar() override; - virtual PP_VarType GetType() const override; + ProxyObjectVar* AsProxyObjectVar() override; + PP_VarType GetType() const override; proxy::PluginDispatcher* dispatcher() const { return dispatcher_; } int32 host_var_id() const { return host_var_id_; } diff --git a/chromium/ppapi/proxy/raw_var_data.cc b/chromium/ppapi/proxy/raw_var_data.cc index 97a6d944ae5..ac925c9fd56 100644 --- a/chromium/ppapi/proxy/raw_var_data.cc +++ b/chromium/ppapi/proxy/raw_var_data.cc @@ -188,11 +188,11 @@ scoped_ptr<RawVarDataGraph> RawVarDataGraph::Read(const IPC::Message* m, PickleIterator* iter) { scoped_ptr<RawVarDataGraph> result(new RawVarDataGraph); uint32_t size = 0; - if (!m->ReadUInt32(iter, &size)) + if (!iter->ReadUInt32(&size)) return scoped_ptr<RawVarDataGraph>(); for (uint32_t i = 0; i < size; ++i) { int32_t type; - if (!m->ReadInt(iter, &type)) + if (!iter->ReadInt(&type)) return scoped_ptr<RawVarDataGraph>(); PP_VarType var_type = static_cast<PP_VarType>(type); result->data_.push_back(RawVarData::Create(var_type)); @@ -323,13 +323,13 @@ bool BasicRawVarData::Read(PP_VarType type, break; case PP_VARTYPE_BOOL: { bool bool_value; - if (!m->ReadBool(iter, &bool_value)) + if (!iter->ReadBool(&bool_value)) return false; result.value.as_bool = PP_FromBool(bool_value); break; } case PP_VARTYPE_INT32: - if (!m->ReadInt(iter, &result.value.as_int)) + if (!iter->ReadInt(&result.value.as_int)) return false; break; case PP_VARTYPE_DOUBLE: @@ -337,7 +337,7 @@ bool BasicRawVarData::Read(PP_VarType type, return false; break; case PP_VARTYPE_OBJECT: - if (!m->ReadInt64(iter, &result.value.as_id)) + if (!iter->ReadInt64(&result.value.as_id)) return false; break; default: @@ -385,7 +385,7 @@ void StringRawVarData::Write(IPC::Message* m, bool StringRawVarData::Read(PP_VarType type, const IPC::Message* m, PickleIterator* iter) { - if (!m->ReadString(iter, &data_)) + if (!iter->ReadString(&data_)) return false; return true; } @@ -503,12 +503,12 @@ bool ArrayBufferRawVarData::Read(PP_VarType type, const IPC::Message* m, PickleIterator* iter) { int shmem_type; - if (!m->ReadInt(iter, &shmem_type)) + if (!iter->ReadInt(&shmem_type)) return false; type_ = static_cast<ShmemType>(shmem_type); switch (type_) { case ARRAY_BUFFER_SHMEM_HOST: - if (!m->ReadInt(iter, &host_shm_handle_id_)) + if (!iter->ReadInt(&host_shm_handle_id_)) return false; break; case ARRAY_BUFFER_SHMEM_PLUGIN: @@ -518,7 +518,7 @@ bool ArrayBufferRawVarData::Read(PP_VarType type, } break; case ARRAY_BUFFER_NO_SHMEM: - if (!m->ReadString(iter, &data_)) + if (!iter->ReadString(&data_)) return false; break; default: @@ -584,11 +584,11 @@ bool ArrayRawVarData::Read(PP_VarType type, const IPC::Message* m, PickleIterator* iter) { uint32_t size; - if (!m->ReadUInt32(iter, &size)) + if (!iter->ReadUInt32(&size)) return false; for (uint32_t i = 0; i < size; ++i) { uint32_t index; - if (!m->ReadUInt32(iter, &index)) + if (!iter->ReadUInt32(&index)) return false; children_.push_back(index); } @@ -650,14 +650,14 @@ bool DictionaryRawVarData::Read(PP_VarType type, const IPC::Message* m, PickleIterator* iter) { uint32_t size; - if (!m->ReadUInt32(iter, &size)) + if (!iter->ReadUInt32(&size)) return false; for (uint32_t i = 0; i < size; ++i) { std::string key; uint32_t value; - if (!m->ReadString(iter, &key)) + if (!iter->ReadString(&key)) return false; - if (!m->ReadUInt32(iter, &value)) + if (!iter->ReadUInt32(&value)) return false; children_.push_back(make_pair(key, value)); } @@ -727,15 +727,15 @@ bool ResourceRawVarData::Read(PP_VarType type, const IPC::Message* m, PickleIterator* iter) { int value; - if (!m->ReadInt(iter, &value)) + if (!iter->ReadInt(&value)) return false; pp_resource_ = static_cast<PP_Resource>(value); - if (!m->ReadInt(iter, &pending_renderer_host_id_)) + if (!iter->ReadInt(&pending_renderer_host_id_)) return false; - if (!m->ReadInt(iter, &pending_browser_host_id_)) + if (!iter->ReadInt(&pending_browser_host_id_)) return false; bool has_creation_message; - if (!m->ReadBool(iter, &has_creation_message)) + if (!iter->ReadBool(&has_creation_message)) return false; if (has_creation_message) { creation_message_.reset(new IPC::Message()); diff --git a/chromium/ppapi/proxy/raw_var_data.h b/chromium/ppapi/proxy/raw_var_data.h index 4387eb2d561..08b85fad02d 100644 --- a/chromium/ppapi/proxy/raw_var_data.h +++ b/chromium/ppapi/proxy/raw_var_data.h @@ -129,19 +129,18 @@ class RawVarData { class BasicRawVarData : public RawVarData { public: BasicRawVarData(); - virtual ~BasicRawVarData(); + ~BasicRawVarData() override; // RawVarData implementation. - virtual PP_VarType Type() override; - virtual bool Init(const PP_Var& var, PP_Instance instance) override; - virtual PP_Var CreatePPVar(PP_Instance instance) override; - virtual void PopulatePPVar(const PP_Var& var, - const std::vector<PP_Var>& graph) override; - virtual void Write(IPC::Message* m, - const HandleWriter& handle_writer) override; - virtual bool Read(PP_VarType type, - const IPC::Message* m, - PickleIterator* iter) override; + PP_VarType Type() override; + bool Init(const PP_Var& var, PP_Instance instance) override; + PP_Var CreatePPVar(PP_Instance instance) override; + void PopulatePPVar(const PP_Var& var, + const std::vector<PP_Var>& graph) override; + void Write(IPC::Message* m, const HandleWriter& handle_writer) override; + bool Read(PP_VarType type, + const IPC::Message* m, + PickleIterator* iter) override; private: PP_Var var_; @@ -151,19 +150,18 @@ class BasicRawVarData : public RawVarData { class StringRawVarData : public RawVarData { public: StringRawVarData(); - virtual ~StringRawVarData(); + ~StringRawVarData() override; // RawVarData implementation. - virtual PP_VarType Type() override; - virtual bool Init(const PP_Var& var, PP_Instance instance) override; - virtual PP_Var CreatePPVar(PP_Instance instance) override; - virtual void PopulatePPVar(const PP_Var& var, - const std::vector<PP_Var>& graph) override; - virtual void Write(IPC::Message* m, - const HandleWriter& handle_writer) override; - virtual bool Read(PP_VarType type, - const IPC::Message* m, - PickleIterator* iter) override; + PP_VarType Type() override; + bool Init(const PP_Var& var, PP_Instance instance) override; + PP_Var CreatePPVar(PP_Instance instance) override; + void PopulatePPVar(const PP_Var& var, + const std::vector<PP_Var>& graph) override; + void Write(IPC::Message* m, const HandleWriter& handle_writer) override; + bool Read(PP_VarType type, + const IPC::Message* m, + PickleIterator* iter) override; private: // The data in the string. @@ -181,20 +179,19 @@ class ArrayBufferRawVarData : public RawVarData { }; ArrayBufferRawVarData(); - virtual ~ArrayBufferRawVarData(); + ~ArrayBufferRawVarData() override; // RawVarData implementation. - virtual PP_VarType Type() override; - virtual bool Init(const PP_Var& var, PP_Instance instance) override; - virtual PP_Var CreatePPVar(PP_Instance instance) override; - virtual void PopulatePPVar(const PP_Var& var, - const std::vector<PP_Var>& graph) override; - virtual void Write(IPC::Message* m, - const HandleWriter& handle_writer) override; - virtual bool Read(PP_VarType type, - const IPC::Message* m, - PickleIterator* iter) override; - virtual SerializedHandle* GetHandle() override; + PP_VarType Type() override; + bool Init(const PP_Var& var, PP_Instance instance) override; + PP_Var CreatePPVar(PP_Instance instance) override; + void PopulatePPVar(const PP_Var& var, + const std::vector<PP_Var>& graph) override; + void Write(IPC::Message* m, const HandleWriter& handle_writer) override; + bool Read(PP_VarType type, + const IPC::Message* m, + PickleIterator* iter) override; + SerializedHandle* GetHandle() override; private: // The type of the storage underlying the array buffer. @@ -211,21 +208,20 @@ class ArrayBufferRawVarData : public RawVarData { class ArrayRawVarData : public RawVarData { public: ArrayRawVarData(); - virtual ~ArrayRawVarData(); + ~ArrayRawVarData() override; void AddChild(size_t element); // RawVarData implementation. - virtual PP_VarType Type() override; - virtual bool Init(const PP_Var& var, PP_Instance instance) override; - virtual PP_Var CreatePPVar(PP_Instance instance) override; - virtual void PopulatePPVar(const PP_Var& var, - const std::vector<PP_Var>& graph) override; - virtual void Write(IPC::Message* m, - const HandleWriter& handle_writer) override; - virtual bool Read(PP_VarType type, - const IPC::Message* m, - PickleIterator* iter) override; + PP_VarType Type() override; + bool Init(const PP_Var& var, PP_Instance instance) override; + PP_Var CreatePPVar(PP_Instance instance) override; + void PopulatePPVar(const PP_Var& var, + const std::vector<PP_Var>& graph) override; + void Write(IPC::Message* m, const HandleWriter& handle_writer) override; + bool Read(PP_VarType type, + const IPC::Message* m, + PickleIterator* iter) override; private: std::vector<size_t> children_; @@ -235,21 +231,20 @@ class ArrayRawVarData : public RawVarData { class DictionaryRawVarData : public RawVarData { public: DictionaryRawVarData(); - virtual ~DictionaryRawVarData(); + ~DictionaryRawVarData() override; void AddChild(const std::string& key, size_t value); // RawVarData implementation. - virtual PP_VarType Type() override; - virtual bool Init(const PP_Var& var, PP_Instance instance) override; - virtual PP_Var CreatePPVar(PP_Instance instance) override; - virtual void PopulatePPVar(const PP_Var& var, - const std::vector<PP_Var>& graph) override; - virtual void Write(IPC::Message* m, - const HandleWriter& handle_writer) override; - virtual bool Read(PP_VarType type, - const IPC::Message* m, - PickleIterator* iter) override; + PP_VarType Type() override; + bool Init(const PP_Var& var, PP_Instance instance) override; + PP_Var CreatePPVar(PP_Instance instance) override; + void PopulatePPVar(const PP_Var& var, + const std::vector<PP_Var>& graph) override; + void Write(IPC::Message* m, const HandleWriter& handle_writer) override; + bool Read(PP_VarType type, + const IPC::Message* m, + PickleIterator* iter) override; private: std::vector<std::pair<std::string, size_t> > children_; @@ -264,19 +259,18 @@ class DictionaryRawVarData : public RawVarData { class ResourceRawVarData : public RawVarData { public: ResourceRawVarData(); - virtual ~ResourceRawVarData(); + ~ResourceRawVarData() override; // RawVarData implementation. - virtual PP_VarType Type() override; - virtual bool Init(const PP_Var& var, PP_Instance instance) override; - virtual PP_Var CreatePPVar(PP_Instance instance) override; - virtual void PopulatePPVar(const PP_Var& var, - const std::vector<PP_Var>& graph) override; - virtual void Write(IPC::Message* m, - const HandleWriter& handle_writer) override; - virtual bool Read(PP_VarType type, - const IPC::Message* m, - PickleIterator* iter) override; + PP_VarType Type() override; + bool Init(const PP_Var& var, PP_Instance instance) override; + PP_Var CreatePPVar(PP_Instance instance) override; + void PopulatePPVar(const PP_Var& var, + const std::vector<PP_Var>& graph) override; + void Write(IPC::Message* m, const HandleWriter& handle_writer) override; + bool Read(PP_VarType type, + const IPC::Message* m, + PickleIterator* iter) override; private: // Resource ID in the plugin. If one has not yet been created, this is 0. diff --git a/chromium/ppapi/proxy/raw_var_data_unittest.cc b/chromium/ppapi/proxy/raw_var_data_unittest.cc index e1c56a3358d..f555990bc96 100644 --- a/chromium/ppapi/proxy/raw_var_data_unittest.cc +++ b/chromium/ppapi/proxy/raw_var_data_unittest.cc @@ -17,7 +17,7 @@ #include "ppapi/shared_impl/resource_var.h" #include "ppapi/shared_impl/scoped_pp_var.h" #include "ppapi/shared_impl/test_globals.h" -#include "ppapi/shared_impl/unittest_utils.h" +#include "ppapi/shared_impl/test_utils.h" #include "ppapi/shared_impl/var.h" #include "ppapi/shared_impl/var_tracker.h" #include "testing/gtest/include/gtest/gtest.h" @@ -38,7 +38,6 @@ class RawVarDataTest : public testing::Test { // testing::Test implementation. virtual void SetUp() { - ProxyLock::EnableLockingOnThreadForTest(); ProxyLock::Acquire(); } virtual void TearDown() { @@ -97,7 +96,7 @@ TEST_F(RawVarDataTest, StringTest) { TEST_F(RawVarDataTest, ArrayBufferTest) { std::string data = "hello world!"; PP_Var var = PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( - data.size(), data.data()); + static_cast<uint32_t>(data.size()), data.data()); EXPECT_TRUE(WriteReadAndCompare(var)); var = PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( 0, static_cast<void*>(NULL)); @@ -114,25 +113,25 @@ TEST_F(RawVarDataTest, DictionaryArrayTest) { size_t index = 0; // Array with primitives. - array->Set(index++, PP_MakeUndefined()); - array->Set(index++, PP_MakeNull()); - array->Set(index++, PP_MakeInt32(100)); - array->Set(index++, PP_MakeBool(PP_FALSE)); - array->Set(index++, PP_MakeDouble(0.123)); + array->Set(static_cast<uint32_t>(index++), PP_MakeUndefined()); + array->Set(static_cast<uint32_t>(index++), PP_MakeNull()); + array->Set(static_cast<uint32_t>(index++), PP_MakeInt32(100)); + array->Set(static_cast<uint32_t>(index++), PP_MakeBool(PP_FALSE)); + array->Set(static_cast<uint32_t>(index++), PP_MakeDouble(0.123)); EXPECT_TRUE(WriteReadAndCompare(array->GetPPVar())); // Array with 2 references to the same string. ScopedPPVar release_string( ScopedPPVar::PassRef(), StringVar::StringToPPVar("abc")); - array->Set(index++, release_string.get()); - array->Set(index++, release_string.get()); + array->Set(static_cast<uint32_t>(index++), release_string.get()); + array->Set(static_cast<uint32_t>(index++), release_string.get()); EXPECT_TRUE(WriteReadAndCompare(array->GetPPVar())); // Array with nested array that references the same string. scoped_refptr<ArrayVar> array2(new ArrayVar); ScopedPPVar release_array2(ScopedPPVar::PassRef(), array2->GetPPVar()); array2->Set(0, release_string.get()); - array->Set(index++, release_array2.get()); + array->Set(static_cast<uint32_t>(index++), release_array2.get()); EXPECT_TRUE(WriteReadAndCompare(array->GetPPVar())); // Empty dictionary. @@ -163,7 +162,7 @@ TEST_F(RawVarDataTest, DictionaryArrayTest) { EXPECT_TRUE(WriteReadAndCompare(dictionary->GetPPVar())); // Array with dictionary. - array->Set(index++, release_dictionary.get()); + array->Set(static_cast<uint32_t>(index++), release_dictionary.get()); EXPECT_TRUE(WriteReadAndCompare(array->GetPPVar())); // Array with dictionary with array. @@ -181,10 +180,10 @@ TEST_F(RawVarDataTest, DictionaryArrayTest) { dictionary->DeleteWithStringKey("10"); // Array with self references. - array->Set(index, release_array.get()); + array->Set(static_cast<uint32_t>(index), release_array.get()); ASSERT_FALSE(WriteAndRead(release_array.get(), &result)); // Break the self reference. - array->Set(index, PP_MakeUndefined()); + array->Set(static_cast<uint32_t>(index), PP_MakeUndefined()); } TEST_F(RawVarDataTest, ResourceTest) { diff --git a/chromium/ppapi/proxy/resource_creation_proxy.cc b/chromium/ppapi/proxy/resource_creation_proxy.cc index 99e890b1de9..e20eb9df203 100644 --- a/chromium/ppapi/proxy/resource_creation_proxy.cc +++ b/chromium/ppapi/proxy/resource_creation_proxy.cc @@ -7,6 +7,7 @@ #include "ppapi/c/pp_errors.h" #include "ppapi/c/pp_size.h" #include "ppapi/proxy/audio_input_resource.h" +#include "ppapi/proxy/camera_device_resource.h" #include "ppapi/proxy/compositor_resource.h" #include "ppapi/proxy/connection.h" #include "ppapi/proxy/file_chooser_resource.h" @@ -37,7 +38,6 @@ #include "ppapi/proxy/ppb_video_decoder_proxy.h" #include "ppapi/proxy/ppb_x509_certificate_private_proxy.h" #include "ppapi/proxy/printing_resource.h" -#include "ppapi/proxy/talk_resource.h" #include "ppapi/proxy/tcp_server_socket_private_resource.h" #include "ppapi/proxy/tcp_socket_private_resource.h" #include "ppapi/proxy/tcp_socket_resource.h" @@ -50,6 +50,7 @@ #include "ppapi/proxy/video_capture_resource.h" #include "ppapi/proxy/video_decoder_resource.h" #include "ppapi/proxy/video_destination_resource.h" +#include "ppapi/proxy/video_encoder_resource.h" #include "ppapi/proxy/video_source_resource.h" #include "ppapi/proxy/websocket_resource.h" #include "ppapi/shared_impl/api_id.h" @@ -220,6 +221,11 @@ PP_Resource ResourceCreationProxy::CreateAudioConfig( OBJECT_IS_PROXY, instance, sample_rate, sample_frame_count); } +PP_Resource ResourceCreationProxy::CreateCameraDevicePrivate( + PP_Instance instance) { + return (new CameraDeviceResource(GetConnection(), instance))->GetReference(); +} + PP_Resource ResourceCreationProxy::CreateCompositor(PP_Instance instance) { return (new CompositorResource(GetConnection(), instance))->GetReference(); } @@ -387,6 +393,10 @@ PP_Resource ResourceCreationProxy::CreateVideoDestination( instance))->GetReference(); } +PP_Resource ResourceCreationProxy::CreateVideoEncoder(PP_Instance instance) { + return (new VideoEncoderResource(GetConnection(), instance))->GetReference(); +} + PP_Resource ResourceCreationProxy::CreateVideoSource( PP_Instance instance) { return (new VideoSourceResource(GetConnection(), instance))->GetReference(); @@ -465,10 +475,6 @@ PP_Resource ResourceCreationProxy::CreateScrollbar(PP_Instance instance, return 0; } -PP_Resource ResourceCreationProxy::CreateTalk(PP_Instance instance) { - return (new TalkResource(GetConnection(), instance))->GetReference(); -} - PP_Resource ResourceCreationProxy::CreateVideoCapture(PP_Instance instance) { PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); if (!dispatcher) diff --git a/chromium/ppapi/proxy/resource_creation_proxy.h b/chromium/ppapi/proxy/resource_creation_proxy.h index a3e633eb885..1e6d9014d55 100644 --- a/chromium/ppapi/proxy/resource_creation_proxy.h +++ b/chromium/ppapi/proxy/resource_creation_proxy.h @@ -30,36 +30,36 @@ class ResourceCreationProxy : public InterfaceProxy, public thunk::ResourceCreationAPI { public: explicit ResourceCreationProxy(Dispatcher* dispatcher); - virtual ~ResourceCreationProxy(); + ~ResourceCreationProxy() override; // Factory function used for registration (normal code can just use the // constructor). static InterfaceProxy* Create(Dispatcher* dispatcher); // ResourceCreationAPI (called in plugin). - virtual PP_Resource CreateFileIO(PP_Instance instance) override; - virtual PP_Resource CreateFileRef( + PP_Resource CreateFileIO(PP_Instance instance) override; + PP_Resource CreateFileRef( PP_Instance instance, const FileRefCreateInfo& create_info) override; - virtual PP_Resource CreateFileSystem(PP_Instance instance, - PP_FileSystemType type) override; - virtual PP_Resource CreateIMEInputEvent(PP_Instance instance, - PP_InputEvent_Type type, - PP_TimeTicks time_stamp, - struct PP_Var text, - uint32_t segment_number, - const uint32_t* segment_offsets, - int32_t target_segment, - uint32_t selection_start, - uint32_t selection_end) override; - virtual PP_Resource CreateKeyboardInputEvent_1_0( + PP_Resource CreateFileSystem(PP_Instance instance, + PP_FileSystemType type) override; + PP_Resource CreateIMEInputEvent(PP_Instance instance, + PP_InputEvent_Type type, + PP_TimeTicks time_stamp, + struct PP_Var text, + uint32_t segment_number, + const uint32_t* segment_offsets, + int32_t target_segment, + uint32_t selection_start, + uint32_t selection_end) override; + PP_Resource CreateKeyboardInputEvent_1_0( PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers, uint32_t key_code, PP_Var character_text) override; - virtual PP_Resource CreateKeyboardInputEvent_1_2( + PP_Resource CreateKeyboardInputEvent_1_2( PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, @@ -67,7 +67,7 @@ class ResourceCreationProxy : public InterfaceProxy, uint32_t key_code, PP_Var character_text, PP_Var code) override; - virtual PP_Resource CreateMouseInputEvent( + PP_Resource CreateMouseInputEvent( PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, @@ -76,120 +76,114 @@ class ResourceCreationProxy : public InterfaceProxy, const PP_Point* mouse_position, int32_t click_count, const PP_Point* mouse_movement) override; - virtual PP_Resource CreateTouchInputEvent( + PP_Resource CreateTouchInputEvent( PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers) override; - virtual PP_Resource CreateTrueTypeFont( + PP_Resource CreateTrueTypeFont( PP_Instance instance, const PP_TrueTypeFontDesc_Dev* desc) override; - virtual PP_Resource CreateURLLoader(PP_Instance instance) override; - virtual PP_Resource CreateURLRequestInfo( - PP_Instance instance) override; - virtual PP_Resource CreateWheelInputEvent( + PP_Resource CreateURLLoader(PP_Instance instance) override; + PP_Resource CreateURLRequestInfo(PP_Instance instance) override; + PP_Resource CreateWheelInputEvent( PP_Instance instance, PP_TimeTicks time_stamp, uint32_t modifiers, const PP_FloatPoint* wheel_delta, const PP_FloatPoint* wheel_ticks, PP_Bool scroll_by_page) override; - virtual PP_Resource CreateAudio1_0(PP_Instance instance, - PP_Resource config_id, - PPB_Audio_Callback_1_0 audio_callback, - void* user_data) override; - virtual PP_Resource CreateAudio(PP_Instance instance, - PP_Resource config_id, - PPB_Audio_Callback audio_callback, - void* user_data) override; - virtual PP_Resource CreateAudioTrusted(PP_Instance instance) override; - virtual PP_Resource CreateAudioConfig(PP_Instance instance, - PP_AudioSampleRate sample_rate, - uint32_t sample_frame_count) override; - virtual PP_Resource CreateCompositor(PP_Instance instance) override; - virtual PP_Resource CreateFileChooser(PP_Instance instance, - PP_FileChooserMode_Dev mode, - const PP_Var& accept_types) override; - virtual PP_Resource CreateGraphics2D(PP_Instance pp_instance, - const PP_Size* size, - PP_Bool is_always_opaque) override; - virtual PP_Resource CreateGraphics3D(PP_Instance instance, - PP_Resource share_context, - const int32_t* attrib_list) override; - virtual PP_Resource CreateGraphics3DRaw( + PP_Resource CreateAudio1_0(PP_Instance instance, + PP_Resource config_id, + PPB_Audio_Callback_1_0 audio_callback, + void* user_data) override; + PP_Resource CreateAudio(PP_Instance instance, + PP_Resource config_id, + PPB_Audio_Callback audio_callback, + void* user_data) override; + PP_Resource CreateAudioTrusted(PP_Instance instance) override; + PP_Resource CreateAudioConfig(PP_Instance instance, + PP_AudioSampleRate sample_rate, + uint32_t sample_frame_count) override; + PP_Resource CreateCameraDevicePrivate(PP_Instance instance) override; + PP_Resource CreateCompositor(PP_Instance instance) override; + PP_Resource CreateFileChooser(PP_Instance instance, + PP_FileChooserMode_Dev mode, + const PP_Var& accept_types) override; + PP_Resource CreateGraphics2D(PP_Instance pp_instance, + const PP_Size* size, + PP_Bool is_always_opaque) override; + PP_Resource CreateGraphics3D(PP_Instance instance, + PP_Resource share_context, + const int32_t* attrib_list) override; + PP_Resource CreateGraphics3DRaw( PP_Instance instance, PP_Resource share_context, const int32_t* attrib_list, gpu::Capabilities* capabilities, base::SharedMemoryHandle* shared_state) override; - virtual PP_Resource CreateHostResolver(PP_Instance instance) override; - virtual PP_Resource CreateHostResolverPrivate(PP_Instance instance) override; - virtual PP_Resource CreateImageData(PP_Instance instance, - PP_ImageDataFormat format, - const PP_Size* size, - PP_Bool init_to_zero) override; - virtual PP_Resource CreateImageDataSimple(PP_Instance instance, - PP_ImageDataFormat format, - const PP_Size* size, - PP_Bool init_to_zero) override; - virtual PP_Resource CreateMediaStreamVideoTrack( - PP_Instance instance) override; - virtual PP_Resource CreateNetAddressFromIPv4Address( + PP_Resource CreateHostResolver(PP_Instance instance) override; + PP_Resource CreateHostResolverPrivate(PP_Instance instance) override; + PP_Resource CreateImageData(PP_Instance instance, + PP_ImageDataFormat format, + const PP_Size* size, + PP_Bool init_to_zero) override; + PP_Resource CreateImageDataSimple(PP_Instance instance, + PP_ImageDataFormat format, + const PP_Size* size, + PP_Bool init_to_zero) override; + PP_Resource CreateMediaStreamVideoTrack(PP_Instance instance) override; + PP_Resource CreateNetAddressFromIPv4Address( PP_Instance instance, const PP_NetAddress_IPv4* ipv4_addr) override; - virtual PP_Resource CreateNetAddressFromIPv6Address( + PP_Resource CreateNetAddressFromIPv6Address( PP_Instance instance, const PP_NetAddress_IPv6* ipv6_addr) override; - virtual PP_Resource CreateNetAddressFromNetAddressPrivate( + PP_Resource CreateNetAddressFromNetAddressPrivate( PP_Instance instance, const PP_NetAddress_Private& private_addr) override; - virtual PP_Resource CreateNetworkMonitor(PP_Instance instance) override; - virtual PP_Resource CreateOutputProtectionPrivate( - PP_Instance instance) override; - virtual PP_Resource CreatePrinting(PP_Instance) override; - virtual PP_Resource CreateTCPServerSocketPrivate( - PP_Instance instance) override; - virtual PP_Resource CreateTCPSocket1_0(PP_Instance instance) override; - virtual PP_Resource CreateTCPSocket(PP_Instance instance) override; - virtual PP_Resource CreateTCPSocketPrivate(PP_Instance instance) override; - virtual PP_Resource CreateUDPSocket(PP_Instance instance) override; - virtual PP_Resource CreateUDPSocketPrivate(PP_Instance instance) override; - virtual PP_Resource CreateVideoDecoder(PP_Instance instance) override; - virtual PP_Resource CreateVideoDestination(PP_Instance instance) override; - virtual PP_Resource CreateVideoSource(PP_Instance instance) override; - virtual PP_Resource CreateWebSocket(PP_Instance instance) override; - virtual PP_Resource CreateX509CertificatePrivate( - PP_Instance instance) override; + PP_Resource CreateNetworkMonitor(PP_Instance instance) override; + PP_Resource CreateOutputProtectionPrivate(PP_Instance instance) override; + PP_Resource CreatePrinting(PP_Instance) override; + PP_Resource CreateTCPServerSocketPrivate(PP_Instance instance) override; + PP_Resource CreateTCPSocket1_0(PP_Instance instance) override; + PP_Resource CreateTCPSocket(PP_Instance instance) override; + PP_Resource CreateTCPSocketPrivate(PP_Instance instance) override; + PP_Resource CreateUDPSocket(PP_Instance instance) override; + PP_Resource CreateUDPSocketPrivate(PP_Instance instance) override; + PP_Resource CreateVideoDecoder(PP_Instance instance) override; + PP_Resource CreateVideoDestination(PP_Instance instance) override; + PP_Resource CreateVideoEncoder(PP_Instance instance) override; + PP_Resource CreateVideoSource(PP_Instance instance) override; + PP_Resource CreateWebSocket(PP_Instance instance) override; + PP_Resource CreateX509CertificatePrivate(PP_Instance instance) override; #if !defined(OS_NACL) - virtual PP_Resource CreateAudioInput(PP_Instance instance) override; - virtual PP_Resource CreateBroker(PP_Instance instance) override; - virtual PP_Resource CreateBrowserFont( + PP_Resource CreateAudioInput(PP_Instance instance) override; + PP_Resource CreateBroker(PP_Instance instance) override; + PP_Resource CreateBrowserFont( PP_Instance instance, const PP_BrowserFont_Trusted_Description* description) override; - virtual PP_Resource CreateBuffer(PP_Instance instance, - uint32_t size) override; - virtual PP_Resource CreateFlashDRM(PP_Instance instance) override; - virtual PP_Resource CreateFlashFontFile( + PP_Resource CreateBuffer(PP_Instance instance, uint32_t size) override; + PP_Resource CreateFlashDRM(PP_Instance instance) override; + PP_Resource CreateFlashFontFile( PP_Instance instance, const PP_BrowserFont_Trusted_Description* description, PP_PrivateFontCharset charset) override; - virtual PP_Resource CreateFlashMenu(PP_Instance instance, - const PP_Flash_Menu* menu_data) override; - virtual PP_Resource CreateFlashMessageLoop(PP_Instance instance) override; - virtual PP_Resource CreatePlatformVerificationPrivate( - PP_Instance instance) override; - virtual PP_Resource CreateScrollbar(PP_Instance instance, - PP_Bool vertical) override; - virtual PP_Resource CreateTalk(PP_Instance instance) override; - virtual PP_Resource CreateVideoCapture(PP_Instance instance) override; - virtual PP_Resource CreateVideoDecoderDev( + PP_Resource CreateFlashMenu(PP_Instance instance, + const PP_Flash_Menu* menu_data) override; + PP_Resource CreateFlashMessageLoop(PP_Instance instance) override; + PP_Resource CreatePlatformVerificationPrivate(PP_Instance instance) override; + PP_Resource CreateScrollbar(PP_Instance instance, + PP_Bool vertical) override; + PP_Resource CreateVideoCapture(PP_Instance instance) override; + PP_Resource CreateVideoDecoderDev( PP_Instance instance, PP_Resource context3d_id, PP_VideoDecoder_Profile profile) override; #endif // !defined(OS_NACL) - virtual bool Send(IPC::Message* msg) override; - virtual bool OnMessageReceived(const IPC::Message& msg) override; + bool Send(IPC::Message* msg) override; + bool OnMessageReceived(const IPC::Message& msg) override; private: Connection GetConnection(); diff --git a/chromium/ppapi/proxy/resource_message_filter.h b/chromium/ppapi/proxy/resource_message_filter.h new file mode 100644 index 00000000000..a7c4d263cdd --- /dev/null +++ b/chromium/ppapi/proxy/resource_message_filter.h @@ -0,0 +1,51 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_PROXY_RESOURCE_MESSAGE_FILTER_H_ +#define PPAPI_PROXY_RESOURCE_MESSAGE_FILTER_H_ + +#include "base/memory/ref_counted.h" +#include "ppapi/proxy/ppapi_proxy_export.h" + +namespace IPC { +class Message; +} + +namespace ppapi { +namespace proxy { +class ResourceMessageReplyParams; + +// A ResourceMessageFilter lives on the IO thread and handles messages for a +// particular resource type. This is necessary in some cases where we want to +// reduce latency by doing some work on the IO thread rather than having to +// PostTask to the main Pepper thread. +// +// Note: In some cases we can rely on a reply being associated with a +// particular TrackedCallback, in which case we can dispatch directly to the +// TrackedCallback's thread. See ReplyThreadRegistrar. That should be the first +// choice for avoiding an unecessary jump to the main-thread. +// +// ResourceMessageFilter is for cases where there is not a one-to-one +// relationship between a reply message and a TrackedCallback. For example, for +// UDP Socket resources, the browser pushes data to the plugin even when the +// plugin does not have a pending callback. We can't use the +// ReplyThreadRegistrar, because data may arrive when there's not yet a +// TrackedCallback to tell us what thread to use. So instead, we define a +// UDPSocketFilter which accepts and queues UDP data on the IO thread. +class PPAPI_PROXY_EXPORT ResourceMessageFilter + : public base::RefCountedThreadSafe<ResourceMessageFilter> { + public: + virtual bool OnResourceReplyReceived( + const ResourceMessageReplyParams& reply_params, + const IPC::Message& nested_msg) = 0; + + protected: + friend class base::RefCountedThreadSafe<ResourceMessageFilter>; + virtual ~ResourceMessageFilter() {} +}; + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_RESOURCE_MESSAGE_FILTER_H_ diff --git a/chromium/ppapi/proxy/resource_message_params.h b/chromium/ppapi/proxy/resource_message_params.h index 2e21e757a2f..da945b35d55 100644 --- a/chromium/ppapi/proxy/resource_message_params.h +++ b/chromium/ppapi/proxy/resource_message_params.h @@ -139,14 +139,13 @@ class PPAPI_PROXY_EXPORT ResourceMessageCallParams public: ResourceMessageCallParams(); ResourceMessageCallParams(PP_Resource resource, int32_t sequence); - virtual ~ResourceMessageCallParams(); + ~ResourceMessageCallParams() override; void set_has_callback() { has_callback_ = true; } bool has_callback() const { return has_callback_; } - virtual void Serialize(IPC::Message* msg) const override; - virtual bool Deserialize(const IPC::Message* msg, - PickleIterator* iter) override; + void Serialize(IPC::Message* msg) const override; + bool Deserialize(const IPC::Message* msg, PickleIterator* iter) override; private: bool has_callback_; @@ -158,14 +157,13 @@ class PPAPI_PROXY_EXPORT ResourceMessageReplyParams public: ResourceMessageReplyParams(); ResourceMessageReplyParams(PP_Resource resource, int32_t sequence); - virtual ~ResourceMessageReplyParams(); + ~ResourceMessageReplyParams() override; void set_result(int32_t r) { result_ = r; } int32_t result() const { return result_; } - virtual void Serialize(IPC::Message* msg) const override; - virtual bool Deserialize(const IPC::Message* msg, - PickleIterator* iter) override; + void Serialize(IPC::Message* msg) const override; + bool Deserialize(const IPC::Message* msg, PickleIterator* iter) override; // Writes everything except the handles to |msg|. void WriteReplyHeader(IPC::Message* msg) const; diff --git a/chromium/ppapi/proxy/resource_message_test_sink.cc b/chromium/ppapi/proxy/resource_message_test_sink.cc index 2c237b0670a..2ce9f41a2d8 100644 --- a/chromium/ppapi/proxy/resource_message_test_sink.cc +++ b/chromium/ppapi/proxy/resource_message_test_sink.cc @@ -24,8 +24,8 @@ GetAllResourceMessagesMatching(const ResourceMessageTestSink& sink, if (msg->type() == WrapperMessage::ID) { typename WrapperMessage::Param params; WrapperMessage::Read(msg, ¶ms); - Params cur_params = params.a; - IPC::Message cur_msg = params.b; + Params cur_params = get<0>(params); + IPC::Message cur_msg = get<1>(params); if (cur_msg.type() == id) { result.push_back(std::make_pair(cur_params, cur_msg)); } @@ -130,8 +130,8 @@ bool ResourceSyncCallHandler::OnMessageReceived(const IPC::Message& msg) { bool success = PpapiHostMsg_ResourceSyncCall::ReadSendParam( &msg, &send_params); DCHECK(success); - ResourceMessageCallParams call_params = send_params.a; - IPC::Message call_msg = send_params.b; + ResourceMessageCallParams call_params = get<0>(send_params); + IPC::Message call_msg = get<1>(send_params); if (call_msg.type() != incoming_type_) return false; IPC::Message* wrapper_reply_msg = IPC::SyncMessage::GenerateReply(&msg); diff --git a/chromium/ppapi/proxy/resource_message_test_sink.h b/chromium/ppapi/proxy/resource_message_test_sink.h index 9c7513fbbac..3e40e31060d 100644 --- a/chromium/ppapi/proxy/resource_message_test_sink.h +++ b/chromium/ppapi/proxy/resource_message_test_sink.h @@ -21,11 +21,11 @@ class SerializedHandle; class ResourceMessageTestSink : public IPC::TestSink { public: ResourceMessageTestSink(); - virtual ~ResourceMessageTestSink(); + ~ResourceMessageTestSink() override; // IPC::TestSink. // Overridden to handle sync messages. - virtual bool Send(IPC::Message* msg) override; + bool Send(IPC::Message* msg) override; // Sets the reply message that will be returned to the next sync message sent. // This test sink owns any reply messages passed into this method. @@ -82,10 +82,10 @@ class ResourceSyncCallHandler : public IPC::Listener { uint32 incoming_type, int32_t result, const IPC::Message& reply_msg); - virtual ~ResourceSyncCallHandler(); + ~ResourceSyncCallHandler() override; // IPC::Listener. - virtual bool OnMessageReceived(const IPC::Message& message) override; + bool OnMessageReceived(const IPC::Message& message) override; IPC::Message last_handled_msg() { return last_handled_msg_; } diff --git a/chromium/ppapi/proxy/resource_reply_thread_registrar.cc b/chromium/ppapi/proxy/resource_reply_thread_registrar.cc index d0c697deab7..274d9026492 100644 --- a/chromium/ppapi/proxy/resource_reply_thread_registrar.cc +++ b/chromium/ppapi/proxy/resource_reply_thread_registrar.cc @@ -50,11 +50,6 @@ void ResourceReplyThreadRegistrar::Unregister(PP_Resource resource) { map_.erase(resource); } -void ResourceReplyThreadRegistrar::HandleOnIOThread(uint32 nested_msg_type) { - base::AutoLock auto_lock(lock_); - io_thread_message_types_.insert(nested_msg_type); -} - scoped_refptr<base::MessageLoopProxy> ResourceReplyThreadRegistrar::GetTargetThread( const ResourceMessageReplyParams& reply_params, @@ -72,9 +67,6 @@ ResourceReplyThreadRegistrar::GetTargetThread( } } - if (io_thread_message_types_.count(nested_msg.type()) != 0) - return scoped_refptr<base::MessageLoopProxy>(); - return main_thread_; } diff --git a/chromium/ppapi/proxy/resource_reply_thread_registrar.h b/chromium/ppapi/proxy/resource_reply_thread_registrar.h index ded54e9de3d..38d596bedb2 100644 --- a/chromium/ppapi/proxy/resource_reply_thread_registrar.h +++ b/chromium/ppapi/proxy/resource_reply_thread_registrar.h @@ -47,13 +47,6 @@ class PPAPI_PROXY_EXPORT ResourceReplyThreadRegistrar scoped_refptr<TrackedCallback> reply_thread_hint); void Unregister(PP_Resource resource); - // This results in Resource::OnReplyReceived() for the specified message type - // to be called on the IO thread directly, while holding the Pepper proxy - // lock. - void HandleOnIOThread(uint32 nested_msg_type); - - // This method returns NULL if the target thread is the IO thread (because - // that is the thread on which this method is supposed to be called). scoped_refptr<base::MessageLoopProxy> GetTargetThread( const ResourceMessageReplyParams& reply_params, const IPC::Message& nested_msg); @@ -72,7 +65,6 @@ class PPAPI_PROXY_EXPORT ResourceReplyThreadRegistrar // holding |lock_|, otherwise we will cause deadlock. base::Lock lock_; ResourceMap map_; - std::set<uint32> io_thread_message_types_; scoped_refptr<base::MessageLoopProxy> main_thread_; DISALLOW_COPY_AND_ASSIGN(ResourceReplyThreadRegistrar); diff --git a/chromium/ppapi/proxy/serialized_flash_menu.cc b/chromium/ppapi/proxy/serialized_flash_menu.cc index bbd698cc7b4..9f39916ea61 100644 --- a/chromium/ppapi/proxy/serialized_flash_menu.cc +++ b/chromium/ppapi/proxy/serialized_flash_menu.cc @@ -81,18 +81,18 @@ bool ReadMenuItem(int depth, PickleIterator* iter, PP_Flash_MenuItem* menu_item) { uint32_t type; - if (!m->ReadUInt32(iter, &type)) + if (!iter->ReadUInt32(&type)) return false; if (type > PP_FLASH_MENUITEM_TYPE_SUBMENU) return false; menu_item->type = static_cast<PP_Flash_MenuItem_Type>(type); std::string name; - if (!m->ReadString(iter, &name)) + if (!iter->ReadString(&name)) return false; menu_item->name = new char[name.size() + 1]; std::copy(name.begin(), name.end(), menu_item->name); menu_item->name[name.size()] = 0; - if (!m->ReadInt(iter, &menu_item->id)) + if (!iter->ReadInt(&menu_item->id)) return false; if (!IPC::ParamTraits<PP_Bool>::Read(m, iter, &menu_item->enabled)) return false; @@ -116,7 +116,7 @@ PP_Flash_Menu* ReadMenu(int depth, PP_Flash_Menu* menu = new PP_Flash_Menu; menu->items = NULL; - if (!m->ReadUInt32(iter, &menu->count)) { + if (!iter->ReadUInt32(&menu->count)) { FreeMenu(menu); return NULL; } diff --git a/chromium/ppapi/proxy/serialized_var.cc b/chromium/ppapi/proxy/serialized_var.cc index d00a7d39aab..eb7ba4efe70 100644 --- a/chromium/ppapi/proxy/serialized_var.cc +++ b/chromium/ppapi/proxy/serialized_var.cc @@ -149,7 +149,7 @@ bool SerializedVar::Inner::ReadFromMessage(const IPC::Message* m, #endif // When reading, the dispatcher should be set when we get a Deserialize // call (which will supply a dispatcher). - if (!m->ReadBool(iter, &is_valid_var_)) + if (!iter->ReadBool(&is_valid_var_)) return false; if (is_valid_var_) { raw_var_data_ = RawVarDataGraph::Read(m, iter); diff --git a/chromium/ppapi/proxy/serialized_var_unittest.cc b/chromium/ppapi/proxy/serialized_var_unittest.cc index fcde77795a3..d88c848317e 100644 --- a/chromium/ppapi/proxy/serialized_var_unittest.cc +++ b/chromium/ppapi/proxy/serialized_var_unittest.cc @@ -4,6 +4,7 @@ #include "ppapi/proxy/ppapi_proxy_test.h" +#include "ppapi/proxy/proxy_object_var.h" #include "ppapi/proxy/serialized_var.h" #include "ppapi/shared_impl/proxy_lock.h" @@ -257,7 +258,7 @@ TEST_F(SerializedVarTest, PluginVectorReceiveInput) { // Take a reference to a string and then release it. Make sure no messages // are sent. - uint32_t old_message_count = sink().message_count(); + uint32_t old_message_count = static_cast<uint32_t>(sink().message_count()); var_tracker().AddRefVar(plugin_objects[1]); EXPECT_EQ(2, var_tracker().GetRefCountForObject(plugin_objects[1])); var_tracker().ReleaseVar(plugin_objects[1]); @@ -272,6 +273,38 @@ TEST_F(SerializedVarTest, PluginVectorReceiveInput) { EXPECT_EQ(-1, var_tracker().GetRefCountForObject(plugin_objects2[1])); } +// Tests the browser sending a String var as a return value to make sure we +// ref-count the host side properly. +typedef HostProxyTest HostSerializedVarTest; +TEST_F(HostSerializedVarTest, PluginReceiveStringReturn) { + { + PP_Var string_var = StringVar::StringToPPVar("Hello"); + EXPECT_EQ(1, var_tracker().GetRefCountForObject(string_var)); + GetDispatcher()->serialization_rules()->BeginSendPassRef(string_var); + GetDispatcher()->serialization_rules()->EndSendPassRef(string_var); + // It should be gone, so we should get -1 to indicate that. + EXPECT_EQ(-1, var_tracker().GetRefCountForObject(string_var)); + } + + { + // Note this is as little weird; we're testing the behavior of the host- + // side of the proxy, but we use ProxyObjectVar, because this unit test + // doesn't have access to stuff in content/renderer/pepper. The ref-counting + // behavior should be the same, however. All we're really testing + // is the code in ppapi/proxy (HostVarSerializationRules). + scoped_refptr<Var> obj_var = new ProxyObjectVar(NULL, 1234); + PP_Var obj_pp_var = obj_var->GetPPVar(); + EXPECT_EQ(1, var_tracker().GetRefCountForObject(obj_pp_var)); + GetDispatcher()->serialization_rules()->BeginSendPassRef(obj_pp_var); + GetDispatcher()->serialization_rules()->EndSendPassRef(obj_pp_var); + // The host side for object vars always keeps 1 ref on behalf of the plugin. + // See HostVarSerializationRules and PluginVarSerializationRules for an + // explanation. + EXPECT_EQ(1, var_tracker().GetRefCountForObject(obj_pp_var)); + var_tracker().ReleaseVar(obj_pp_var); + } +} + // Tests the plugin receiving a var as a return value from the browser // two different times (passing ownership). TEST_F(SerializedVarTest, PluginReceiveReturn) { diff --git a/chromium/ppapi/proxy/talk_resource.cc b/chromium/ppapi/proxy/talk_resource.cc deleted file mode 100644 index b076064df6e..00000000000 --- a/chromium/ppapi/proxy/talk_resource.cc +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/proxy/talk_resource.h" - -#include "base/bind.h" -#include "ppapi/proxy/ppapi_messages.h" - -namespace ppapi { -namespace proxy { - -TalkResource::TalkResource(Connection connection, PP_Instance instance) - : PluginResource(connection, instance), - event_callback_(NULL), - event_callback_user_data_(NULL) { - SendCreate(BROWSER, PpapiHostMsg_Talk_Create()); -} - -TalkResource::~TalkResource() { -} - -thunk::PPB_Talk_Private_API* TalkResource::AsPPB_Talk_Private_API() { - return this; -} - -int32_t TalkResource::RequestPermission( - PP_TalkPermission permission, - scoped_refptr<TrackedCallback> callback) { - if (TrackedCallback::IsPending(permission_callback_)) - return PP_ERROR_INPROGRESS; - - permission_callback_ = callback; - - Call<PpapiPluginMsg_Talk_RequestPermissionReply>( - BROWSER, - PpapiHostMsg_Talk_RequestPermission(permission), - base::Bind(&TalkResource::OnRequestPermissionReply, - base::Unretained(this))); - return PP_OK_COMPLETIONPENDING; -} - -int32_t TalkResource::StartRemoting(PP_TalkEventCallback event_callback, - void* user_data, - scoped_refptr<TrackedCallback> callback) { - if (TrackedCallback::IsPending(start_callback_) || - event_callback_ != NULL) - return PP_ERROR_INPROGRESS; - - start_callback_ = callback; - event_callback_ = event_callback; - event_callback_user_data_ = user_data; - - Call<PpapiPluginMsg_Talk_StartRemotingReply>( - BROWSER, - PpapiHostMsg_Talk_StartRemoting(), - base::Bind(&TalkResource::OnStartRemotingReply, - base::Unretained(this))); - return PP_OK_COMPLETIONPENDING; -} - -int32_t TalkResource::StopRemoting(scoped_refptr<TrackedCallback> callback) { - if (TrackedCallback::IsPending(stop_callback_)) - return PP_ERROR_INPROGRESS; - - if (event_callback_ == NULL) - return PP_ERROR_FAILED; - - stop_callback_ = callback; - - Call<PpapiPluginMsg_Talk_StopRemotingReply>( - BROWSER, - PpapiHostMsg_Talk_StopRemoting(), - base::Bind(&TalkResource::OnStopRemotingReply, - base::Unretained(this))); - return PP_OK_COMPLETIONPENDING; -} - -void TalkResource::OnReplyReceived(const ResourceMessageReplyParams& params, - const IPC::Message& msg) { - PPAPI_BEGIN_MESSAGE_MAP(TalkResource, msg) - PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL( - PpapiPluginMsg_Talk_NotifyEvent, - OnNotifyEvent) - PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED( - PluginResource::OnReplyReceived(params, msg)) - PPAPI_END_MESSAGE_MAP() -} - -void TalkResource::OnNotifyEvent(const ResourceMessageReplyParams& params, - PP_TalkEvent event) { - if (event_callback_ != NULL) - event_callback_(event_callback_user_data_, event); -} - -void TalkResource::OnRequestPermissionReply( - const ResourceMessageReplyParams& params) { - permission_callback_->Run(params.result()); -} - -void TalkResource::OnStartRemotingReply( - const ResourceMessageReplyParams& params) { - start_callback_->Run(params.result()); -} - -void TalkResource::OnStopRemotingReply( - const ResourceMessageReplyParams& params) { - event_callback_ = NULL; - event_callback_user_data_ = NULL; - stop_callback_->Run(params.result()); -} - -} // namespace proxy -} // namespace ppapi diff --git a/chromium/ppapi/proxy/talk_resource.h b/chromium/ppapi/proxy/talk_resource.h deleted file mode 100644 index e86199e7b32..00000000000 --- a/chromium/ppapi/proxy/talk_resource.h +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef PPAPI_PROXY_TALK_RESOURCE_H_ -#define PPAPI_PROXY_TALK_RESOURCE_H_ - -#include "ppapi/proxy/plugin_resource.h" -#include "ppapi/proxy/ppapi_proxy_export.h" -#include "ppapi/shared_impl/tracked_callback.h" -#include "ppapi/thunk/ppb_talk_private_api.h" - -namespace ppapi { -namespace proxy { - -class PPAPI_PROXY_EXPORT TalkResource - : public PluginResource, - public NON_EXPORTED_BASE(thunk::PPB_Talk_Private_API) { - public: - TalkResource(Connection connection, PP_Instance instance); - virtual ~TalkResource(); - - // Resource overrides. - thunk::PPB_Talk_Private_API* AsPPB_Talk_Private_API(); - - private: - // PPB_Talk_API implementation. - virtual int32_t RequestPermission( - PP_TalkPermission permission, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t StartRemoting( - PP_TalkEventCallback event_callback, - void* user_data, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t StopRemoting( - scoped_refptr<TrackedCallback> callback) override; - - // PluginResource override. - virtual void OnReplyReceived(const ResourceMessageReplyParams& params, - const IPC::Message& msg) override; - - void OnNotifyEvent(const ResourceMessageReplyParams& params, - PP_TalkEvent event); - void OnRequestPermissionReply(const ResourceMessageReplyParams& params); - void OnStartRemotingReply(const ResourceMessageReplyParams& params); - void OnStopRemotingReply(const ResourceMessageReplyParams& params); - - scoped_refptr<TrackedCallback> permission_callback_; - scoped_refptr<TrackedCallback> start_callback_; - scoped_refptr<TrackedCallback> stop_callback_; - PP_TalkEventCallback event_callback_; - void* event_callback_user_data_; - - DISALLOW_COPY_AND_ASSIGN(TalkResource); -}; - -} // namespace proxy -} // namespace ppapi - -#endif // PPAPI_PROXY_TALK_RESOURCE_H_ diff --git a/chromium/ppapi/proxy/talk_resource_unittest.cc b/chromium/ppapi/proxy/talk_resource_unittest.cc deleted file mode 100644 index 3b7d5ff43fe..00000000000 --- a/chromium/ppapi/proxy/talk_resource_unittest.cc +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/proxy/locking_resource_releaser.h" -#include "ppapi/proxy/plugin_message_filter.h" -#include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/proxy/ppapi_proxy_test.h" -#include "ppapi/proxy/talk_resource.h" -#include "ppapi/thunk/thunk.h" - -namespace ppapi { -namespace proxy { - -namespace { - -template <class ResultType> -class MockCallbackBase { - public: - MockCallbackBase() : called_(false) { - } - - bool called() { - return called_; - } - - ResultType result() { - return result_; - } - - void Reset() { - called_ = false; - } - - static void Callback(void* user_data, ResultType result) { - MockCallbackBase* that = reinterpret_cast<MockCallbackBase*>(user_data); - that->called_ = true; - that->result_ = result; - } - - private: - bool called_; - ResultType result_; -}; - -typedef MockCallbackBase<int32_t> MockCompletionCallback; -typedef MockCallbackBase<PP_TalkEvent> TalkEventCallback; - -class TalkResourceTest : public PluginProxyTest { - public: - void SendReply( - uint32_t id, - const IPC::Message& reply, - int32_t result) { - IPC::Message msg; - ResourceMessageCallParams params; - ASSERT_TRUE(sink().GetFirstResourceCallMatching(id, ¶ms, &msg)); - - ResourceMessageReplyParams reply_params(params.pp_resource(), - params.sequence()); - reply_params.set_result(result); - PluginMessageFilter::DispatchResourceReplyForTest(reply_params, reply); - } -}; - - -} // namespace - -TEST_F(TalkResourceTest, GetPermission) { - const PPB_Talk_Private_1_0* talk = thunk::GetPPB_Talk_Private_1_0_Thunk(); - LockingResourceReleaser res(talk->Create(pp_instance())); - MockCompletionCallback callback; - - int32_t result = talk->GetPermission( - res.get(), - PP_MakeCompletionCallback(&MockCompletionCallback::Callback, &callback)); - ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); - - ResourceMessageCallParams params; - IPC::Message msg; - ASSERT_TRUE(sink().GetFirstResourceCallMatching( - PpapiHostMsg_Talk_RequestPermission::ID, ¶ms, &msg)); - - ResourceMessageReplyParams reply_params(params.pp_resource(), - params.sequence()); - reply_params.set_result(1); - PluginMessageFilter::DispatchResourceReplyForTest( - reply_params, PpapiPluginMsg_Talk_RequestPermissionReply()); - - ASSERT_TRUE(callback.called()); - ASSERT_EQ(1, callback.result()); -} - -TEST_F(TalkResourceTest, RequestPermission) { - const PPB_Talk_Private_2_0* talk = thunk::GetPPB_Talk_Private_2_0_Thunk(); - LockingResourceReleaser res(talk->Create(pp_instance())); - MockCompletionCallback callback; - - int32_t result = talk->RequestPermission( - res.get(), - PP_TALKPERMISSION_REMOTING_CONTINUE, - PP_MakeCompletionCallback(&MockCompletionCallback::Callback, &callback)); - ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); - - ResourceMessageCallParams params; - IPC::Message msg; - ASSERT_TRUE(sink().GetFirstResourceCallMatching( - PpapiHostMsg_Talk_RequestPermission::ID, ¶ms, &msg)); - - ResourceMessageReplyParams reply_params(params.pp_resource(), - params.sequence()); - reply_params.set_result(1); - PluginMessageFilter::DispatchResourceReplyForTest( - reply_params, PpapiPluginMsg_Talk_RequestPermissionReply()); - - ASSERT_TRUE(callback.called()); - ASSERT_EQ(1, callback.result()); -} - -TEST_F(TalkResourceTest, StartStopRemoting) { - const PPB_Talk_Private_2_0* talk = thunk::GetPPB_Talk_Private_2_0_Thunk(); - LockingResourceReleaser res(talk->Create(pp_instance())); - MockCompletionCallback callback; - TalkEventCallback event_callback; - - // Start - int32_t result = talk->StartRemoting( - res.get(), - &TalkEventCallback::Callback, - &event_callback, - PP_MakeCompletionCallback(&MockCompletionCallback::Callback, &callback)); - ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); - - SendReply(PpapiHostMsg_Talk_StartRemoting::ID, - PpapiPluginMsg_Talk_StartRemotingReply(), - PP_OK); - - ASSERT_TRUE(callback.called()); - ASSERT_EQ(PP_OK, callback.result()); - - // Receive an event - ASSERT_FALSE(event_callback.called()); - ResourceMessageReplyParams notify_params(res.get(), 0); - PluginMessageFilter::DispatchResourceReplyForTest( - notify_params, PpapiPluginMsg_Talk_NotifyEvent(PP_TALKEVENT_ERROR)); - ASSERT_TRUE(event_callback.called()); - ASSERT_EQ(PP_TALKEVENT_ERROR, event_callback.result()); - - // Stop - callback.Reset(); - result = talk->StopRemoting( - res.get(), - PP_MakeCompletionCallback(&MockCompletionCallback::Callback, &callback)); - ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); - - SendReply(PpapiHostMsg_Talk_StopRemoting::ID, - PpapiPluginMsg_Talk_StopRemotingReply(), - PP_OK); - - ASSERT_TRUE(callback.called()); - ASSERT_EQ(PP_OK, callback.result()); - - // Events should be discarded at this point - event_callback.Reset(); - PluginMessageFilter::DispatchResourceReplyForTest( - notify_params, PpapiPluginMsg_Talk_NotifyEvent(PP_TALKEVENT_ERROR)); - ASSERT_FALSE(event_callback.called()); -} - -} // namespace proxy -} // namespace ppapi diff --git a/chromium/ppapi/proxy/tcp_server_socket_private_resource.h b/chromium/ppapi/proxy/tcp_server_socket_private_resource.h index dad3fd89ab8..055b3b05db2 100644 --- a/chromium/ppapi/proxy/tcp_server_socket_private_resource.h +++ b/chromium/ppapi/proxy/tcp_server_socket_private_resource.h @@ -21,20 +21,20 @@ class PPAPI_PROXY_EXPORT TCPServerSocketPrivateResource public thunk::PPB_TCPServerSocket_Private_API { public: TCPServerSocketPrivateResource(Connection connection, PP_Instance instance); - virtual ~TCPServerSocketPrivateResource(); + ~TCPServerSocketPrivateResource() override; // PluginResource implementation. - virtual thunk::PPB_TCPServerSocket_Private_API* - AsPPB_TCPServerSocket_Private_API() override; + thunk::PPB_TCPServerSocket_Private_API* AsPPB_TCPServerSocket_Private_API() + override; // PPB_TCPServerSocket_Private_API implementation. - virtual int32_t Listen(const PP_NetAddress_Private* addr, - int32_t backlog, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t Accept(PP_Resource* tcp_socket, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t GetLocalAddress(PP_NetAddress_Private* addr) override; - virtual void StopListening() override; + int32_t Listen(const PP_NetAddress_Private* addr, + int32_t backlog, + scoped_refptr<TrackedCallback> callback) override; + int32_t Accept(PP_Resource* tcp_socket, + scoped_refptr<TrackedCallback> callback) override; + int32_t GetLocalAddress(PP_NetAddress_Private* addr) override; + void StopListening() override; private: enum State { diff --git a/chromium/ppapi/proxy/tcp_socket_private_resource.cc b/chromium/ppapi/proxy/tcp_socket_private_resource.cc index 76ed4b9e1e2..454c3faf1a3 100644 --- a/chromium/ppapi/proxy/tcp_socket_private_resource.cc +++ b/chromium/ppapi/proxy/tcp_socket_private_resource.cc @@ -101,7 +101,9 @@ int32_t TCPSocketPrivateResource::SetOption( case PP_TCPSOCKETOPTION_PRIVATE_INVALID: return PP_ERROR_BADARGUMENT; case PP_TCPSOCKETOPTION_PRIVATE_NO_DELAY: - return SetOptionImpl(PP_TCPSOCKET_OPTION_NO_DELAY, value, callback); + return SetOptionImpl(PP_TCPSOCKET_OPTION_NO_DELAY, value, + true, // Check connect() state. + callback); default: NOTREACHED(); return PP_ERROR_BADARGUMENT; diff --git a/chromium/ppapi/proxy/tcp_socket_private_resource.h b/chromium/ppapi/proxy/tcp_socket_private_resource.h index 9c0b1823c59..bbc5b1cc7da 100644 --- a/chromium/ppapi/proxy/tcp_socket_private_resource.h +++ b/chromium/ppapi/proxy/tcp_socket_private_resource.h @@ -27,40 +27,40 @@ class PPAPI_PROXY_EXPORT TCPSocketPrivateResource const PP_NetAddress_Private& local_addr, const PP_NetAddress_Private& remote_addr); - virtual ~TCPSocketPrivateResource(); + ~TCPSocketPrivateResource() override; // PluginResource overrides. - virtual PPB_TCPSocket_Private_API* AsPPB_TCPSocket_Private_API() override; + PPB_TCPSocket_Private_API* AsPPB_TCPSocket_Private_API() override; // PPB_TCPSocket_Private_API implementation. - virtual int32_t Connect(const char* host, - uint16_t port, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t ConnectWithNetAddress( + int32_t Connect(const char* host, + uint16_t port, + scoped_refptr<TrackedCallback> callback) override; + int32_t ConnectWithNetAddress( const PP_NetAddress_Private* addr, scoped_refptr<TrackedCallback> callback) override; - virtual PP_Bool GetLocalAddress(PP_NetAddress_Private* local_addr) override; - virtual PP_Bool GetRemoteAddress(PP_NetAddress_Private* remote_addr) override; - virtual int32_t SSLHandshake( + PP_Bool GetLocalAddress(PP_NetAddress_Private* local_addr) override; + PP_Bool GetRemoteAddress(PP_NetAddress_Private* remote_addr) override; + int32_t SSLHandshake( const char* server_name, uint16_t server_port, scoped_refptr<TrackedCallback> callback) override; - virtual PP_Resource GetServerCertificate() override; - virtual PP_Bool AddChainBuildingCertificate(PP_Resource certificate, - PP_Bool trusted) override; - virtual int32_t Read(char* buffer, - int32_t bytes_to_read, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t Write(const char* buffer, - int32_t bytes_to_write, - scoped_refptr<TrackedCallback> callback) override; - virtual void Disconnect() override; - virtual int32_t SetOption(PP_TCPSocketOption_Private name, - const PP_Var& value, - scoped_refptr<TrackedCallback> callback) override; + PP_Resource GetServerCertificate() override; + PP_Bool AddChainBuildingCertificate(PP_Resource certificate, + PP_Bool trusted) override; + int32_t Read(char* buffer, + int32_t bytes_to_read, + scoped_refptr<TrackedCallback> callback) override; + int32_t Write(const char* buffer, + int32_t bytes_to_write, + scoped_refptr<TrackedCallback> callback) override; + void Disconnect() override; + int32_t SetOption(PP_TCPSocketOption_Private name, + const PP_Var& value, + scoped_refptr<TrackedCallback> callback) override; // TCPSocketResourceBase implementation. - virtual PP_Resource CreateAcceptedSocket( + PP_Resource CreateAcceptedSocket( int pending_host_id, const PP_NetAddress_Private& local_addr, const PP_NetAddress_Private& remote_addr) override; diff --git a/chromium/ppapi/proxy/tcp_socket_resource.cc b/chromium/ppapi/proxy/tcp_socket_resource.cc index f8f8f68f261..5466d0d23ab 100644 --- a/chromium/ppapi/proxy/tcp_socket_resource.cc +++ b/chromium/ppapi/proxy/tcp_socket_resource.cc @@ -115,10 +115,21 @@ void TCPSocketResource::Close() { CloseImpl(); } +int32_t TCPSocketResource::SetOption1_1( + PP_TCPSocket_Option name, + const PP_Var& value, + scoped_refptr<TrackedCallback> callback) { + return SetOptionImpl(name, value, + true, // Check connect() state. + callback); +} + int32_t TCPSocketResource::SetOption(PP_TCPSocket_Option name, const PP_Var& value, scoped_refptr<TrackedCallback> callback) { - return SetOptionImpl(name, value, callback); + return SetOptionImpl(name, value, + false, // Do not check connect() state. + callback); } PP_Resource TCPSocketResource::CreateAcceptedSocket( diff --git a/chromium/ppapi/proxy/tcp_socket_resource.h b/chromium/ppapi/proxy/tcp_socket_resource.h index 6a8e9fff0f4..449cab69622 100644 --- a/chromium/ppapi/proxy/tcp_socket_resource.h +++ b/chromium/ppapi/proxy/tcp_socket_resource.h @@ -24,35 +24,39 @@ class PPAPI_PROXY_EXPORT TCPSocketResource : public thunk::PPB_TCPSocket_API, PP_Instance instance, TCPSocketVersion version); - virtual ~TCPSocketResource(); + ~TCPSocketResource() override; // PluginResource overrides. - virtual thunk::PPB_TCPSocket_API* AsPPB_TCPSocket_API() override; + thunk::PPB_TCPSocket_API* AsPPB_TCPSocket_API() override; // thunk::PPB_TCPSocket_API implementation. - virtual int32_t Bind(PP_Resource addr, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t Connect(PP_Resource addr, - scoped_refptr<TrackedCallback> callback) override; - virtual PP_Resource GetLocalAddress() override; - virtual PP_Resource GetRemoteAddress() override; - virtual int32_t Read(char* buffer, - int32_t bytes_to_read, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t Write(const char* buffer, - int32_t bytes_to_write, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t Listen(int32_t backlog, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t Accept(PP_Resource* accepted_tcp_socket, - scoped_refptr<TrackedCallback> callback) override; - virtual void Close() override; - virtual int32_t SetOption(PP_TCPSocket_Option name, - const PP_Var& value, - scoped_refptr<TrackedCallback> callback) override; + int32_t Bind(PP_Resource addr, + scoped_refptr<TrackedCallback> callback) override; + int32_t Connect(PP_Resource addr, + scoped_refptr<TrackedCallback> callback) override; + PP_Resource GetLocalAddress() override; + PP_Resource GetRemoteAddress() override; + int32_t Read(char* buffer, + int32_t bytes_to_read, + scoped_refptr<TrackedCallback> callback) override; + int32_t Write(const char* buffer, + int32_t bytes_to_write, + scoped_refptr<TrackedCallback> callback) override; + int32_t Listen(int32_t backlog, + scoped_refptr<TrackedCallback> callback) override; + int32_t Accept(PP_Resource* accepted_tcp_socket, + scoped_refptr<TrackedCallback> callback) override; + void Close() override; + int32_t SetOption1_1( + PP_TCPSocket_Option name, + const PP_Var& value, + scoped_refptr<TrackedCallback> callback) override; + int32_t SetOption(PP_TCPSocket_Option name, + const PP_Var& value, + scoped_refptr<TrackedCallback> callback) override; // TCPSocketResourceBase implementation. - virtual PP_Resource CreateAcceptedSocket( + PP_Resource CreateAcceptedSocket( int pending_host_id, const PP_NetAddress_Private& local_addr, const PP_NetAddress_Private& remote_addr) override; diff --git a/chromium/ppapi/proxy/tcp_socket_resource_base.cc b/chromium/ppapi/proxy/tcp_socket_resource_base.cc index 39c9fa311d6..fb4db5bee64 100644 --- a/chromium/ppapi/proxy/tcp_socket_resource_base.cc +++ b/chromium/ppapi/proxy/tcp_socket_resource_base.cc @@ -318,11 +318,12 @@ void TCPSocketResourceBase::CloseImpl() { int32_t TCPSocketResourceBase::SetOptionImpl( PP_TCPSocket_Option name, const PP_Var& value, + bool check_connect_state, scoped_refptr<TrackedCallback> callback) { SocketOptionData option_data; switch (name) { case PP_TCPSOCKET_OPTION_NO_DELAY: { - if (!state_.IsConnected()) + if (check_connect_state && !state_.IsConnected()) return PP_ERROR_FAILED; if (value.type != PP_VARTYPE_BOOL) @@ -332,7 +333,7 @@ int32_t TCPSocketResourceBase::SetOptionImpl( } case PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE: case PP_TCPSOCKET_OPTION_RECV_BUFFER_SIZE: { - if (!state_.IsConnected()) + if (check_connect_state && !state_.IsConnected()) return PP_ERROR_FAILED; if (value.type != PP_VARTYPE_INT32) diff --git a/chromium/ppapi/proxy/tcp_socket_resource_base.h b/chromium/ppapi/proxy/tcp_socket_resource_base.h index 8835ab974b1..3274fb9518e 100644 --- a/chromium/ppapi/proxy/tcp_socket_resource_base.h +++ b/chromium/ppapi/proxy/tcp_socket_resource_base.h @@ -95,6 +95,7 @@ class PPAPI_PROXY_EXPORT TCPSocketResourceBase : public PluginResource { void CloseImpl(); int32_t SetOptionImpl(PP_TCPSocket_Option name, const PP_Var& value, + bool check_connect_state, scoped_refptr<TrackedCallback> callback); void PostAbortIfNecessary(scoped_refptr<TrackedCallback>* callback); diff --git a/chromium/ppapi/proxy/tracked_callback_unittest.cc b/chromium/ppapi/proxy/tracked_callback_unittest.cc new file mode 100644 index 00000000000..748dcfb4784 --- /dev/null +++ b/chromium/ppapi/proxy/tracked_callback_unittest.cc @@ -0,0 +1,471 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/bind.h" +#include "base/memory/ref_counted.h" +#include "base/message_loop/message_loop.h" +#include "base/run_loop.h" +#include "base/synchronization/waitable_event.h" +#include "base/threading/simple_thread.h" +#include "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/proxy/ppapi_proxy_test.h" +#include "ppapi/proxy/ppb_message_loop_proxy.h" +#include "ppapi/shared_impl/callback_tracker.h" +#include "ppapi/shared_impl/proxy_lock.h" +#include "ppapi/shared_impl/resource.h" +#include "ppapi/shared_impl/resource_tracker.h" +#include "ppapi/shared_impl/scoped_pp_resource.h" +#include "ppapi/shared_impl/test_globals.h" +#include "ppapi/shared_impl/tracked_callback.h" +#include "testing/gtest/include/gtest/gtest.h" + +// Note, this file tests TrackedCallback which lives in ppapi/shared_impl. +// Unfortunately, we need the test to live in ppapi/proxy so that it can use +// the thread support there. +namespace ppapi { +namespace proxy { + +namespace { + +class CallbackThread : public base::SimpleThread { + public: + explicit CallbackThread(PP_Instance instance) + : SimpleThread("CallbackThread"), instance_(instance) {} + ~CallbackThread() override {} + + // base::SimpleThread overrides. + void Start() override { + { + ProxyAutoLock acquire; + // Create the message loop here, after PpapiGlobals has been created. + message_loop_ = new MessageLoopResource(instance_); + } + base::SimpleThread::Start(); + } + void Join() override { + { + ProxyAutoLock acquire; + message_loop()->PostQuit(PP_TRUE); + message_loop_ = nullptr; + } + base::SimpleThread::Join(); + } + void Run() override { + ProxyAutoLock acquire; + // Make a local copy of message_loop_ for this thread so we can interact + // with it even after the main thread releases it. + scoped_refptr<MessageLoopResource> message_loop(message_loop_); + message_loop->AttachToCurrentThread(); + // Note, run releases the lock to run events. + message_loop->Run(); + message_loop->DetachFromThread(); + } + + MessageLoopResource* message_loop() { return message_loop_.get(); } + + private: + PP_Instance instance_; + scoped_refptr<MessageLoopResource> message_loop_; +}; + +class TrackedCallbackTest : public PluginProxyTest { + public: + TrackedCallbackTest() : thread_(pp_instance()) {} + CallbackThread& thread() { return thread_; } + + private: + // PluginProxyTest overrides. + void SetUp() override { + PluginProxyTest::SetUp(); + thread_.Start(); + } + void TearDown() override { + thread_.Join(); + PluginProxyTest::TearDown(); + base::RunLoop run_loop; + run_loop.RunUntilIdle(); + } + CallbackThread thread_; +}; + +// All valid results (PP_OK, PP_ERROR_...) are nonpositive. +const int32_t kInitializedResultValue = 1; +const int32_t kOverrideResultValue = 2; + +struct CallbackRunInfo { + explicit CallbackRunInfo(base::ThreadChecker* thread_checker) + : run_count_(0), + result_(kInitializedResultValue), + completion_task_run_count_(0), + completion_task_result_(kInitializedResultValue), + thread_checker_(thread_checker), + callback_did_run_event_(true, false) {} + void CallbackDidRun(int32_t result) { + CHECK(thread_checker_->CalledOnValidThread()); + if (!run_count_) + result_ = result; + ++run_count_; + callback_did_run_event_.Signal(); + } + void CompletionTaskDidRun(int32_t result) { + CHECK(thread_checker_->CalledOnValidThread()); + if (!completion_task_run_count_) + completion_task_result_ = result; + ++completion_task_run_count_; + } + void WaitUntilCompleted() { callback_did_run_event_.Wait(); } + unsigned run_count() { return run_count_; } + int32_t result() { return result_; } + unsigned completion_task_run_count() { return completion_task_run_count_; } + int32_t completion_task_result() { return completion_task_result_; } + private: + unsigned run_count_; + int32_t result_; + unsigned completion_task_run_count_; + int32_t completion_task_result_; + // Weak; owned by the creator of CallbackRunInfo. + base::ThreadChecker* thread_checker_; + + base::WaitableEvent callback_did_run_event_; +}; + +void TestCallback(void* user_data, int32_t result) { + CallbackRunInfo* info = static_cast<CallbackRunInfo*>(user_data); + info->CallbackDidRun(result); +} + +// CallbackShutdownTest -------------------------------------------------------- + +class CallbackShutdownTest : public TrackedCallbackTest { + public: + CallbackShutdownTest() : info_did_run_(&thread_checker_), + info_did_abort_(&thread_checker_), + info_didnt_run_(&thread_checker_) {} + + // Cases: + // (1) A callback which is run (so shouldn't be aborted on shutdown). + // (2) A callback which is aborted (so shouldn't be aborted on shutdown). + // (3) A callback which isn't run (so should be aborted on shutdown). + CallbackRunInfo& info_did_run() { return info_did_run_; } // (1) + CallbackRunInfo& info_did_abort() { return info_did_abort_; } // (2) + CallbackRunInfo& info_didnt_run() { return info_didnt_run_; } // (3) + + private: + base::ThreadChecker thread_checker_; + CallbackRunInfo info_did_run_; + CallbackRunInfo info_did_abort_; + CallbackRunInfo info_didnt_run_; +}; + +} // namespace + +// Tests that callbacks are properly aborted on module shutdown. +TEST_F(CallbackShutdownTest, AbortOnShutdown) { + ProxyAutoLock lock; + scoped_refptr<Resource> resource( + new Resource(OBJECT_IS_PROXY, pp_instance())); + + // Set up case (1) (see above). + EXPECT_EQ(0U, info_did_run().run_count()); + // TODO(dmichael): Test this on a background thread? + scoped_refptr<TrackedCallback> callback_did_run = new TrackedCallback( + resource.get(), + PP_MakeCompletionCallback(&TestCallback, &info_did_run())); + EXPECT_EQ(0U, info_did_run().run_count()); + callback_did_run->Run(PP_OK); + EXPECT_EQ(1U, info_did_run().run_count()); + EXPECT_EQ(PP_OK, info_did_run().result()); + + // Set up case (2). + EXPECT_EQ(0U, info_did_abort().run_count()); + scoped_refptr<TrackedCallback> callback_did_abort = new TrackedCallback( + resource.get(), + PP_MakeCompletionCallback(&TestCallback, &info_did_abort())); + EXPECT_EQ(0U, info_did_abort().run_count()); + callback_did_abort->Abort(); + EXPECT_EQ(1U, info_did_abort().run_count()); + EXPECT_EQ(PP_ERROR_ABORTED, info_did_abort().result()); + + // Set up case (3). + EXPECT_EQ(0U, info_didnt_run().run_count()); + scoped_refptr<TrackedCallback> callback_didnt_run = new TrackedCallback( + resource.get(), + PP_MakeCompletionCallback(&TestCallback, &info_didnt_run())); + EXPECT_EQ(0U, info_didnt_run().run_count()); + + GetGlobals()->GetCallbackTrackerForInstance(pp_instance())->AbortAll(); + + // Check case (1). + EXPECT_EQ(1U, info_did_run().run_count()); + + // Check case (2). + EXPECT_EQ(1U, info_did_abort().run_count()); + + // Check case (3). + EXPECT_EQ(1U, info_didnt_run().run_count()); + EXPECT_EQ(PP_ERROR_ABORTED, info_didnt_run().result()); +} + +// CallbackResourceTest -------------------------------------------------------- + +namespace { + +class CallbackResourceTest : public TrackedCallbackTest { + public: + CallbackResourceTest() {} +}; + +class CallbackMockResource : public Resource { + public: + static scoped_refptr<CallbackMockResource> Create(PP_Instance instance) { + ProxyAutoLock acquire; + return scoped_refptr<CallbackMockResource>( + new CallbackMockResource(instance)); + } + ~CallbackMockResource() {} + + // Take a reference to this resource, which will add it to the tracker. + void TakeRef() { + ProxyAutoLock acquire; + ScopedPPResource temp_resource(ScopedPPResource::PassRef(), GetReference()); + EXPECT_NE(0, temp_resource.get()); + reference_holder_ = temp_resource; + } + // Release it, removing it from the tracker. + void ReleaseRef() { + ProxyAutoLock acquire; + reference_holder_ = 0; + } + + // Create the test callbacks on a background thread, so that we can verify + // they are run on the same thread where they were created. + void CreateCallbacksOnLoop(MessageLoopResource* loop_resource) { + ProxyAutoLock acquire; + // |thread_checker_| will bind to the background thread. + thread_checker_.DetachFromThread(); + loop_resource->message_loop_proxy()->PostTask(FROM_HERE, + RunWhileLocked( + base::Bind(&CallbackMockResource::CreateCallbacks, this))); + } + + int32_t CompletionTask(CallbackRunInfo* info, int32_t result) { + // The completion task must run on the thread where the callback was + // created, and must hold the proxy lock. + CHECK(thread_checker_.CalledOnValidThread()); + ProxyLock::AssertAcquired(); + + // We should run before the callback. + CHECK_EQ(0U, info->run_count()); + info->CompletionTaskDidRun(result); + return kOverrideResultValue; + } + + void CheckInitialState() { + callbacks_created_event_.Wait(); + EXPECT_EQ(0U, info_did_run_.run_count()); + EXPECT_EQ(0U, info_did_run_.completion_task_run_count()); + + EXPECT_EQ(0U, info_did_run_with_completion_task_.run_count()); + EXPECT_EQ(0U, + info_did_run_with_completion_task_.completion_task_run_count()); + + EXPECT_EQ(0U, info_did_abort_.run_count()); + EXPECT_EQ(0U, info_did_abort_.completion_task_run_count()); + + EXPECT_EQ(0U, info_didnt_run_.run_count()); + EXPECT_EQ(0U, info_didnt_run_.completion_task_run_count()); + } + + void RunCallbacks() { + callback_did_run_->Run(PP_OK); + callback_did_run_with_completion_task_->Run(PP_OK); + callback_did_abort_->Abort(); + info_did_run_.WaitUntilCompleted(); + info_did_run_with_completion_task_.WaitUntilCompleted(); + info_did_abort_.WaitUntilCompleted(); + } + + void CheckIntermediateState() { + EXPECT_EQ(1U, info_did_run_.run_count()); + EXPECT_EQ(PP_OK, info_did_run_.result()); + EXPECT_EQ(0U, info_did_run_.completion_task_run_count()); + + EXPECT_EQ(1U, info_did_run_with_completion_task_.run_count()); + // completion task should override the result. + EXPECT_EQ(kOverrideResultValue, + info_did_run_with_completion_task_.result()); + EXPECT_EQ(1U, + info_did_run_with_completion_task_.completion_task_run_count()); + EXPECT_EQ(PP_OK, + info_did_run_with_completion_task_.completion_task_result()); + + EXPECT_EQ(1U, info_did_abort_.run_count()); + // completion task shouldn't override an abort. + EXPECT_EQ(PP_ERROR_ABORTED, info_did_abort_.result()); + EXPECT_EQ(1U, info_did_abort_.completion_task_run_count()); + EXPECT_EQ(PP_ERROR_ABORTED, info_did_abort_.completion_task_result()); + + EXPECT_EQ(0U, info_didnt_run_.completion_task_run_count()); + EXPECT_EQ(0U, info_didnt_run_.run_count()); + } + + void CheckFinalState() { + info_didnt_run_.WaitUntilCompleted(); + EXPECT_EQ(1U, info_did_run_with_completion_task_.run_count()); + EXPECT_EQ(kOverrideResultValue, + info_did_run_with_completion_task_.result()); + callback_did_run_with_completion_task_ = nullptr; + EXPECT_EQ(1U, info_did_run_.run_count()); + EXPECT_EQ(PP_OK, info_did_run_.result()); + callback_did_run_ = nullptr; + EXPECT_EQ(1U, info_did_abort_.run_count()); + EXPECT_EQ(PP_ERROR_ABORTED, info_did_abort_.result()); + callback_did_abort_ = nullptr; + EXPECT_EQ(1U, info_didnt_run_.run_count()); + EXPECT_EQ(PP_ERROR_ABORTED, info_didnt_run_.result()); + callback_didnt_run_ = nullptr; + } + + private: + explicit CallbackMockResource(PP_Instance instance) + : Resource(OBJECT_IS_PROXY, instance), + info_did_run_(&thread_checker_), + info_did_run_with_completion_task_(&thread_checker_), + info_did_abort_(&thread_checker_), + info_didnt_run_(&thread_checker_), + callbacks_created_event_(true, false) {} + void CreateCallbacks() { + // Bind thread_checker_ to the thread where we create the callbacks. + // Later, when the callback runs, it will check that it was invoked on this + // same thread. + CHECK(thread_checker_.CalledOnValidThread()); + + callback_did_run_ = new TrackedCallback( + this, PP_MakeCompletionCallback(&TestCallback, &info_did_run_)); + + // In order to test that the completion task can override the callback + // result, we need to test callbacks with and without a completion task. + callback_did_run_with_completion_task_ = new TrackedCallback( + this, + PP_MakeCompletionCallback(&TestCallback, + &info_did_run_with_completion_task_)); + callback_did_run_with_completion_task_->set_completion_task( + Bind(&CallbackMockResource::CompletionTask, + this, + &info_did_run_with_completion_task_)); + + callback_did_abort_ = new TrackedCallback( + this, PP_MakeCompletionCallback(&TestCallback, &info_did_abort_)); + callback_did_abort_->set_completion_task( + Bind(&CallbackMockResource::CompletionTask, this, &info_did_abort_)); + + callback_didnt_run_ = new TrackedCallback( + this, PP_MakeCompletionCallback(&TestCallback, &info_didnt_run_)); + callback_didnt_run_->set_completion_task( + Bind(&CallbackMockResource::CompletionTask, this, &info_didnt_run_)); + + callbacks_created_event_.Signal(); + } + + // Used to verify that the callback runs on the same thread where it is + // created. + base::ThreadChecker thread_checker_; + + scoped_refptr<TrackedCallback> callback_did_run_; + CallbackRunInfo info_did_run_; + + scoped_refptr<TrackedCallback> callback_did_run_with_completion_task_; + CallbackRunInfo info_did_run_with_completion_task_; + + scoped_refptr<TrackedCallback> callback_did_abort_; + CallbackRunInfo info_did_abort_; + + scoped_refptr<TrackedCallback> callback_didnt_run_; + CallbackRunInfo info_didnt_run_; + + base::WaitableEvent callbacks_created_event_; + + ScopedPPResource reference_holder_; +}; + +} // namespace + +// Test that callbacks get aborted on the last resource unref. +TEST_F(CallbackResourceTest, AbortOnNoRef) { + // Test several things: Unref-ing a resource (to zero refs) with callbacks + // which (1) have been run, (2) have been aborted, (3) haven't been completed. + // Check that the uncompleted one gets aborted, and that the others don't get + // called again. + scoped_refptr<CallbackMockResource> resource_1( + CallbackMockResource::Create(pp_instance())); + resource_1->CreateCallbacksOnLoop(thread().message_loop()); + resource_1->CheckInitialState(); + resource_1->RunCallbacks(); + resource_1->TakeRef(); + resource_1->CheckIntermediateState(); + + // Also do the same for a second resource, and make sure that unref-ing the + // first resource doesn't much up the second resource. + scoped_refptr<CallbackMockResource> resource_2( + CallbackMockResource::Create(pp_instance())); + resource_2->CreateCallbacksOnLoop(thread().message_loop()); + resource_2->CheckInitialState(); + resource_2->RunCallbacks(); + resource_2->TakeRef(); + resource_2->CheckIntermediateState(); + + // Double-check that resource #1 is still okay. + resource_1->CheckIntermediateState(); + + // Kill resource #1, spin the message loop to run posted calls, and check that + // things are in the expected states. + resource_1->ReleaseRef(); + + resource_1->CheckFinalState(); + resource_2->CheckIntermediateState(); + + // Kill resource #2. + resource_2->ReleaseRef(); + + resource_1->CheckFinalState(); + resource_2->CheckFinalState(); + + { + ProxyAutoLock lock; + resource_1 = nullptr; + resource_2 = nullptr; + } +} + +// Test that "resurrecting" a resource (getting a new ID for a |Resource|) +// doesn't resurrect callbacks. +TEST_F(CallbackResourceTest, Resurrection) { + scoped_refptr<CallbackMockResource> resource( + CallbackMockResource::Create(pp_instance())); + resource->CreateCallbacksOnLoop(thread().message_loop()); + resource->CheckInitialState(); + resource->RunCallbacks(); + resource->TakeRef(); + resource->CheckIntermediateState(); + + // Unref it and check that things are in the expected states. + resource->ReleaseRef(); + resource->CheckFinalState(); + + // "Resurrect" it and check that the callbacks are still dead. + resource->TakeRef(); + resource->CheckFinalState(); + + // Unref it again and do the same. + resource->ReleaseRef(); + resource->CheckFinalState(); + { + ProxyAutoLock lock; + resource = nullptr; + } +} + +} // namespace proxy +} // namespace ppapi diff --git a/chromium/ppapi/proxy/truetype_font_resource.h b/chromium/ppapi/proxy/truetype_font_resource.h index fb5f5c2fa5c..2f44365b027 100644 --- a/chromium/ppapi/proxy/truetype_font_resource.h +++ b/chromium/ppapi/proxy/truetype_font_resource.h @@ -30,19 +30,19 @@ class PPAPI_PROXY_EXPORT TrueTypeFontResource TrueTypeFontResource(Connection connection, PP_Instance instance, const PP_TrueTypeFontDesc_Dev& desc); - virtual ~TrueTypeFontResource(); + ~TrueTypeFontResource() override; // Resource implementation. - virtual thunk::PPB_TrueTypeFont_API* AsPPB_TrueTypeFont_API() override; + thunk::PPB_TrueTypeFont_API* AsPPB_TrueTypeFont_API() override; // PPB_TrueTypeFont_API implementation. - virtual int32_t Describe( + int32_t Describe( PP_TrueTypeFontDesc_Dev* desc, scoped_refptr<TrackedCallback> callback) override; - virtual int32_t GetTableTags( + int32_t GetTableTags( const PP_ArrayOutput& output, scoped_refptr<TrackedCallback> callback) override; - virtual int32_t GetTable( + int32_t GetTable( uint32_t table, int32_t offset, int32_t max_data_length, @@ -50,8 +50,8 @@ class PPAPI_PROXY_EXPORT TrueTypeFontResource scoped_refptr<TrackedCallback> callback) override; // PluginResource implementation. - virtual void OnReplyReceived(const ResourceMessageReplyParams& params, - const IPC::Message& msg) override; + void OnReplyReceived(const ResourceMessageReplyParams& params, + const IPC::Message& msg) override; private: void OnPluginMsgCreateComplete( diff --git a/chromium/ppapi/proxy/truetype_font_singleton_resource.h b/chromium/ppapi/proxy/truetype_font_singleton_resource.h index 78d02a6c03c..df09471da07 100644 --- a/chromium/ppapi/proxy/truetype_font_singleton_resource.h +++ b/chromium/ppapi/proxy/truetype_font_singleton_resource.h @@ -27,18 +27,18 @@ class TrueTypeFontSingletonResource public thunk::PPB_TrueTypeFont_Singleton_API { public: TrueTypeFontSingletonResource(Connection connection, PP_Instance instance); - virtual ~TrueTypeFontSingletonResource(); + ~TrueTypeFontSingletonResource() override; // Resource override. - virtual thunk::PPB_TrueTypeFont_Singleton_API* - AsPPB_TrueTypeFont_Singleton_API() override; + thunk::PPB_TrueTypeFont_Singleton_API* AsPPB_TrueTypeFont_Singleton_API() + override; // thunk::PPB_TrueTypeFont_Singleton_API implementation. - virtual int32_t GetFontFamilies( + int32_t GetFontFamilies( PP_Instance instance, const PP_ArrayOutput& output, const scoped_refptr<TrackedCallback>& callback) override; - virtual int32_t GetFontsInFamily( + int32_t GetFontsInFamily( PP_Instance instance, PP_Var family, const PP_ArrayOutput& output, diff --git a/chromium/ppapi/proxy/udp_socket_filter.cc b/chromium/ppapi/proxy/udp_socket_filter.cc new file mode 100644 index 00000000000..8d7ff9de3a7 --- /dev/null +++ b/chromium/ppapi/proxy/udp_socket_filter.cc @@ -0,0 +1,245 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/proxy/udp_socket_filter.h" + +#include <algorithm> +#include <cstring> + +#include "base/logging.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/proxy/error_conversion.h" +#include "ppapi/proxy/plugin_globals.h" +#include "ppapi/proxy/ppapi_messages.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/resource_creation_api.h" + +namespace ppapi { +namespace proxy { + +const int32_t UDPSocketFilter::kMaxReadSize = 128 * 1024; +const int32_t UDPSocketFilter::kMaxReceiveBufferSize = + 1024 * UDPSocketFilter::kMaxReadSize; +const size_t UDPSocketFilter::kPluginReceiveBufferSlots = 32u; + +namespace { + +int32_t SetRecvFromOutput(PP_Instance pp_instance, + const scoped_ptr<std::string>& data, + const PP_NetAddress_Private& addr, + char* output_buffer, + int32_t num_bytes, + PP_Resource* output_addr, + int32_t browser_result) { + ProxyLock::AssertAcquired(); + DCHECK_GE(num_bytes, static_cast<int32_t>(data->size())); + + int32_t result = browser_result; + if (result == PP_OK && output_addr) { + thunk::EnterResourceCreationNoLock enter(pp_instance); + if (enter.succeeded()) { + *output_addr = enter.functions()->CreateNetAddressFromNetAddressPrivate( + pp_instance, addr); + } else { + result = PP_ERROR_FAILED; + } + } + + if (result == PP_OK && !data->empty()) + memcpy(output_buffer, data->c_str(), data->size()); + + return result == PP_OK ? static_cast<int32_t>(data->size()) : result; +} + +} // namespace + +UDPSocketFilter::UDPSocketFilter() { +} + +UDPSocketFilter::~UDPSocketFilter() { +} + +void UDPSocketFilter::AddUDPResource( + PP_Instance instance, + PP_Resource resource, + bool private_api, + const base::Closure& slot_available_callback) { + ProxyLock::AssertAcquired(); + base::AutoLock acquire(lock_); + DCHECK(!queues_.contains(resource)); + queues_.add(resource, scoped_ptr<RecvQueue>(new RecvQueue( + instance, private_api, slot_available_callback))); +} + +void UDPSocketFilter::RemoveUDPResource(PP_Resource resource) { + ProxyLock::AssertAcquired(); + base::AutoLock acquire(lock_); + DCHECK(queues_.contains(resource)); + queues_.erase(resource); +} + +int32_t UDPSocketFilter::RequestData( + PP_Resource resource, + int32_t num_bytes, + char* buffer, + PP_Resource* addr, + const scoped_refptr<TrackedCallback>& callback) { + ProxyLock::AssertAcquired(); + base::AutoLock acquire(lock_); + RecvQueue* queue_ptr = queues_.get(resource); + if (!queue_ptr) { + NOTREACHED(); + return PP_ERROR_FAILED; + } + return queue_ptr->RequestData(num_bytes, buffer, addr, callback); +} + +bool UDPSocketFilter::OnResourceReplyReceived( + const ResourceMessageReplyParams& params, + const IPC::Message& nested_msg) { + bool handled = true; + PPAPI_BEGIN_MESSAGE_MAP(UDPSocketFilter, nested_msg) + PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(PpapiPluginMsg_UDPSocket_PushRecvResult, + OnPluginMsgPushRecvResult) + PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED(handled = false) + PPAPI_END_MESSAGE_MAP() + return handled; +} + +PP_NetAddress_Private UDPSocketFilter::GetLastAddrPrivate( + PP_Resource resource) const { + base::AutoLock acquire(lock_); + return queues_.get(resource)->GetLastAddrPrivate(); +} + +void UDPSocketFilter::OnPluginMsgPushRecvResult( + const ResourceMessageReplyParams& params, + int32_t result, + const std::string& data, + const PP_NetAddress_Private& addr) { + DCHECK(PluginGlobals::Get()->ipc_task_runner()->RunsTasksOnCurrentThread()); + base::AutoLock acquire(lock_); + RecvQueue* queue_ptr = queues_.get(params.pp_resource()); + // The RecvQueue might be gone if there were messages in-flight for a + // resource that has been destroyed. + if (queue_ptr) { + // TODO(yzshen): Support passing in a non-const string ref, so that we can + // eliminate one copy when storing the data in the buffer. + queue_ptr->DataReceivedOnIOThread(result, data, addr); + } +} + +UDPSocketFilter::RecvQueue::RecvQueue( + PP_Instance pp_instance, + bool private_api, + const base::Closure& slot_available_callback) + : pp_instance_(pp_instance), + read_buffer_(nullptr), + bytes_to_read_(0), + recvfrom_addr_resource_(nullptr), + last_recvfrom_addr_(), + private_api_(private_api), + slot_available_callback_(slot_available_callback) { +} + +UDPSocketFilter::RecvQueue::~RecvQueue() { + if (TrackedCallback::IsPending(recvfrom_callback_)) + recvfrom_callback_->PostAbort(); +} + +void UDPSocketFilter::RecvQueue::DataReceivedOnIOThread( + int32_t result, + const std::string& data, + const PP_NetAddress_Private& addr) { + DCHECK(PluginGlobals::Get()->ipc_task_runner()->RunsTasksOnCurrentThread()); + DCHECK_LT(recv_buffers_.size(), UDPSocketFilter::kPluginReceiveBufferSlots); + + if (!TrackedCallback::IsPending(recvfrom_callback_) || !read_buffer_) { + recv_buffers_.push(RecvBuffer()); + RecvBuffer& back = recv_buffers_.back(); + back.result = result; + back.data = data; + back.addr = addr; + return; + } + DCHECK_EQ(recv_buffers_.size(), 0u); + + if (bytes_to_read_ < static_cast<int32_t>(data.size())) { + recv_buffers_.push(RecvBuffer()); + RecvBuffer& back = recv_buffers_.back(); + back.result = result; + back.data = data; + back.addr = addr; + + result = PP_ERROR_MESSAGE_TOO_BIG; + } else { + // Instead of calling SetRecvFromOutput directly, post it as a completion + // task, so that: + // 1) It can run with the ProxyLock (we can't lock it on the IO thread.) + // 2) So that we only write to the output params in the case of success. + // (Since the callback will complete on another thread, it's possible + // that the resource will be deleted and abort the callback before it + // is actually run.) + scoped_ptr<std::string> data_to_pass(new std::string(data)); + recvfrom_callback_->set_completion_task(base::Bind( + &SetRecvFromOutput, pp_instance_, base::Passed(data_to_pass.Pass()), + addr, base::Unretained(read_buffer_), bytes_to_read_, + base::Unretained(recvfrom_addr_resource_))); + last_recvfrom_addr_ = addr; + PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( + FROM_HERE, + RunWhileLocked(slot_available_callback_)); + } + + read_buffer_ = NULL; + bytes_to_read_ = -1; + recvfrom_addr_resource_ = NULL; + + recvfrom_callback_->Run( + ConvertNetworkAPIErrorForCompatibility(result, private_api_)); +} + +int32_t UDPSocketFilter::RecvQueue::RequestData( + int32_t num_bytes, + char* buffer_out, + PP_Resource* addr_out, + const scoped_refptr<TrackedCallback>& callback) { + ProxyLock::AssertAcquired(); + if (!buffer_out || num_bytes <= 0) + return PP_ERROR_BADARGUMENT; + if (TrackedCallback::IsPending(recvfrom_callback_)) + return PP_ERROR_INPROGRESS; + + if (recv_buffers_.empty()) { + read_buffer_ = buffer_out; + bytes_to_read_ = std::min(num_bytes, UDPSocketFilter::kMaxReadSize); + recvfrom_addr_resource_ = addr_out; + recvfrom_callback_ = callback; + return PP_OK_COMPLETIONPENDING; + } else { + RecvBuffer& front = recv_buffers_.front(); + + if (static_cast<size_t>(num_bytes) < front.data.size()) + return PP_ERROR_MESSAGE_TOO_BIG; + + int32_t result = static_cast<int32_t>(front.data.size()); + scoped_ptr<std::string> data_to_pass(new std::string); + data_to_pass->swap(front.data); + SetRecvFromOutput(pp_instance_, data_to_pass.Pass(), front.addr, buffer_out, + num_bytes, addr_out, PP_OK); + last_recvfrom_addr_ = front.addr; + recv_buffers_.pop(); + slot_available_callback_.Run(); + + return result; + } +} + +PP_NetAddress_Private UDPSocketFilter::RecvQueue::GetLastAddrPrivate() const { + CHECK(private_api_); + return last_recvfrom_addr_; +} + +} // namespace proxy +} // namespace ppapi diff --git a/chromium/ppapi/proxy/udp_socket_filter.h b/chromium/ppapi/proxy/udp_socket_filter.h new file mode 100644 index 00000000000..faa62e09989 --- /dev/null +++ b/chromium/ppapi/proxy/udp_socket_filter.h @@ -0,0 +1,137 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_PROXY_UDP_SOCKET_FILTER_H_ +#define PPAPI_PROXY_UDP_SOCKET_FILTER_H_ + +#include <queue> +#include <string> + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "base/containers/scoped_ptr_hash_map.h" +#include "base/memory/ref_counted.h" +#include "ppapi/c/ppb_udp_socket.h" +#include "ppapi/c/private/ppb_net_address_private.h" +#include "ppapi/proxy/plugin_resource.h" +#include "ppapi/proxy/ppapi_proxy_export.h" +#include "ppapi/proxy/resource_message_filter.h" +#include "ppapi/shared_impl/tracked_callback.h" + +namespace ppapi { +namespace proxy { + +class ResourceMessageReplyParams; + +// Handles receiving UDP packets on the IO thread so that when the recipient is +// not on the main thread, we can post directly to the appropriate thread. +class PPAPI_PROXY_EXPORT UDPSocketFilter : public ResourceMessageFilter { + public: + UDPSocketFilter(); + + // All these are called on whatever thread the plugin wants, while already + // holding the ppapi::ProxyLock. The "slot_available_callback" will be invoked + // whenever we detect that a slot is now available, so that the client can + // take appropriate action (like informing the host we can receive another + // buffer). It will always be run with the ProxyLock. + void AddUDPResource(PP_Instance instance, + PP_Resource resource, + bool private_api, + const base::Closure& slot_available_callback); + void RemoveUDPResource(PP_Resource resource); + // Note, the slot_available_callback that was provided to AddUDPResource may + // be invoked during the RequestData call; this gives the client the + // opportunity to post a message to the host immediately. + int32_t RequestData(PP_Resource resource, + int32_t num_bytes, + char* buffer, + PP_Resource* addr, + const scoped_refptr<TrackedCallback>& callback); + + // ResourceMessageFilter implementation. + bool OnResourceReplyReceived(const ResourceMessageReplyParams& reply_params, + const IPC::Message& nested_msg) override; + + PP_NetAddress_Private GetLastAddrPrivate(PP_Resource resource) const; + + // The maximum number of bytes that each + // PpapiPluginMsg_PPBUDPSocket_PushRecvResult message is allowed to carry. + static const int32_t kMaxReadSize; + // The maximum number that we allow for setting + // PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE. This number is only for input + // argument sanity check, it doesn't mean the browser guarantees to support + // such a buffer size. + static const int32_t kMaxReceiveBufferSize; + // The maximum number of received packets that we allow instances of this + // class to buffer. + static const size_t kPluginReceiveBufferSlots; + + private: + // The queue of received data intended for 1 UDPSocketResourceBase. All usage + // must be protected by UDPSocketFilter::lock_. + class RecvQueue { + public: + explicit RecvQueue(PP_Instance instance, + bool private_api, + const base::Closure& slot_available_callback); + ~RecvQueue(); + + // Called on the IO thread when data is received. It will post |callback_| + // if it's valid, otherwise push the data on buffers_. + // The ppapi::ProxyLock should *not* be held, and won't be acquired. + void DataReceivedOnIOThread(int32_t result, + const std::string& d, + const PP_NetAddress_Private& addr); + // Called on whatever thread the plugin chooses. Must already hold the + // PpapiProxyLock. Returns a code from pp_errors.h, or a positive number. + // + // Note, the out-params are owned by the plugin, and if the request can't be + // handled immediately, they will be written later just before the callback + // is invoked. + int32_t RequestData(int32_t num_bytes, + char* buffer_out, + PP_Resource* addr_out, + const scoped_refptr<TrackedCallback>& callback); + PP_NetAddress_Private GetLastAddrPrivate() const; + + private: + struct RecvBuffer { + int32_t result; + std::string data; + PP_NetAddress_Private addr; + }; + std::queue<RecvBuffer> recv_buffers_; + + PP_Instance pp_instance_; + scoped_refptr<ppapi::TrackedCallback> recvfrom_callback_; + char* read_buffer_; + int32_t bytes_to_read_; + PP_Resource* recvfrom_addr_resource_; + PP_NetAddress_Private last_recvfrom_addr_; + bool private_api_; + // Callback to invoke when a UDP receive slot is available. + base::Closure slot_available_callback_; + }; + + private: + // This is deleted via RefCountedThreadSafe (see ResourceMessageFilter). + ~UDPSocketFilter(); + void OnPluginMsgPushRecvResult(const ResourceMessageReplyParams& params, + int32_t result, + const std::string& data, + const PP_NetAddress_Private& addr); + + // lock_ protects queues_. + // + // Lock order (if >1 acquired): + // 1 ppapi::ProxyLock + // \-->2 Filter lock_ + mutable base::Lock lock_; + base::ScopedPtrHashMap<PP_Resource, scoped_ptr<RecvQueue>> queues_; +}; + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_UDP_SOCKET_FILTER_H_ diff --git a/chromium/ppapi/proxy/udp_socket_private_resource.cc b/chromium/ppapi/proxy/udp_socket_private_resource.cc index af43c10fb05..60afc6f3593 100644 --- a/chromium/ppapi/proxy/udp_socket_private_resource.cc +++ b/chromium/ppapi/proxy/udp_socket_private_resource.cc @@ -41,7 +41,9 @@ int32_t UDPSocketPrivateResource::SetSocketFeature( NOTREACHED(); return PP_ERROR_BADARGUMENT; } - int32_t result = SetOptionImpl(public_name, value, NULL); + int32_t result = SetOptionImpl(public_name, value, + true, // Check bind() state. + NULL); return result == PP_OK_COMPLETIONPENDING ? PP_OK : result; } diff --git a/chromium/ppapi/proxy/udp_socket_private_resource.h b/chromium/ppapi/proxy/udp_socket_private_resource.h index 899c5886b65..f335c6c9482 100644 --- a/chromium/ppapi/proxy/udp_socket_private_resource.h +++ b/chromium/ppapi/proxy/udp_socket_private_resource.h @@ -19,27 +19,26 @@ class PPAPI_PROXY_EXPORT UDPSocketPrivateResource public thunk::PPB_UDPSocket_Private_API { public: UDPSocketPrivateResource(Connection connection, PP_Instance instance); - virtual ~UDPSocketPrivateResource(); + ~UDPSocketPrivateResource() override; // PluginResource implementation. - virtual thunk::PPB_UDPSocket_Private_API* - AsPPB_UDPSocket_Private_API() override; + thunk::PPB_UDPSocket_Private_API* AsPPB_UDPSocket_Private_API() override; // PPB_UDPSocket_Private_API implementation. - virtual int32_t SetSocketFeature(PP_UDPSocketFeature_Private name, - PP_Var value) override; - virtual int32_t Bind(const PP_NetAddress_Private* addr, - scoped_refptr<TrackedCallback> callback) override; - virtual PP_Bool GetBoundAddress(PP_NetAddress_Private* addr) override; - virtual int32_t RecvFrom(char* buffer, - int32_t num_bytes, - scoped_refptr<TrackedCallback> callback) override; - virtual PP_Bool GetRecvFromAddress(PP_NetAddress_Private* addr) override; - virtual int32_t SendTo(const char* buffer, - int32_t num_bytes, - const PP_NetAddress_Private* addr, - scoped_refptr<TrackedCallback> callback) override; - virtual void Close() override; + int32_t SetSocketFeature(PP_UDPSocketFeature_Private name, + PP_Var value) override; + int32_t Bind(const PP_NetAddress_Private* addr, + scoped_refptr<TrackedCallback> callback) override; + PP_Bool GetBoundAddress(PP_NetAddress_Private* addr) override; + int32_t RecvFrom(char* buffer, + int32_t num_bytes, + scoped_refptr<TrackedCallback> callback) override; + PP_Bool GetRecvFromAddress(PP_NetAddress_Private* addr) override; + int32_t SendTo(const char* buffer, + int32_t num_bytes, + const PP_NetAddress_Private* addr, + scoped_refptr<TrackedCallback> callback) override; + void Close() override; private: DISALLOW_COPY_AND_ASSIGN(UDPSocketPrivateResource); diff --git a/chromium/ppapi/proxy/udp_socket_resource.cc b/chromium/ppapi/proxy/udp_socket_resource.cc index 9ce7c91f130..25a0f880c28 100644 --- a/chromium/ppapi/proxy/udp_socket_resource.cc +++ b/chromium/ppapi/proxy/udp_socket_resource.cc @@ -75,11 +75,59 @@ void UDPSocketResource::Close() { CloseImpl(); } +int32_t UDPSocketResource::SetOption1_0( + PP_UDPSocket_Option name, + const PP_Var& value, + scoped_refptr<TrackedCallback> callback) { + if (name > PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE) + return PP_ERROR_BADARGUMENT; + + return SetOptionImpl(name, value, + true, // Check bind() state. + callback); +} + +int32_t UDPSocketResource::SetOption1_1( + PP_UDPSocket_Option name, + const PP_Var& value, + scoped_refptr<TrackedCallback> callback) { + if (name > PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE) + return PP_ERROR_BADARGUMENT; + + return SetOptionImpl(name, value, + false, // Check bind() state. + callback); +} + int32_t UDPSocketResource::SetOption( PP_UDPSocket_Option name, const PP_Var& value, scoped_refptr<TrackedCallback> callback) { - return SetOptionImpl(name, value, callback); + return SetOptionImpl(name, value, + false, // Check bind() state. + callback); +} + +int32_t UDPSocketResource::JoinGroup( + PP_Resource group, + scoped_refptr<TrackedCallback> callback) { + EnterNetAddressNoLock enter(group, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + + return JoinGroupImpl(&enter.object()->GetNetAddressPrivate(), + callback); +} + +int32_t UDPSocketResource::LeaveGroup( + PP_Resource group, + scoped_refptr<TrackedCallback> callback) { + EnterNetAddressNoLock enter(group, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + + return LeaveGroupImpl(&enter.object()->GetNetAddressPrivate(), + callback); } } // namespace proxy diff --git a/chromium/ppapi/proxy/udp_socket_resource.h b/chromium/ppapi/proxy/udp_socket_resource.h index e0d099afef2..5217d96956c 100644 --- a/chromium/ppapi/proxy/udp_socket_resource.h +++ b/chromium/ppapi/proxy/udp_socket_resource.h @@ -18,27 +18,39 @@ class PPAPI_PROXY_EXPORT UDPSocketResource : public UDPSocketResourceBase, public thunk::PPB_UDPSocket_API { public: UDPSocketResource(Connection connection, PP_Instance instance); - virtual ~UDPSocketResource(); + ~UDPSocketResource() override; // PluginResource implementation. - virtual thunk::PPB_UDPSocket_API* AsPPB_UDPSocket_API() override; + thunk::PPB_UDPSocket_API* AsPPB_UDPSocket_API() override; // thunk::PPB_UDPSocket_API implementation. - virtual int32_t Bind(PP_Resource addr, - scoped_refptr<TrackedCallback> callback) override; - virtual PP_Resource GetBoundAddress() override; - virtual int32_t RecvFrom(char* buffer, - int32_t num_bytes, - PP_Resource* addr, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t SendTo(const char* buffer, - int32_t num_bytes, - PP_Resource addr, - scoped_refptr<TrackedCallback> callback) override; - virtual void Close() override; - virtual int32_t SetOption(PP_UDPSocket_Option name, - const PP_Var& value, - scoped_refptr<TrackedCallback> callback) override; + int32_t Bind(PP_Resource addr, + scoped_refptr<TrackedCallback> callback) override; + PP_Resource GetBoundAddress() override; + int32_t RecvFrom(char* buffer, + int32_t num_bytes, + PP_Resource* addr, + scoped_refptr<TrackedCallback> callback) override; + int32_t SendTo(const char* buffer, + int32_t num_bytes, + PP_Resource addr, + scoped_refptr<TrackedCallback> callback) override; + void Close() override; + int32_t SetOption1_0( + PP_UDPSocket_Option name, + const PP_Var& value, + scoped_refptr<TrackedCallback> callback) override; + int32_t SetOption1_1( + PP_UDPSocket_Option name, + const PP_Var& value, + scoped_refptr<TrackedCallback> callback) override; + int32_t SetOption(PP_UDPSocket_Option name, + const PP_Var& value, + scoped_refptr<TrackedCallback> callback) override; + int32_t JoinGroup(PP_Resource group, + scoped_refptr<TrackedCallback> callback) override; + int32_t LeaveGroup(PP_Resource group, + scoped_refptr<TrackedCallback> callback) override; private: DISALLOW_COPY_AND_ASSIGN(UDPSocketResource); diff --git a/chromium/ppapi/proxy/udp_socket_resource_base.cc b/chromium/ppapi/proxy/udp_socket_resource_base.cc index 521a6e2f4e2..795b63b4040 100644 --- a/chromium/ppapi/proxy/udp_socket_resource_base.cc +++ b/chromium/ppapi/proxy/udp_socket_resource_base.cc @@ -4,73 +4,100 @@ #include "ppapi/proxy/udp_socket_resource_base.h" -#include <algorithm> #include <cstring> #include "base/logging.h" #include "ppapi/c/pp_bool.h" -#include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" #include "ppapi/proxy/error_conversion.h" #include "ppapi/proxy/plugin_globals.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/shared_impl/socket_option_data.h" #include "ppapi/thunk/enter.h" -#include "ppapi/thunk/resource_creation_api.h" namespace ppapi { namespace proxy { -const int32_t UDPSocketResourceBase::kMaxReadSize = 128 * 1024; const int32_t UDPSocketResourceBase::kMaxWriteSize = 128 * 1024; const int32_t UDPSocketResourceBase::kMaxSendBufferSize = 1024 * UDPSocketResourceBase::kMaxWriteSize; -const int32_t UDPSocketResourceBase::kMaxReceiveBufferSize = - 1024 * UDPSocketResourceBase::kMaxReadSize; -const size_t UDPSocketResourceBase::kPluginReceiveBufferSlots = 32u; +const size_t UDPSocketResourceBase::kPluginSendBufferSlots = 8u; + +namespace { + +void RunCallback(scoped_refptr<TrackedCallback> callback, + int32_t pp_result, + bool private_api) { + callback->Run(ConvertNetworkAPIErrorForCompatibility(pp_result, private_api)); +} + +void PostAbortIfNecessary(const scoped_refptr<TrackedCallback>& callback) { + if (TrackedCallback::IsPending(callback)) + callback->PostAbort(); +} + +} // namespace UDPSocketResourceBase::UDPSocketResourceBase(Connection connection, PP_Instance instance, bool private_api) : PluginResource(connection, instance), private_api_(private_api), + bind_called_(false), bound_(false), closed_(false), - read_buffer_(NULL), - bytes_to_read_(-1), - recvfrom_addr_resource_(NULL) { - recvfrom_addr_.size = 0; - memset(recvfrom_addr_.data, 0, - arraysize(recvfrom_addr_.data) * sizeof(*recvfrom_addr_.data)); - bound_addr_.size = 0; - memset(bound_addr_.data, 0, - arraysize(bound_addr_.data) * sizeof(*bound_addr_.data)); - + recv_filter_(PluginGlobals::Get()->udp_socket_filter()), + bound_addr_() { + recv_filter_->AddUDPResource( + pp_instance(), pp_resource(), private_api, + base::Bind(&UDPSocketResourceBase::SlotBecameAvailable, pp_resource())); if (private_api) SendCreate(BROWSER, PpapiHostMsg_UDPSocket_CreatePrivate()); else SendCreate(BROWSER, PpapiHostMsg_UDPSocket_Create()); - - PluginGlobals::Get()->resource_reply_thread_registrar()->HandleOnIOThread( - PpapiPluginMsg_UDPSocket_PushRecvResult::ID); } UDPSocketResourceBase::~UDPSocketResourceBase() { + CloseImpl(); } int32_t UDPSocketResourceBase::SetOptionImpl( PP_UDPSocket_Option name, const PP_Var& value, + bool check_bind_state, scoped_refptr<TrackedCallback> callback) { if (closed_) return PP_ERROR_FAILED; - SocketOptionData option_data; + // Check if socket is expected to be bound or not according to the option. switch (name) { case PP_UDPSOCKET_OPTION_ADDRESS_REUSE: - case PP_UDPSOCKET_OPTION_BROADCAST: { - if (bound_) + case PP_UDPSOCKET_OPTION_BROADCAST: + case PP_UDPSOCKET_OPTION_MULTICAST_LOOP: + case PP_UDPSOCKET_OPTION_MULTICAST_TTL: { + if ((check_bind_state || name == PP_UDPSOCKET_OPTION_ADDRESS_REUSE) && + bind_called_) { + // SetOption should fail in this case in order to give predictable + // behavior while binding. Note that we use |bind_called_| rather + // than |bound_| since the latter is only set on successful completion + // of Bind(). return PP_ERROR_FAILED; + } + break; + } + case PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE: + case PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE: { + if (check_bind_state && !bound_) + return PP_ERROR_FAILED; + break; + } + } + + SocketOptionData option_data; + switch (name) { + case PP_UDPSOCKET_OPTION_ADDRESS_REUSE: + case PP_UDPSOCKET_OPTION_BROADCAST: + case PP_UDPSOCKET_OPTION_MULTICAST_LOOP: { if (value.type != PP_VARTYPE_BOOL) return PP_ERROR_BADARGUMENT; option_data.SetBool(PP_ToBool(value.value.as_bool)); @@ -78,13 +105,18 @@ int32_t UDPSocketResourceBase::SetOptionImpl( } case PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE: case PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE: { - if (!bound_) - return PP_ERROR_FAILED; if (value.type != PP_VARTYPE_INT32) return PP_ERROR_BADARGUMENT; option_data.SetInt32(value.value.as_int); break; } + case PP_UDPSOCKET_OPTION_MULTICAST_TTL: { + int32_t ival = value.value.as_int; + if (value.type != PP_VARTYPE_INT32 && (ival < 0 || ival > 255)) + return PP_ERROR_BADARGUMENT; + option_data.SetInt32(ival); + break; + } default: { NOTREACHED(); return PP_ERROR_BADARGUMENT; @@ -94,7 +126,7 @@ int32_t UDPSocketResourceBase::SetOptionImpl( Call<PpapiPluginMsg_UDPSocket_SetOptionReply>( BROWSER, PpapiHostMsg_UDPSocket_SetOption(name, option_data), - base::Bind(&UDPSocketResourceBase::OnPluginMsgSetOptionReply, + base::Bind(&UDPSocketResourceBase::OnPluginMsgGeneralReply, base::Unretained(this), callback), callback); @@ -111,6 +143,7 @@ int32_t UDPSocketResourceBase::BindImpl( if (TrackedCallback::IsPending(bind_callback_)) return PP_ERROR_INPROGRESS; + bind_called_ = true; bind_callback_ = callback; // Send the request, the browser will call us back via BindReply. @@ -133,45 +166,21 @@ PP_Bool UDPSocketResourceBase::GetBoundAddressImpl( } int32_t UDPSocketResourceBase::RecvFromImpl( - char* buffer, + char* buffer_out, int32_t num_bytes, PP_Resource* addr, scoped_refptr<TrackedCallback> callback) { - if (!buffer || num_bytes <= 0) - return PP_ERROR_BADARGUMENT; if (!bound_) return PP_ERROR_FAILED; - if (TrackedCallback::IsPending(recvfrom_callback_)) - return PP_ERROR_INPROGRESS; - - if (recv_buffers_.empty()) { - read_buffer_ = buffer; - bytes_to_read_ = std::min(num_bytes, kMaxReadSize); - recvfrom_addr_resource_ = addr; - recvfrom_callback_ = callback; - - return PP_OK_COMPLETIONPENDING; - } else { - RecvBuffer& front = recv_buffers_.front(); - - if (num_bytes < static_cast<int32_t>(front.data.size())) - return PP_ERROR_MESSAGE_TOO_BIG; - - int32_t result = SetRecvFromOutput(front.result, front.data, front.addr, - buffer, num_bytes, addr); - - recv_buffers_.pop(); - Post(BROWSER, PpapiHostMsg_UDPSocket_RecvSlotAvailable()); - - return result; - } + return recv_filter_->RequestData(pp_resource(), num_bytes, buffer_out, addr, + callback); } PP_Bool UDPSocketResourceBase::GetRecvFromAddressImpl( PP_NetAddress_Private* addr) { if (!addr) return PP_FALSE; - *addr = recvfrom_addr_; + *addr = recv_filter_->GetLastAddrPrivate(pp_resource()); return PP_TRUE; } @@ -184,13 +193,13 @@ int32_t UDPSocketResourceBase::SendToImpl( return PP_ERROR_BADARGUMENT; if (!bound_) return PP_ERROR_FAILED; - if (TrackedCallback::IsPending(sendto_callback_)) + if (sendto_callbacks_.size() == kPluginSendBufferSlots) return PP_ERROR_INPROGRESS; if (num_bytes > kMaxWriteSize) num_bytes = kMaxWriteSize; - sendto_callback_ = callback; + sendto_callbacks_.push(callback); // Send the request, the browser will call us back via SendToReply. Call<PpapiPluginMsg_UDPSocket_SendToReply>( @@ -211,37 +220,50 @@ void UDPSocketResourceBase::CloseImpl() { Post(BROWSER, PpapiHostMsg_UDPSocket_Close()); - PostAbortIfNecessary(&bind_callback_); - PostAbortIfNecessary(&recvfrom_callback_); - PostAbortIfNecessary(&sendto_callback_); - - read_buffer_ = NULL; - bytes_to_read_ = -1; + PostAbortIfNecessary(bind_callback_); + while (!sendto_callbacks_.empty()) { + scoped_refptr<TrackedCallback> callback = sendto_callbacks_.front(); + sendto_callbacks_.pop(); + PostAbortIfNecessary(callback); + } + recv_filter_->RemoveUDPResource(pp_resource()); } -void UDPSocketResourceBase::OnReplyReceived( - const ResourceMessageReplyParams& params, - const IPC::Message& msg) { - PPAPI_BEGIN_MESSAGE_MAP(UDPSocketResourceBase, msg) - PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL( - PpapiPluginMsg_UDPSocket_PushRecvResult, - OnPluginMsgPushRecvResult) - PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED( - PluginResource::OnReplyReceived(params, msg)) - PPAPI_END_MESSAGE_MAP() +int32_t UDPSocketResourceBase::JoinGroupImpl( + const PP_NetAddress_Private *group, + scoped_refptr<TrackedCallback> callback) { + DCHECK(group); + + Call<PpapiPluginMsg_UDPSocket_JoinGroupReply>( + BROWSER, + PpapiHostMsg_UDPSocket_JoinGroup(*group), + base::Bind(&UDPSocketResourceBase::OnPluginMsgGeneralReply, + base::Unretained(this), + callback), + callback); + return PP_OK_COMPLETIONPENDING; } -void UDPSocketResourceBase::PostAbortIfNecessary( - scoped_refptr<TrackedCallback>* callback) { - if (TrackedCallback::IsPending(*callback)) - (*callback)->PostAbort(); +int32_t UDPSocketResourceBase::LeaveGroupImpl( + const PP_NetAddress_Private *group, + scoped_refptr<TrackedCallback> callback) { + DCHECK(group); + + Call<PpapiPluginMsg_UDPSocket_LeaveGroupReply>( + BROWSER, + PpapiHostMsg_UDPSocket_LeaveGroup(*group), + base::Bind(&UDPSocketResourceBase::OnPluginMsgGeneralReply, + base::Unretained(this), + callback), + callback); + return PP_OK_COMPLETIONPENDING; } -void UDPSocketResourceBase::OnPluginMsgSetOptionReply( +void UDPSocketResourceBase::OnPluginMsgGeneralReply( scoped_refptr<TrackedCallback> callback, const ResourceMessageReplyParams& params) { if (TrackedCallback::IsPending(callback)) - RunCallback(callback, params.result()); + RunCallback(callback, params.result(), private_api_); } void UDPSocketResourceBase::OnPluginMsgBindReply( @@ -257,96 +279,46 @@ void UDPSocketResourceBase::OnPluginMsgBindReply( if (params.result() == PP_OK) bound_ = true; bound_addr_ = bound_addr; - RunCallback(bind_callback_, params.result()); -} - -void UDPSocketResourceBase::OnPluginMsgPushRecvResult( - const ResourceMessageReplyParams& params, - int32_t result, - const std::string& data, - const PP_NetAddress_Private& addr) { - // TODO(yzshen): Support passing in a non-const string ref, so that we can - // eliminate one copy when storing the data in the buffer. - - DCHECK_LT(recv_buffers_.size(), kPluginReceiveBufferSlots); - - if (!TrackedCallback::IsPending(recvfrom_callback_) || !read_buffer_) { - recv_buffers_.push(RecvBuffer()); - RecvBuffer& back = recv_buffers_.back(); - back.result = result; - back.data = data; - back.addr = addr; - - return; - } - - DCHECK_EQ(recv_buffers_.size(), 0u); - - if (bytes_to_read_ < static_cast<int32_t>(data.size())) { - recv_buffers_.push(RecvBuffer()); - RecvBuffer& back = recv_buffers_.back(); - back.result = result; - back.data = data; - back.addr = addr; - - result = PP_ERROR_MESSAGE_TOO_BIG; - } else { - result = SetRecvFromOutput(result, data, addr, read_buffer_, bytes_to_read_, - recvfrom_addr_resource_); - Post(BROWSER, PpapiHostMsg_UDPSocket_RecvSlotAvailable()); - } - - read_buffer_ = NULL; - bytes_to_read_ = -1; - recvfrom_addr_resource_ = NULL; - - RunCallback(recvfrom_callback_, result); + RunCallback(bind_callback_, params.result(), private_api_); } void UDPSocketResourceBase::OnPluginMsgSendToReply( const ResourceMessageReplyParams& params, int32_t bytes_written) { - if (!TrackedCallback::IsPending(sendto_callback_)) + // This can be empty if the socket was closed, but there are still tasks + // to be posted for this resource. + if (sendto_callbacks_.empty()) + return; + + scoped_refptr<TrackedCallback> callback = sendto_callbacks_.front(); + sendto_callbacks_.pop(); + if (!TrackedCallback::IsPending(callback)) return; if (params.result() == PP_OK) - RunCallback(sendto_callback_, bytes_written); + RunCallback(callback, bytes_written, private_api_); else - RunCallback(sendto_callback_, params.result()); + RunCallback(callback, params.result(), private_api_); } -void UDPSocketResourceBase::RunCallback(scoped_refptr<TrackedCallback> callback, - int32_t pp_result) { - callback->Run(ConvertNetworkAPIErrorForCompatibility(pp_result, - private_api_)); -} - -int32_t UDPSocketResourceBase::SetRecvFromOutput( - int32_t browser_result, - const std::string& data, - const PP_NetAddress_Private& addr, - char* output_buffer, - int32_t num_bytes, - PP_Resource* output_addr) { - DCHECK_GE(num_bytes, static_cast<int32_t>(data.size())); - - int32_t result = browser_result; - if (result == PP_OK && output_addr) { - thunk::EnterResourceCreationNoLock enter(pp_instance()); - if (enter.succeeded()) { - *output_addr = enter.functions()->CreateNetAddressFromNetAddressPrivate( - pp_instance(), addr); - } else { - result = PP_ERROR_FAILED; - } +// static +void UDPSocketResourceBase::SlotBecameAvailable(PP_Resource resource) { + ProxyLock::AssertAcquired(); + UDPSocketResourceBase* thiz = nullptr; + // We have to try to enter all subclasses of UDPSocketResourceBase. Currently, + // these are the public and private resources. + thunk::EnterResourceNoLock<thunk::PPB_UDPSocket_API> enter(resource, false); + if (enter.succeeded()) { + thiz = static_cast<UDPSocketResourceBase*>(enter.resource()); + } else { + thunk::EnterResourceNoLock<thunk::PPB_UDPSocket_Private_API> enter_private( + resource, false); + if (enter_private.succeeded()) + thiz = static_cast<UDPSocketResourceBase*>(enter_private.resource()); } - if (result == PP_OK && !data.empty()) - memcpy(output_buffer, data.c_str(), data.size()); - - recvfrom_addr_ = addr; - - return result == PP_OK ? static_cast<int32_t>(data.size()) : result; + if (thiz && !thiz->closed_) + thiz->Post(BROWSER, PpapiHostMsg_UDPSocket_RecvSlotAvailable()); } } // namespace proxy diff --git a/chromium/ppapi/proxy/udp_socket_resource_base.h b/chromium/ppapi/proxy/udp_socket_resource_base.h index 5400f6be995..e5a8aef805f 100644 --- a/chromium/ppapi/proxy/udp_socket_resource_base.h +++ b/chromium/ppapi/proxy/udp_socket_resource_base.h @@ -6,7 +6,6 @@ #define PPAPI_PROXY_UDP_SOCKET_RESOURCE_BASE_H_ #include <queue> -#include <string> #include "base/basictypes.h" #include "base/compiler_specific.h" @@ -15,6 +14,7 @@ #include "ppapi/c/private/ppb_net_address_private.h" #include "ppapi/proxy/plugin_resource.h" #include "ppapi/proxy/ppapi_proxy_export.h" +#include "ppapi/proxy/udp_socket_filter.h" #include "ppapi/shared_impl/tracked_callback.h" namespace ppapi { @@ -22,7 +22,7 @@ namespace proxy { class ResourceMessageReplyParams; -class PPAPI_PROXY_EXPORT UDPSocketResourceBase: public PluginResource { +class PPAPI_PROXY_EXPORT UDPSocketResourceBase : public PluginResource { public: // The maximum number of bytes that each // PpapiPluginMsg_PPBUDPSocket_PushRecvResult message is allowed to carry. @@ -45,6 +45,9 @@ class PPAPI_PROXY_EXPORT UDPSocketResourceBase: public PluginResource { // The maximum number of received packets that we allow instances of this // class to buffer. static const size_t kPluginReceiveBufferSlots; + // The maximum number of buffers that we allow instances of this class to be + // sending before we block the plugin. + static const size_t kPluginSendBufferSlots; protected: UDPSocketResourceBase(Connection connection, @@ -54,6 +57,7 @@ class PPAPI_PROXY_EXPORT UDPSocketResourceBase: public PluginResource { int32_t SetOptionImpl(PP_UDPSocket_Option name, const PP_Var& value, + bool check_bind_state, scoped_refptr<TrackedCallback> callback); int32_t BindImpl(const PP_NetAddress_Private* addr, scoped_refptr<TrackedCallback> callback); @@ -69,58 +73,38 @@ class PPAPI_PROXY_EXPORT UDPSocketResourceBase: public PluginResource { const PP_NetAddress_Private* addr, scoped_refptr<TrackedCallback> callback); void CloseImpl(); + int32_t JoinGroupImpl(const PP_NetAddress_Private *group, + scoped_refptr<TrackedCallback> callback); + int32_t LeaveGroupImpl(const PP_NetAddress_Private *group, + scoped_refptr<TrackedCallback> callback); private: - struct RecvBuffer { - int32_t result; - std::string data; - PP_NetAddress_Private addr; - }; - - // Resource overrides. - virtual void OnReplyReceived(const ResourceMessageReplyParams& params, - const IPC::Message& msg) override; - - void PostAbortIfNecessary(scoped_refptr<TrackedCallback>* callback); - // IPC message handlers. - void OnPluginMsgSetOptionReply(scoped_refptr<TrackedCallback> callback, - const ResourceMessageReplyParams& params); + void OnPluginMsgGeneralReply(scoped_refptr<TrackedCallback> callback, + const ResourceMessageReplyParams& params); void OnPluginMsgBindReply(const ResourceMessageReplyParams& params, const PP_NetAddress_Private& bound_addr); - void OnPluginMsgPushRecvResult(const ResourceMessageReplyParams& params, - int32_t result, - const std::string& data, - const PP_NetAddress_Private& addr); void OnPluginMsgSendToReply(const ResourceMessageReplyParams& params, int32_t bytes_written); - void RunCallback(scoped_refptr<TrackedCallback> callback, int32_t pp_result); - - // Callers must ensure that |output_buffer| is big enough to store |data|. - int32_t SetRecvFromOutput(int32_t browser_result, - const std::string& data, - const PP_NetAddress_Private& addr, - char* output_buffer, - int32_t num_bytes, - PP_Resource* output_addr); + static void SlotBecameAvailable(PP_Resource resource); + static void SlotBecameAvailableWithLock(PP_Resource resource); bool private_api_; + + // |bind_called_| is true after Bind() is called, while |bound_| is true + // after Bind() succeeds. Bind() is an asynchronous method, so the timing + // on which of these is set is slightly different. + bool bind_called_; bool bound_; bool closed_; scoped_refptr<TrackedCallback> bind_callback_; - scoped_refptr<TrackedCallback> recvfrom_callback_; - scoped_refptr<TrackedCallback> sendto_callback_; - - char* read_buffer_; - int32_t bytes_to_read_; - PP_Resource* recvfrom_addr_resource_; + scoped_refptr<UDPSocketFilter> recv_filter_; - PP_NetAddress_Private recvfrom_addr_; PP_NetAddress_Private bound_addr_; - std::queue<RecvBuffer> recv_buffers_; + std::queue<scoped_refptr<TrackedCallback>> sendto_callbacks_; DISALLOW_COPY_AND_ASSIGN(UDPSocketResourceBase); }; diff --git a/chromium/ppapi/proxy/uma_private_resource.h b/chromium/ppapi/proxy/uma_private_resource.h index 2057ff0e409..3215e647577 100644 --- a/chromium/ppapi/proxy/uma_private_resource.h +++ b/chromium/ppapi/proxy/uma_private_resource.h @@ -19,32 +19,32 @@ class PPAPI_PROXY_EXPORT UMAPrivateResource public thunk::PPB_UMA_Singleton_API { public: UMAPrivateResource(Connection connection, PP_Instance instance); - virtual ~UMAPrivateResource(); + ~UMAPrivateResource() override; // Resource overrides. - virtual thunk::PPB_UMA_Singleton_API* AsPPB_UMA_Singleton_API() override; + thunk::PPB_UMA_Singleton_API* AsPPB_UMA_Singleton_API() override; // PPB_UMA_Singleton_API implementation. - virtual void HistogramCustomTimes(PP_Instance instance, - struct PP_Var name, - int64_t sample, - int64_t min, - int64_t max, - uint32_t bucket_count) override; - - virtual void HistogramCustomCounts(PP_Instance instance, - struct PP_Var name, - int32_t sample, - int32_t min, - int32_t max, - uint32_t bucket_count) override; - - virtual void HistogramEnumeration(PP_Instance instance, - struct PP_Var name, - int32_t sample, - int32_t boundary_value) override; - - virtual int32_t IsCrashReportingEnabled( + void HistogramCustomTimes(PP_Instance instance, + struct PP_Var name, + int64_t sample, + int64_t min, + int64_t max, + uint32_t bucket_count) override; + + void HistogramCustomCounts(PP_Instance instance, + struct PP_Var name, + int32_t sample, + int32_t min, + int32_t max, + uint32_t bucket_count) override; + + void HistogramEnumeration(PP_Instance instance, + struct PP_Var name, + int32_t sample, + int32_t boundary_value) override; + + int32_t IsCrashReportingEnabled( PP_Instance instance, scoped_refptr<TrackedCallback> callback) override; diff --git a/chromium/ppapi/proxy/url_loader_resource.cc b/chromium/ppapi/proxy/url_loader_resource.cc index 73bdb2342f4..0697e905c28 100644 --- a/chromium/ppapi/proxy/url_loader_resource.cc +++ b/chromium/ppapi/proxy/url_loader_resource.cc @@ -5,6 +5,7 @@ #include "ppapi/proxy/url_loader_resource.h" #include "base/logging.h" +#include "base/numerics/safe_conversions.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/ppb_url_loader.h" @@ -374,7 +375,7 @@ void URLLoaderResource::SaveResponseInfo(const URLResponseInfoData& data) { connection(), pp_instance(), data, body_as_file_ref); } -size_t URLLoaderResource::FillUserBuffer() { +int32_t URLLoaderResource::FillUserBuffer() { DCHECK(user_buffer_); DCHECK(user_buffer_size_); @@ -393,7 +394,7 @@ size_t URLLoaderResource::FillUserBuffer() { // Reset for next time. user_buffer_ = NULL; user_buffer_size_ = 0; - return bytes_to_copy; + return base::checked_cast<int32_t>(bytes_to_copy); } } // namespace proxy diff --git a/chromium/ppapi/proxy/url_loader_resource.h b/chromium/ppapi/proxy/url_loader_resource.h index 49869326a20..f96c1aba2e4 100644 --- a/chromium/ppapi/proxy/url_loader_resource.h +++ b/chromium/ppapi/proxy/url_loader_resource.h @@ -36,39 +36,38 @@ class PPAPI_PROXY_EXPORT URLLoaderResource int pending_main_document_loader_id, const URLResponseInfoData& data); - virtual ~URLLoaderResource(); + ~URLLoaderResource() override; // Resource override. thunk::PPB_URLLoader_API* AsPPB_URLLoader_API() override; // PPB_URLLoader_API implementation. - virtual int32_t Open(PP_Resource request_id, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t Open(const URLRequestInfoData& data, - int requestor_pid, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t FollowRedirect( - scoped_refptr<TrackedCallback> callback) override; - virtual PP_Bool GetUploadProgress(int64_t* bytes_sent, - int64_t* total_bytes_to_be_sent) override; - virtual PP_Bool GetDownloadProgress( + int32_t Open(PP_Resource request_id, + scoped_refptr<TrackedCallback> callback) override; + int32_t Open(const URLRequestInfoData& data, + int requestor_pid, + scoped_refptr<TrackedCallback> callback) override; + int32_t FollowRedirect(scoped_refptr<TrackedCallback> callback) override; + PP_Bool GetUploadProgress(int64_t* bytes_sent, + int64_t* total_bytes_to_be_sent) override; + PP_Bool GetDownloadProgress( int64_t* bytes_received, int64_t* total_bytes_to_be_received) override; - virtual PP_Resource GetResponseInfo() override; - virtual int32_t ReadResponseBody( + PP_Resource GetResponseInfo() override; + int32_t ReadResponseBody( void* buffer, int32_t bytes_to_read, scoped_refptr<TrackedCallback> callback) override; - virtual int32_t FinishStreamingToFile( + int32_t FinishStreamingToFile( scoped_refptr<TrackedCallback> callback) override; - virtual void Close() override; - virtual void GrantUniversalAccess() override; - virtual void RegisterStatusCallback( + void Close() override; + void GrantUniversalAccess() override; + void RegisterStatusCallback( PP_URLLoaderTrusted_StatusCallback callback) override; // PluginResource implementation. - virtual void OnReplyReceived(const ResourceMessageReplyParams& params, - const IPC::Message& msg) override; + void OnReplyReceived(const ResourceMessageReplyParams& params, + const IPC::Message& msg) override; private: enum Mode { @@ -114,7 +113,7 @@ class PPAPI_PROXY_EXPORT URLLoaderResource // necessary. This does not issue any callbacks. void SaveResponseInfo(const URLResponseInfoData& data); - size_t FillUserBuffer(); + int32_t FillUserBuffer(); Mode mode_; URLRequestInfoData request_data_; diff --git a/chromium/ppapi/proxy/url_request_info_resource.cc b/chromium/ppapi/proxy/url_request_info_resource.cc index 19d02d726ce..a1ba17cc085 100644 --- a/chromium/ppapi/proxy/url_request_info_resource.cc +++ b/chromium/ppapi/proxy/url_request_info_resource.cc @@ -4,6 +4,7 @@ #include "ppapi/proxy/url_request_info_resource.h" +#include "base/strings/string_number_conversions.h" #include "ppapi/shared_impl/var.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_file_ref_api.h" @@ -66,6 +67,14 @@ PP_Bool URLRequestInfoResource::SetProperty(PP_URLRequestProperty property, default: break; } + if (!result) { + std::string error_msg("PPB_URLRequestInfo.SetProperty: Attempted to set a " + "value for PP_URLRequestProperty "); + error_msg += base::IntToString(property); + error_msg += ", but either this property type is invalid or its parameter " + "was inappropriate (e.g., the wrong type of PP_Var)."; + Log(PP_LOGLEVEL_ERROR, error_msg); + } return result; } diff --git a/chromium/ppapi/proxy/url_request_info_resource.h b/chromium/ppapi/proxy/url_request_info_resource.h index 8b07c7a3eb9..318668fb0a2 100644 --- a/chromium/ppapi/proxy/url_request_info_resource.h +++ b/chromium/ppapi/proxy/url_request_info_resource.h @@ -21,21 +21,20 @@ class PPAPI_PROXY_EXPORT URLRequestInfoResource public: URLRequestInfoResource(Connection connection, PP_Instance instance, const URLRequestInfoData& data); - virtual ~URLRequestInfoResource(); + ~URLRequestInfoResource() override; // Resource overrides. - virtual thunk::PPB_URLRequestInfo_API* AsPPB_URLRequestInfo_API() override; + 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_Bool SetProperty(PP_URLRequestProperty property, PP_Var var) override; + PP_Bool AppendDataToBody(const void* data, uint32_t len) override; + 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 URLRequestInfoData& GetData() const override; + const URLRequestInfoData& GetData() const override; bool SetUndefinedProperty(PP_URLRequestProperty property); bool SetBooleanProperty(PP_URLRequestProperty property, bool value); diff --git a/chromium/ppapi/proxy/url_response_info_resource.h b/chromium/ppapi/proxy/url_response_info_resource.h index 1cf83366c88..e20417fbb0f 100644 --- a/chromium/ppapi/proxy/url_response_info_resource.h +++ b/chromium/ppapi/proxy/url_response_info_resource.h @@ -28,14 +28,14 @@ class PPAPI_PROXY_EXPORT URLResponseInfoResource PP_Instance instance, const URLResponseInfoData& data, PP_Resource file_ref_resource); - virtual ~URLResponseInfoResource(); + ~URLResponseInfoResource() override; // Resource override. - virtual PPB_URLResponseInfo_API* AsPPB_URLResponseInfo_API() override; + PPB_URLResponseInfo_API* AsPPB_URLResponseInfo_API() override; // PPB_URLResponseInfo_API implementation. - virtual PP_Var GetProperty(PP_URLResponseProperty property) override; - virtual PP_Resource GetBodyAsFileRef() override; + PP_Var GetProperty(PP_URLResponseProperty property) override; + PP_Resource GetBodyAsFileRef() override; const URLResponseInfoData& data() const { return data_; } diff --git a/chromium/ppapi/proxy/video_capture_resource.cc b/chromium/ppapi/proxy/video_capture_resource.cc index 5c95ed81710..ca69d382b43 100644 --- a/chromium/ppapi/proxy/video_capture_resource.cc +++ b/chromium/ppapi/proxy/video_capture_resource.cc @@ -166,7 +166,7 @@ void VideoCaptureResource::OnPluginMsgOnDeviceInfo( pp_instance(), pp_resource(), &info, - buffers.size(), + static_cast<uint32_t>(buffers.size()), resources.get()); for (size_t i = 0; i < buffers.size(); ++i) diff --git a/chromium/ppapi/proxy/video_capture_resource.h b/chromium/ppapi/proxy/video_capture_resource.h index d0ea0a75b97..add97136129 100644 --- a/chromium/ppapi/proxy/video_capture_resource.h +++ b/chromium/ppapi/proxy/video_capture_resource.h @@ -21,33 +21,33 @@ class VideoCaptureResource VideoCaptureResource(Connection connection, PP_Instance instance, PluginDispatcher* dispatcher); - virtual ~VideoCaptureResource(); + ~VideoCaptureResource() override; // PluginResource override. - virtual thunk::PPB_VideoCapture_API* AsPPB_VideoCapture_API() override { + thunk::PPB_VideoCapture_API* AsPPB_VideoCapture_API() override { return this; } // PPB_VideoCapture_API implementation. - virtual int32_t EnumerateDevices( + int32_t EnumerateDevices( const PP_ArrayOutput& output, scoped_refptr<TrackedCallback> callback) override; - virtual int32_t MonitorDeviceChange( + int32_t MonitorDeviceChange( PP_MonitorDeviceChangeCallback callback, void* user_data) override; - virtual int32_t Open(const std::string& device_id, - const PP_VideoCaptureDeviceInfo_Dev& requested_info, - uint32_t buffer_count, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t StartCapture() override; - virtual int32_t ReuseBuffer(uint32_t buffer) override; - virtual int32_t StopCapture() override; - virtual void Close() override; - virtual int32_t EnumerateDevicesSync(const PP_ArrayOutput& devices) override; + int32_t Open(const std::string& device_id, + const PP_VideoCaptureDeviceInfo_Dev& requested_info, + uint32_t buffer_count, + scoped_refptr<TrackedCallback> callback) override; + int32_t StartCapture() override; + int32_t ReuseBuffer(uint32_t buffer) override; + int32_t StopCapture() override; + void Close() override; + int32_t EnumerateDevicesSync(const PP_ArrayOutput& devices) override; protected: // Resource override. - virtual void LastPluginRefWasDeleted() override; + void LastPluginRefWasDeleted() override; private: enum OpenState { @@ -57,8 +57,8 @@ class VideoCaptureResource }; // PluginResource overrides. - virtual void OnReplyReceived(const ResourceMessageReplyParams& params, - const IPC::Message& msg) override; + void OnReplyReceived(const ResourceMessageReplyParams& params, + const IPC::Message& msg) override; void OnPluginMsgOnDeviceInfo(const ResourceMessageReplyParams& params, const struct PP_VideoCaptureDeviceInfo_Dev& info, diff --git a/chromium/ppapi/proxy/video_decoder_resource.cc b/chromium/ppapi/proxy/video_decoder_resource.cc index 2dbe60e8919..bcc0e6e844a 100644 --- a/chromium/ppapi/proxy/video_decoder_resource.cc +++ b/chromium/ppapi/proxy/video_decoder_resource.cc @@ -73,7 +73,7 @@ VideoDecoderResource::VideoDecoderResource(Connection connection, // just testing |decoder_last_error_|. decoder_last_error_(PP_ERROR_FAILED) { // Clear the decode_ids_ array. - memset(decode_ids_, 0, arraysize(decode_ids_)); + memset(decode_ids_, 0, sizeof(decode_ids_)); SendCreate(RENDERER, PpapiHostMsg_VideoDecoder_Create()); } @@ -367,9 +367,9 @@ void VideoDecoderResource::OnPluginMsgRequestTextures( gles2_impl_->ActiveTexture(GL_TEXTURE0); gles2_impl_->BindTexture(texture_target, texture_ids[i]); gles2_impl_->TexParameteri( - texture_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + texture_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); gles2_impl_->TexParameteri( - texture_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + texture_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gles2_impl_->TexParameterf( texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); gles2_impl_->TexParameterf( diff --git a/chromium/ppapi/proxy/video_decoder_resource.h b/chromium/ppapi/proxy/video_decoder_resource.h index bcc8906980b..aaa1b9571d4 100644 --- a/chromium/ppapi/proxy/video_decoder_resource.h +++ b/chromium/ppapi/proxy/video_decoder_resource.h @@ -37,37 +37,37 @@ class PPAPI_PROXY_EXPORT VideoDecoderResource public thunk::PPB_VideoDecoder_API { public: VideoDecoderResource(Connection connection, PP_Instance instance); - virtual ~VideoDecoderResource(); + ~VideoDecoderResource() override; // Resource overrides. - virtual thunk::PPB_VideoDecoder_API* AsPPB_VideoDecoder_API() override; + thunk::PPB_VideoDecoder_API* AsPPB_VideoDecoder_API() override; // PPB_VideoDecoder_API implementation. - virtual int32_t Initialize0_1( + int32_t Initialize0_1( PP_Resource graphics_context, PP_VideoProfile profile, PP_Bool allow_software_fallback, scoped_refptr<TrackedCallback> callback) override; - virtual int32_t Initialize(PP_Resource graphics_context, - PP_VideoProfile profile, - PP_HardwareAcceleration acceleration, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t Decode(uint32_t decode_id, - uint32_t size, - const void* buffer, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t GetPicture0_1( + int32_t Initialize(PP_Resource graphics_context, + PP_VideoProfile profile, + PP_HardwareAcceleration acceleration, + scoped_refptr<TrackedCallback> callback) override; + int32_t Decode(uint32_t decode_id, + uint32_t size, + const void* buffer, + scoped_refptr<TrackedCallback> callback) override; + int32_t GetPicture0_1( PP_VideoPicture_0_1* picture, scoped_refptr<TrackedCallback> callback) override; - virtual int32_t GetPicture(PP_VideoPicture* picture, - scoped_refptr<TrackedCallback> callback) override; - virtual void RecyclePicture(const PP_VideoPicture* picture) override; - virtual int32_t Flush(scoped_refptr<TrackedCallback> callback) override; - virtual int32_t Reset(scoped_refptr<TrackedCallback> callback) override; + int32_t GetPicture(PP_VideoPicture* picture, + scoped_refptr<TrackedCallback> callback) override; + void RecyclePicture(const PP_VideoPicture* picture) override; + int32_t Flush(scoped_refptr<TrackedCallback> callback) override; + int32_t Reset(scoped_refptr<TrackedCallback> callback) override; // PluginResource implementation. - virtual void OnReplyReceived(const ResourceMessageReplyParams& params, - const IPC::Message& msg) override; + void OnReplyReceived(const ResourceMessageReplyParams& params, + const IPC::Message& msg) override; // Called only by unit tests. This bypasses Graphics3D setup, which doesn't // work in ppapi::proxy::PluginProxyTest. diff --git a/chromium/ppapi/proxy/video_destination_resource.h b/chromium/ppapi/proxy/video_destination_resource.h index bf22161898f..2e545a3aca0 100644 --- a/chromium/ppapi/proxy/video_destination_resource.h +++ b/chromium/ppapi/proxy/video_destination_resource.h @@ -27,18 +27,18 @@ class PPAPI_PROXY_EXPORT VideoDestinationResource public: VideoDestinationResource(Connection connection, PP_Instance instance); - virtual ~VideoDestinationResource(); + ~VideoDestinationResource() override; // Resource overrides. - virtual thunk::PPB_VideoDestination_Private_API* - AsPPB_VideoDestination_Private_API() override; + thunk::PPB_VideoDestination_Private_API* AsPPB_VideoDestination_Private_API() + override; // PPB_VideoDestination_Private_API implementation. - virtual int32_t Open( + int32_t Open( const PP_Var& stream_url, scoped_refptr<TrackedCallback> callback) override; - virtual int32_t PutFrame(const PP_VideoFrame_Private& frame) override; - virtual void Close() override; + int32_t PutFrame(const PP_VideoFrame_Private& frame) override; + void Close() override; private: void OnPluginMsgOpenComplete( diff --git a/chromium/ppapi/proxy/video_encoder_resource.cc b/chromium/ppapi/proxy/video_encoder_resource.cc new file mode 100644 index 00000000000..01c6b0e1612 --- /dev/null +++ b/chromium/ppapi/proxy/video_encoder_resource.cc @@ -0,0 +1,482 @@ +// Copyright 2015 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/memory/shared_memory.h" +#include "base/numerics/safe_conversions.h" +#include "ppapi/c/pp_array_output.h" +#include "ppapi/proxy/ppapi_messages.h" +#include "ppapi/proxy/video_encoder_resource.h" +#include "ppapi/proxy/video_frame_resource.h" +#include "ppapi/shared_impl/array_writer.h" +#include "ppapi/shared_impl/media_stream_buffer.h" +#include "ppapi/shared_impl/media_stream_buffer_manager.h" +#include "ppapi/thunk/enter.h" + +using ppapi::proxy::SerializedHandle; +using ppapi::thunk::EnterResourceNoLock; +using ppapi::thunk::PPB_VideoEncoder_API; + +namespace ppapi { +namespace proxy { + +namespace { + +void RunCallback(scoped_refptr<TrackedCallback>* callback, int32_t error) { + if (!TrackedCallback::IsPending(*callback)) + return; + + scoped_refptr<TrackedCallback> temp; + callback->swap(temp); + temp->Run(error); +} + +std::vector<PP_VideoProfileDescription_0_1> PP_VideoProfileDescriptionTo_0_1( + std::vector<PP_VideoProfileDescription> profiles) { + std::vector<PP_VideoProfileDescription_0_1> profiles_0_1; + + for (uint32_t i = 0; i < profiles.size(); ++i) { + const PP_VideoProfileDescription& profile = profiles[i]; + PP_VideoProfileDescription_0_1 profile_0_1; + + profile_0_1.profile = profile.profile; + profile_0_1.max_resolution = profile.max_resolution; + profile_0_1.max_framerate_numerator = profile.max_framerate_numerator; + profile_0_1.max_framerate_denominator = profile.max_framerate_denominator; + profile_0_1.acceleration = profile.hardware_accelerated == PP_TRUE + ? PP_HARDWAREACCELERATION_ONLY + : PP_HARDWAREACCELERATION_NONE; + + profiles_0_1.push_back(profile_0_1); + } + + return profiles_0_1; +} + +} // namespace + +VideoEncoderResource::ShmBuffer::ShmBuffer(uint32_t id, + scoped_ptr<base::SharedMemory> shm) + : id(id), shm(shm.Pass()) { +} + +VideoEncoderResource::ShmBuffer::~ShmBuffer() { +} + +VideoEncoderResource::BitstreamBuffer::BitstreamBuffer(uint32_t id, + uint32_t size, + bool key_frame) + : id(id), size(size), key_frame(key_frame) { +} + +VideoEncoderResource::BitstreamBuffer::~BitstreamBuffer() { +} + +VideoEncoderResource::VideoEncoderResource(Connection connection, + PP_Instance instance) + : PluginResource(connection, instance), + initialized_(false), + closed_(false), + // Set |encoder_last_error_| to PP_OK after successful initialization. + // This makes error checking a little more concise, since we can check + // that the encoder has been initialized and hasn't returned an error by + // just testing |encoder_last_error_|. + encoder_last_error_(PP_ERROR_FAILED), + input_frame_count_(0), + input_coded_size_(PP_MakeSize(0, 0)), + buffer_manager_(this), + get_video_frame_data_(nullptr), + get_bitstream_buffer_data_(nullptr) { + SendCreate(RENDERER, PpapiHostMsg_VideoEncoder_Create()); +} + +VideoEncoderResource::~VideoEncoderResource() { + Close(); +} + +PPB_VideoEncoder_API* VideoEncoderResource::AsPPB_VideoEncoder_API() { + return this; +} + +int32_t VideoEncoderResource::GetSupportedProfiles( + const PP_ArrayOutput& output, + const scoped_refptr<TrackedCallback>& callback) { + if (TrackedCallback::IsPending(get_supported_profiles_callback_)) + return PP_ERROR_INPROGRESS; + + get_supported_profiles_callback_ = callback; + Call<PpapiPluginMsg_VideoEncoder_GetSupportedProfilesReply>( + RENDERER, PpapiHostMsg_VideoEncoder_GetSupportedProfiles(), + base::Bind(&VideoEncoderResource::OnPluginMsgGetSupportedProfilesReply, + this, output, false)); + return PP_OK_COMPLETIONPENDING; +} + +int32_t VideoEncoderResource::GetSupportedProfiles0_1( + const PP_ArrayOutput& output, + const scoped_refptr<TrackedCallback>& callback) { + if (TrackedCallback::IsPending(get_supported_profiles_callback_)) + return PP_ERROR_INPROGRESS; + + get_supported_profiles_callback_ = callback; + Call<PpapiPluginMsg_VideoEncoder_GetSupportedProfilesReply>( + RENDERER, PpapiHostMsg_VideoEncoder_GetSupportedProfiles(), + base::Bind(&VideoEncoderResource::OnPluginMsgGetSupportedProfilesReply, + this, output, true)); + return PP_OK_COMPLETIONPENDING; +} + +int32_t VideoEncoderResource::GetFramesRequired() { + if (encoder_last_error_) + return encoder_last_error_; + return input_frame_count_; +} + +int32_t VideoEncoderResource::GetFrameCodedSize(PP_Size* size) { + if (encoder_last_error_) + return encoder_last_error_; + *size = input_coded_size_; + return PP_OK; +} + +int32_t VideoEncoderResource::Initialize( + PP_VideoFrame_Format input_format, + const PP_Size* input_visible_size, + PP_VideoProfile output_profile, + uint32_t initial_bitrate, + PP_HardwareAcceleration acceleration, + const scoped_refptr<TrackedCallback>& callback) { + if (initialized_) + return PP_ERROR_FAILED; + if (TrackedCallback::IsPending(initialize_callback_)) + return PP_ERROR_INPROGRESS; + + initialize_callback_ = callback; + Call<PpapiPluginMsg_VideoEncoder_InitializeReply>( + RENDERER, PpapiHostMsg_VideoEncoder_Initialize( + input_format, *input_visible_size, output_profile, + initial_bitrate, acceleration), + base::Bind(&VideoEncoderResource::OnPluginMsgInitializeReply, this)); + return PP_OK_COMPLETIONPENDING; +} + +int32_t VideoEncoderResource::GetVideoFrame( + PP_Resource* video_frame, + const scoped_refptr<TrackedCallback>& callback) { + if (encoder_last_error_) + return encoder_last_error_; + + if (TrackedCallback::IsPending(get_video_frame_callback_)) + return PP_ERROR_INPROGRESS; + + get_video_frame_data_ = video_frame; + get_video_frame_callback_ = callback; + + // Lazily ask for a shared memory buffer in which video frames are allocated. + if (buffer_manager_.number_of_buffers() == 0) { + Call<PpapiPluginMsg_VideoEncoder_GetVideoFramesReply>( + RENDERER, PpapiHostMsg_VideoEncoder_GetVideoFrames(), + base::Bind(&VideoEncoderResource::OnPluginMsgGetVideoFramesReply, + this)); + } else { + TryWriteVideoFrame(); + } + + return PP_OK_COMPLETIONPENDING; +} + +int32_t VideoEncoderResource::Encode( + PP_Resource video_frame, + PP_Bool force_keyframe, + const scoped_refptr<TrackedCallback>& callback) { + if (encoder_last_error_) + return encoder_last_error_; + + VideoFrameMap::iterator it = video_frames_.find(video_frame); + if (it == video_frames_.end()) + // TODO(llandwerlin): accept MediaStreamVideoTrack's video frames. + return PP_ERROR_BADRESOURCE; + + scoped_refptr<VideoFrameResource> frame_resource = it->second; + + encode_callbacks_.insert(std::make_pair(video_frame, callback)); + + Call<PpapiPluginMsg_VideoEncoder_EncodeReply>( + RENDERER, + PpapiHostMsg_VideoEncoder_Encode(frame_resource->GetBufferIndex(), + PP_ToBool(force_keyframe)), + base::Bind(&VideoEncoderResource::OnPluginMsgEncodeReply, this, + video_frame)); + + // Invalidate the frame to prevent the plugin from modifying it. + it->second->Invalidate(); + video_frames_.erase(it); + + return PP_OK_COMPLETIONPENDING; +} + +int32_t VideoEncoderResource::GetBitstreamBuffer( + PP_BitstreamBuffer* bitstream_buffer, + const scoped_refptr<TrackedCallback>& callback) { + if (encoder_last_error_) + return encoder_last_error_; + if (TrackedCallback::IsPending(get_bitstream_buffer_callback_)) + return PP_ERROR_INPROGRESS; + + get_bitstream_buffer_callback_ = callback; + get_bitstream_buffer_data_ = bitstream_buffer; + + if (!available_bitstream_buffers_.empty()) { + BitstreamBuffer buffer(available_bitstream_buffers_.front()); + available_bitstream_buffers_.pop_front(); + WriteBitstreamBuffer(buffer); + } + + return PP_OK_COMPLETIONPENDING; +} + +void VideoEncoderResource::RecycleBitstreamBuffer( + const PP_BitstreamBuffer* bitstream_buffer) { + if (encoder_last_error_) + return; + BitstreamBufferMap::const_iterator iter = + bitstream_buffer_map_.find(bitstream_buffer->buffer); + if (iter != bitstream_buffer_map_.end()) { + Post(RENDERER, + PpapiHostMsg_VideoEncoder_RecycleBitstreamBuffer(iter->second)); + } +} + +void VideoEncoderResource::RequestEncodingParametersChange(uint32_t bitrate, + uint32_t framerate) { + if (encoder_last_error_) + return; + Post(RENDERER, PpapiHostMsg_VideoEncoder_RequestEncodingParametersChange( + bitrate, framerate)); +} + +void VideoEncoderResource::Close() { + if (closed_) + return; + Post(RENDERER, PpapiHostMsg_VideoEncoder_Close()); + closed_ = true; + if (!encoder_last_error_ || !initialized_) + NotifyError(PP_ERROR_ABORTED); + ReleaseFrames(); +} + +void VideoEncoderResource::OnReplyReceived( + const ResourceMessageReplyParams& params, + const IPC::Message& msg) { + PPAPI_BEGIN_MESSAGE_MAP(VideoEncoderResource, msg) + PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL( + PpapiPluginMsg_VideoEncoder_BitstreamBuffers, + OnPluginMsgBitstreamBuffers) + PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL( + PpapiPluginMsg_VideoEncoder_BitstreamBufferReady, + OnPluginMsgBitstreamBufferReady) + PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(PpapiPluginMsg_VideoEncoder_NotifyError, + OnPluginMsgNotifyError) + PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED( + PluginResource::OnReplyReceived(params, msg)) + PPAPI_END_MESSAGE_MAP() +} + +void VideoEncoderResource::OnPluginMsgGetSupportedProfilesReply( + const PP_ArrayOutput& output, + bool version0_1, + const ResourceMessageReplyParams& params, + const std::vector<PP_VideoProfileDescription>& profiles) { + int32_t error = params.result(); + if (error) { + NotifyError(error); + return; + } + + ArrayWriter writer(output); + if (!writer.is_valid()) { + RunCallback(&get_supported_profiles_callback_, PP_ERROR_BADARGUMENT); + return; + } + + bool write_result; + if (version0_1) + write_result = + writer.StoreVector(PP_VideoProfileDescriptionTo_0_1(profiles)); + else + write_result = writer.StoreVector(profiles); + + if (!write_result) { + RunCallback(&get_supported_profiles_callback_, PP_ERROR_FAILED); + return; + } + + RunCallback(&get_supported_profiles_callback_, + base::checked_cast<int32_t>(profiles.size())); +} + +void VideoEncoderResource::OnPluginMsgInitializeReply( + const ResourceMessageReplyParams& params, + uint32_t input_frame_count, + const PP_Size& input_coded_size) { + DCHECK(!initialized_); + + encoder_last_error_ = params.result(); + if (!encoder_last_error_) + initialized_ = true; + + input_frame_count_ = input_frame_count; + input_coded_size_ = input_coded_size; + + RunCallback(&initialize_callback_, encoder_last_error_); +} + +void VideoEncoderResource::OnPluginMsgGetVideoFramesReply( + const ResourceMessageReplyParams& params, + uint32_t frame_count, + uint32_t frame_length, + const PP_Size& frame_size) { + int32_t error = params.result(); + if (error) { + NotifyError(error); + return; + } + + base::SharedMemoryHandle buffer_handle; + params.TakeSharedMemoryHandleAtIndex(0, &buffer_handle); + + if (!buffer_manager_.SetBuffers( + frame_count, frame_length, + make_scoped_ptr(new base::SharedMemory(buffer_handle, false)), + true)) { + NotifyError(PP_ERROR_FAILED); + return; + } + + if (TrackedCallback::IsPending(get_video_frame_callback_)) + TryWriteVideoFrame(); +} + +void VideoEncoderResource::OnPluginMsgEncodeReply( + PP_Resource video_frame, + const ResourceMessageReplyParams& params, + uint32_t frame_id) { + // We need to ensure there are still callbacks to be called before + // processing this message. We might receive a EncodeReply message + // after having sent a Close message to the renderer. In this case, + // we don't have any callback left to call. + if (encode_callbacks_.empty()) + return; + encoder_last_error_ = params.result(); + + EncodeMap::iterator it = encode_callbacks_.find(video_frame); + DCHECK(encode_callbacks_.end() != it); + + scoped_refptr<TrackedCallback> callback = it->second; + encode_callbacks_.erase(it); + RunCallback(&callback, encoder_last_error_); + + buffer_manager_.EnqueueBuffer(frame_id); + // If the plugin is waiting for a video frame, we can give the one + // that just became available again. + if (TrackedCallback::IsPending(get_video_frame_callback_)) + TryWriteVideoFrame(); +} + +void VideoEncoderResource::OnPluginMsgBitstreamBuffers( + const ResourceMessageReplyParams& params, + uint32_t buffer_length) { + std::vector<base::SharedMemoryHandle> shm_handles; + params.TakeAllSharedMemoryHandles(&shm_handles); + if (shm_handles.size() == 0) { + NotifyError(PP_ERROR_FAILED); + return; + } + + for (uint32_t i = 0; i < shm_handles.size(); ++i) { + scoped_ptr<base::SharedMemory> shm( + new base::SharedMemory(shm_handles[i], true)); + CHECK(shm->Map(buffer_length)); + + ShmBuffer* buffer = new ShmBuffer(i, shm.Pass()); + shm_buffers_.push_back(buffer); + bitstream_buffer_map_.insert( + std::make_pair(buffer->shm->memory(), buffer->id)); + } +} + +void VideoEncoderResource::OnPluginMsgBitstreamBufferReady( + const ResourceMessageReplyParams& params, + uint32_t buffer_id, + uint32_t buffer_size, + bool key_frame) { + available_bitstream_buffers_.push_back( + BitstreamBuffer(buffer_id, buffer_size, key_frame)); + + if (TrackedCallback::IsPending(get_bitstream_buffer_callback_)) { + BitstreamBuffer buffer(available_bitstream_buffers_.front()); + available_bitstream_buffers_.pop_front(); + WriteBitstreamBuffer(buffer); + } +} + +void VideoEncoderResource::OnPluginMsgNotifyError( + const ResourceMessageReplyParams& params, + int32_t error) { + NotifyError(error); +} + +void VideoEncoderResource::NotifyError(int32_t error) { + encoder_last_error_ = error; + RunCallback(&get_supported_profiles_callback_, error); + RunCallback(&initialize_callback_, error); + RunCallback(&get_video_frame_callback_, error); + get_video_frame_data_ = nullptr; + RunCallback(&get_bitstream_buffer_callback_, error); + get_bitstream_buffer_data_ = nullptr; + for (EncodeMap::iterator it = encode_callbacks_.begin(); + it != encode_callbacks_.end(); ++it) { + scoped_refptr<TrackedCallback> callback = it->second; + RunCallback(&callback, error); + } + encode_callbacks_.clear(); +} + +void VideoEncoderResource::TryWriteVideoFrame() { + DCHECK(TrackedCallback::IsPending(get_video_frame_callback_)); + + int32_t frame_id = buffer_manager_.DequeueBuffer(); + if (frame_id < 0) + return; + + scoped_refptr<VideoFrameResource> resource = new VideoFrameResource( + pp_instance(), frame_id, buffer_manager_.GetBufferPointer(frame_id)); + video_frames_.insert( + VideoFrameMap::value_type(resource->pp_resource(), resource)); + + *get_video_frame_data_ = resource->GetReference(); + get_video_frame_data_ = nullptr; + RunCallback(&get_video_frame_callback_, PP_OK); +} + +void VideoEncoderResource::WriteBitstreamBuffer(const BitstreamBuffer& buffer) { + DCHECK_LT(buffer.id, shm_buffers_.size()); + + get_bitstream_buffer_data_->size = buffer.size; + get_bitstream_buffer_data_->buffer = shm_buffers_[buffer.id]->shm->memory(); + get_bitstream_buffer_data_->key_frame = PP_FromBool(buffer.key_frame); + get_bitstream_buffer_data_ = nullptr; + RunCallback(&get_bitstream_buffer_callback_, PP_OK); +} + +void VideoEncoderResource::ReleaseFrames() { + for (VideoFrameMap::iterator it = video_frames_.begin(); + it != video_frames_.end(); ++it) { + it->second->Invalidate(); + it->second = nullptr; + } + video_frames_.clear(); +} + +} // namespace proxy +} // namespace ppapi diff --git a/chromium/ppapi/proxy/video_encoder_resource.h b/chromium/ppapi/proxy/video_encoder_resource.h new file mode 100644 index 00000000000..41f33c7e92b --- /dev/null +++ b/chromium/ppapi/proxy/video_encoder_resource.h @@ -0,0 +1,165 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_PROXY_VIDEO_ENCODER_RESOURCE_H_ +#define PPAPI_PROXY_VIDEO_ENCODER_RESOURCE_H_ + +#include <deque> + +#include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" +#include "base/memory/scoped_vector.h" +#include "ppapi/proxy/connection.h" +#include "ppapi/proxy/plugin_resource.h" +#include "ppapi/shared_impl/media_stream_buffer_manager.h" +#include "ppapi/shared_impl/resource.h" +#include "ppapi/thunk/ppb_video_encoder_api.h" + +namespace base { +class SharedMemory; +} + +namespace ppapi { + +class TrackedCallback; + +namespace proxy { + +class SerializedHandle; +class VideoFrameResource; + +class PPAPI_PROXY_EXPORT VideoEncoderResource + : public PluginResource, + public thunk::PPB_VideoEncoder_API, + public ppapi::MediaStreamBufferManager::Delegate { + public: + VideoEncoderResource(Connection connection, PP_Instance instance); + ~VideoEncoderResource() override; + + thunk::PPB_VideoEncoder_API* AsPPB_VideoEncoder_API() override; + + private: + struct ShmBuffer { + ShmBuffer(uint32_t id, scoped_ptr<base::SharedMemory> shm); + ~ShmBuffer(); + + // Index of the buffer in the ScopedVector. Buffers have the same id in + // the plugin and the host. + uint32_t id; + scoped_ptr<base::SharedMemory> shm; + }; + + struct BitstreamBuffer { + BitstreamBuffer(uint32_t id, uint32_t size, bool key_frame); + ~BitstreamBuffer(); + + // Index of the buffer in the ScopedVector. Same as ShmBuffer::id. + uint32_t id; + uint32_t size; + bool key_frame; + }; + + // PPB_VideoEncoder_API implementation. + int32_t GetSupportedProfiles( + const PP_ArrayOutput& output, + const scoped_refptr<TrackedCallback>& callback) override; + int32_t GetSupportedProfiles0_1( + const PP_ArrayOutput& output, + const scoped_refptr<TrackedCallback>& callback) override; + int32_t Initialize(PP_VideoFrame_Format input_format, + const PP_Size* input_visible_size, + PP_VideoProfile output_profile, + uint32_t initial_bitrate, + PP_HardwareAcceleration acceleration, + const scoped_refptr<TrackedCallback>& callback) override; + int32_t GetFramesRequired() override; + int32_t GetFrameCodedSize(PP_Size* size) override; + int32_t GetVideoFrame( + PP_Resource* video_frame, + const scoped_refptr<TrackedCallback>& callback) override; + int32_t Encode(PP_Resource video_frame, + PP_Bool force_keyframe, + const scoped_refptr<TrackedCallback>& callback) override; + int32_t GetBitstreamBuffer( + PP_BitstreamBuffer* picture, + const scoped_refptr<TrackedCallback>& callback) override; + void RecycleBitstreamBuffer(const PP_BitstreamBuffer* picture) override; + void RequestEncodingParametersChange(uint32_t bitrate, + uint32_t framerate) override; + void Close() override; + + // PluginResource implementation. + void OnReplyReceived(const ResourceMessageReplyParams& params, + const IPC::Message& msg) override; + + // Reply message handlers for operations that are done in the host. + void OnPluginMsgGetSupportedProfilesReply( + const PP_ArrayOutput& output, + bool version0_1, + const ResourceMessageReplyParams& params, + const std::vector<PP_VideoProfileDescription>& profiles); + void OnPluginMsgInitializeReply(const ResourceMessageReplyParams& params, + uint32_t input_frame_count, + const PP_Size& input_coded_size); + void OnPluginMsgGetVideoFramesReply(const ResourceMessageReplyParams& params, + uint32_t frame_count, + uint32_t frame_length, + const PP_Size& frame_size); + void OnPluginMsgEncodeReply(PP_Resource video_frame, + const ResourceMessageReplyParams& params, + uint32_t frame_id); + + // Unsolicited reply message handlers. + void OnPluginMsgBitstreamBuffers(const ResourceMessageReplyParams& params, + uint32_t buffer_length); + void OnPluginMsgBitstreamBufferReady(const ResourceMessageReplyParams& params, + uint32_t buffer_id, + uint32_t buffer_size, + bool key_frame); + void OnPluginMsgNotifyError(const ResourceMessageReplyParams& params, + int32_t error); + + // Internal utility functions. + void NotifyError(int32_t error); + void TryWriteVideoFrame(); + void WriteBitstreamBuffer(const BitstreamBuffer& buffer); + void ReleaseFrames(); + + bool initialized_; + bool closed_; + int32_t encoder_last_error_; + + int32_t input_frame_count_; + PP_Size input_coded_size_; + + MediaStreamBufferManager buffer_manager_; + + typedef std::map<PP_Resource, scoped_refptr<VideoFrameResource> > + VideoFrameMap; + VideoFrameMap video_frames_; + + ScopedVector<ShmBuffer> shm_buffers_; + + std::deque<BitstreamBuffer> available_bitstream_buffers_; + typedef std::map<void*, uint32_t> BitstreamBufferMap; + BitstreamBufferMap bitstream_buffer_map_; + + scoped_refptr<TrackedCallback> get_supported_profiles_callback_; + scoped_refptr<TrackedCallback> initialize_callback_; + scoped_refptr<TrackedCallback> get_video_frame_callback_; + PP_Resource* get_video_frame_data_; + + typedef std::map<PP_Resource, scoped_refptr<TrackedCallback> > EncodeMap; + EncodeMap encode_callbacks_; + + scoped_refptr<TrackedCallback> get_bitstream_buffer_callback_; + PP_BitstreamBuffer* get_bitstream_buffer_data_; + + DISALLOW_COPY_AND_ASSIGN(VideoEncoderResource); +}; + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_VIDEO_ENCODER_RESOURCE_H_ diff --git a/chromium/ppapi/proxy/video_encoder_resource_unittest.cc b/chromium/ppapi/proxy/video_encoder_resource_unittest.cc new file mode 100644 index 00000000000..c1d39084d58 --- /dev/null +++ b/chromium/ppapi/proxy/video_encoder_resource_unittest.cc @@ -0,0 +1,1151 @@ +// Copyright 2015 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/memory/shared_memory.h" +#include "base/process/process.h" +#include "base/synchronization/waitable_event.h" +#include "ppapi/c/pp_codecs.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/ppb_video_encoder.h" +#include "ppapi/c/ppb_video_frame.h" +#include "ppapi/proxy/locking_resource_releaser.h" +#include "ppapi/proxy/plugin_message_filter.h" +#include "ppapi/proxy/ppapi_message_utils.h" +#include "ppapi/proxy/ppapi_messages.h" +#include "ppapi/proxy/ppapi_proxy_test.h" +#include "ppapi/proxy/video_encoder_resource.h" +#include "ppapi/shared_impl/media_stream_buffer.h" +#include "ppapi/shared_impl/proxy_lock.h" +#include "ppapi/thunk/thunk.h" + +using ppapi::proxy::ResourceMessageTestSink; + +namespace ppapi { +namespace proxy { + +namespace { + +class MockCompletionCallback { + public: + MockCompletionCallback() : called_(false), call_event_(false, false) {} + + bool called() { return called_; } + int32_t result() { return result_; } + + void WaitUntilCalled() { call_event_.Wait(); } + + void Reset() { + called_ = false; + call_event_.Reset(); + } + + static void Callback(void* user_data, int32_t result) { + MockCompletionCallback* that = + reinterpret_cast<MockCompletionCallback*>(user_data); + that->call_event_.Signal(); + that->called_ = true; + that->result_ = result; + } + + private: + bool called_; + int32_t result_; + base::WaitableEvent call_event_; +}; + +class VideoEncoderResourceTest : public PluginProxyTest, + public MediaStreamBufferManager::Delegate { + public: + VideoEncoderResourceTest() + : encoder_iface_(thunk::GetPPB_VideoEncoder_0_2_Thunk()), + encoder_iface_0_1_(thunk::GetPPB_VideoEncoder_0_1_Thunk()), + video_frames_manager_(this) {} + ~VideoEncoderResourceTest() override {} + + const PPB_VideoEncoder_0_2* encoder_iface() const { return encoder_iface_; } + const PPB_VideoEncoder_0_1* encoder_iface_0_1() const { + return encoder_iface_0_1_; + } + + const uint32_t kBitstreamBufferSize = 4000; + const uint32_t kBitstreamBufferCount = 5; + const uint32_t kVideoFrameCount = 3; + const uint32_t kBitrate = 200000; + + const PP_Size kFrameSize = PP_MakeSize(640, 480); + + void SendReply(const ResourceMessageCallParams& params, + int32_t result, + const IPC::Message& nested_message) { + ResourceMessageReplyParams reply_params(params.pp_resource(), + params.sequence()); + reply_params.set_result(result); + PluginMessageFilter::DispatchResourceReplyForTest(reply_params, + nested_message); + } + + void SendReplyWithHandle(const ResourceMessageCallParams& params, + int32_t result, + const IPC::Message& nested_message, + const SerializedHandle& handle) { + ResourceMessageReplyParams reply_params(params.pp_resource(), + params.sequence()); + reply_params.set_result(result); + reply_params.AppendHandle(handle); + PluginMessageFilter::DispatchResourceReplyForTest(reply_params, + nested_message); + } + + void SendReplyWithHandles(const ResourceMessageCallParams& params, + int32_t result, + const IPC::Message& nested_message, + const std::vector<SerializedHandle>& handles) { + ResourceMessageReplyParams reply_params(params.pp_resource(), + params.sequence()); + reply_params.set_result(result); + for (SerializedHandle handle : handles) + reply_params.AppendHandle(handle); + PluginMessageFilter::DispatchResourceReplyForTest(reply_params, + nested_message); + } + + PP_Resource CreateEncoder() { + PP_Resource result = encoder_iface()->Create(pp_instance()); + return result; + } + + void CreateBitstreamSharedMemory(uint32_t buffer_size, uint32_t nb_buffers) { + shared_memory_bitstreams_.clear(); + for (uint32_t i = 0; i < nb_buffers; ++i) { + scoped_ptr<base::SharedMemory> mem(new base::SharedMemory()); + ASSERT_TRUE(mem->CreateAnonymous(buffer_size)); + shared_memory_bitstreams_.push_back(mem.Pass()); + } + } + + void CreateVideoFramesSharedMemory(uint32_t frame_length, + uint32_t frame_count) { + scoped_ptr<base::SharedMemory> shared_memory_frames( + new base::SharedMemory()); + uint32_t buffer_length = + frame_length + sizeof(ppapi::MediaStreamBuffer::Video); + ASSERT_TRUE(shared_memory_frames->CreateAnonymous(buffer_length * + frame_count)); + ASSERT_TRUE(video_frames_manager_.SetBuffers(frame_count, + buffer_length, + shared_memory_frames.Pass(), + true)); + for (int32_t i = 0; i < video_frames_manager_.number_of_buffers(); ++i) { + ppapi::MediaStreamBuffer::Video* buffer = + &(video_frames_manager_.GetBufferPointer(i)->video); + buffer->header.size = buffer_length; + buffer->header.type = ppapi::MediaStreamBuffer::TYPE_VIDEO; + buffer->format = PP_VIDEOFRAME_FORMAT_I420; + buffer->size = kFrameSize; + buffer->data_size = frame_length; + } + } + + PP_Resource CreateAndInitializeEncoder() { + PP_Resource encoder = CreateEncoder(); + PP_Size size = kFrameSize; + MockCompletionCallback cb; + int32_t result = encoder_iface()->Initialize( + encoder, PP_VIDEOFRAME_FORMAT_I420, &size, PP_VIDEOPROFILE_H264MAIN, + kBitrate, PP_HARDWAREACCELERATION_WITHFALLBACK, + PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback, + &cb)); + if (result != PP_OK_COMPLETIONPENDING) + return 0; + ResourceMessageCallParams params; + IPC::Message msg; + if (!sink().GetFirstResourceCallMatching( + PpapiHostMsg_VideoEncoder_Initialize::ID, ¶ms, &msg)) + return 0; + sink().ClearMessages(); + + SendInitializeReply(params, PP_OK, kVideoFrameCount, kFrameSize); + CreateBitstreamSharedMemory(kBitstreamBufferSize, kBitstreamBufferCount); + SendBitstreamBuffers(params, kBitstreamBufferSize); + + if (!cb.called() || cb.result() != PP_OK) + return 0; + + return encoder; + } + + int32_t CallGetFramesRequired(PP_Resource pp_encoder) { + return encoder_iface()->GetFramesRequired(pp_encoder); + } + + int32_t CallGetFrameCodedSize(PP_Resource pp_encoder, PP_Size* coded_size) { + return encoder_iface()->GetFrameCodedSize(pp_encoder, coded_size); + } + + int32_t CallGetVideoFrame(PP_Resource pp_encoder, + PP_Resource* video_frame, + MockCompletionCallback* cb) { + return encoder_iface()->GetVideoFrame( + pp_encoder, video_frame, PP_MakeOptionalCompletionCallback( + &MockCompletionCallback::Callback, cb)); + } + + int32_t CallFirstGetVideoFrame(PP_Resource pp_encoder, + PP_Resource* video_frame, + MockCompletionCallback* cb) { + int32_t result = encoder_iface()->GetVideoFrame( + pp_encoder, video_frame, PP_MakeOptionalCompletionCallback( + &MockCompletionCallback::Callback, cb)); + if (result != PP_OK_COMPLETIONPENDING) + return result; + + ResourceMessageCallParams params; + CheckGetVideoFramesMsg(¶ms); + + uint32_t frame_length = kFrameSize.width * kFrameSize.height * 2; + CreateVideoFramesSharedMemory(frame_length, kVideoFrameCount); + SendGetVideoFramesReply(params, kVideoFrameCount, frame_length, kFrameSize); + + return result; + } + + int32_t CallEncode(PP_Resource pp_encoder, + PP_Resource video_frame, + PP_Bool force_keyframe, + MockCompletionCallback* cb) { + return encoder_iface()->Encode(pp_encoder, video_frame, force_keyframe, + PP_MakeOptionalCompletionCallback( + &MockCompletionCallback::Callback, cb)); + } + + int32_t CallCompleteEncode(PP_Resource pp_encoder, + PP_Resource video_frame, + PP_Bool force_keyframe, + MockCompletionCallback* cb) { + int32_t result = + encoder_iface()->Encode(pp_encoder, video_frame, force_keyframe, + PP_MakeOptionalCompletionCallback( + &MockCompletionCallback::Callback, cb)); + if (result != PP_OK_COMPLETIONPENDING) + return result; + + ResourceMessageCallParams params; + uint32_t frame_id; + bool forced_keyframe; + if (!CheckEncodeMsg(¶ms, &frame_id, &forced_keyframe)) + return PP_ERROR_FAILED; + + SendEncodeReply(params, frame_id); + + return result; + } + + int32_t CallGetBitstreamBuffer(PP_Resource pp_encoder, + PP_BitstreamBuffer* bitstream_buffer, + MockCompletionCallback* cb) { + return encoder_iface()->GetBitstreamBuffer( + pp_encoder, bitstream_buffer, + PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback, + cb)); + } + + void CallRecycleBitstreamBuffer(PP_Resource pp_encoder, + const PP_BitstreamBuffer& buffer) { + encoder_iface()->RecycleBitstreamBuffer(pp_encoder, &buffer); + } + + void CallRequestEncodingParametersChange(PP_Resource pp_encoder, + uint32_t bitrate, + uint32_t framerate) { + encoder_iface()->RequestEncodingParametersChange(pp_encoder, bitrate, + framerate); + } + + void CallClose(PP_Resource pp_encoder) { + encoder_iface()->Close(pp_encoder); + } + + void SendGetSupportedProfilesReply( + const ResourceMessageCallParams& params, + const std::vector<PP_VideoProfileDescription>& profiles) { + SendReply(params, PP_OK, + PpapiPluginMsg_VideoEncoder_GetSupportedProfilesReply(profiles)); + } + + void SendInitializeReply(const ResourceMessageCallParams& params, + int32_t success, + uint32_t input_frame_count, + const PP_Size& input_coded_size) { + SendReply(params, success, PpapiPluginMsg_VideoEncoder_InitializeReply( + input_frame_count, input_coded_size)); + } + + void SendBitstreamBuffers(const ResourceMessageCallParams& params, + uint32_t buffer_length) { + std::vector<SerializedHandle> handles; + for (base::SharedMemory* mem : shared_memory_bitstreams_) { + ASSERT_EQ(mem->requested_size(), buffer_length); + base::SharedMemoryHandle handle; + + ASSERT_TRUE( + mem->ShareToProcess(base::Process::Current().Handle(), &handle)); + handles.push_back(SerializedHandle(handle, buffer_length)); + } + SendReplyWithHandles( + params, PP_OK, + PpapiPluginMsg_VideoEncoder_BitstreamBuffers(buffer_length), handles); + } + + void SendGetVideoFramesReply(const ResourceMessageCallParams& params, + uint32_t frame_count, + uint32_t frame_length, + const PP_Size& size) { + base::SharedMemoryHandle handle; + ASSERT_TRUE(video_frames_manager_.shm()->ShareToProcess( + base::Process::Current().Handle(), &handle)); + SendReplyWithHandle( + params, PP_OK, PpapiPluginMsg_VideoEncoder_GetVideoFramesReply( + frame_count, + frame_length + sizeof(MediaStreamBuffer::Video), + size), + SerializedHandle( + handle, + static_cast<uint32_t>( + video_frames_manager_.shm()->requested_size()))); + } + + void SendEncodeReply(const ResourceMessageCallParams& params, + uint32_t frame_id) { + SendReply(params, PP_OK, PpapiPluginMsg_VideoEncoder_EncodeReply(frame_id)); + } + + void SendBitstreamBufferReady(const ResourceMessageCallParams& params, + uint32_t buffer_id, + uint32_t buffer_size, + bool keyframe) { + SendReply(params, PP_OK, + PpapiPluginMsg_VideoEncoder_BitstreamBufferReady( + buffer_id, buffer_size, PP_FromBool(keyframe))); + } + + void SendNotifyError(const ResourceMessageCallParams& params, int32_t error) { + SendReply(params, PP_OK, PpapiPluginMsg_VideoEncoder_NotifyError(error)); + } + + bool CheckGetSupportedProfilesMsg(ResourceMessageCallParams* params) { + IPC::Message msg; + return sink().GetFirstResourceCallMatching( + PpapiHostMsg_VideoEncoder_GetSupportedProfiles::ID, params, &msg); + } + + bool CheckInitializeMsg(ResourceMessageCallParams* params, + PP_VideoFrame_Format* input_format, + struct PP_Size* input_visible_size, + PP_VideoProfile* output_profile, + uint32_t* bitrate, + PP_HardwareAcceleration* acceleration) { + IPC::Message msg; + if (!sink().GetFirstResourceCallMatching( + PpapiHostMsg_VideoEncoder_Initialize::ID, params, &msg)) + return false; + sink().ClearMessages(); + return UnpackMessage<PpapiHostMsg_VideoEncoder_Initialize>( + msg, input_format, input_visible_size, output_profile, bitrate, + acceleration); + } + + bool CheckGetVideoFramesMsg(ResourceMessageCallParams* params) { + IPC::Message msg; + if (!sink().GetFirstResourceCallMatching( + PpapiHostMsg_VideoEncoder_GetVideoFrames::ID, params, &msg)) + return false; + sink().ClearMessages(); + return true; + } + + bool CheckEncodeMsg(ResourceMessageCallParams* params, + uint32_t* frame_id, + bool* keyframe) { + IPC::Message msg; + if (!sink().GetFirstResourceCallMatching( + PpapiHostMsg_VideoEncoder_Encode::ID, params, &msg)) + return false; + sink().ClearMessages(); + return UnpackMessage<PpapiHostMsg_VideoEncoder_Encode>(msg, frame_id, + keyframe); + } + + bool CheckRecycleBitstreamBufferMsg(ResourceMessageCallParams* params, + uint32_t* buffer_id) { + IPC::Message msg; + if (!sink().GetFirstResourceCallMatching( + PpapiHostMsg_VideoEncoder_RecycleBitstreamBuffer::ID, params, &msg)) + return false; + sink().ClearMessages(); + return UnpackMessage<PpapiHostMsg_VideoEncoder_RecycleBitstreamBuffer>( + msg, buffer_id); + } + + bool CheckRequestEncodingParametersChangeMsg( + ResourceMessageCallParams* params, + uint32_t* bitrate, + uint32_t* framerate) { + IPC::Message msg; + if (!sink().GetFirstResourceCallMatching( + PpapiHostMsg_VideoEncoder_RequestEncodingParametersChange::ID, + params, &msg)) + return false; + sink().ClearMessages(); + return UnpackMessage< + PpapiHostMsg_VideoEncoder_RequestEncodingParametersChange>(msg, bitrate, + framerate); + } + + bool CheckIsVideoFrame(PP_Resource video_frame) { + return thunk::GetPPB_VideoFrame_0_1_Thunk()->IsVideoFrame(video_frame); + } + + bool CheckIsVideoFrameValid(PP_Resource video_frame) { + PP_Size frame_size; + return thunk::GetPPB_VideoFrame_0_1_Thunk()->GetSize( + video_frame, &frame_size) == PP_TRUE; + } + + private: + // MediaStreamBufferManager::Delegate: + void OnNewBufferEnqueued() override {} + + const PPB_VideoEncoder_0_2* encoder_iface_; + const PPB_VideoEncoder_0_1* encoder_iface_0_1_; + + ScopedVector<base::SharedMemory> shared_memory_bitstreams_; + + MediaStreamBufferManager video_frames_manager_; +}; + +void* ForwardUserData(void* user_data, + uint32_t element_count, + uint32_t element_size) { + return user_data; +} + +} // namespace + +TEST_F(VideoEncoderResourceTest, GetSupportedProfiles) { + // Verifies that GetSupportedProfiles calls into the renderer and + // the we get the right results back. + { + LockingResourceReleaser encoder(CreateEncoder()); + PP_VideoProfileDescription profiles[2]; + PP_ArrayOutput output; + output.user_data = &profiles[0]; + output.GetDataBuffer = ForwardUserData; + ResourceMessageCallParams params; + MockCompletionCallback cb; + int32_t result = encoder_iface()->GetSupportedProfiles( + encoder.get(), output, PP_MakeOptionalCompletionCallback( + &MockCompletionCallback::Callback, &cb)); + ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); + ASSERT_TRUE(CheckGetSupportedProfilesMsg(¶ms)); + + std::vector<PP_VideoProfileDescription> profiles_response; + PP_VideoProfileDescription profile; + profile.profile = PP_VIDEOPROFILE_H264MAIN; + profile.max_resolution.width = 1920; + profile.max_resolution.height = 1080; + profile.max_framerate_numerator = 30; + profile.max_framerate_denominator = 1; + profile.hardware_accelerated = PP_TRUE; + profiles_response.push_back(profile); + profile.profile = PP_VIDEOPROFILE_VP8_ANY; + profile.max_resolution.width = 1920; + profile.max_resolution.height = 1080; + profile.max_framerate_numerator = 30; + profile.max_framerate_denominator = 1; + profile.hardware_accelerated = PP_FALSE; + profiles_response.push_back(profile); + + SendGetSupportedProfilesReply(params, profiles_response); + ASSERT_EQ(profiles_response.size(), static_cast<uint32_t>(cb.result())); + ASSERT_EQ(0, memcmp(&profiles[0], &profiles_response[0], sizeof(profiles))); + } +} + +TEST_F(VideoEncoderResourceTest, GetSupportedProfiles0_1) { + // Verifies that GetSupportedProfiles calls into the renderer and + // the we get the right results back. + { + LockingResourceReleaser encoder(CreateEncoder()); + PP_VideoProfileDescription_0_1 profiles[2]; + PP_ArrayOutput output; + output.user_data = &profiles[0]; + output.GetDataBuffer = ForwardUserData; + ResourceMessageCallParams params; + MockCompletionCallback cb; + int32_t result = encoder_iface_0_1()->GetSupportedProfiles( + encoder.get(), output, PP_MakeOptionalCompletionCallback( + &MockCompletionCallback::Callback, &cb)); + ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); + ASSERT_TRUE(CheckGetSupportedProfilesMsg(¶ms)); + + std::vector<PP_VideoProfileDescription> profiles_response; + PP_VideoProfileDescription profile; + profile.profile = PP_VIDEOPROFILE_H264MAIN; + profile.max_resolution.width = 1920; + profile.max_resolution.height = 1080; + profile.max_framerate_numerator = 30; + profile.max_framerate_denominator = 1; + profile.hardware_accelerated = PP_TRUE; + profiles_response.push_back(profile); + profile.profile = PP_VIDEOPROFILE_VP8_ANY; + profile.max_resolution.width = 1920; + profile.max_resolution.height = 1080; + profile.max_framerate_numerator = 30; + profile.max_framerate_denominator = 1; + profile.hardware_accelerated = PP_FALSE; + profiles_response.push_back(profile); + + SendGetSupportedProfilesReply(params, profiles_response); + + ASSERT_EQ(profiles_response.size(), static_cast<uint32_t>(cb.result())); + + for (uint32 i = 0; i < profiles_response.size(); i++) { + ASSERT_EQ(profiles_response[i].profile, profiles[i].profile); + ASSERT_EQ(profiles_response[i].max_resolution.width, + profiles[i].max_resolution.width); + ASSERT_EQ(profiles_response[i].max_resolution.height, + profiles[i].max_resolution.height); + ASSERT_EQ(profiles_response[i].max_framerate_numerator, + profiles[i].max_framerate_numerator); + ASSERT_EQ(profiles_response[i].max_framerate_denominator, + profiles[i].max_framerate_denominator); + if (profiles_response[i].hardware_accelerated) + ASSERT_EQ(PP_HARDWAREACCELERATION_ONLY, profiles[i].acceleration); + else + ASSERT_EQ(PP_HARDWAREACCELERATION_NONE, profiles[i].acceleration); + } + } +} + +TEST_F(VideoEncoderResourceTest, InitializeFailure) { + { + // Verify the initialize callback is called in case of failure. + LockingResourceReleaser encoder(CreateEncoder()); + ResourceMessageCallParams params; + PP_Size size = kFrameSize; + MockCompletionCallback cb; + int32_t result = encoder_iface()->Initialize( + encoder.get(), PP_VIDEOFRAME_FORMAT_BGRA, &size, + PP_VIDEOPROFILE_H264MAIN, kBitrate, + PP_HARDWAREACCELERATION_WITHFALLBACK, + PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback, + &cb)); + ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); + + PP_VideoFrame_Format input_format; + PP_Size input_visible_size; + PP_VideoProfile output_profile; + uint32_t bitrate; + PP_HardwareAcceleration acceleration; + ASSERT_TRUE(CheckInitializeMsg(¶ms, &input_format, &input_visible_size, + &output_profile, &bitrate, &acceleration)); + ASSERT_EQ(PP_VIDEOFRAME_FORMAT_BGRA, input_format); + ASSERT_EQ(size.width, input_visible_size.width); + ASSERT_EQ(size.height, input_visible_size.height); + ASSERT_EQ(kBitrate, bitrate); + ASSERT_EQ(PP_VIDEOPROFILE_H264MAIN, output_profile); + ASSERT_EQ(PP_HARDWAREACCELERATION_WITHFALLBACK, acceleration); + + SendInitializeReply(params, PP_ERROR_NOTSUPPORTED, kVideoFrameCount, + kFrameSize); + ASSERT_TRUE(cb.called()); + ASSERT_EQ(PP_ERROR_NOTSUPPORTED, cb.result()); + } + { + // Verify the initialize callback is called in case of error + // notification. + LockingResourceReleaser encoder(CreateEncoder()); + ResourceMessageCallParams params; + PP_Size size = kFrameSize; + MockCompletionCallback cb; + int32_t result = encoder_iface()->Initialize( + encoder.get(), PP_VIDEOFRAME_FORMAT_BGRA, &size, + PP_VIDEOPROFILE_H264MAIN, kBitrate, + PP_HARDWAREACCELERATION_WITHFALLBACK, + PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback, + &cb)); + ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); + + PP_VideoFrame_Format input_format; + PP_Size input_visible_size; + PP_VideoProfile output_profile; + uint32_t bitrate; + PP_HardwareAcceleration acceleration; + ASSERT_TRUE(CheckInitializeMsg(¶ms, &input_format, &input_visible_size, + &output_profile, &bitrate, &acceleration)); + ASSERT_EQ(PP_VIDEOFRAME_FORMAT_BGRA, input_format); + ASSERT_EQ(kFrameSize.width, input_visible_size.width); + ASSERT_EQ(kFrameSize.height, input_visible_size.height); + ASSERT_EQ(kBitrate, bitrate); + ASSERT_EQ(PP_VIDEOPROFILE_H264MAIN, output_profile); + ASSERT_EQ(PP_HARDWAREACCELERATION_WITHFALLBACK, acceleration); + + ResourceMessageCallParams error_params(encoder.get(), 0); + SendNotifyError(error_params, PP_ERROR_FAILED); + ASSERT_TRUE(cb.called()); + ASSERT_EQ(PP_ERROR_FAILED, cb.result()); + } + { + // Verify that calling initialize twice fails the second time if + // we haven't received a response yet. + LockingResourceReleaser encoder(CreateEncoder()); + ResourceMessageCallParams params; + PP_Size size = kFrameSize; + MockCompletionCallback cb; + int32_t result = encoder_iface()->Initialize( + encoder.get(), PP_VIDEOFRAME_FORMAT_BGRA, &size, + PP_VIDEOPROFILE_H264MAIN, kBitrate, + PP_HARDWAREACCELERATION_WITHFALLBACK, + PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback, + &cb)); + ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); + + PP_VideoFrame_Format input_format; + PP_Size input_visible_size; + PP_VideoProfile output_profile; + uint32_t bitrate; + PP_HardwareAcceleration acceleration; + ASSERT_TRUE(CheckInitializeMsg(¶ms, &input_format, &input_visible_size, + &output_profile, &bitrate, &acceleration)); + ASSERT_EQ(PP_VIDEOFRAME_FORMAT_BGRA, input_format); + ASSERT_EQ(size.width, input_visible_size.width); + ASSERT_EQ(size.height, input_visible_size.height); + ASSERT_EQ(kBitrate, bitrate); + ASSERT_EQ(PP_VIDEOPROFILE_H264MAIN, output_profile); + ASSERT_EQ(PP_HARDWAREACCELERATION_WITHFALLBACK, acceleration); + + result = encoder_iface()->Initialize( + encoder.get(), PP_VIDEOFRAME_FORMAT_BGRA, &size, + PP_VIDEOPROFILE_H264MAIN, kBitrate, + PP_HARDWAREACCELERATION_WITHFALLBACK, + PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback, + &cb)); + ASSERT_EQ(PP_ERROR_INPROGRESS, result); + + ResourceMessageCallParams error_params(encoder.get(), 0); + SendNotifyError(error_params, PP_ERROR_FAILED); + ASSERT_TRUE(cb.called()); + ASSERT_EQ(PP_ERROR_FAILED, cb.result()); + } +} + +TEST_F(VideoEncoderResourceTest, InitializeSuccess) { + { + // Verify the initialize callback is called when initialization is + // successfull. + LockingResourceReleaser encoder(CreateEncoder()); + ResourceMessageCallParams params; + PP_Size size = kFrameSize; + const uint32_t kBitrate = 420000; + MockCompletionCallback cb; + int32_t result = encoder_iface()->Initialize( + encoder.get(), PP_VIDEOFRAME_FORMAT_I420, &size, + PP_VIDEOPROFILE_H264MAIN, kBitrate, + PP_HARDWAREACCELERATION_WITHFALLBACK, + PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback, + &cb)); + ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); + + PP_VideoFrame_Format input_format; + PP_Size input_visible_size; + PP_VideoProfile output_profile; + uint32_t bitrate; + PP_HardwareAcceleration acceleration; + ASSERT_TRUE(CheckInitializeMsg(¶ms, &input_format, &input_visible_size, + &output_profile, &bitrate, &acceleration)); + ASSERT_EQ(PP_VIDEOFRAME_FORMAT_I420, input_format); + ASSERT_EQ(kFrameSize.width, input_visible_size.width); + ASSERT_EQ(kFrameSize.height, input_visible_size.height); + ASSERT_EQ(kBitrate, bitrate); + ASSERT_EQ(PP_VIDEOPROFILE_H264MAIN, output_profile); + ASSERT_EQ(PP_HARDWAREACCELERATION_WITHFALLBACK, acceleration); + + SendInitializeReply(params, PP_OK, kVideoFrameCount, kFrameSize); + + ASSERT_TRUE(cb.called()); + ASSERT_EQ(PP_OK, cb.result()); + } + { + // Verify that calling initialize a second time, after it already + // succeeded, fails. + LockingResourceReleaser encoder(CreateEncoder()); + ResourceMessageCallParams params; + PP_Size size = kFrameSize; + const uint32_t kBitrate = 420000; + MockCompletionCallback cb; + int32_t result = encoder_iface()->Initialize( + encoder.get(), PP_VIDEOFRAME_FORMAT_I420, &size, + PP_VIDEOPROFILE_H264MAIN, kBitrate, + PP_HARDWAREACCELERATION_WITHFALLBACK, + PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback, + &cb)); + ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); + + PP_VideoFrame_Format input_format; + PP_Size input_visible_size; + PP_VideoProfile output_profile; + uint32_t bitrate; + PP_HardwareAcceleration acceleration; + ASSERT_TRUE(CheckInitializeMsg(¶ms, &input_format, &input_visible_size, + &output_profile, &bitrate, &acceleration)); + ASSERT_EQ(PP_VIDEOFRAME_FORMAT_I420, input_format); + ASSERT_EQ(kFrameSize.width, input_visible_size.width); + ASSERT_EQ(kFrameSize.height, input_visible_size.height); + ASSERT_EQ(kBitrate, bitrate); + ASSERT_EQ(PP_VIDEOPROFILE_H264MAIN, output_profile); + ASSERT_EQ(PP_HARDWAREACCELERATION_WITHFALLBACK, acceleration); + + SendInitializeReply(params, PP_OK, kVideoFrameCount, kFrameSize); + + ASSERT_TRUE(cb.called()); + ASSERT_EQ(PP_OK, cb.result()); + + result = encoder_iface()->Initialize( + encoder.get(), PP_VIDEOFRAME_FORMAT_I420, &size, + PP_VIDEOPROFILE_H264MAIN, kBitrate, + PP_HARDWAREACCELERATION_WITHFALLBACK, + PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback, + &cb)); + ASSERT_EQ(PP_ERROR_FAILED, result); + } + { + // Verify the sending the bitstream buffers details makes them + // available through the API. the right values. + LockingResourceReleaser encoder(CreateEncoder()); + ResourceMessageCallParams params; + PP_Size size = kFrameSize; + const uint32_t kBitrate = 420000; + MockCompletionCallback cb; + int32_t result = encoder_iface()->Initialize( + encoder.get(), PP_VIDEOFRAME_FORMAT_I420, &size, + PP_VIDEOPROFILE_H264MAIN, kBitrate, + PP_HARDWAREACCELERATION_WITHFALLBACK, + PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback, + &cb)); + ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); + + PP_VideoFrame_Format input_format; + PP_Size input_visible_size; + PP_VideoProfile output_profile; + uint32_t bitrate; + PP_HardwareAcceleration acceleration; + ASSERT_TRUE(CheckInitializeMsg(¶ms, &input_format, &input_visible_size, + &output_profile, &bitrate, &acceleration)); + ASSERT_EQ(PP_VIDEOFRAME_FORMAT_I420, input_format); + ASSERT_EQ(kFrameSize.width, input_visible_size.width); + ASSERT_EQ(kFrameSize.height, input_visible_size.height); + ASSERT_EQ(kBitrate, bitrate); + ASSERT_EQ(PP_VIDEOPROFILE_H264MAIN, output_profile); + ASSERT_EQ(PP_HARDWAREACCELERATION_WITHFALLBACK, acceleration); + + SendInitializeReply(params, PP_OK, kVideoFrameCount, kFrameSize); + + ASSERT_TRUE(cb.called()); + ASSERT_EQ(PP_OK, cb.result()); + + PP_Size coded_size; + ASSERT_EQ(PP_OK, CallGetFrameCodedSize(encoder.get(), &coded_size)); + ASSERT_EQ(kFrameSize.width, coded_size.width); + ASSERT_EQ(kFrameSize.height, coded_size.height); + ASSERT_EQ(static_cast<int32_t>(kVideoFrameCount), + CallGetFramesRequired(encoder.get())); + } +} + +TEST_F(VideoEncoderResourceTest, Uninitialized) { + // Operations on uninitialized encoders should fail. + LockingResourceReleaser encoder(CreateEncoder()); + + ASSERT_EQ(PP_ERROR_FAILED, CallGetFramesRequired(encoder.get())); + + PP_Size size; + ASSERT_EQ(PP_ERROR_FAILED, CallGetFrameCodedSize(encoder.get(), &size)); + + MockCompletionCallback uncalled_cb; + PP_Resource video_frame = 0; + ASSERT_EQ(PP_ERROR_FAILED, + CallGetVideoFrame(encoder.get(), &video_frame, &uncalled_cb)); + ASSERT_FALSE(uncalled_cb.called()); + ASSERT_EQ(0, video_frame); + + ASSERT_EQ(PP_ERROR_FAILED, + CallEncode(encoder.get(), video_frame, PP_FALSE, &uncalled_cb)); + ASSERT_FALSE(uncalled_cb.called()); + + PP_BitstreamBuffer bitstream_buffer; + ASSERT_EQ( + PP_ERROR_FAILED, + CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer, &uncalled_cb)); + ASSERT_FALSE(uncalled_cb.called()); + + ResourceMessageCallParams params; + uint32_t buffer_id; + CallRecycleBitstreamBuffer(encoder.get(), bitstream_buffer); + ASSERT_FALSE(CheckRecycleBitstreamBufferMsg(¶ms, &buffer_id)); + + uint32_t bitrate, framerate; + CallRequestEncodingParametersChange(encoder.get(), 0, 0); + ASSERT_FALSE( + CheckRequestEncodingParametersChangeMsg(¶ms, &bitrate, &framerate)); +} + +TEST_F(VideoEncoderResourceTest, InitializeAndGetVideoFrame) { + // Verify that we can pull the right number of video frames before + // the proxy makes us wait. + LockingResourceReleaser encoder(CreateAndInitializeEncoder()); + ResourceMessageCallParams params; + std::vector<PP_Resource> video_frames; + MockCompletionCallback get_frame_cb; + + video_frames.resize(kVideoFrameCount + 1); + + ASSERT_EQ(PP_OK_COMPLETIONPENDING, + CallGetVideoFrame(encoder.get(), &video_frames[0], &get_frame_cb)); + ASSERT_FALSE(get_frame_cb.called()); + ASSERT_TRUE(CheckGetVideoFramesMsg(¶ms)); + + uint32_t frame_length = kFrameSize.width * kFrameSize.height * 2; + CreateVideoFramesSharedMemory(frame_length, kVideoFrameCount); + SendGetVideoFramesReply(params, kVideoFrameCount, frame_length, kFrameSize); + + for (uint32_t i = 1; i < kVideoFrameCount; ++i) { + get_frame_cb.Reset(); + ASSERT_EQ( + PP_OK_COMPLETIONPENDING, + CallGetVideoFrame(encoder.get(), &video_frames[i], &get_frame_cb)); + ASSERT_TRUE(get_frame_cb.called()); + ASSERT_EQ(PP_OK, get_frame_cb.result()); + ASSERT_TRUE(CheckIsVideoFrame(video_frames[i])); + } + + get_frame_cb.Reset(); + ASSERT_EQ(PP_OK_COMPLETIONPENDING, + CallGetVideoFrame(encoder.get(), &video_frames[kVideoFrameCount], + &get_frame_cb)); + ASSERT_FALSE(get_frame_cb.called()); + + MockCompletionCallback get_frame_fail_cb; + ASSERT_EQ(PP_ERROR_INPROGRESS, + CallGetVideoFrame(encoder.get(), &video_frames[kVideoFrameCount], + &get_frame_fail_cb)); + ASSERT_FALSE(get_frame_fail_cb.called()); + + // Unblock the GetVideoFrame callback by freeing up a frame. + MockCompletionCallback encode_cb; + ASSERT_EQ( + PP_OK_COMPLETIONPENDING, + CallCompleteEncode(encoder.get(), video_frames[0], PP_FALSE, &encode_cb)); + ASSERT_TRUE(encode_cb.called()); + ASSERT_EQ(PP_OK, encode_cb.result()); + ASSERT_TRUE(get_frame_cb.called()); + + CallClose(encoder.get()); +} + +TEST_F(VideoEncoderResourceTest, Encode) { + // Check Encode() calls into the renderer. + LockingResourceReleaser encoder(CreateAndInitializeEncoder()); + PP_Resource video_frame; + MockCompletionCallback get_frame_cb; + + ASSERT_EQ(PP_OK_COMPLETIONPENDING, + CallFirstGetVideoFrame(encoder.get(), &video_frame, &get_frame_cb)); + ASSERT_TRUE(get_frame_cb.called()); + ASSERT_EQ(PP_OK, get_frame_cb.result()); + + MockCompletionCallback encode_cb; + ASSERT_EQ(PP_OK_COMPLETIONPENDING, + CallEncode(encoder.get(), video_frame, PP_TRUE, &encode_cb)); + ASSERT_FALSE(encode_cb.called()); + ASSERT_FALSE(CheckIsVideoFrameValid(video_frame)); + + ResourceMessageCallParams params; + uint32_t frame_id; + bool force_frame; + ASSERT_TRUE(CheckEncodeMsg(¶ms, &frame_id, &force_frame)); + + SendEncodeReply(params, frame_id); + + ASSERT_TRUE(encode_cb.called()); + ASSERT_EQ(PP_OK, encode_cb.result()); +} + +TEST_F(VideoEncoderResourceTest, EncodeAndGetVideoFrame) { + // Check the encoding loop works well. + LockingResourceReleaser encoder(CreateAndInitializeEncoder()); + ResourceMessageCallParams params; + PP_Resource video_frame; + MockCompletionCallback get_frame_cb, encode_cb; + + ASSERT_EQ(PP_OK_COMPLETIONPENDING, + CallFirstGetVideoFrame(encoder.get(), &video_frame, &get_frame_cb)); + ASSERT_TRUE(get_frame_cb.called()); + ASSERT_EQ(PP_OK, get_frame_cb.result()); + + for (uint32_t i = 1; i < 20 * kVideoFrameCount; ++i) { + encode_cb.Reset(); + ASSERT_EQ( + PP_OK_COMPLETIONPENDING, + CallCompleteEncode(encoder.get(), video_frame, PP_FALSE, &encode_cb)); + ASSERT_TRUE(encode_cb.called()); + ASSERT_EQ(PP_OK, encode_cb.result()); + + get_frame_cb.Reset(); + ASSERT_EQ(PP_OK_COMPLETIONPENDING, + CallGetVideoFrame(encoder.get(), &video_frame, &get_frame_cb)); + ASSERT_TRUE(get_frame_cb.called()); + ASSERT_EQ(PP_OK, get_frame_cb.result()); + ASSERT_TRUE(CheckIsVideoFrame(video_frame)); + } + + ASSERT_EQ( + PP_OK_COMPLETIONPENDING, + CallCompleteEncode(encoder.get(), video_frame, PP_FALSE, &encode_cb)); + ASSERT_TRUE(encode_cb.called()); + ASSERT_EQ(PP_OK, encode_cb.result()); +} + +TEST_F(VideoEncoderResourceTest, GetBitstreamBuffer) { + { + // Verify that the GetBitstreamBuffer callback is fired whenever the + // renderer signals a buffer is available. + LockingResourceReleaser encoder(CreateAndInitializeEncoder()); + + MockCompletionCallback get_bitstream_buffer_cb; + PP_BitstreamBuffer bitstream_buffer; + ASSERT_EQ(PP_OK_COMPLETIONPENDING, + CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer, + &get_bitstream_buffer_cb)); + ASSERT_FALSE(get_bitstream_buffer_cb.called()); + + ResourceMessageCallParams buffer_params(encoder.get(), 0); + SendBitstreamBufferReady(buffer_params, 0, 10, true); + + ASSERT_TRUE(get_bitstream_buffer_cb.called()); + ASSERT_EQ(PP_OK, get_bitstream_buffer_cb.result()); + ASSERT_EQ(10U, bitstream_buffer.size); + ASSERT_EQ(PP_TRUE, bitstream_buffer.key_frame); + } + { + // Verify that calling GetBitstreamBuffer a second time, while the + // first callback hasn't been fired fails. + LockingResourceReleaser encoder(CreateAndInitializeEncoder()); + + MockCompletionCallback get_bitstream_buffer_cb; + PP_BitstreamBuffer bitstream_buffer; + ASSERT_EQ(PP_OK_COMPLETIONPENDING, + CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer, + &get_bitstream_buffer_cb)); + ASSERT_FALSE(get_bitstream_buffer_cb.called()); + + ASSERT_EQ(PP_ERROR_INPROGRESS, + CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer, + &get_bitstream_buffer_cb)); + ASSERT_FALSE(get_bitstream_buffer_cb.called()); + + ResourceMessageCallParams buffer_params(encoder.get(), 0); + SendBitstreamBufferReady(buffer_params, 0, 10, true); + } +} + +TEST_F(VideoEncoderResourceTest, RecycleBitstreamBuffer) { + // Verify that we signal the renderer that a bitstream buffer has been + // recycled. + LockingResourceReleaser encoder(CreateAndInitializeEncoder()); + + MockCompletionCallback get_bitstream_buffer_cb; + PP_BitstreamBuffer bitstream_buffer; + ASSERT_EQ(PP_OK_COMPLETIONPENDING, + CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer, + &get_bitstream_buffer_cb)); + ASSERT_FALSE(get_bitstream_buffer_cb.called()); + + ResourceMessageCallParams buffer_params(encoder.get(), 0); + SendBitstreamBufferReady(buffer_params, kBitstreamBufferCount - 1, 10, true); + + ASSERT_TRUE(get_bitstream_buffer_cb.called()); + ASSERT_EQ(PP_OK, get_bitstream_buffer_cb.result()); + + CallRecycleBitstreamBuffer(encoder.get(), bitstream_buffer); + + ResourceMessageCallParams recycle_params; + uint32_t buffer_id; + ASSERT_TRUE(CheckRecycleBitstreamBufferMsg(&recycle_params, &buffer_id)); + ASSERT_EQ(kBitstreamBufferCount - 1, buffer_id); +} + +TEST_F(VideoEncoderResourceTest, RequestEncodingParametersChange) { + // Check encoding parameter changes are correctly sent to the + // renderer. + LockingResourceReleaser encoder(CreateAndInitializeEncoder()); + + CallRequestEncodingParametersChange(encoder.get(), 1, 2); + ResourceMessageCallParams params; + uint32_t bitrate, framerate; + ASSERT_TRUE( + CheckRequestEncodingParametersChangeMsg(¶ms, &bitrate, &framerate)); + ASSERT_EQ(1U, bitrate); + ASSERT_EQ(2U, framerate); +} + +TEST_F(VideoEncoderResourceTest, NotifyError) { + { + // Check an error from the encoder aborts GetVideoFrame and + // GetBitstreamBuffer callbacks. + LockingResourceReleaser encoder(CreateAndInitializeEncoder()); + + MockCompletionCallback get_frame_cb; + PP_Resource video_frame; + ASSERT_EQ(PP_OK_COMPLETIONPENDING, + CallGetVideoFrame(encoder.get(), &video_frame, &get_frame_cb)); + ASSERT_FALSE(get_frame_cb.called()); + + MockCompletionCallback get_bitstream_buffer_cb; + PP_BitstreamBuffer bitstream_buffer; + ASSERT_EQ(PP_OK_COMPLETIONPENDING, + CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer, + &get_bitstream_buffer_cb)); + + ResourceMessageCallParams error_params(encoder.get(), 0); + SendNotifyError(error_params, PP_ERROR_FAILED); + + ASSERT_TRUE(get_frame_cb.called()); + ASSERT_EQ(PP_ERROR_FAILED, get_frame_cb.result()); + ASSERT_TRUE(get_bitstream_buffer_cb.called()); + ASSERT_EQ(PP_ERROR_FAILED, get_bitstream_buffer_cb.result()); + } + { + // Check an error from the encoder aborts Encode and GetBitstreamBuffer + // callbacks. + LockingResourceReleaser encoder(CreateAndInitializeEncoder()); + + MockCompletionCallback get_frame_cb, encode_cb1, encode_cb2; + PP_Resource video_frame1, video_frame2; + ASSERT_EQ( + PP_OK_COMPLETIONPENDING, + CallFirstGetVideoFrame(encoder.get(), &video_frame1, &get_frame_cb)); + ASSERT_TRUE(get_frame_cb.called()); + ASSERT_EQ(PP_OK, get_frame_cb.result()); + + get_frame_cb.Reset(); + ASSERT_EQ( + PP_OK_COMPLETIONPENDING, + CallFirstGetVideoFrame(encoder.get(), &video_frame2, &get_frame_cb)); + ASSERT_TRUE(get_frame_cb.called()); + ASSERT_EQ(PP_OK, get_frame_cb.result()); + + ASSERT_EQ(PP_OK_COMPLETIONPENDING, + CallEncode(encoder.get(), video_frame1, PP_FALSE, &encode_cb1)); + ASSERT_FALSE(encode_cb1.called()); + ASSERT_EQ(PP_OK_COMPLETIONPENDING, + CallEncode(encoder.get(), video_frame2, PP_FALSE, &encode_cb2)); + ASSERT_FALSE(encode_cb2.called()); + + MockCompletionCallback get_bitstream_buffer_cb; + PP_BitstreamBuffer bitstream_buffer; + ASSERT_EQ(PP_OK_COMPLETIONPENDING, + CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer, + &get_bitstream_buffer_cb)); + + ResourceMessageCallParams error_params(encoder.get(), 0); + SendNotifyError(error_params, PP_ERROR_FAILED); + + ASSERT_TRUE(encode_cb1.called()); + ASSERT_EQ(PP_ERROR_FAILED, encode_cb1.result()); + ASSERT_TRUE(encode_cb2.called()); + ASSERT_EQ(PP_ERROR_FAILED, encode_cb2.result()); + ASSERT_TRUE(get_bitstream_buffer_cb.called()); + ASSERT_EQ(PP_ERROR_FAILED, get_bitstream_buffer_cb.result()); + } +} + +TEST_F(VideoEncoderResourceTest, Close) { + { + // Check closing the encoder aborts GetVideoFrame and + // GetBitstreamBuffer callbacks. + LockingResourceReleaser encoder(CreateAndInitializeEncoder()); + + MockCompletionCallback get_frame_cb; + PP_Resource video_frame; + ASSERT_EQ(PP_OK_COMPLETIONPENDING, + CallGetVideoFrame(encoder.get(), &video_frame, &get_frame_cb)); + ASSERT_FALSE(get_frame_cb.called()); + + MockCompletionCallback get_bitstream_buffer_cb; + PP_BitstreamBuffer bitstream_buffer; + ASSERT_EQ(PP_OK_COMPLETIONPENDING, + CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer, + &get_bitstream_buffer_cb)); + + CallClose(encoder.get()); + + ASSERT_TRUE(get_frame_cb.called()); + ASSERT_EQ(PP_ERROR_ABORTED, get_frame_cb.result()); + ASSERT_TRUE(get_bitstream_buffer_cb.called()); + ASSERT_EQ(PP_ERROR_ABORTED, get_bitstream_buffer_cb.result()); + } + { + // Check closing the encoder aborts Encode and GetBitstreamBuffer + // callbacks. + LockingResourceReleaser encoder(CreateAndInitializeEncoder()); + + MockCompletionCallback get_frame_cb, encode_cb1, encode_cb2; + PP_Resource video_frame1, video_frame2; + ASSERT_EQ( + PP_OK_COMPLETIONPENDING, + CallFirstGetVideoFrame(encoder.get(), &video_frame1, &get_frame_cb)); + ASSERT_TRUE(get_frame_cb.called()); + ASSERT_EQ(PP_OK, get_frame_cb.result()); + + get_frame_cb.Reset(); + ASSERT_EQ( + PP_OK_COMPLETIONPENDING, + CallFirstGetVideoFrame(encoder.get(), &video_frame2, &get_frame_cb)); + ASSERT_TRUE(get_frame_cb.called()); + ASSERT_EQ(PP_OK, get_frame_cb.result()); + + ASSERT_EQ(PP_OK_COMPLETIONPENDING, + CallEncode(encoder.get(), video_frame1, PP_FALSE, &encode_cb1)); + ASSERT_FALSE(encode_cb1.called()); + ASSERT_EQ(PP_OK_COMPLETIONPENDING, + CallEncode(encoder.get(), video_frame2, PP_FALSE, &encode_cb2)); + ASSERT_FALSE(encode_cb2.called()); + + MockCompletionCallback get_bitstream_buffer_cb; + PP_BitstreamBuffer bitstream_buffer; + ASSERT_EQ(PP_OK_COMPLETIONPENDING, + CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer, + &get_bitstream_buffer_cb)); + + CallClose(encoder.get()); + + ASSERT_TRUE(encode_cb1.called()); + ASSERT_EQ(PP_ERROR_ABORTED, encode_cb1.result()); + ASSERT_TRUE(encode_cb2.called()); + ASSERT_EQ(PP_ERROR_ABORTED, encode_cb2.result()); + ASSERT_TRUE(get_bitstream_buffer_cb.called()); + ASSERT_EQ(PP_ERROR_ABORTED, get_bitstream_buffer_cb.result()); + + // Verify that a remaining encode response from the renderer is + // discarded. + ResourceMessageCallParams params; + uint32_t frame_id; + bool force_frame; + ASSERT_TRUE(CheckEncodeMsg(¶ms, &frame_id, &force_frame)); + SendEncodeReply(params, frame_id); + } +} + +} // namespace proxy +} // namespace ppapi diff --git a/chromium/ppapi/proxy/video_frame_resource.h b/chromium/ppapi/proxy/video_frame_resource.h index 13901a65492..e796eed8d45 100644 --- a/chromium/ppapi/proxy/video_frame_resource.h +++ b/chromium/ppapi/proxy/video_frame_resource.h @@ -22,21 +22,21 @@ class PPAPI_PROXY_EXPORT VideoFrameResource : public Resource, int32_t index, MediaStreamBuffer* buffer); - virtual ~VideoFrameResource(); + ~VideoFrameResource() override; // PluginResource overrides: - virtual thunk::PPB_VideoFrame_API* AsPPB_VideoFrame_API() override; + thunk::PPB_VideoFrame_API* AsPPB_VideoFrame_API() override; // PPB_VideoFrame_API overrides: - virtual PP_TimeDelta GetTimestamp() override; - virtual void SetTimestamp(PP_TimeDelta timestamp) override; - virtual PP_VideoFrame_Format GetFormat() override; - virtual PP_Bool GetSize(PP_Size* size) override; - virtual void* GetDataBuffer() override; - virtual uint32_t GetDataBufferSize() override; - virtual MediaStreamBuffer* GetBuffer() override; - virtual int32_t GetBufferIndex() override; - virtual void Invalidate() override; + PP_TimeDelta GetTimestamp() override; + void SetTimestamp(PP_TimeDelta timestamp) override; + PP_VideoFrame_Format GetFormat() override; + PP_Bool GetSize(PP_Size* size) override; + void* GetDataBuffer() override; + uint32_t GetDataBufferSize() override; + MediaStreamBuffer* GetBuffer() override; + int32_t GetBufferIndex() override; + void Invalidate() override; // Frame index int32_t index_; diff --git a/chromium/ppapi/proxy/video_source_resource.h b/chromium/ppapi/proxy/video_source_resource.h index a2c587df72d..56cd7ddd3e2 100644 --- a/chromium/ppapi/proxy/video_source_resource.h +++ b/chromium/ppapi/proxy/video_source_resource.h @@ -29,20 +29,19 @@ class PPAPI_PROXY_EXPORT VideoSourceResource public: VideoSourceResource(Connection connection, PP_Instance instance); - virtual ~VideoSourceResource(); + ~VideoSourceResource() override; // Resource overrides. - virtual thunk::PPB_VideoSource_Private_API* - AsPPB_VideoSource_Private_API() override; + thunk::PPB_VideoSource_Private_API* AsPPB_VideoSource_Private_API() override; // PPB_VideoSource_Private_API implementation. - virtual int32_t Open( + int32_t Open( const PP_Var& stream_url, scoped_refptr<TrackedCallback> callback) override; - virtual int32_t GetFrame( + int32_t GetFrame( PP_VideoFrame_Private* frame, scoped_refptr<TrackedCallback> callback) override; - virtual void Close() override; + void Close() override; private: void OnPluginMsgOpenComplete( diff --git a/chromium/ppapi/proxy/websocket_resource.cc b/chromium/ppapi/proxy/websocket_resource.cc index d03121a870f..bc4e8535520 100644 --- a/chromium/ppapi/proxy/websocket_resource.cc +++ b/chromium/ppapi/proxy/websocket_resource.cc @@ -9,6 +9,7 @@ #include <vector> #include "base/bind.h" +#include "base/numerics/safe_conversions.h" #include "ppapi/c/pp_errors.h" #include "ppapi/proxy/dispatch_reply_message.h" #include "ppapi/proxy/ppapi_messages.h" @@ -424,7 +425,7 @@ void WebSocketResource::OnPluginMsgReceiveBinaryReply( // Append received data to queue. scoped_refptr<Var> message_var( PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferVar( - message.size(), + base::checked_cast<uint32_t>(message.size()), &message.front())); received_messages_.push(message_var); diff --git a/chromium/ppapi/proxy/websocket_resource.h b/chromium/ppapi/proxy/websocket_resource.h index 8106abd0007..51fb52d0626 100644 --- a/chromium/ppapi/proxy/websocket_resource.h +++ b/chromium/ppapi/proxy/websocket_resource.h @@ -26,36 +26,36 @@ class PPAPI_PROXY_EXPORT WebSocketResource public NON_EXPORTED_BASE(thunk::PPB_WebSocket_API) { public: WebSocketResource(Connection connection, PP_Instance instance); - virtual ~WebSocketResource(); + ~WebSocketResource() override; // PluginResource implementation. - virtual thunk::PPB_WebSocket_API* AsPPB_WebSocket_API() override; + thunk::PPB_WebSocket_API* AsPPB_WebSocket_API() override; // PPB_WebSocket_API implementation. - virtual int32_t Connect(const PP_Var& url, - const PP_Var protocols[], - uint32_t protocol_count, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t Close(uint16_t code, - const PP_Var& reason, - scoped_refptr<TrackedCallback> callback) override; - virtual int32_t ReceiveMessage( + int32_t Connect(const PP_Var& url, + const PP_Var protocols[], + uint32_t protocol_count, + scoped_refptr<TrackedCallback> callback) override; + int32_t Close(uint16_t code, + const PP_Var& reason, + scoped_refptr<TrackedCallback> callback) override; + int32_t ReceiveMessage( PP_Var* message, scoped_refptr<TrackedCallback> callback) override; - virtual int32_t SendMessage(const PP_Var& message) override; - virtual uint64_t GetBufferedAmount() override; - virtual uint16_t GetCloseCode() override; - virtual PP_Var GetCloseReason() override; - virtual PP_Bool GetCloseWasClean() override; - virtual PP_Var GetExtensions() override; - virtual PP_Var GetProtocol() override; - virtual PP_WebSocketReadyState GetReadyState() override; - virtual PP_Var GetURL() override; + int32_t SendMessage(const PP_Var& message) override; + uint64_t GetBufferedAmount() override; + uint16_t GetCloseCode() override; + PP_Var GetCloseReason() override; + PP_Bool GetCloseWasClean() override; + PP_Var GetExtensions() override; + PP_Var GetProtocol() override; + PP_WebSocketReadyState GetReadyState() override; + PP_Var GetURL() override; private: // PluginResource override. - virtual void OnReplyReceived(const ResourceMessageReplyParams& params, - const IPC::Message& msg) override; + void OnReplyReceived(const ResourceMessageReplyParams& params, + const IPC::Message& msg) override; // IPC message handlers. void OnPluginMsgConnectReply(const ResourceMessageReplyParams& params, diff --git a/chromium/ppapi/proxy/websocket_resource_unittest.cc b/chromium/ppapi/proxy/websocket_resource_unittest.cc index eac6d8f8320..f65c2a59223 100644 --- a/chromium/ppapi/proxy/websocket_resource_unittest.cc +++ b/chromium/ppapi/proxy/websocket_resource_unittest.cc @@ -47,7 +47,8 @@ PP_CompletionCallback MakeCallback() { PP_Var MakeStringVar(const std::string& string) { if (!ppb_var_) ppb_var_ = ppapi::PPB_Var_Shared::GetVarInterface1_2(); - return ppb_var_->VarFromUtf8(string.c_str(), string.length()); + return ppb_var_->VarFromUtf8(string.c_str(), + static_cast<uint32_t>(string.length())); } } // namespace @@ -77,9 +78,9 @@ TEST_F(WebSocketResourceTest, Connect) { PpapiHostMsg_WebSocket_Connect::ID, ¶ms, &msg)); PpapiHostMsg_WebSocket_Connect::Schema::Param p; PpapiHostMsg_WebSocket_Connect::Read(&msg, &p); - EXPECT_EQ(url, p.a); - EXPECT_EQ(protocol0, p.b[0]); - EXPECT_EQ(protocol1, p.b[1]); + EXPECT_EQ(url, get<0>(p)); + EXPECT_EQ(protocol0, get<1>(p)[0]); + EXPECT_EQ(protocol1, get<1>(p)[1]); // Synthesize a response. ResourceMessageReplyParams reply_params(params.pp_resource(), diff --git a/chromium/ppapi/shared_impl/BUILD.gn b/chromium/ppapi/shared_impl/BUILD.gn new file mode 100644 index 00000000000..9d205ece5ef --- /dev/null +++ b/chromium/ppapi/shared_impl/BUILD.gn @@ -0,0 +1,209 @@ +# Copyright 2015 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. + +component("shared_impl") { + output_name = "ppapi_shared" + + sources = [ + "array_var.cc", + "array_var.h", + "array_writer.cc", + "array_writer.h", + "callback_tracker.cc", + "callback_tracker.h", + "compositor_layer_data.cc", + "compositor_layer_data.h", + "dictionary_var.cc", + "dictionary_var.h", + "file_growth.cc", + "file_growth.h", + "file_io_state_manager.cc", + "file_io_state_manager.h", + "file_path.cc", + "file_path.h", + "file_ref_create_info.cc", + "file_ref_create_info.h", + "file_ref_util.cc", + "file_ref_util.h", + "file_system_util.cc", + "file_system_util.h", + "file_type_conversion.cc", + "file_type_conversion.h", + "host_resource.cc", + "host_resource.h", + "id_assignment.cc", + "id_assignment.h", + "media_stream_audio_track_shared.cc", + "media_stream_audio_track_shared.h", + "media_stream_buffer.h", + "media_stream_buffer_manager.cc", + "media_stream_buffer_manager.h", + "media_stream_video_track_shared.cc", + "media_stream_video_track_shared.h", + "platform_file.cc", + "platform_file.h", + "ppapi_constants.h", + "ppapi_globals.cc", + "ppapi_globals.h", + "ppapi_nacl_plugin_args.cc", + "ppapi_nacl_plugin_args.h", + "ppapi_permissions.cc", + "ppapi_permissions.h", + "ppapi_preferences.cc", + "ppapi_preferences.h", + "ppapi_switches.cc", + "ppapi_switches.h", + "ppb_audio_config_shared.cc", + "ppb_audio_config_shared.h", + "ppb_audio_shared.cc", + "ppb_audio_shared.h", + "ppb_crypto_shared.cc", + "ppb_device_ref_shared.cc", + "ppb_device_ref_shared.h", + "ppb_gamepad_shared.cc", + "ppb_gamepad_shared.h", + "ppb_graphics_3d_shared.cc", + "ppb_graphics_3d_shared.h", + "ppb_image_data_shared.cc", + "ppb_image_data_shared.h", + "ppb_input_event_shared.cc", + "ppb_input_event_shared.h", + "ppb_instance_shared.cc", + "ppb_instance_shared.h", + "ppb_memory_shared.cc", + "ppb_message_loop_shared.cc", + "ppb_message_loop_shared.h", + "ppb_opengles2_shared.cc", + "ppb_opengles2_shared.h", + "ppb_tcp_socket_shared.cc", + "ppb_tcp_socket_shared.h", + "ppb_trace_event_impl.cc", + "ppb_trace_event_impl.h", + "ppb_var_shared.cc", + "ppb_var_shared.h", + "ppb_view_shared.cc", + "ppb_view_shared.h", + "ppp_flash_browser_operations_shared.h", + "ppp_instance_combined.cc", + "ppp_instance_combined.h", + "proxy_lock.cc", + "proxy_lock.h", + "resource.cc", + "resource.h", + "resource_tracker.cc", + "resource_tracker.h", + "resource_var.cc", + "resource_var.h", + "scoped_pp_resource.cc", + "scoped_pp_resource.h", + "scoped_pp_var.cc", + "scoped_pp_var.h", + "socket_option_data.cc", + "socket_option_data.h", + "thread_aware_callback.cc", + "thread_aware_callback.h", + "time_conversion.cc", + "time_conversion.h", + "tracked_callback.cc", + "tracked_callback.h", + "url_request_info_data.cc", + "url_request_info_data.h", + "url_response_info_data.cc", + "url_response_info_data.h", + "var.cc", + "var.h", + "var_tracker.cc", + "var_tracker.h", + + # TODO(viettrungluu): Split these out; it won"t be used in NaCl. + "private/net_address_private_impl.cc", + "private/net_address_private_impl.h", + "private/net_address_private_impl_constants.cc", + "private/ppb_x509_certificate_private_shared.cc", + "private/ppb_x509_certificate_private_shared.h", + ] + + if (!is_nacl) { + sources += [ + "flash_clipboard_format_registry.cc", + "flash_clipboard_format_registry.h", + "ppb_url_util_shared.cc", + "ppb_url_util_shared.h", + "ppb_video_decoder_shared.cc", + "ppb_video_decoder_shared.h", + "private/ppb_char_set_shared.cc", + "private/ppb_char_set_shared.h", + ] + } + + # TODO(GYP) this isn't correct. This should only be specifically for the + # nacl_win64 build (cross-compiled for a 32-bit Chrome), rather than the + # native 64-bit Chrome build. + # See also //ppapi/thunk + if (is_win && current_cpu == "x64" && current_toolchain != default_toolchain) { + sources -= [ + "ppb_audio_shared.cc", + "ppb_graphics_3d_shared.cc", + "ppb_opengles2_shared.cc", + "private/net_address_private_impl.cc", + "private/ppb_host_resolver_shared.cc", + ] + } + + defines = [ + "PPAPI_SHARED_IMPLEMENTATION", + + # This target goes in the same library as thunk (in GYP they are the same). + "PPAPI_THUNK_IMPLEMENTATION", + ] + + deps = [ + "//base", + "//base:i18n", + "//base/third_party/dynamic_annotations", + "//gpu/command_buffer/client", + "//gpu/command_buffer/client:gles2_cmd_helper", + "//gpu/command_buffer/client:gles2_implementation", + "//gpu/command_buffer/common", + "//ipc", + "//media:shared_memory_support", + "//ppapi/c", + "//ppapi/thunk", + "//third_party/icu:icuuc", + "//url", + ] + + if (!is_nacl) { + deps += [ + "//skia", + "//ui/events:events_base", + "//ui/surface", + ] + } + + if (is_mac) { + libs = [ "QuartzCore.framework" ] + } +} + +source_set("test_support") { + testonly = true + + sources = [ + "test_globals.cc", + "test_globals.h", + "test_utils.cc", + "test_utils.h", + ] + + deps = [ + "//base/test:test_support", + "//ipc", + "//ipc:test_support", + "//ppapi/proxy", + "//ppapi/shared_impl", + "//testing/gmock", + "//testing/gtest", + ] +} diff --git a/chromium/ppapi/shared_impl/array_var.h b/chromium/ppapi/shared_impl/array_var.h index 84515d0ee8b..2e3ab02861b 100644 --- a/chromium/ppapi/shared_impl/array_var.h +++ b/chromium/ppapi/shared_impl/array_var.h @@ -28,8 +28,8 @@ class PPAPI_SHARED_EXPORT ArrayVar : public Var { static ArrayVar* FromPPVar(const PP_Var& var); // Var overrides. - virtual ArrayVar* AsArrayVar() override; - virtual PP_VarType GetType() const override; + ArrayVar* AsArrayVar() override; + PP_VarType GetType() const override; // The returned PP_Var has had a ref added on behalf of the caller. PP_Var Get(uint32_t index) const; @@ -42,7 +42,7 @@ class PPAPI_SHARED_EXPORT ArrayVar : public Var { ElementVector& elements() { return elements_; } protected: - virtual ~ArrayVar(); + ~ArrayVar() override; private: ElementVector elements_; diff --git a/chromium/ppapi/shared_impl/array_writer.h b/chromium/ppapi/shared_impl/array_writer.h index fce10e4fc73..1d2608adc04 100644 --- a/chromium/ppapi/shared_impl/array_writer.h +++ b/chromium/ppapi/shared_impl/array_writer.h @@ -74,7 +74,8 @@ class PPAPI_SHARED_EXPORT ArrayWriter { // comment of StoreArray() for detail. template <typename T> bool StoreVector(const std::vector<T>& input) { - return StoreArray(input.size() ? &input[0] : NULL, input.size()); + return StoreArray(input.size() ? &input[0] : NULL, + static_cast<uint32_t>(input.size())); } // Stores the given vector of resources as PP_Resources to the output vector, diff --git a/chromium/ppapi/shared_impl/callback_tracker.cc b/chromium/ppapi/shared_impl/callback_tracker.cc index feefb0e117d..3ed009a89b5 100644 --- a/chromium/ppapi/shared_impl/callback_tracker.cc +++ b/chromium/ppapi/shared_impl/callback_tracker.cc @@ -11,18 +11,25 @@ #include "base/logging.h" #include "base/message_loop/message_loop.h" #include "ppapi/c/pp_completion_callback.h" +#include "ppapi/shared_impl/proxy_lock.h" #include "ppapi/shared_impl/tracked_callback.h" namespace ppapi { // CallbackTracker ------------------------------------------------------------- -CallbackTracker::CallbackTracker() {} +CallbackTracker::CallbackTracker() : abort_all_called_(false) {} void CallbackTracker::AbortAll() { - // Iterate over a copy since |Abort()| calls |Remove()| (indirectly). - // TODO(viettrungluu): This obviously isn't so efficient. - CallbackSetMap pending_callbacks_copy = pending_callbacks_; + // Iterate over a copy: + // 1) because |Abort()| calls |Remove()| (indirectly). + // 2) So we can drop the lock before calling in to TrackedCallback. + CallbackSetMap pending_callbacks_copy; + { + base::AutoLock acquire(lock_); + pending_callbacks_copy = pending_callbacks_; + abort_all_called_ = true; + } for (CallbackSetMap::iterator it1 = pending_callbacks_copy.begin(); it1 != pending_callbacks_copy.end(); ++it1) { @@ -35,15 +42,21 @@ void CallbackTracker::AbortAll() { } void CallbackTracker::PostAbortForResource(PP_Resource resource_id) { - CHECK(resource_id != 0); - CallbackSetMap::iterator it1 = pending_callbacks_.find(resource_id); - if (it1 == pending_callbacks_.end()) - return; - for (CallbackSet::iterator it2 = it1->second.begin(); - it2 != it1->second.end(); - ++it2) { - // Post the abort. - (*it2)->PostAbort(); + // Only TrackedCallbacks with a valid resource should appear in the tracker. + DCHECK_NE(resource_id, 0); + CallbackSet callbacks_for_resource; + { + base::AutoLock acquire(lock_); + CallbackSetMap::iterator iter = pending_callbacks_.find(resource_id); + // The resource may have no callbacks, so it won't be found, and we're done. + if (iter == pending_callbacks_.end()) + return; + // Copy the set so we can drop the lock before calling in to + // TrackedCallback. + callbacks_for_resource = iter->second; + } + for (const auto& iter : callbacks_for_resource) { + iter->PostAbort(); } } @@ -54,7 +67,11 @@ CallbackTracker::~CallbackTracker() { void CallbackTracker::Add( const scoped_refptr<TrackedCallback>& tracked_callback) { + base::AutoLock acquire(lock_); + DCHECK(!abort_all_called_); PP_Resource resource_id = tracked_callback->resource_id(); + // Only TrackedCallbacks with a valid resource should appear in the tracker. + DCHECK_NE(resource_id, 0); DCHECK(pending_callbacks_[resource_id].find(tracked_callback) == pending_callbacks_[resource_id].end()); pending_callbacks_[resource_id].insert(tracked_callback); @@ -62,6 +79,7 @@ void CallbackTracker::Add( void CallbackTracker::Remove( const scoped_refptr<TrackedCallback>& tracked_callback) { + base::AutoLock acquire(lock_); CallbackSetMap::iterator map_it = pending_callbacks_.find(tracked_callback->resource_id()); DCHECK(map_it != pending_callbacks_.end()); diff --git a/chromium/ppapi/shared_impl/callback_tracker.h b/chromium/ppapi/shared_impl/callback_tracker.h index f19f27669ed..bafd818fa6b 100644 --- a/chromium/ppapi/shared_impl/callback_tracker.h +++ b/chromium/ppapi/shared_impl/callback_tracker.h @@ -10,6 +10,7 @@ #include "base/basictypes.h" #include "base/memory/ref_counted.h" +#include "base/synchronization/lock.h" #include "ppapi/c/pp_resource.h" #include "ppapi/shared_impl/ppapi_shared_export.h" @@ -19,15 +20,17 @@ class TrackedCallback; // Pepper callbacks have the following semantics (unless otherwise specified; // in particular, the below apply to all completion callbacks): -// - Callbacks are always run on the main thread. -// - Callbacks are always called from the main message loop. In particular, -// calling into Pepper will not result in the plugin being re-entered via a -// synchronously-run callback. +// - Callbacks are always run on the thread where the plugin called a Pepper +// function providing that callback. +// - Callbacks are always called from the message loop of the thread. In +// particular, calling into Pepper will not result in the plugin being +// re-entered via a synchronously-run callback. // - Each callback will be executed (a.k.a. completed) exactly once. // - Each callback may be *aborted*, which means that it will be executed with -// result |PP_ERROR_ABORTED| (in the case of completion callbacks). -// - Before |PPP_ShutdownModule()| is called, every pending callback (for that -// module) will be aborted. +// result |PP_ERROR_ABORTED| (in the case of completion callbacks). The +// ABORT counts as the callback's one completion. +// - Before |PPP_ShutdownModule()| is called, every pending callback (for every +// instance of that module) will be aborted. // - Callbacks are usually associated to a resource, whose "deletion" provides // a "cancellation" (or abort) mechanism -- see below. // - When a plugin releases its last reference to resource, all callbacks @@ -42,25 +45,29 @@ class TrackedCallback; // progress, or may be completed (successfully or not). In fact, the // operation may still proceed after the callback has been aborted. // - Any output data buffers provided to Pepper are associated with a resource. -// Once that resource is released, no subsequent writes to those buffers. (If -// background threads are set up to write into such buffers, the final -// release operation should not return into the plugin until it can -// guaranteed that those threads will no longer write into the buffers.) +// Once that resource is released, no subsequent writes to those buffers +// will occur. When operations occur on background threads, writing to the +// plugin's data buffers should be delayed to happen on the callback's thread +// to ensure that we don't write to the buffers if the callback has been +// aborted (see TrackedCallback::set_completion_task()). // // Thread-safety notes: -// Currently, everything should happen on the main thread. The objects are -// thread-safe ref-counted, so objects which live on different threads may keep -// references. Releasing a reference to |TrackedCallback| on a different thread -// (possibly causing destruction) is also okay. Otherwise, all methods should be -// called only from the main thread. - -// |CallbackTracker| tracks pending Pepper callbacks for a single module. It -// also tracks, for each resource ID, which callbacks are pending. When a -// callback is (just about to be) completed, it is removed from the tracker. We -// use |CallbackTracker| for two things: (1) to ensure that all callbacks are -// properly aborted before module shutdown, and (2) to ensure that all callbacks -// associated to a given resource are aborted when a plugin (module) releases -// its last reference to that resource. +// |CallbackTracker| uses a lock to protect its dictionary of callbacks. This +// is primarily to allow the safe removal of callbacks from any thread without +// requiring that the |ProxyLock| is held. Methods that may invoke a callback +// need to have the |ProxyLock| (and those methods assert that it's acquired). +// |TrackedCallback| is thread-safe ref-counted, so objects which live on +// different threads may keep references. Releasing a reference to +// |TrackedCallback| on a different thread (possibly causing destruction) is +// also okay. +// +// |CallbackTracker| tracks pending Pepper callbacks for a single instance. It +// also tracks, for each resource ID, which callbacks are pending. Just before +// a callback is completed, it is removed from the tracker. We use +// |CallbackTracker| for two things: (1) to ensure that all callbacks are +// properly aborted before instance shutdown, and (2) to ensure that all +// callbacks associated with a given resource are aborted when a plugin instance +// releases its last reference to that resource. class PPAPI_SHARED_EXPORT CallbackTracker : public base::RefCountedThreadSafe<CallbackTracker> { public: @@ -92,6 +99,11 @@ class PPAPI_SHARED_EXPORT CallbackTracker typedef std::map<PP_Resource, CallbackSet> CallbackSetMap; CallbackSetMap pending_callbacks_; + // Used to ensure we don't add any callbacks after AbortAll. + bool abort_all_called_; + + base::Lock lock_; + DISALLOW_COPY_AND_ASSIGN(CallbackTracker); }; diff --git a/chromium/ppapi/shared_impl/dictionary_var.h b/chromium/ppapi/shared_impl/dictionary_var.h index 628fdeec660..06f9502c48d 100644 --- a/chromium/ppapi/shared_impl/dictionary_var.h +++ b/chromium/ppapi/shared_impl/dictionary_var.h @@ -29,8 +29,8 @@ class PPAPI_SHARED_EXPORT DictionaryVar : public Var { static DictionaryVar* FromPPVar(const PP_Var& var); // Var overrides. - virtual DictionaryVar* AsDictionaryVar() override; - virtual PP_VarType GetType() const override; + DictionaryVar* AsDictionaryVar() override; + PP_VarType GetType() const override; // The returned PP_Var has had a ref added on behalf of the caller. PP_Var Get(const PP_Var& key) const; @@ -48,7 +48,7 @@ class PPAPI_SHARED_EXPORT DictionaryVar : public Var { const KeyValueMap& key_value_map() const { return key_value_map_; } protected: - virtual ~DictionaryVar(); + ~DictionaryVar() override; private: KeyValueMap key_value_map_; diff --git a/chromium/ppapi/shared_impl/flash_clipboard_format_registry.cc b/chromium/ppapi/shared_impl/flash_clipboard_format_registry.cc index 89a051e2d3d..fa43478a339 100644 --- a/chromium/ppapi/shared_impl/flash_clipboard_format_registry.cc +++ b/chromium/ppapi/shared_impl/flash_clipboard_format_registry.cc @@ -6,6 +6,8 @@ #include <cctype> +#include "base/numerics/safe_conversions.h" + namespace ppapi { namespace { @@ -43,7 +45,8 @@ uint32_t FlashClipboardFormatRegistry::RegisterFormat( custom_formats_.size() > kMaxNumFormats) { return PP_FLASH_CLIPBOARD_FORMAT_INVALID; } - uint32_t key = kFirstCustomFormat + custom_formats_.size(); + uint32_t key = kFirstCustomFormat + + base::checked_cast<uint32_t>(custom_formats_.size()); custom_formats_[key] = format_name; return key; } diff --git a/chromium/ppapi/shared_impl/id_assignment.cc b/chromium/ppapi/shared_impl/id_assignment.cc index 363dbb49f91..5c5aed6b822 100644 --- a/chromium/ppapi/shared_impl/id_assignment.cc +++ b/chromium/ppapi/shared_impl/id_assignment.cc @@ -12,7 +12,7 @@ const unsigned int kPPIdTypeBits = 2; const int32 kMaxPPId = kint32max >> kPPIdTypeBits; -COMPILE_ASSERT(PP_ID_TYPE_COUNT <= (1 << kPPIdTypeBits), - kPPIdTypeBits_is_too_small_for_all_id_types); +static_assert(PP_ID_TYPE_COUNT <= (1 << kPPIdTypeBits), + "kPPIdTypeBits is too small for all id types"); } // namespace ppapi diff --git a/chromium/ppapi/shared_impl/media_stream_buffer_manager.h b/chromium/ppapi/shared_impl/media_stream_buffer_manager.h index eafd10cc2e9..28d8e806ae5 100644 --- a/chromium/ppapi/shared_impl/media_stream_buffer_manager.h +++ b/chromium/ppapi/shared_impl/media_stream_buffer_manager.h @@ -53,6 +53,8 @@ class PPAPI_SHARED_EXPORT MediaStreamBufferManager { int32_t buffer_size() const { return buffer_size_; } + base::SharedMemory* shm() { return shm_.get(); } + // Initializes shared memory for buffers transmission. bool SetBuffers(int32_t number_of_buffers, int32_t buffer_size, diff --git a/chromium/ppapi/shared_impl/media_stream_buffer_manager_unittest.cc b/chromium/ppapi/shared_impl/media_stream_buffer_manager_unittest.cc index 090cb2a36d6..3db0117f592 100644 --- a/chromium/ppapi/shared_impl/media_stream_buffer_manager_unittest.cc +++ b/chromium/ppapi/shared_impl/media_stream_buffer_manager_unittest.cc @@ -30,7 +30,7 @@ namespace ppapi { class MockDelegate : public MediaStreamBufferManager::Delegate { public: MockDelegate() : new_buffer_enqueue_counter_(0) {} - virtual void OnNewBufferEnqueued() override { + void OnNewBufferEnqueued() override { new_buffer_enqueue_counter_++; } @@ -84,10 +84,15 @@ TEST(MediaStreamBufferManager, General) { EXPECT_EQ(NULL, manager.GetBufferPointer(kNumberOfBuffers)); // Test crash for passing invalid index to EnqueueBuffer(). - EXPECT_DEATH(manager.EnqueueBuffer(-1), - ".*Check failed: index >= 0.*"); + // String arguments aren't passed to CHECK() in official builds. +#if defined(OFFICIAL_BUILD) && defined(NDEBUG) + EXPECT_DEATH(manager.EnqueueBuffer(-1), ""); + EXPECT_DEATH(manager.EnqueueBuffer(kNumberOfBuffers), ""); +#else + EXPECT_DEATH(manager.EnqueueBuffer(-1), ".*Check failed: index >= 0.*"); EXPECT_DEATH(manager.EnqueueBuffer(kNumberOfBuffers), ".*Check failed: index < number_of_buffers_.*"); +#endif } { diff --git a/chromium/ppapi/shared_impl/ppapi_constants.h b/chromium/ppapi/shared_impl/ppapi_constants.h index dcc9b29de5e..d5b71aadb95 100644 --- a/chromium/ppapi/shared_impl/ppapi_constants.h +++ b/chromium/ppapi/shared_impl/ppapi_constants.h @@ -14,6 +14,14 @@ namespace ppapi { // used to kill inactive plugins by the embedder host. const unsigned kKeepaliveThrottleIntervalDefaultMilliseconds = 5000; +#if defined(OS_WIN) +const char kPowerSaverTestPluginName[] = "power_saver_test_plugin.dll"; +#elif defined(OS_MACOSX) +const char kPowerSaverTestPluginName[] = "power_saver_test_plugin.plugin"; +#elif defined(OS_POSIX) +const char kPowerSaverTestPluginName[] = "libpower_saver_test_plugin.so"; +#endif + } // namespace ppapi #endif // PPAPI_SHARED_IMPL_PPAPI_CONSTANTS_H_ diff --git a/chromium/ppapi/shared_impl/ppapi_permissions.cc b/chromium/ppapi/shared_impl/ppapi_permissions.cc index 3fc6578384c..a2d252184dd 100644 --- a/chromium/ppapi/shared_impl/ppapi_permissions.cc +++ b/chromium/ppapi/shared_impl/ppapi_permissions.cc @@ -28,7 +28,7 @@ PpapiPermissions PpapiPermissions::GetForCommandLine(uint32 base_perms) { #if !defined(OS_NACL) // Testing permissions. The testing flag implies all permissions since the // test plugin needs to test all interfaces. - if (CommandLine::ForCurrentProcess()->HasSwitch( + if (base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnablePepperTesting)) additional_permissions |= ppapi::PERMISSION_ALL_BITS; #endif diff --git a/chromium/ppapi/shared_impl/ppb_audio_config_shared.h b/chromium/ppapi/shared_impl/ppb_audio_config_shared.h index 59c6cbb4cde..5e7d3598f3b 100644 --- a/chromium/ppapi/shared_impl/ppb_audio_config_shared.h +++ b/chromium/ppapi/shared_impl/ppb_audio_config_shared.h @@ -24,7 +24,7 @@ class PPAPI_SHARED_EXPORT PPB_AudioConfig_Shared : public Resource, public thunk::PPB_AudioConfig_API { public: - virtual ~PPB_AudioConfig_Shared(); + ~PPB_AudioConfig_Shared() override; static PP_Resource Create(ResourceObjectType type, PP_Instance instance, @@ -40,11 +40,11 @@ class PPAPI_SHARED_EXPORT PPB_AudioConfig_Shared static PP_AudioSampleRate RecommendSampleRate(PP_Instance); // Resource overrides. - virtual thunk::PPB_AudioConfig_API* AsPPB_AudioConfig_API() override; + thunk::PPB_AudioConfig_API* AsPPB_AudioConfig_API() override; // PPB_AudioConfig_API implementation. - virtual PP_AudioSampleRate GetSampleRate() override; - virtual uint32_t GetSampleFrameCount() override; + PP_AudioSampleRate GetSampleRate() override; + uint32_t GetSampleFrameCount() override; private: // You must call Init before using this object. diff --git a/chromium/ppapi/shared_impl/ppb_audio_shared.cc b/chromium/ppapi/shared_impl/ppb_audio_shared.cc index 99af9d7e7e2..b4454d5ffb4 100644 --- a/chromium/ppapi/shared_impl/ppb_audio_shared.cc +++ b/chromium/ppapi/shared_impl/ppb_audio_shared.cc @@ -4,8 +4,8 @@ #include "ppapi/shared_impl/ppb_audio_shared.h" -#include "base/debug/trace_event.h" #include "base/logging.h" +#include "base/trace_event/trace_event.h" #include "ppapi/nacl_irt/public/irt_ppapi.h" #include "ppapi/shared_impl/ppapi_globals.h" #include "ppapi/shared_impl/ppb_audio_config_shared.h" @@ -51,6 +51,7 @@ void AudioCallbackCombined::Run(void* sample_buffer, PPB_Audio_Shared::PPB_Audio_Shared() : playing_(false), shared_memory_size_(0), + nacl_thread_id_(0), nacl_thread_active_(false), user_data_(NULL), client_buffer_size_bytes_(0), diff --git a/chromium/ppapi/shared_impl/ppb_device_ref_shared.h b/chromium/ppapi/shared_impl/ppb_device_ref_shared.h index e9bccab58b0..aac1206d659 100644 --- a/chromium/ppapi/shared_impl/ppb_device_ref_shared.h +++ b/chromium/ppapi/shared_impl/ppb_device_ref_shared.h @@ -38,12 +38,12 @@ class PPAPI_SHARED_EXPORT PPB_DeviceRef_Shared const DeviceRefData& data); // Resource overrides. - virtual PPB_DeviceRef_API* AsPPB_DeviceRef_API() override; + PPB_DeviceRef_API* AsPPB_DeviceRef_API() override; // PPB_DeviceRef_API implementation. - virtual const DeviceRefData& GetDeviceRefData() const override; - virtual PP_DeviceType_Dev GetType() override; - virtual PP_Var GetName() override; + const DeviceRefData& GetDeviceRefData() const override; + PP_DeviceType_Dev GetType() override; + PP_Var GetName() override; private: DeviceRefData data_; diff --git a/chromium/ppapi/shared_impl/ppb_gamepad_shared.cc b/chromium/ppapi/shared_impl/ppb_gamepad_shared.cc index c9134014817..2bf0b572acd 100644 --- a/chromium/ppapi/shared_impl/ppb_gamepad_shared.cc +++ b/chromium/ppapi/shared_impl/ppb_gamepad_shared.cc @@ -4,22 +4,28 @@ #include "ppapi/shared_impl/ppb_gamepad_shared.h" +#include <algorithm> + #include "base/basictypes.h" namespace ppapi { +const size_t WebKitGamepads::kItemsLengthCap; + void ConvertWebKitGamepadData(const WebKitGamepads& webkit_data, PP_GamepadsSampleData* output_data) { - output_data->length = webkit_data.length; - for (unsigned i = 0; i < webkit_data.length; ++i) { + size_t length = std::min(WebKitGamepads::kItemsLengthCap, + static_cast<const size_t>(webkit_data.length)); + output_data->length = static_cast<unsigned>(length); + for (unsigned i = 0; i < length; ++i) { PP_GamepadSampleData& output_pad = output_data->items[i]; const WebKitGamepad& webkit_pad = webkit_data.items[i]; output_pad.connected = webkit_pad.connected ? PP_TRUE : PP_FALSE; if (webkit_pad.connected) { - COMPILE_ASSERT(sizeof(output_pad.id) == sizeof(webkit_pad.id), - id_size_does_not_match); + static_assert(sizeof(output_pad.id) == sizeof(webkit_pad.id), + "id size does not match"); memcpy(output_pad.id, webkit_pad.id, sizeof(output_pad.id)); - output_pad.timestamp = webkit_pad.timestamp; + output_pad.timestamp = static_cast<double>(webkit_pad.timestamp); output_pad.axes_length = webkit_pad.axes_length; for (unsigned j = 0; j < webkit_pad.axes_length; ++j) output_pad.axes[j] = static_cast<float>(webkit_pad.axes[j]); diff --git a/chromium/ppapi/shared_impl/ppb_graphics_3d_shared.h b/chromium/ppapi/shared_impl/ppb_graphics_3d_shared.h index 8df6219aea6..09bc0f53829 100644 --- a/chromium/ppapi/shared_impl/ppb_graphics_3d_shared.h +++ b/chromium/ppapi/shared_impl/ppb_graphics_3d_shared.h @@ -30,26 +30,26 @@ class PPAPI_SHARED_EXPORT PPB_Graphics3D_Shared public thunk::PPB_Graphics3D_API { public: // Resource overrides. - virtual thunk::PPB_Graphics3D_API* AsPPB_Graphics3D_API() override; + thunk::PPB_Graphics3D_API* AsPPB_Graphics3D_API() override; // PPB_Graphics3D_API implementation. - virtual int32_t GetAttribs(int32_t attrib_list[]) override; - virtual int32_t SetAttribs(const 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(scoped_refptr<TrackedCallback> callback) override; - virtual int32_t GetAttribMaxValue(int32_t attribute, int32_t* value) 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; + int32_t GetAttribs(int32_t attrib_list[]) override; + int32_t SetAttribs(const int32_t attrib_list[]) override; + int32_t GetError() override; + int32_t ResizeBuffers(int32_t width, int32_t height) override; + int32_t SwapBuffers(scoped_refptr<TrackedCallback> callback) override; + int32_t GetAttribMaxValue(int32_t attribute, int32_t* value) override; + + void* MapTexSubImage2DCHROMIUM(GLenum target, + GLint level, + GLint xoffset, + GLint yoffset, + GLsizei width, + GLsizei height, + GLenum format, + GLenum type, + GLenum access) override; + void UnmapTexSubImage2DCHROMIUM(const void* mem) override; gpu::gles2::GLES2Implementation* gles2_impl() { return gles2_impl_.get(); } @@ -59,7 +59,7 @@ class PPAPI_SHARED_EXPORT PPB_Graphics3D_Shared protected: PPB_Graphics3D_Shared(PP_Instance instance); PPB_Graphics3D_Shared(const HostResource& host_resource); - virtual ~PPB_Graphics3D_Shared(); + ~PPB_Graphics3D_Shared() override; virtual gpu::CommandBuffer* GetCommandBuffer() = 0; virtual gpu::GpuControl* GetGpuControl() = 0; diff --git a/chromium/ppapi/shared_impl/ppb_input_event_shared.h b/chromium/ppapi/shared_impl/ppb_input_event_shared.h index bd0d1755951..92d31088302 100644 --- a/chromium/ppapi/shared_impl/ppb_input_event_shared.h +++ b/chromium/ppapi/shared_impl/ppb_input_event_shared.h @@ -72,35 +72,33 @@ class PPAPI_SHARED_EXPORT PPB_InputEvent_Shared const InputEventData& data); // Resource overrides. - virtual PPB_InputEvent_API* AsPPB_InputEvent_API() override; + 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 PP_Var GetCode() 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; - virtual void AddTouchPoint(PP_TouchListType list, - const PP_TouchPoint& point) override; - virtual uint32_t GetTouchCount(PP_TouchListType list) override; - virtual PP_TouchPoint GetTouchByIndex(PP_TouchListType list, - uint32_t index) override; - virtual PP_TouchPoint GetTouchById(PP_TouchListType list, - uint32_t id) override; - virtual PP_Bool TraceInputLatency(PP_Bool has_damage) override; + const InputEventData& GetInputEventData() const override; + PP_InputEvent_Type GetType() override; + PP_TimeTicks GetTimeStamp() override; + uint32_t GetModifiers() override; + PP_InputEvent_MouseButton GetMouseButton() override; + PP_Point GetMousePosition() override; + int32_t GetMouseClickCount() override; + PP_Point GetMouseMovement() override; + PP_FloatPoint GetWheelDelta() override; + PP_FloatPoint GetWheelTicks() override; + PP_Bool GetWheelScrollByPage() override; + uint32_t GetKeyCode() override; + PP_Var GetCharacterText() override; + PP_Var GetCode() override; + uint32_t GetIMESegmentNumber() override; + uint32_t GetIMESegmentOffset(uint32_t index) override; + int32_t GetIMETargetSegment() override; + void GetIMESelection(uint32_t* start, uint32_t* end) override; + void AddTouchPoint(PP_TouchListType list, + const PP_TouchPoint& point) override; + uint32_t GetTouchCount(PP_TouchListType list) override; + PP_TouchPoint GetTouchByIndex(PP_TouchListType list, uint32_t index) override; + PP_TouchPoint GetTouchById(PP_TouchListType list, uint32_t id) override; + PP_Bool TraceInputLatency(PP_Bool has_damage) override; // Implementations for event creation. static PP_Resource CreateIMEInputEvent(ResourceObjectType type, diff --git a/chromium/ppapi/shared_impl/ppb_instance_shared.cc b/chromium/ppapi/shared_impl/ppb_instance_shared.cc index 49b865a47e5..53f4fb7cd5d 100644 --- a/chromium/ppapi/shared_impl/ppb_instance_shared.cc +++ b/chromium/ppapi/shared_impl/ppb_instance_shared.cc @@ -6,8 +6,8 @@ #include <string> -#include "base/debug/trace_event.h" #include "base/threading/platform_thread.h" +#include "base/trace_event/trace_event.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/ppb_input_event.h" #include "ppapi/shared_impl/ppapi_globals.h" diff --git a/chromium/ppapi/shared_impl/ppb_instance_shared.h b/chromium/ppapi/shared_impl/ppb_instance_shared.h index 717adedd9e3..bcd284e4761 100644 --- a/chromium/ppapi/shared_impl/ppb_instance_shared.h +++ b/chromium/ppapi/shared_impl/ppb_instance_shared.h @@ -15,16 +15,14 @@ namespace ppapi { class PPAPI_SHARED_EXPORT PPB_Instance_Shared : NON_EXPORTED_BASE(public thunk::PPB_Instance_API) { public: - virtual ~PPB_Instance_Shared(); + ~PPB_Instance_Shared() override; // Implementation of some shared PPB_Instance_FunctionAPI functions. - virtual void Log(PP_Instance instance, - PP_LogLevel log_level, - PP_Var value) override; - virtual void LogWithSource(PP_Instance instance, - PP_LogLevel log_level, - PP_Var source, - PP_Var value) override; + void Log(PP_Instance instance, PP_LogLevel log_level, PP_Var value) override; + void LogWithSource(PP_Instance instance, + PP_LogLevel log_level, + PP_Var source, + PP_Var value) override; // Error checks the given resquest to Request[Filtering]InputEvents. Returns // PP_OK if the given classes are all valid, PP_ERROR_NOTSUPPORTED if not. diff --git a/chromium/ppapi/shared_impl/ppb_trace_event_impl.cc b/chromium/ppapi/shared_impl/ppb_trace_event_impl.cc index ce1afb94b51..1fc2bc3a3d6 100644 --- a/chromium/ppapi/shared_impl/ppb_trace_event_impl.cc +++ b/chromium/ppapi/shared_impl/ppb_trace_event_impl.cc @@ -5,8 +5,8 @@ #include "ppapi/shared_impl/ppb_trace_event_impl.h" #include "base/basictypes.h" -#include "base/debug/trace_event.h" #include "base/threading/platform_thread.h" +#include "base/trace_event/trace_event.h" #include "ppapi/thunk/thunk.h" namespace ppapi { @@ -24,7 +24,7 @@ void* TraceEventImpl::GetCategoryEnabled(const char* category_name) { // return a pointer type to the caller without some const_cast. The pointer // type the tracing system works with is normally unsigned char*. return const_cast<void*>(static_cast<const void*>( - base::debug::TraceLog::GetInstance()->GetCategoryGroupEnabled( + base::trace_event::TraceLog::GetInstance()->GetCategoryGroupEnabled( category_name))); } @@ -39,9 +39,10 @@ void TraceEventImpl::AddTraceEvent(int8_t phase, const uint64_t arg_values[], uint8_t flags) { - COMPILE_ASSERT(sizeof(unsigned long long) == sizeof(uint64_t), msg); + static_assert(sizeof(unsigned long long) == sizeof(uint64_t), + "unexpected data type sizes"); - base::debug::TraceLog::GetInstance()->AddTraceEvent( + base::trace_event::TraceLog::GetInstance()->AddTraceEvent( phase, static_cast<const unsigned char*>(category_enabled), name, @@ -71,16 +72,17 @@ void TraceEventImpl::AddTraceEventWithThreadIdAndTimestamp( const uint8_t arg_types[], const uint64_t arg_values[], uint8_t flags) { - base::debug::TraceLog::GetInstance()->AddTraceEventWithThreadIdAndTimestamp( - phase, - static_cast<const unsigned char*>(category_enabled), - name, - id, - thread_id, - base::TimeTicks::FromInternalValue(timestamp), - num_args, - arg_names, - arg_types, + base::trace_event::TraceLog::GetInstance() + ->AddTraceEventWithThreadIdAndTimestamp( + phase, + static_cast<const unsigned char*>(category_enabled), + name, + id, + thread_id, + base::TimeTicks::FromInternalValue(timestamp), + num_args, + arg_names, + arg_types, // This cast is necessary for LP64 systems, where uint64_t is defined as // an unsigned long int, but trace_event internals are hermetic and // accepts an |unsigned long long*|. The pointer types are compatible but diff --git a/chromium/ppapi/shared_impl/ppb_video_decoder_shared.h b/chromium/ppapi/shared_impl/ppb_video_decoder_shared.h index e08493e9976..23c860896ff 100644 --- a/chromium/ppapi/shared_impl/ppb_video_decoder_shared.h +++ b/chromium/ppapi/shared_impl/ppb_video_decoder_shared.h @@ -31,14 +31,13 @@ class PPAPI_SHARED_EXPORT PPB_VideoDecoder_Shared public: explicit PPB_VideoDecoder_Shared(PP_Instance instance); explicit PPB_VideoDecoder_Shared(const HostResource& host_resource); - virtual ~PPB_VideoDecoder_Shared(); + ~PPB_VideoDecoder_Shared() override; // Resource overrides. - virtual thunk::PPB_VideoDecoder_Dev_API* AsPPB_VideoDecoder_Dev_API() - override; + thunk::PPB_VideoDecoder_Dev_API* AsPPB_VideoDecoder_Dev_API() override; // PPB_VideoDecoder_Dev_API implementation. - virtual void Destroy() override; + void Destroy() override; protected: bool SetFlushCallback(scoped_refptr<TrackedCallback> callback); diff --git a/chromium/ppapi/shared_impl/ppb_view_shared.h b/chromium/ppapi/shared_impl/ppb_view_shared.h index 32bfb358252..a0e37945f44 100644 --- a/chromium/ppapi/shared_impl/ppb_view_shared.h +++ b/chromium/ppapi/shared_impl/ppb_view_shared.h @@ -36,21 +36,21 @@ class PPAPI_SHARED_EXPORT PPB_View_Shared : public Resource, PPB_View_Shared(ResourceObjectType type, PP_Instance instance, const ViewData& data); - virtual ~PPB_View_Shared(); + ~PPB_View_Shared() override; // Resource overrides. - virtual thunk::PPB_View_API* AsPPB_View_API() override; + thunk::PPB_View_API* AsPPB_View_API() override; // PPB_View_API implementation. - virtual const ViewData& GetData() const override; - virtual PP_Bool GetRect(PP_Rect* viewport) const override; - virtual PP_Bool IsFullscreen() const override; - virtual PP_Bool IsVisible() const override; - virtual PP_Bool IsPageVisible() const override; - virtual PP_Bool GetClipRect(PP_Rect* clip) const override; - virtual float GetDeviceScale() const override; - virtual float GetCSSScale() const override; - virtual PP_Bool GetScrollOffset(PP_Point* scroll_offset) const override; + const ViewData& GetData() const override; + PP_Bool GetRect(PP_Rect* viewport) const override; + PP_Bool IsFullscreen() const override; + PP_Bool IsVisible() const override; + PP_Bool IsPageVisible() const override; + PP_Bool GetClipRect(PP_Rect* clip) const override; + float GetDeviceScale() const override; + float GetCSSScale() const override; + PP_Bool GetScrollOffset(PP_Point* scroll_offset) const override; private: ViewData data_; diff --git a/chromium/ppapi/shared_impl/private/net_address_private_impl.cc b/chromium/ppapi/shared_impl/private/net_address_private_impl.cc index 19dae3c8b18..7515592c006 100644 --- a/chromium/ppapi/shared_impl/private/net_address_private_impl.cc +++ b/chromium/ppapi/shared_impl/private/net_address_private_impl.cc @@ -92,14 +92,14 @@ struct NetAddress { // that the alignment is the same on both sides of the NaCl proxy, which is // important because we serialize and deserialize PP_NetAddress_Private by // simply copying the raw bytes. -COMPILE_ASSERT(sizeof(NetAddress) == 28, - NetAddress_different_for_compiler); +static_assert(sizeof(NetAddress) == 28, + "NetAddress different for compiler"); // Make sure the storage in |PP_NetAddress_Private| is big enough. (Do it here // since the data is opaque elsewhere.) -COMPILE_ASSERT(sizeof(reinterpret_cast<PP_NetAddress_Private*>(0)->data) >= - sizeof(NetAddress), - PP_NetAddress_Private_data_too_small); +static_assert(sizeof(reinterpret_cast<PP_NetAddress_Private*>(0)->data) >= + sizeof(NetAddress), + "PP_NetAddress_Private data too small"); size_t GetAddressSize(const NetAddress* net_addr) { return net_addr->is_ipv6 ? kIPv6AddressSize : kIPv4AddressSize; @@ -451,7 +451,7 @@ bool NetAddressPrivateImpl::SockaddrToNetAddress( // static bool NetAddressPrivateImpl::IPEndPointToNetAddress( const std::vector<unsigned char>& address, - int port, + uint16 port, PP_NetAddress_Private* addr) { if (!addr) return false; @@ -461,14 +461,14 @@ bool NetAddressPrivateImpl::IPEndPointToNetAddress( case kIPv4AddressSize: { net_addr->is_valid = true; net_addr->is_ipv6 = false; - net_addr->port = static_cast<uint16_t>(port); + net_addr->port = port; std::copy(address.begin(), address.end(), net_addr->address); break; } case kIPv6AddressSize: { net_addr->is_valid = true; net_addr->is_ipv6 = true; - net_addr->port = static_cast<uint16_t>(port); + net_addr->port = port; std::copy(address.begin(), address.end(), net_addr->address); break; } @@ -484,7 +484,7 @@ bool NetAddressPrivateImpl::IPEndPointToNetAddress( bool NetAddressPrivateImpl::NetAddressToIPEndPoint( const PP_NetAddress_Private& addr, std::vector<unsigned char>* address, - int* port) { + uint16* port) { if (!address || !port) return false; @@ -518,6 +518,12 @@ std::string NetAddressPrivateImpl::DescribeNetAddress( } // static +void NetAddressPrivateImpl::GetAnyAddress(PP_Bool is_ipv6, + PP_NetAddress_Private* addr) { + ppapi::GetAnyAddress(is_ipv6, addr); +} + +// static void NetAddressPrivateImpl::CreateNetAddressPrivateFromIPv4Address( const PP_NetAddress_IPv4& ipv4_addr, PP_NetAddress_Private* addr) { @@ -556,8 +562,8 @@ bool NetAddressPrivateImpl::DescribeNetAddressPrivateAsIPv4Address( ipv4_addr->port = ConvertToNetEndian16(net_addr->port); - COMPILE_ASSERT(sizeof(ipv4_addr->addr) == kIPv4AddressSize, - mismatched_IPv4_address_size); + static_assert(sizeof(ipv4_addr->addr) == kIPv4AddressSize, + "mismatched IPv4 address size"); memcpy(ipv4_addr->addr, net_addr->address, kIPv4AddressSize); return true; @@ -576,8 +582,8 @@ bool NetAddressPrivateImpl::DescribeNetAddressPrivateAsIPv6Address( ipv6_addr->port = ConvertToNetEndian16(net_addr->port); - COMPILE_ASSERT(sizeof(ipv6_addr->addr) == kIPv6AddressSize, - mismatched_IPv6_address_size); + static_assert(sizeof(ipv6_addr->addr) == kIPv6AddressSize, + "mismatched IPv6 address size"); memcpy(ipv6_addr->addr, net_addr->address, kIPv6AddressSize); return true; diff --git a/chromium/ppapi/shared_impl/private/net_address_private_impl.h b/chromium/ppapi/shared_impl/private/net_address_private_impl.h index a8ba0592956..814633b4dff 100644 --- a/chromium/ppapi/shared_impl/private/net_address_private_impl.h +++ b/chromium/ppapi/shared_impl/private/net_address_private_impl.h @@ -27,16 +27,18 @@ class PPAPI_SHARED_EXPORT NetAddressPrivateImpl { PP_NetAddress_Private* net_addr); static bool IPEndPointToNetAddress(const std::vector<unsigned char>& address, - int port, + uint16 port, PP_NetAddress_Private* net_addr); static bool NetAddressToIPEndPoint(const PP_NetAddress_Private& net_addr, std::vector<unsigned char>* address, - int* port); + uint16* port); static std::string DescribeNetAddress(const PP_NetAddress_Private& addr, bool include_port); + static void GetAnyAddress(PP_Bool is_ipv6, PP_NetAddress_Private* addr); + // Conversion methods to make PPB_NetAddress resource work with // PP_NetAddress_Private. // TODO(yzshen): Remove them once PPB_NetAddress resource doesn't use diff --git a/chromium/ppapi/shared_impl/private/ppb_x509_certificate_private_shared.h b/chromium/ppapi/shared_impl/private/ppb_x509_certificate_private_shared.h index 727f5522c5b..1eaedbb3155 100644 --- a/chromium/ppapi/shared_impl/private/ppb_x509_certificate_private_shared.h +++ b/chromium/ppapi/shared_impl/private/ppb_x509_certificate_private_shared.h @@ -49,15 +49,14 @@ class PPAPI_SHARED_EXPORT PPB_X509Certificate_Private_Shared PPB_X509Certificate_Private_Shared(ResourceObjectType type, PP_Instance instance, const PPB_X509Certificate_Fields& fields); - virtual ~PPB_X509Certificate_Private_Shared(); + ~PPB_X509Certificate_Private_Shared() override; // Resource overrides. - virtual PPB_X509Certificate_Private_API* - AsPPB_X509Certificate_Private_API() override; + PPB_X509Certificate_Private_API* AsPPB_X509Certificate_Private_API() override; // PPB_X509Certificate_Private_API implementation. - virtual PP_Bool Initialize(const char* bytes, uint32_t length) override; - virtual PP_Var GetField(PP_X509Certificate_Private_Field field) override; + PP_Bool Initialize(const char* bytes, uint32_t length) override; + PP_Var GetField(PP_X509Certificate_Private_Field field) override; protected: virtual bool ParseDER(const std::vector<char>& der, diff --git a/chromium/ppapi/shared_impl/proxy_lock.cc b/chromium/ppapi/shared_impl/proxy_lock.cc index 6598379ca8b..cd302f9dcc6 100644 --- a/chromium/ppapi/shared_impl/proxy_lock.cc +++ b/chromium/ppapi/shared_impl/proxy_lock.cc @@ -79,15 +79,13 @@ void ProxyLock::DisableLocking() { g_disable_locking = true; } -// static -void ProxyLock::DisableLockingOnThreadForTest() { +ProxyLock::LockingDisablerForTest::LockingDisablerForTest() { // Note, we don't DCHECK that this flag isn't already set, because multiple // unit tests may run in succession and all set it. g_disable_locking_for_thread.Get().Set(true); } -// static -void ProxyLock::EnableLockingOnThreadForTest() { +ProxyLock::LockingDisablerForTest::~LockingDisablerForTest() { g_disable_locking_for_thread.Get().Set(false); } diff --git a/chromium/ppapi/shared_impl/proxy_lock.h b/chromium/ppapi/shared_impl/proxy_lock.h index 23afc0e5506..66d4a739047 100644 --- a/chromium/ppapi/shared_impl/proxy_lock.h +++ b/chromium/ppapi/shared_impl/proxy_lock.h @@ -8,6 +8,7 @@ #include "base/basictypes.h" #include "base/bind.h" #include "base/callback.h" +#include "base/memory/scoped_ptr.h" #include "base/threading/thread_checker.h" #include "ppapi/shared_impl/ppapi_shared_export.h" @@ -59,12 +60,11 @@ class PPAPI_SHARED_EXPORT ProxyLock { // We have some unit tests where one thread pretends to be the host and one // pretends to be the plugin. This allows the lock to do nothing on only one // thread to support these tests. See TwoWayTest for more information. - static void DisableLockingOnThreadForTest(); - - // Enables locking on the current thread. Although locking is enabled by - // default, unit tests that rely on the lock being enabled should *still* - // call this, since a previous test may have disabled locking. - static void EnableLockingOnThreadForTest(); + class PPAPI_SHARED_EXPORT LockingDisablerForTest { + public: + LockingDisablerForTest(); + ~LockingDisablerForTest(); + }; private: friend class content::HostGlobals; @@ -170,63 +170,63 @@ namespace internal { template <typename RunType> class RunWhileLockedHelper; +// A helper class to ensure that a callback is always run and destroyed while +// the ProxyLock is held. A callback that is bound with ref-counted Var or +// Resource parameters may invoke methods on the VarTracker or the +// ResourceTracker in its destructor, and these require the ProxyLock. template <> class RunWhileLockedHelper<void()> { public: typedef base::Callback<void()> CallbackType; explicit RunWhileLockedHelper(const CallbackType& callback) : callback_(new CallbackType(callback)) { - // Copying |callback| may adjust reference counts for bound Vars or - // Resources; we should have the lock already. - ProxyLock::AssertAcquired(); // CallWhileLocked and destruction might happen on a different thread from // creation. thread_checker_.DetachFromThread(); } - void CallWhileLocked() { + static void CallWhileLocked(scoped_ptr<RunWhileLockedHelper> ptr) { // Bind thread_checker_ to this thread so we can check in the destructor. - DCHECK(thread_checker_.CalledOnValidThread()); + // *If* the callback gets invoked, it's important that RunWhileLockedHelper + // is destroyed on the same thread (see the comments in the destructor). + DCHECK(ptr->thread_checker_.CalledOnValidThread()); ProxyAutoLock lock; { // Use a scope and local Callback to ensure that the callback is cleared // before the lock is released, even in the unlikely event that Run() // throws an exception. - scoped_ptr<CallbackType> temp_callback(callback_.Pass()); + scoped_ptr<CallbackType> temp_callback(ptr->callback_.Pass()); temp_callback->Run(); } } ~RunWhileLockedHelper() { // Check that the Callback is destroyed on the same thread as where - // CallWhileLocked happened (if CallWhileLocked happened). + // CallWhileLocked happened if CallWhileLocked happened. If we weren't + // invoked, thread_checked_ isn't bound to a thread. DCHECK(thread_checker_.CalledOnValidThread()); // Here we read callback_ without the lock. This is why the callback must be - // destroyed on the same thread where it runs. There are 2 cases where - // callback_ will be NULL: - // 1) This is the original RunWhileLockedHelper that RunWhileLocked - // created. When it was copied somewhere else (e.g., to a MessageLoop - // queue), callback_ was passed to the new copy, and the original - // RunWhileLockedHelper's callback_ was set to NULL (since scoped_ptrs - // only ever have 1 owner). In this case, we don't want to acquire the - // lock, because we already have it. - // 2) callback_ has already been run via CallWhileLocked. In this case, - // there's no need to acquire the lock, because we don't touch any - // shared data. + // destroyed on the same thread where it runs. Note that callback_ will be + // NULL if it has already been run via CallWhileLocked. In this case, + // there's no need to acquire the lock, because we don't touch any shared + // data. if (callback_) { - // If the callback was not run, we still need to have the lock when we - // destroy the callback in case it had a Resource bound to it. This - // ensures that the Resource's destructor is invoked only with the lock - // held. + // If the callback was *not* run, we're in a case where the task queue + // we got pushed to has been destroyed (e.g., the thread is shut down and + // its MessageLoop destroyed before all tasks have run.) // - // Also: Resource and Var inherit RefCounted (not ThreadSafeRefCounted), - // and these callbacks need to be usable on any thread. So we need to lock - // when releasing the callback to avoid ref counting races. + // We still need to have the lock when we destroy the callback: + // - Because Resource and Var inherit RefCounted (not + // ThreadSafeRefCounted). + // - Because if the callback owns the last ref to a Resource, it will + // call the ResourceTracker and also the Resource's destructor, which + // both require the ProxyLock. ProxyAutoLock lock; callback_.reset(); } } private: + DISALLOW_COPY_AND_ASSIGN(RunWhileLockedHelper); scoped_ptr<CallbackType> callback_; // Used to ensure that the Callback is run and deleted on the same thread. @@ -239,14 +239,13 @@ class RunWhileLockedHelper<void(P1)> { typedef base::Callback<void(P1)> CallbackType; explicit RunWhileLockedHelper(const CallbackType& callback) : callback_(new CallbackType(callback)) { - ProxyLock::AssertAcquired(); thread_checker_.DetachFromThread(); } - void CallWhileLocked(P1 p1) { - DCHECK(thread_checker_.CalledOnValidThread()); + static void CallWhileLocked(scoped_ptr<RunWhileLockedHelper> ptr, P1 p1) { + DCHECK(ptr->thread_checker_.CalledOnValidThread()); ProxyAutoLock lock; { - scoped_ptr<CallbackType> temp_callback(callback_.Pass()); + scoped_ptr<CallbackType> temp_callback(ptr->callback_.Pass()); temp_callback->Run(p1); } } @@ -259,6 +258,7 @@ class RunWhileLockedHelper<void(P1)> { } private: + DISALLOW_COPY_AND_ASSIGN(RunWhileLockedHelper); scoped_ptr<CallbackType> callback_; base::ThreadChecker thread_checker_; }; @@ -269,14 +269,14 @@ class RunWhileLockedHelper<void(P1, P2)> { typedef base::Callback<void(P1, P2)> CallbackType; explicit RunWhileLockedHelper(const CallbackType& callback) : callback_(new CallbackType(callback)) { - ProxyLock::AssertAcquired(); thread_checker_.DetachFromThread(); } - void CallWhileLocked(P1 p1, P2 p2) { - DCHECK(thread_checker_.CalledOnValidThread()); + static void CallWhileLocked( + scoped_ptr<RunWhileLockedHelper> ptr, P1 p1, P2 p2) { + DCHECK(ptr->thread_checker_.CalledOnValidThread()); ProxyAutoLock lock; { - scoped_ptr<CallbackType> temp_callback(callback_.Pass()); + scoped_ptr<CallbackType> temp_callback(ptr->callback_.Pass()); temp_callback->Run(p1, p2); } } @@ -289,6 +289,7 @@ class RunWhileLockedHelper<void(P1, P2)> { } private: + DISALLOW_COPY_AND_ASSIGN(RunWhileLockedHelper); scoped_ptr<CallbackType> callback_; base::ThreadChecker thread_checker_; }; @@ -299,14 +300,14 @@ class RunWhileLockedHelper<void(P1, P2, P3)> { typedef base::Callback<void(P1, P2, P3)> CallbackType; explicit RunWhileLockedHelper(const CallbackType& callback) : callback_(new CallbackType(callback)) { - ProxyLock::AssertAcquired(); thread_checker_.DetachFromThread(); } - void CallWhileLocked(P1 p1, P2 p2, P3 p3) { - DCHECK(thread_checker_.CalledOnValidThread()); + static void CallWhileLocked( + scoped_ptr<RunWhileLockedHelper> ptr, P1 p1, P2 p2, P3 p3) { + DCHECK(ptr->thread_checker_.CalledOnValidThread()); ProxyAutoLock lock; { - scoped_ptr<CallbackType> temp_callback(callback_.Pass()); + scoped_ptr<CallbackType> temp_callback(ptr->callback_.Pass()); temp_callback->Run(p1, p2, p3); } } @@ -319,6 +320,7 @@ class RunWhileLockedHelper<void(P1, P2, P3)> { } private: + DISALLOW_COPY_AND_ASSIGN(RunWhileLockedHelper); scoped_ptr<CallbackType> callback_; base::ThreadChecker thread_checker_; }; @@ -356,11 +358,26 @@ class RunWhileLockedHelper<void(P1, P2, P3)> { template <class FunctionType> inline base::Callback<FunctionType> RunWhileLocked( const base::Callback<FunctionType>& callback) { - internal::RunWhileLockedHelper<FunctionType>* helper = - new internal::RunWhileLockedHelper<FunctionType>(callback); + // NOTE: the reason we use "scoped_ptr" here instead of letting the callback + // own it via base::Owned is kind of subtle. Imagine for the moment that we + // call RunWhileLocked without the ProxyLock: + // { + // base::Callback<void ()> local_callback = base::Bind(&Foo); + // some_task_runner.PostTask(FROM_HERE, RunWhileLocked(local_callback)); + // } + // In this case, since we don't have a lock synchronizing us, it's possible + // for the callback to run on the other thread before we return and destroy + // |local_callback|. The important thing here is that even though the other + // thread gets a copy of the callback, the internal "BindState" of the + // callback is refcounted and shared between all copies of the callback. So + // in that case, if we used base::Owned, we might delete RunWhileLockedHelper + // on this thread, which will violate the RunWhileLockedHelper's assumption + // that it is destroyed on the same thread where it is run. + scoped_ptr<internal::RunWhileLockedHelper<FunctionType>> helper( + new internal::RunWhileLockedHelper<FunctionType>(callback)); return base::Bind( &internal::RunWhileLockedHelper<FunctionType>::CallWhileLocked, - base::Owned(helper)); + base::Passed(helper.Pass())); } } // namespace ppapi diff --git a/chromium/ppapi/shared_impl/resource.h b/chromium/ppapi/shared_impl/resource.h index fdcf4fc6401..21c62de2201 100644 --- a/chromium/ppapi/shared_impl/resource.h +++ b/chromium/ppapi/shared_impl/resource.h @@ -29,13 +29,14 @@ F(PPB_BrowserFont_Singleton_API) \ F(PPB_BrowserFont_Trusted_API) \ F(PPB_Buffer_API) \ + F(PPB_CameraCapabilities_API) \ + F(PPB_CameraDevice_API) \ F(PPB_Compositor_API) \ F(PPB_CompositorLayer_API) \ F(PPB_DeviceRef_API) \ F(PPB_Ext_CrxFileSystem_Private_API) \ F(PPB_FileChooser_API) \ F(PPB_FileIO_API) \ - F(PPB_FileMapping_API) \ F(PPB_FileRef_API) \ F(PPB_FileSystem_API) \ F(PPB_Find_API) \ @@ -67,7 +68,6 @@ F(PPB_PlatformVerification_API) \ F(PPB_Printing_API) \ F(PPB_Scrollbar_API) \ - F(PPB_Talk_Private_API) \ F(PPB_TrueTypeFont_API) \ F(PPB_TrueTypeFont_Singleton_API) \ F(PPB_TCPServerSocket_Private_API) \ @@ -83,6 +83,7 @@ F(PPB_VideoDecoder_API) \ F(PPB_VideoDecoder_Dev_API) \ F(PPB_VideoDestination_Private_API) \ + F(PPB_VideoEncoder_API) \ F(PPB_VideoFrame_API) \ F(PPB_VideoLayer_API) \ F(PPB_VideoSource_Private_API) \ diff --git a/chromium/ppapi/shared_impl/resource_tracker.cc b/chromium/ppapi/shared_impl/resource_tracker.cc index 9b151846f83..208212c95dc 100644 --- a/chromium/ppapi/shared_impl/resource_tracker.cc +++ b/chromium/ppapi/shared_impl/resource_tracker.cc @@ -89,14 +89,6 @@ void ResourceTracker::ReleaseResource(PP_Resource res) { } } -void ResourceTracker::ReleaseResourceSoon(PP_Resource res) { - base::MessageLoop::current()->PostNonNestableTask( - FROM_HERE, - RunWhileLocked(base::Bind(&ResourceTracker::ReleaseResource, - weak_ptr_factory_.GetWeakPtr(), - res))); -} - void ResourceTracker::DidCreateInstance(PP_Instance instance) { CheckThreadingPreconditions(); // Due to the infrastructure of some tests, the instance is registered diff --git a/chromium/ppapi/shared_impl/resource_tracker.h b/chromium/ppapi/shared_impl/resource_tracker.h index 6feeea7692b..f22f9482922 100644 --- a/chromium/ppapi/shared_impl/resource_tracker.h +++ b/chromium/ppapi/shared_impl/resource_tracker.h @@ -46,9 +46,6 @@ class PPAPI_SHARED_EXPORT ResourceTracker { // ResourceHost. void ReleaseResource(PP_Resource res); - // Releases a reference on the given resource once the message loop returns. - void ReleaseResourceSoon(PP_Resource res); - // Notifies the tracker that a new instance has been created. This must be // called before creating any resources associated with the instance. void DidCreateInstance(PP_Instance instance); diff --git a/chromium/ppapi/shared_impl/resource_tracker_unittest.cc b/chromium/ppapi/shared_impl/resource_tracker_unittest.cc index 31c61b3f412..a8fac3b139f 100644 --- a/chromium/ppapi/shared_impl/resource_tracker_unittest.cc +++ b/chromium/ppapi/shared_impl/resource_tracker_unittest.cc @@ -23,12 +23,12 @@ class MyMockResource : public Resource { MyMockResource(PP_Instance instance) : Resource(OBJECT_IS_IMPL, instance) { mock_resource_alive_count++; } - virtual ~MyMockResource() { mock_resource_alive_count--; } + ~MyMockResource() override { mock_resource_alive_count--; } - virtual void LastPluginRefWasDeleted() override { + void LastPluginRefWasDeleted() override { last_plugin_ref_was_deleted_count++; } - virtual void InstanceWasDeleted() override { instance_was_deleted_count++; } + void InstanceWasDeleted() override { instance_was_deleted_count++; } }; } // namespace @@ -38,12 +38,12 @@ class ResourceTrackerTest : public testing::Test { ResourceTrackerTest() {} // Test implementation. - virtual void SetUp() override { + void SetUp() override { ASSERT_EQ(0, mock_resource_alive_count); last_plugin_ref_was_deleted_count = 0; instance_was_deleted_count = 0; } - virtual void TearDown() override {} + void TearDown() override {} ResourceTracker& resource_tracker() { return *globals_.GetResourceTracker(); } diff --git a/chromium/ppapi/shared_impl/resource_var.h b/chromium/ppapi/shared_impl/resource_var.h index 121859ae076..0696d57e13f 100644 --- a/chromium/ppapi/shared_impl/resource_var.h +++ b/chromium/ppapi/shared_impl/resource_var.h @@ -41,8 +41,8 @@ class PPAPI_SHARED_EXPORT ResourceVar : public Var { virtual bool IsPending() const = 0; // Var override. - virtual ResourceVar* AsResourceVar() override; - virtual PP_VarType GetType() const override; + ResourceVar* AsResourceVar() override; + PP_VarType GetType() const override; // Helper function that converts a PP_Var to a ResourceVar. This will // return NULL if the PP_Var is not of Resource type. @@ -51,7 +51,7 @@ class PPAPI_SHARED_EXPORT ResourceVar : public Var { protected: ResourceVar(); - virtual ~ResourceVar(); + ~ResourceVar() override; private: DISALLOW_COPY_AND_ASSIGN(ResourceVar); diff --git a/chromium/ppapi/shared_impl/singleton_resource_id.h b/chromium/ppapi/shared_impl/singleton_resource_id.h index 4d34fd638bb..0d21ec7e8a6 100644 --- a/chromium/ppapi/shared_impl/singleton_resource_id.h +++ b/chromium/ppapi/shared_impl/singleton_resource_id.h @@ -15,7 +15,6 @@ enum SingletonResourceID { // resource model. BROKER_SINGLETON_ID, BROWSER_FONT_SINGLETON_ID, - FILE_MAPPING_SINGLETON_ID, FLASH_CLIPBOARD_SINGLETON_ID, FLASH_FILE_SINGLETON_ID, FLASH_FULLSCREEN_SINGLETON_ID, diff --git a/chromium/ppapi/shared_impl/test_globals.h b/chromium/ppapi/shared_impl/test_globals.h index a01eeffb8a3..fba9a57250a 100644 --- a/chromium/ppapi/shared_impl/test_globals.h +++ b/chromium/ppapi/shared_impl/test_globals.h @@ -17,35 +17,35 @@ namespace ppapi { class TestVarTracker : public VarTracker { public: TestVarTracker() : VarTracker(THREAD_SAFE) {} - virtual ~TestVarTracker() {} - virtual PP_Var MakeResourcePPVarFromMessage( + ~TestVarTracker() override {} + PP_Var MakeResourcePPVarFromMessage( PP_Instance instance, const IPC::Message& creation_message, int pending_renderer_id, int pending_browser_id) override { return PP_MakeNull(); } - virtual ResourceVar* MakeResourceVar(PP_Resource pp_resource) override { + ResourceVar* MakeResourceVar(PP_Resource pp_resource) override { return NULL; } - virtual ArrayBufferVar* CreateArrayBuffer(uint32 size_in_bytes) override { + ArrayBufferVar* CreateArrayBuffer(uint32 size_in_bytes) override { return NULL; } - virtual ArrayBufferVar* CreateShmArrayBuffer(uint32 size_in_bytes, - base::SharedMemoryHandle handle) - override { + ArrayBufferVar* CreateShmArrayBuffer( + uint32 size_in_bytes, + base::SharedMemoryHandle handle) override { return NULL; } - virtual void DidDeleteInstance(PP_Instance instance) override {} - virtual int TrackSharedMemoryHandle(PP_Instance instance, - base::SharedMemoryHandle handle, - uint32 size_in_bytes) override { + void DidDeleteInstance(PP_Instance instance) override {} + int TrackSharedMemoryHandle(PP_Instance instance, + base::SharedMemoryHandle handle, + uint32 size_in_bytes) override { return -1; } - virtual bool StopTrackingSharedMemoryHandle(int id, - PP_Instance instance, - base::SharedMemoryHandle* handle, - uint32* size_in_bytes) override { + bool StopTrackingSharedMemoryHandle(int id, + PP_Instance instance, + base::SharedMemoryHandle* handle, + uint32* size_in_bytes) override { return false; } }; @@ -56,33 +56,31 @@ class TestGlobals : public PpapiGlobals { public: TestGlobals(); explicit TestGlobals(PpapiGlobals::PerThreadForTest); - virtual ~TestGlobals(); + ~TestGlobals() override; // PpapiGlobals implementation. - virtual ResourceTracker* GetResourceTracker() override; - virtual VarTracker* GetVarTracker() override; - virtual CallbackTracker* GetCallbackTrackerForInstance(PP_Instance instance) - override; - virtual thunk::PPB_Instance_API* GetInstanceAPI(PP_Instance instance) - override; - virtual thunk::ResourceCreationAPI* GetResourceCreationAPI( + ResourceTracker* GetResourceTracker() override; + VarTracker* GetVarTracker() override; + CallbackTracker* GetCallbackTrackerForInstance(PP_Instance instance) override; + thunk::PPB_Instance_API* GetInstanceAPI(PP_Instance instance) override; + thunk::ResourceCreationAPI* GetResourceCreationAPI( PP_Instance instance) override; - virtual PP_Module GetModuleForInstance(PP_Instance instance) override; - virtual std::string GetCmdLine() override; - virtual void PreCacheFontForFlash(const void* logfontw) override; - virtual void LogWithSource(PP_Instance instance, - PP_LogLevel level, - const std::string& source, - const std::string& value) override; - virtual void BroadcastLogWithSource(PP_Module module, - PP_LogLevel level, - const std::string& source, - const std::string& value) override; - virtual MessageLoopShared* GetCurrentMessageLoop() override; - virtual base::TaskRunner* GetFileTaskRunner() override; + PP_Module GetModuleForInstance(PP_Instance instance) override; + std::string GetCmdLine() override; + void PreCacheFontForFlash(const void* logfontw) override; + void LogWithSource(PP_Instance instance, + PP_LogLevel level, + const std::string& source, + const std::string& value) override; + void BroadcastLogWithSource(PP_Module module, + PP_LogLevel level, + const std::string& source, + const std::string& value) override; + MessageLoopShared* GetCurrentMessageLoop() override; + base::TaskRunner* GetFileTaskRunner() override; // PpapiGlobals overrides: - virtual bool IsHostGlobals() const override; + bool IsHostGlobals() const override; private: ResourceTracker resource_tracker_; diff --git a/chromium/ppapi/shared_impl/test_harness_utils.cc b/chromium/ppapi/shared_impl/test_harness_utils.cc deleted file mode 100644 index 93ba755c958..00000000000 --- a/chromium/ppapi/shared_impl/test_harness_utils.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2014 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/test_harness_utils.h" - -#include <string> -#include "base/macros.h" - -namespace ppapi { - -std::string StripTestPrefixes(const std::string& test_name) { - const char* const kTestPrefixes[] = { - "FAILS_", "FLAKY_", "DISABLED_", "SLOW_" }; - for (size_t i = 0; i < arraysize(kTestPrefixes); ++i) - if (test_name.find(kTestPrefixes[i]) == 0) - return test_name.substr(strlen(kTestPrefixes[i])); - return test_name; -} - -base::FilePath::StringType GetTestLibraryName() { -#if defined(OS_WIN) - return L"ppapi_tests.dll"; -#elif defined(OS_MACOSX) - return "ppapi_tests.plugin"; -#elif defined(OS_POSIX) - return "libppapi_tests.so"; -#endif -} - -} // namespace ppapi diff --git a/chromium/ppapi/shared_impl/test_harness_utils.h b/chromium/ppapi/shared_impl/test_harness_utils.h deleted file mode 100644 index 0098969cf8b..00000000000 --- a/chromium/ppapi/shared_impl/test_harness_utils.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2014 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_TESTS_TEST_HARNESS_UTILS_H_ -#define PPAPI_TESTS_TEST_HARNESS_UTILS_H_ - -#include <string> -#include "base/files/file_path.h" -#include "ppapi/shared_impl/ppapi_shared_export.h" - -// This file specifies utility functions used in Pepper testing in -// browser_tests and content_browsertests. - -namespace base { -class CommandLine; -} - -namespace ppapi { - -// Strips prefixes used to annotate tests from a test name. -std::string PPAPI_SHARED_EXPORT StripTestPrefixes(const std::string& test_name); - -// Returns a platform-specific filename relative to the chrome executable. -base::FilePath::StringType PPAPI_SHARED_EXPORT GetTestLibraryName(); - -} // namespace ppapi - -#endif // PPAPI_TESTS_TEST_HARNESS_UTILS_H_ diff --git a/chromium/ppapi/shared_impl/unittest_utils.cc b/chromium/ppapi/shared_impl/test_utils.cc index af904324187..6f85fce4911 100644 --- a/chromium/ppapi/shared_impl/unittest_utils.cc +++ b/chromium/ppapi/shared_impl/test_utils.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/unittest_utils.h" +#include "ppapi/shared_impl/test_utils.h" #include <cmath> @@ -209,4 +209,10 @@ bool TestEqual(const PP_Var& expected, return Equals(expected, actual, test_string_references, &visited_map); } +std::string StripTestPrefixes(const std::string& test_name) { + if (test_name.find("DISABLED_") == 0) + return test_name.substr(strlen("DISABLED_")); + return test_name; +} + } // namespace ppapi diff --git a/chromium/ppapi/shared_impl/unittest_utils.h b/chromium/ppapi/shared_impl/test_utils.h index a6fb296ea64..876b9349509 100644 --- a/chromium/ppapi/shared_impl/unittest_utils.h +++ b/chromium/ppapi/shared_impl/test_utils.h @@ -2,8 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef PPAPI_SHARED_IMPL_UNITTEST_UTILS_H_ -#define PPAPI_SHARED_IMPL_UNITTEST_UTILS_H_ +#ifndef PPAPI_SHARED_IMPL_TEST_UTILS_H_ +#define PPAPI_SHARED_IMPL_TEST_UTILS_H_ + +#include <string> #include "ppapi/c/pp_var.h" @@ -19,6 +21,8 @@ bool TestEqual(const PP_Var& expected, const PP_Var& actual, bool test_string_references); +std::string StripTestPrefixes(const std::string& test_name); + } // namespace ppapi -#endif // PPAPI_SHARED_IMPL_UNITTEST_UTILS_H_ +#endif // PPAPI_SHARED_IMPL_TEST_UTILS_H_ diff --git a/chromium/ppapi/shared_impl/thread_aware_callback_unittest.cc b/chromium/ppapi/shared_impl/thread_aware_callback_unittest.cc index 9e9189b0668..7081daae565 100644 --- a/chromium/ppapi/shared_impl/thread_aware_callback_unittest.cc +++ b/chromium/ppapi/shared_impl/thread_aware_callback_unittest.cc @@ -53,19 +53,19 @@ class ThreadAwareCallbackMultiThreadTest : public proxy::PluginProxyMultiThreadTest { public: ThreadAwareCallbackMultiThreadTest() : main_thread_callback_called_(false) {} - virtual ~ThreadAwareCallbackMultiThreadTest() { + ~ThreadAwareCallbackMultiThreadTest() override { CHECK(main_thread_callback_called_); } // proxy::PluginProxyMultiThreadTest implementation. - virtual void SetUpTestOnMainThread() override { + void SetUpTestOnMainThread() override { ProxyAutoLock auto_lock; main_thread_callback_.reset( ThreadAwareCallback<CallbackFunc>::Create(&MainThreadCallbackBody)); } - virtual void SetUpTestOnSecondaryThread() override { + void SetUpTestOnSecondaryThread() override { { ProxyAutoLock auto_lock; main_thread_callback_->RunOnTargetThread(this); @@ -100,17 +100,17 @@ class ThreadAwareCallbackMultiThreadTest class ThreadAwareCallbackAbortTest : public proxy::PluginProxyMultiThreadTest { public: ThreadAwareCallbackAbortTest() {} - virtual ~ThreadAwareCallbackAbortTest() {} + ~ThreadAwareCallbackAbortTest() override {} // proxy::PluginProxyMultiThreadTest implementation. - virtual void SetUpTestOnMainThread() override { + void SetUpTestOnMainThread() override { ProxyAutoLock auto_lock; main_thread_callback_.reset( ThreadAwareCallback<CallbackFunc>::Create(&MainThreadCallbackBody)); } - virtual void SetUpTestOnSecondaryThread() override { + void SetUpTestOnSecondaryThread() override { { ProxyAutoLock auto_lock; main_thread_message_loop_proxy_->PostTask( diff --git a/chromium/ppapi/shared_impl/tracked_callback.cc b/chromium/ppapi/shared_impl/tracked_callback.cc index 7ddfd39c13c..da0da429f73 100644 --- a/chromium/ppapi/shared_impl/tracked_callback.cc +++ b/chromium/ppapi/shared_impl/tracked_callback.cc @@ -30,6 +30,7 @@ bool IsMainThread() { int32_t RunCompletionTask(TrackedCallback::CompletionTask completion_task, int32_t result) { + ProxyLock::AssertAcquired(); int32_t task_result = completion_task.Run(result); if (result != PP_ERROR_ABORTED) result = task_result; @@ -64,6 +65,7 @@ TrackedCallback::TrackedCallback(Resource* resource, base::Lock* proxy_lock = ProxyLock::Get(); if (proxy_lock) { + ProxyLock::AssertAcquired(); // If the proxy_lock is valid, we're running out-of-process, and locking // is enabled. if (is_blocking()) { @@ -82,17 +84,26 @@ TrackedCallback::TrackedCallback(Resource* resource, TrackedCallback::~TrackedCallback() {} -void TrackedCallback::Abort() { Run(PP_ERROR_ABORTED); } +void TrackedCallback::Abort() { + Run(PP_ERROR_ABORTED); +} -void TrackedCallback::PostAbort() { PostRun(PP_ERROR_ABORTED); } +void TrackedCallback::PostAbort() { + PostRun(PP_ERROR_ABORTED); +} void TrackedCallback::Run(int32_t result) { + // Retain ourselves, since SignalBlockingCallback and MarkAsCompleted might + // otherwise cause |this| to be deleted. Do this before acquiring lock_ so + // that |this| is definitely valid at the time we release |lock_|. + scoped_refptr<TrackedCallback> thiz(this); + base::AutoLock acquire(lock_); // Only allow the callback to be run once. Note that this also covers the case // where the callback was previously Aborted because its associated Resource // went away. The callback may live on for a while because of a reference from // a Closure. But when the Closure runs, Run() quietly does nothing, and the // callback will go away when all referring Closures go away. - if (completed()) + if (completed_) return; if (result == PP_ERROR_ABORTED) aborted_ = true; @@ -101,87 +112,43 @@ void TrackedCallback::Run(int32_t result) { // PostAbort() being called. If we have been told to Abort, that always // trumps a result that was scheduled before, so we should make sure to pass // PP_ERROR_ABORTED. - if (aborted()) + if (aborted_) result = PP_ERROR_ABORTED; if (is_blocking()) { - // If the condition variable is invalid, there are two possibilities. One, - // we're running in-process, in which case the call should have come in on - // the main thread and we should have returned PP_ERROR_BLOCKS_MAIN_THREAD - // well before this. Otherwise, this callback was not created as a - // blocking callback. Either way, there's some internal error. - if (!operation_completed_condvar_.get()) { - NOTREACHED(); - return; - } - result_for_blocked_callback_ = result; - // Retain ourselves, since MarkAsCompleted will remove us from the - // tracker. Then MarkAsCompleted before waking up the blocked thread, - // which could potentially re-enter. - scoped_refptr<TrackedCallback> thiz(this); - MarkAsCompleted(); - // Wake up the blocked thread. See BlockUntilComplete for where the thread - // Wait()s. - operation_completed_condvar_->Signal(); + // This is a blocking callback; signal the condvar to wake up the thread. + SignalBlockingCallback(result); } else { // If there's a target_loop_, and we're not on the right thread, we need to // post to target_loop_. - if (target_loop_.get() && + if (target_loop_ && target_loop_.get() != PpapiGlobals::Get()->GetCurrentMessageLoop()) { - PostRun(result); + PostRunWithLock(result); return; } - - // Copy callback fields now, since |MarkAsCompleted()| may delete us. - PP_CompletionCallback callback = callback_; - CompletionTask completion_task = completion_task_; - completion_task_.Reset(); // Do this before running the callback in case of reentrancy from running - // the completion task. - MarkAsCompleted(); + // the completion callback. + MarkAsCompletedWithLock(); - if (!completion_task.is_null()) - result = RunCompletionTask(completion_task, result); + if (!completion_task_.is_null()) + result = RunCompletionTask(completion_task_, result); - // TODO(dmichael): Associate a message loop with the callback; if it's not - // the same as the current thread's loop, then post it to the right loop. - CallWhileUnlocked(PP_RunCompletionCallback, &callback, result); + { + base::AutoUnlock release(lock_); + // Call the callback without lock_ and without the ProxyLock. + CallWhileUnlocked(PP_RunCompletionCallback, &callback_, result); + } } } void TrackedCallback::PostRun(int32_t result) { - if (completed()) { - NOTREACHED(); - return; - } - if (result == PP_ERROR_ABORTED) - aborted_ = true; - // We might abort when there's already a scheduled callback, but callers - // should never try to PostRun more than once otherwise. - DCHECK(result == PP_ERROR_ABORTED || !is_scheduled_); - - if (is_blocking()) { - // We might not have a MessageLoop to post to, so we must call Run() - // directly. - Run(result); - } else { - base::Closure callback_closure( - RunWhileLocked(base::Bind(&TrackedCallback::Run, this, result))); - if (target_loop_.get()) { - target_loop_->PostClosure(FROM_HERE, callback_closure, 0); - } else { - // We must be running in-process and on the main thread (the Enter - // classes protect against having a null target_loop_ otherwise). - DCHECK(IsMainThread()); - DCHECK(PpapiGlobals::Get()->IsHostGlobals()); - base::MessageLoop::current()->PostTask(FROM_HERE, callback_closure); - } - } - is_scheduled_ = true; + base::AutoLock acquire(lock_); + PostRunWithLock(result); } void TrackedCallback::set_completion_task( const CompletionTask& completion_task) { + base::AutoLock acquire(lock_); DCHECK(completion_task_.is_null()); completion_task_ = completion_task; } @@ -189,34 +156,50 @@ void TrackedCallback::set_completion_task( // static bool TrackedCallback::IsPending( const scoped_refptr<TrackedCallback>& callback) { - if (!callback.get()) + if (!callback) return false; - if (callback->aborted()) + base::AutoLock acquire(callback->lock_); + if (callback->aborted_) return false; - return !callback->completed(); + return !callback->completed_; } // static bool TrackedCallback::IsScheduledToRun( const scoped_refptr<TrackedCallback>& callback) { - return IsPending(callback) && callback->is_scheduled_; + if (!callback) + return false; + base::AutoLock acquire(callback->lock_); + if (callback->aborted_) + return false; + return !callback->completed_ && callback->is_scheduled_; } int32_t TrackedCallback::BlockUntilComplete() { - // Note, we are already holding the proxy lock in all these methods, including - // this one (see ppapi/thunk/enter.cc for where it gets acquired). + // Note, we are already holding the proxy lock in this method and many others + // (see ppapi/thunk/enter.cc for where it gets acquired). + ProxyLock::AssertAcquired(); + base::AutoLock acquire(lock_); // It doesn't make sense to wait on a non-blocking callback. Furthermore, // BlockUntilComplete should never be called for in-process plugins, where // blocking callbacks are not supported. - CHECK(operation_completed_condvar_.get()); - if (!is_blocking() || !operation_completed_condvar_.get()) { - NOTREACHED(); - return PP_ERROR_FAILED; - } - - while (!completed()) + CHECK(is_blocking() && operation_completed_condvar_); + + // Protect us from being deleted to ensure operation_completed_condvar_ is + // available to wait on when we drop our lock. + scoped_refptr<TrackedCallback> thiz(this); + while (!completed_) { + // Unlock our lock temporarily; any thread that tries to signal us will need + // the lock. + lock_.Release(); operation_completed_condvar_->Wait(); + // Note that the condvar releases the ProxyLock during Wait and re-acquires + // the ProxyLock when it's signaled. We reacquire lock_ immediately after, + // preserving lock order. + ProxyLock::AssertAcquired(); + lock_.Acquire(); + } if (!completion_task_.is_null()) { result_for_blocked_callback_ = @@ -227,7 +210,13 @@ int32_t TrackedCallback::BlockUntilComplete() { } void TrackedCallback::MarkAsCompleted() { - DCHECK(!completed()); + base::AutoLock acquire(lock_); + MarkAsCompletedWithLock(); +} + +void TrackedCallback::MarkAsCompletedWithLock() { + lock_.AssertAcquired(); + DCHECK(!completed_); // We will be removed; maintain a reference to ensure we won't be deleted // until we're done. @@ -237,6 +226,62 @@ void TrackedCallback::MarkAsCompleted() { if (resource_id_) tracker_->Remove(thiz); tracker_ = NULL; + target_loop_ = NULL; +} + +void TrackedCallback::PostRunWithLock(int32_t result) { + lock_.AssertAcquired(); + if (completed_) { + NOTREACHED(); + return; + } + if (result == PP_ERROR_ABORTED) + aborted_ = true; + // We might abort when there's already a scheduled callback, but callers + // should never try to PostRun more than once otherwise. + DCHECK(result == PP_ERROR_ABORTED || !is_scheduled_); + + if (is_blocking()) { + // We might not have a MessageLoop to post to, so we must Signal + // directly. + SignalBlockingCallback(result); + } else { + base::Closure callback_closure( + RunWhileLocked(base::Bind(&TrackedCallback::Run, this, result))); + if (target_loop_) { + target_loop_->PostClosure(FROM_HERE, callback_closure, 0); + } else { + // We must be running in-process and on the main thread (the Enter + // classes protect against having a null target_loop_ otherwise). + DCHECK(IsMainThread()); + DCHECK(PpapiGlobals::Get()->IsHostGlobals()); + base::MessageLoop::current()->PostTask(FROM_HERE, callback_closure); + } + } + is_scheduled_ = true; +} + +void TrackedCallback::SignalBlockingCallback(int32_t result) { + lock_.AssertAcquired(); + DCHECK(is_blocking()); + if (!operation_completed_condvar_) { + // If the condition variable is invalid, there are two possibilities. One, + // we're running in-process, in which case the call should have come in on + // the main thread and we should have returned PP_ERROR_BLOCKS_MAIN_THREAD + // well before this. Otherwise, this callback was not created as a + // blocking callback. Either way, there's some internal error. + NOTREACHED(); + return; + } + result_for_blocked_callback_ = result; + // Retain ourselves, since MarkAsCompleted will remove us from the + // tracker. Then MarkAsCompleted before waking up the blocked thread, + // which could potentially re-enter. + scoped_refptr<TrackedCallback> thiz(this); + MarkAsCompletedWithLock(); + // Wake up the blocked thread. See BlockUntilComplete for where the thread + // Wait()s. + operation_completed_condvar_->Signal(); } } // namespace ppapi diff --git a/chromium/ppapi/shared_impl/tracked_callback.h b/chromium/ppapi/shared_impl/tracked_callback.h index 294c9b99b4e..8bf7a4b3373 100644 --- a/chromium/ppapi/shared_impl/tracked_callback.h +++ b/chromium/ppapi/shared_impl/tracked_callback.h @@ -13,6 +13,7 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/synchronization/condition_variable.h" +#include "base/synchronization/lock.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" @@ -52,13 +53,14 @@ class EnterBase; // the "owning" |CallbackTracker| will keep a reference until the callback is // completed. // -// Subclasses must do several things: -// - They must ensure that the callback is executed at most once (by looking at -// |completed()| before running the callback). -// - They must ensure that the callback is run abortively if it is marked as to -// be aborted (by looking at |aborted()| before running the callback). -// - They must call |MarkAsCompleted()| immediately before actually running the -// callback; see the comment for |MarkAsCompleted()| for a caveat. +// A note on threading: +// TrackedCallback is usable on any thread. It is *mostly* only used when +// ppapi::ProxyLock is held. However, it's necessary that Run() can be called +// without the ProxyLock. This is used to allow running the callback from +// the IO thread. In particular, blocking callbacks may not have a message loop +// to which we could post, so Run() must be able to signal the condition +// variable to wake up the thread that's waiting on the blocking callback, and +// Run() must be able to do this while not holding the ProxyLock. class PPAPI_SHARED_EXPORT TrackedCallback : public base::RefCountedThreadSafe<TrackedCallback> { public: @@ -80,6 +82,7 @@ class PPAPI_SHARED_EXPORT TrackedCallback // (as determined by target_loop_). If invoked on a different thread, the // callback will be scheduled to run later on target_loop_. void Run(int32_t result); + void AcquireProxyLockAndRun(int32_t result); // PostRun is like Run(), except it guarantees that the callback will be run // later. In particular, if you invoke PostRun on the same thread on which the // callback is targeted to run, it will *not* be run immediately. @@ -93,25 +96,26 @@ class PPAPI_SHARED_EXPORT TrackedCallback typedef base::Callback<int32_t(int32_t /* result */)> CompletionTask; // Sets a task that is run just before calling back into the plugin. This - // should only be called once. + // should only be called once. Note that the CompletionTask always runs while + // holding the ppapi::ProxyLock. void set_completion_task(const CompletionTask& completion_task); // Returns the ID of the resource which "owns" the callback, or 0 if the // callback is not associated with any resource. PP_Resource resource_id() const { return resource_id_; } - // Returns true if the callback was completed (possibly aborted). - bool completed() const { return completed_; } - - // Returns true if the callback was or should be aborted; this will be the - // case whenever |Abort()| or |PostAbort()| is called before a non-abortive - // completion. - bool aborted() const { return aborted_; } - // Returns true if this is a blocking callback. - bool is_blocking() { return !callback_.func; } + bool is_blocking() const { + // This is set on construction and never changes after that, so there is + // no need to lock. + return !callback_.func; + } - MessageLoopShared* target_loop() const { return target_loop_.get(); } + MessageLoopShared* target_loop() const { + // This is set on construction and never changes after that, so there is + // no need to lock. + return target_loop_.get(); + } // Determines if the given callback is pending. A callback is pending if it // has not completed and has not been aborted. When receiving a plugin call, @@ -127,21 +131,26 @@ class PPAPI_SHARED_EXPORT TrackedCallback // message loop. static bool IsScheduledToRun(const scoped_refptr<TrackedCallback>& callback); - protected: + private: bool is_required() { return (callback_.func && !(callback_.flags & PP_COMPLETIONCALLBACK_FLAG_OPTIONAL)); } - bool is_optional() { - return (callback_.func && - (callback_.flags & PP_COMPLETIONCALLBACK_FLAG_OPTIONAL)); - } bool has_null_target_loop() const { return target_loop_.get() == NULL; } - private: - // TrackedCallback and EnterBase manage dealing with how to invoke callbacks - // appropriately. Pepper interface implementations and proxies should not have - // to check the type of callback, block, or mark them complete explicitly. + // Same as PostRun(), but lock_ must already be held. + void PostRunWithLock(int32_t result); + + void SignalBlockingCallback(int32_t result); + + // TrackedCallback and EnterBase work together to provide appropriate behavior + // for callbacks. Pepper interface implementations and proxies should + // usually not have to check whether callbacks are required, optional, or + // blocking. Nor should interface and proxy implementations have to worry + // about blocking on a callback or marking them complete explicitly. + // + // (There are exceptions; e.g. FileIO checks is_blocking() in order to do + // some operations directly on the calling thread if possible.) friend class ppapi::thunk::subtle::EnterBase; // Block until the associated operation has completed. Returns the result. @@ -152,10 +161,13 @@ class PPAPI_SHARED_EXPORT TrackedCallback // be called once. Note that running this may result in this object being // deleted (so keep a reference if it'll still be needed). void MarkAsCompleted(); + void MarkAsCompletedWithLock(); // This class is ref counted. friend class base::RefCountedThreadSafe<TrackedCallback>; - virtual ~TrackedCallback(); + ~TrackedCallback(); + + mutable base::Lock lock_; // Flag used by |PostAbort()| and |PostRun()| to check that we don't schedule // the callback more than once. diff --git a/chromium/ppapi/shared_impl/tracked_callback_unittest.cc b/chromium/ppapi/shared_impl/tracked_callback_unittest.cc deleted file mode 100644 index 18199477ff6..00000000000 --- a/chromium/ppapi/shared_impl/tracked_callback_unittest.cc +++ /dev/null @@ -1,342 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/bind.h" -#include "base/memory/ref_counted.h" -#include "base/message_loop/message_loop.h" -#include "ppapi/c/pp_completion_callback.h" -#include "ppapi/c/pp_errors.h" -#include "ppapi/shared_impl/callback_tracker.h" -#include "ppapi/shared_impl/proxy_lock.h" -#include "ppapi/shared_impl/resource.h" -#include "ppapi/shared_impl/resource_tracker.h" -#include "ppapi/shared_impl/test_globals.h" -#include "ppapi/shared_impl/tracked_callback.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace ppapi { - -namespace { - -class TrackedCallbackTest : public testing::Test { - public: - TrackedCallbackTest() : pp_instance_(1234) {} - - PP_Instance pp_instance() const { return pp_instance_; } - - virtual void SetUp() override { - ProxyLock::EnableLockingOnThreadForTest(); - ProxyAutoLock lock; - globals_.GetResourceTracker()->DidCreateInstance(pp_instance_); - } - virtual void TearDown() override { - ProxyAutoLock lock; - globals_.GetResourceTracker()->DidDeleteInstance(pp_instance_); - } - - private: - base::MessageLoop message_loop_; - TestGlobals globals_; - PP_Instance pp_instance_; -}; - -// All valid results (PP_OK, PP_ERROR_...) are nonpositive. -const int32_t kInitializedResultValue = 1; -const int32_t kOverrideResultValue = 2; - -struct CallbackRunInfo { - CallbackRunInfo() - : run_count(0), - result(kInitializedResultValue), - completion_task_run_count(0), - completion_task_result(kInitializedResultValue) {} - unsigned run_count; - int32_t result; - unsigned completion_task_run_count; - int32_t completion_task_result; -}; - -void TestCallback(void* user_data, int32_t result) { - CallbackRunInfo* info = reinterpret_cast<CallbackRunInfo*>(user_data); - info->run_count++; - if (info->run_count == 1) - info->result = result; -} - -} // namespace - -// CallbackShutdownTest -------------------------------------------------------- - -namespace { - -class CallbackShutdownTest : public TrackedCallbackTest { - public: - CallbackShutdownTest() {} - - // Cases: - // (1) A callback which is run (so shouldn't be aborted on shutdown). - // (2) A callback which is aborted (so shouldn't be aborted on shutdown). - // (3) A callback which isn't run (so should be aborted on shutdown). - CallbackRunInfo& info_did_run() { return info_did_run_; } // (1) - CallbackRunInfo& info_did_abort() { return info_did_abort_; } // (2) - CallbackRunInfo& info_didnt_run() { return info_didnt_run_; } // (3) - - private: - CallbackRunInfo info_did_run_; - CallbackRunInfo info_did_abort_; - CallbackRunInfo info_didnt_run_; -}; - -} // namespace - -// Tests that callbacks are properly aborted on module shutdown. -TEST_F(CallbackShutdownTest, AbortOnShutdown) { - ProxyAutoLock lock; - scoped_refptr<Resource> resource(new Resource(OBJECT_IS_IMPL, pp_instance())); - - // Set up case (1) (see above). - EXPECT_EQ(0U, info_did_run().run_count); - scoped_refptr<TrackedCallback> callback_did_run = new TrackedCallback( - resource.get(), - PP_MakeCompletionCallback(&TestCallback, &info_did_run())); - EXPECT_EQ(0U, info_did_run().run_count); - callback_did_run->Run(PP_OK); - EXPECT_EQ(1U, info_did_run().run_count); - EXPECT_EQ(PP_OK, info_did_run().result); - - // Set up case (2). - EXPECT_EQ(0U, info_did_abort().run_count); - scoped_refptr<TrackedCallback> callback_did_abort = new TrackedCallback( - resource.get(), - PP_MakeCompletionCallback(&TestCallback, &info_did_abort())); - EXPECT_EQ(0U, info_did_abort().run_count); - callback_did_abort->Abort(); - EXPECT_EQ(1U, info_did_abort().run_count); - EXPECT_EQ(PP_ERROR_ABORTED, info_did_abort().result); - - // Set up case (3). - EXPECT_EQ(0U, info_didnt_run().run_count); - scoped_refptr<TrackedCallback> callback_didnt_run = new TrackedCallback( - resource.get(), - PP_MakeCompletionCallback(&TestCallback, &info_didnt_run())); - EXPECT_EQ(0U, info_didnt_run().run_count); - - PpapiGlobals::Get()->GetCallbackTrackerForInstance(pp_instance())->AbortAll(); - - // Check case (1). - EXPECT_EQ(1U, info_did_run().run_count); - - // Check case (2). - EXPECT_EQ(1U, info_did_abort().run_count); - - // Check case (3). - EXPECT_EQ(1U, info_didnt_run().run_count); - EXPECT_EQ(PP_ERROR_ABORTED, info_didnt_run().result); -} - -// CallbackResourceTest -------------------------------------------------------- - -namespace { - -class CallbackResourceTest : public TrackedCallbackTest { - public: - CallbackResourceTest() {} -}; - -class CallbackMockResource : public Resource { - public: - CallbackMockResource(PP_Instance instance) - : Resource(OBJECT_IS_IMPL, instance) {} - ~CallbackMockResource() {} - - PP_Resource SetupForTest() { - PP_Resource resource_id = GetReference(); - EXPECT_NE(0, resource_id); - - callback_did_run_ = new TrackedCallback( - this, PP_MakeCompletionCallback(&TestCallback, &info_did_run_)); - EXPECT_EQ(0U, info_did_run_.run_count); - EXPECT_EQ(0U, info_did_run_.completion_task_run_count); - - // In order to test that the completion task can override the callback - // result, we need to test callbacks with and without a completion task. - callback_did_run_with_completion_task_ = new TrackedCallback( - this, - PP_MakeCompletionCallback(&TestCallback, - &info_did_run_with_completion_task_)); - callback_did_run_with_completion_task_->set_completion_task( - Bind(&CallbackMockResource::CompletionTask, - this, - &info_did_run_with_completion_task_)); - EXPECT_EQ(0U, info_did_run_with_completion_task_.run_count); - EXPECT_EQ(0U, info_did_run_with_completion_task_.completion_task_run_count); - - callback_did_abort_ = new TrackedCallback( - this, PP_MakeCompletionCallback(&TestCallback, &info_did_abort_)); - callback_did_abort_->set_completion_task( - Bind(&CallbackMockResource::CompletionTask, this, &info_did_abort_)); - EXPECT_EQ(0U, info_did_abort_.run_count); - EXPECT_EQ(0U, info_did_abort_.completion_task_run_count); - - callback_didnt_run_ = new TrackedCallback( - this, PP_MakeCompletionCallback(&TestCallback, &info_didnt_run_)); - callback_didnt_run_->set_completion_task( - Bind(&CallbackMockResource::CompletionTask, this, &info_didnt_run_)); - EXPECT_EQ(0U, info_didnt_run_.run_count); - EXPECT_EQ(0U, info_didnt_run_.completion_task_run_count); - - callback_did_run_->Run(PP_OK); - callback_did_run_with_completion_task_->Run(PP_OK); - callback_did_abort_->Abort(); - - CheckIntermediateState(); - - return resource_id; - } - - int32_t CompletionTask(CallbackRunInfo* info, int32_t result) { - // We should run before the callback. - EXPECT_EQ(0U, info->run_count); - info->completion_task_run_count++; - if (info->completion_task_run_count == 1) - info->completion_task_result = result; - return kOverrideResultValue; - } - - void CheckIntermediateState() { - EXPECT_EQ(1U, info_did_run_.run_count); - EXPECT_EQ(PP_OK, info_did_run_.result); - EXPECT_EQ(0U, info_did_run_.completion_task_run_count); - - EXPECT_EQ(1U, info_did_run_with_completion_task_.run_count); - // completion task should override the result. - EXPECT_EQ(kOverrideResultValue, info_did_run_with_completion_task_.result); - EXPECT_EQ(1U, info_did_run_with_completion_task_.completion_task_run_count); - EXPECT_EQ(PP_OK, info_did_run_with_completion_task_.completion_task_result); - - EXPECT_EQ(1U, info_did_abort_.run_count); - // completion task shouldn't override an abort. - EXPECT_EQ(PP_ERROR_ABORTED, info_did_abort_.result); - EXPECT_EQ(1U, info_did_abort_.completion_task_run_count); - EXPECT_EQ(PP_ERROR_ABORTED, info_did_abort_.completion_task_result); - - EXPECT_EQ(0U, info_didnt_run_.completion_task_run_count); - EXPECT_EQ(0U, info_didnt_run_.run_count); - } - - void CheckFinalState() { - EXPECT_EQ(1U, info_did_run_.run_count); - EXPECT_EQ(PP_OK, info_did_run_.result); - EXPECT_EQ(1U, info_did_abort_.run_count); - EXPECT_EQ(PP_ERROR_ABORTED, info_did_abort_.result); - EXPECT_EQ(1U, info_didnt_run_.run_count); - EXPECT_EQ(PP_ERROR_ABORTED, info_didnt_run_.result); - } - - scoped_refptr<TrackedCallback> callback_did_run_; - CallbackRunInfo info_did_run_; - - scoped_refptr<TrackedCallback> callback_did_run_with_completion_task_; - CallbackRunInfo info_did_run_with_completion_task_; - - scoped_refptr<TrackedCallback> callback_did_abort_; - CallbackRunInfo info_did_abort_; - - scoped_refptr<TrackedCallback> callback_didnt_run_; - CallbackRunInfo info_didnt_run_; -}; - -} // namespace - -// Test that callbacks get aborted on the last resource unref. -TEST_F(CallbackResourceTest, AbortOnNoRef) { - ProxyAutoLock lock; - ResourceTracker* resource_tracker = PpapiGlobals::Get()->GetResourceTracker(); - - // Test several things: Unref-ing a resource (to zero refs) with callbacks - // which (1) have been run, (2) have been aborted, (3) haven't been completed. - // Check that the uncompleted one gets aborted, and that the others don't get - // called again. - scoped_refptr<CallbackMockResource> resource_1( - new CallbackMockResource(pp_instance())); - PP_Resource resource_1_id = resource_1->SetupForTest(); - - // Also do the same for a second resource, and make sure that unref-ing the - // first resource doesn't much up the second resource. - scoped_refptr<CallbackMockResource> resource_2( - new CallbackMockResource(pp_instance())); - PP_Resource resource_2_id = resource_2->SetupForTest(); - - // Double-check that resource #1 is still okay. - resource_1->CheckIntermediateState(); - - // Kill resource #1, spin the message loop to run posted calls, and check that - // things are in the expected states. - resource_tracker->ReleaseResource(resource_1_id); - { - ProxyAutoUnlock unlock; - base::MessageLoop::current()->RunUntilIdle(); - } - resource_1->CheckFinalState(); - resource_2->CheckIntermediateState(); - - // Kill resource #2. - resource_tracker->ReleaseResource(resource_2_id); - { - ProxyAutoUnlock unlock; - base::MessageLoop::current()->RunUntilIdle(); - } - resource_1->CheckFinalState(); - resource_2->CheckFinalState(); - - // This shouldn't be needed, but make sure there are no stranded tasks. - { - ProxyAutoUnlock unlock; - base::MessageLoop::current()->RunUntilIdle(); - } -} - -// Test that "resurrecting" a resource (getting a new ID for a |Resource|) -// doesn't resurrect callbacks. -TEST_F(CallbackResourceTest, Resurrection) { - ProxyAutoLock lock; - ResourceTracker* resource_tracker = PpapiGlobals::Get()->GetResourceTracker(); - - scoped_refptr<CallbackMockResource> resource( - new CallbackMockResource(pp_instance())); - PP_Resource resource_id = resource->SetupForTest(); - - // Unref it, spin the message loop to run posted calls, and check that things - // are in the expected states. - resource_tracker->ReleaseResource(resource_id); - { - ProxyAutoUnlock unlock; - base::MessageLoop::current()->RunUntilIdle(); - } - resource->CheckFinalState(); - - // "Resurrect" it and check that the callbacks are still dead. - PP_Resource new_resource_id = resource->GetReference(); - { - ProxyAutoUnlock unlock; - base::MessageLoop::current()->RunUntilIdle(); - } - resource->CheckFinalState(); - - // Unref it again and do the same. - resource_tracker->ReleaseResource(new_resource_id); - { - ProxyAutoUnlock unlock; - base::MessageLoop::current()->RunUntilIdle(); - } - resource->CheckFinalState(); - - // This shouldn't be needed, but make sure there are no stranded tasks. - { - ProxyAutoUnlock unlock; - base::MessageLoop::current()->RunUntilIdle(); - } -} - -} // namespace ppapi diff --git a/chromium/ppapi/shared_impl/var.h b/chromium/ppapi/shared_impl/var.h index 67b0e3a0706..5e46864fb2a 100644 --- a/chromium/ppapi/shared_impl/var.h +++ b/chromium/ppapi/shared_impl/var.h @@ -101,7 +101,7 @@ class PPAPI_SHARED_EXPORT StringVar : public Var { public: explicit StringVar(const std::string& str); StringVar(const char* str, uint32 len); - virtual ~StringVar(); + ~StringVar() override; const std::string& value() const { return value_; } // Return a pointer to the internal string. This allows other objects to @@ -112,8 +112,8 @@ class PPAPI_SHARED_EXPORT StringVar : public Var { const std::string* ptr() const { return &value_; } // Var override. - virtual StringVar* AsStringVar() override; - virtual PP_VarType GetType() const override; + StringVar* AsStringVar() override; + PP_VarType GetType() const override; // Helper function to create a PP_Var of type string that contains a copy of // the given string. The input data must be valid UTF-8 encoded text, if it @@ -158,7 +158,7 @@ class PPAPI_SHARED_EXPORT StringVar : public Var { class PPAPI_SHARED_EXPORT ArrayBufferVar : public Var { public: ArrayBufferVar(); - virtual ~ArrayBufferVar(); + ~ArrayBufferVar() override; virtual void* Map() = 0; virtual void Unmap() = 0; @@ -176,8 +176,8 @@ class PPAPI_SHARED_EXPORT ArrayBufferVar : public Var { base::SharedMemoryHandle* plugin_shm_handle) = 0; // Var override. - virtual ArrayBufferVar* AsArrayBufferVar() override; - virtual PP_VarType GetType() const override; + ArrayBufferVar* AsArrayBufferVar() override; + PP_VarType GetType() const override; // Helper function that converts a PP_Var to an ArrayBufferVar. This will // return NULL if the PP_Var is not of ArrayBuffer type. diff --git a/chromium/ppapi/shared_impl/var_tracker_unittest.cc b/chromium/ppapi/shared_impl/var_tracker_unittest.cc index fc089abc10e..9dd03b311ab 100644 --- a/chromium/ppapi/shared_impl/var_tracker_unittest.cc +++ b/chromium/ppapi/shared_impl/var_tracker_unittest.cc @@ -21,15 +21,15 @@ class MockStringVar : public StringVar { MockStringVar(const std::string& str) : StringVar(str) { mock_var_alive_count++; } - virtual ~MockStringVar() { mock_var_alive_count--; } + ~MockStringVar() override { mock_var_alive_count--; } bool HasValidVarID() { return GetExistingVarID() != 0; } }; class MockObjectVar : public Var { public: MockObjectVar() : Var() { mock_var_alive_count++; } - virtual ~MockObjectVar() { mock_var_alive_count--; } - virtual PP_VarType GetType() const override { return PP_VARTYPE_OBJECT; } + ~MockObjectVar() override { mock_var_alive_count--; } + PP_VarType GetType() const override { return PP_VARTYPE_OBJECT; } bool HasValidVarID() { return GetExistingVarID() != 0; } }; @@ -40,11 +40,10 @@ class VarTrackerTest : public testing::Test { VarTrackerTest() {} // Test implementation. - virtual void SetUp() override { + void SetUp() override { ASSERT_EQ(0, mock_var_alive_count); - ProxyLock::EnableLockingOnThreadForTest(); } - virtual void TearDown() override {} + void TearDown() override {} VarTracker& var_tracker() { return *globals_.GetVarTracker(); } diff --git a/chromium/ppapi/tests/extensions/extensions.gyp b/chromium/ppapi/tests/extensions/extensions.gyp index 163b8ef3ce6..6d85a94db63 100644 --- a/chromium/ppapi/tests/extensions/extensions.gyp +++ b/chromium/ppapi/tests/extensions/extensions.gyp @@ -37,9 +37,9 @@ 'build_pnacl_newlib': 0, 'nexe_destination_dir': 'test_data/ppapi/tests/extensions/media_galleries', 'sources': [ - 'media_galleries/test_galleries.cc', '<(DEPTH)/ppapi/tests/test_utils.cc', '<(DEPTH)/ppapi/tests/test_utils.h', + 'media_galleries/test_galleries.cc', ], 'test_files': [ 'media_galleries/background.js', @@ -54,10 +54,8 @@ 'type': 'none', 'variables': { 'nexe_target': 'ppapi_tests_extensions_packaged_app', - # TODO(teravest): Add testing for glibc, pnacl, and nonsfi modes. 'build_newlib': 1, 'build_glibc': 0, - 'build_pnacl_newlib': 0, 'nexe_destination_dir': 'test_data/ppapi/tests/extensions/packaged_app', 'sources': [ 'packaged_app/test_packaged_app.cc' @@ -67,6 +65,178 @@ 'packaged_app/index.html', 'packaged_app/main.js', 'packaged_app/manifest.json', + 'packaged_app/test_file.txt', + 'packaged_app/test_file2.txt', + ], + 'create_nmf_args_portable': [ + # Add 129 "files" entries to make sure that open_resource can handle + # more files than IPC::MessageAttachmentSet::kMaxDescriptorsPerMessage + # which is currently 128. + '-xtest_file0:test_file.txt', + '-xtest_file1:test_file2.txt', + '-xtest_file2:test_file.txt', + '-xtest_file3:test_file2.txt', + '-xtest_file4:test_file.txt', + '-xtest_file5:test_file2.txt', + '-xtest_file6:test_file.txt', + '-xtest_file7:test_file2.txt', + '-xtest_file8:test_file.txt', + '-xtest_file9:test_file2.txt', + '-xtest_file10:test_file.txt', + '-xtest_file11:test_file2.txt', + '-xtest_file12:test_file.txt', + '-xtest_file13:test_file2.txt', + '-xtest_file14:test_file.txt', + '-xtest_file15:test_file2.txt', + '-xtest_file16:test_file.txt', + '-xtest_file17:test_file2.txt', + '-xtest_file18:test_file.txt', + '-xtest_file19:test_file2.txt', + '-xtest_file20:test_file.txt', + '-xtest_file21:test_file2.txt', + '-xtest_file22:test_file.txt', + '-xtest_file23:test_file2.txt', + '-xtest_file24:test_file.txt', + '-xtest_file25:test_file2.txt', + '-xtest_file26:test_file.txt', + '-xtest_file27:test_file2.txt', + '-xtest_file28:test_file.txt', + '-xtest_file29:test_file2.txt', + '-xtest_file30:test_file.txt', + '-xtest_file31:test_file2.txt', + '-xtest_file32:test_file.txt', + '-xtest_file33:test_file2.txt', + '-xtest_file34:test_file.txt', + '-xtest_file35:test_file2.txt', + '-xtest_file36:test_file.txt', + '-xtest_file37:test_file2.txt', + '-xtest_file38:test_file.txt', + '-xtest_file39:test_file2.txt', + '-xtest_file40:test_file.txt', + '-xtest_file41:test_file2.txt', + '-xtest_file42:test_file.txt', + '-xtest_file43:test_file2.txt', + '-xtest_file44:test_file.txt', + '-xtest_file45:test_file2.txt', + '-xtest_file46:test_file.txt', + '-xtest_file47:test_file2.txt', + '-xtest_file48:test_file.txt', + '-xtest_file49:test_file2.txt', + '-xtest_file50:test_file.txt', + '-xtest_file51:test_file2.txt', + '-xtest_file52:test_file.txt', + '-xtest_file53:test_file2.txt', + '-xtest_file54:test_file.txt', + '-xtest_file55:test_file2.txt', + '-xtest_file56:test_file.txt', + '-xtest_file57:test_file2.txt', + '-xtest_file58:test_file.txt', + '-xtest_file59:test_file2.txt', + '-xtest_file60:test_file.txt', + '-xtest_file61:test_file2.txt', + '-xtest_file62:test_file.txt', + '-xtest_file63:test_file2.txt', + '-xtest_file64:test_file.txt', + '-xtest_file65:test_file2.txt', + '-xtest_file66:test_file.txt', + '-xtest_file67:test_file2.txt', + '-xtest_file68:test_file.txt', + '-xtest_file69:test_file2.txt', + '-xtest_file70:test_file.txt', + '-xtest_file71:test_file2.txt', + '-xtest_file72:test_file.txt', + '-xtest_file73:test_file2.txt', + '-xtest_file74:test_file.txt', + '-xtest_file75:test_file2.txt', + '-xtest_file76:test_file.txt', + '-xtest_file77:test_file2.txt', + '-xtest_file78:test_file.txt', + '-xtest_file79:test_file2.txt', + '-xtest_file80:test_file.txt', + '-xtest_file81:test_file2.txt', + '-xtest_file82:test_file.txt', + '-xtest_file83:test_file2.txt', + '-xtest_file84:test_file.txt', + '-xtest_file85:test_file2.txt', + '-xtest_file86:test_file.txt', + '-xtest_file87:test_file2.txt', + '-xtest_file88:test_file.txt', + '-xtest_file89:test_file2.txt', + '-xtest_file90:test_file.txt', + '-xtest_file91:test_file2.txt', + '-xtest_file92:test_file.txt', + '-xtest_file93:test_file2.txt', + '-xtest_file94:test_file.txt', + '-xtest_file95:test_file2.txt', + '-xtest_file96:test_file.txt', + '-xtest_file97:test_file2.txt', + '-xtest_file98:test_file.txt', + '-xtest_file99:test_file2.txt', + '-xtest_file100:test_file.txt', + '-xtest_file101:test_file2.txt', + '-xtest_file102:test_file.txt', + '-xtest_file103:test_file2.txt', + '-xtest_file104:test_file.txt', + '-xtest_file105:test_file2.txt', + '-xtest_file106:test_file.txt', + '-xtest_file107:test_file2.txt', + '-xtest_file108:test_file.txt', + '-xtest_file109:test_file2.txt', + '-xtest_file110:test_file.txt', + '-xtest_file111:test_file2.txt', + '-xtest_file112:test_file.txt', + '-xtest_file113:test_file2.txt', + '-xtest_file114:test_file.txt', + '-xtest_file115:test_file2.txt', + '-xtest_file116:test_file.txt', + '-xtest_file117:test_file2.txt', + '-xtest_file118:test_file.txt', + '-xtest_file119:test_file2.txt', + '-xtest_file120:test_file.txt', + '-xtest_file121:test_file2.txt', + '-xtest_file122:test_file.txt', + '-xtest_file123:test_file2.txt', + '-xtest_file124:test_file.txt', + '-xtest_file125:test_file2.txt', + '-xtest_file126:test_file.txt', + '-xtest_file127:test_file2.txt', + '-xtest_file128:test_file.txt', + ], + }, + 'conditions': [ + ['(target_arch=="ia32" or target_arch=="x64") and OS=="linux"', { + # Enable nonsfi testing only on ia32-linux environment. + # See chrome/test/data/nacl/nacl_test_data.gyp for more info. + 'variables': { + 'build_pnacl_newlib': 1, + 'translate_pexe_with_build': 1, + 'enable_x86_32_nonsfi': 1, + }, + }], + ], + # Shim is a dependency for the nexe because we pre-translate. + 'dependencies': [ + '<(DEPTH)/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_irt_shim.gyp:aot', + ], + }, + { + 'target_name': 'ppapi_tests_extensions_socket_permissions', + 'type': 'none', + 'variables': { + 'nexe_target': 'ppapi_tests_extensions_socket_permissions', + # Only newlib build is used in tests, no need to build others. + 'build_newlib': 1, + 'build_glibc': 0, + 'build_pnacl_newlib': 0, + 'nexe_destination_dir': 'test_data/ppapi/tests/extensions/socket_permissions', + 'sources': [ + 'socket_permissions/test_socket_permissions.cc', + ], + 'test_files': [ + 'socket_permissions/controller.js', + 'socket_permissions/index.html', + 'socket_permissions/main.js', + 'socket_permissions/manifest.json', ], }, }, diff --git a/chromium/ppapi/thunk/BUILD.gn b/chromium/ppapi/thunk/BUILD.gn new file mode 100644 index 00000000000..9247bf00814 --- /dev/null +++ b/chromium/ppapi/thunk/BUILD.gn @@ -0,0 +1,203 @@ +# Copyright 2015 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. + +source_set("thunk") { + # In GYP this is the same target as shared_impl. In GN these are split apart + # for clarity but to get component builds correct, targets must only depend + # on these via the shared_impl component. + # TODO(brettw) separate these when GYP compat is no longer required. + visibility = [ "//ppapi/shared_impl" ] + + sources = [ + "enter.cc", + "enter.h", + "ppb_audio_api.h", + "ppb_audio_buffer_api.h", + "ppb_audio_buffer_thunk.cc", + "ppb_audio_config_api.h", + "ppb_audio_config_thunk.cc", + "ppb_audio_input_api.h", + "ppb_audio_thunk.cc", + "ppb_broker_api.h", + "ppb_browser_font_trusted_api.h", + "ppb_buffer_api.h", + "ppb_camera_capabilities_api.h", + "ppb_camera_capabilities_private_thunk.cc", + "ppb_camera_device_api.h", + "ppb_camera_device_private_thunk.cc", + "ppb_compositor_api.h", + "ppb_compositor_layer_api.h", + "ppb_compositor_layer_thunk.cc", + "ppb_compositor_thunk.cc", + "ppb_console_thunk.cc", + "ppb_cursor_control_thunk.cc", + "ppb_device_ref_api.h", + "ppb_device_ref_dev_thunk.cc", + "ppb_ext_crx_file_system_private_thunk.cc", + "ppb_file_chooser_api.h", + "ppb_file_chooser_dev_thunk.cc", + "ppb_file_chooser_trusted_thunk.cc", + "ppb_file_io_api.h", + "ppb_file_io_private_thunk.cc", + "ppb_file_io_thunk.cc", + "ppb_file_ref_api.h", + "ppb_file_ref_thunk.cc", + "ppb_file_system_api.h", + "ppb_file_system_thunk.cc", + "ppb_find_private_thunk.cc", + "ppb_flash_clipboard_api.h", + "ppb_flash_drm_api.h", + "ppb_flash_font_file_api.h", + "ppb_flash_fullscreen_api.h", + "ppb_flash_functions_api.h", + "ppb_flash_menu_api.h", + "ppb_flash_message_loop_api.h", + "ppb_flash_print_thunk.cc", + "ppb_fullscreen_thunk.cc", + "ppb_gamepad_api.h", + "ppb_gamepad_thunk.cc", + "ppb_graphics_2d_api.h", + "ppb_graphics_2d_thunk.cc", + "ppb_graphics_3d_api.h", + "ppb_graphics_3d_thunk.cc", + "ppb_host_resolver_api.h", + "ppb_host_resolver_private_api.h", + "ppb_host_resolver_private_thunk.cc", + "ppb_host_resolver_thunk.cc", + "ppb_image_data_api.h", + "ppb_image_data_thunk.cc", + "ppb_input_event_api.h", + "ppb_input_event_private_thunk.cc", + "ppb_input_event_thunk.cc", + "ppb_instance_api.h", + "ppb_instance_private_thunk.cc", + "ppb_instance_thunk.cc", + "ppb_isolated_file_system_private_api.h", + "ppb_isolated_file_system_private_thunk.cc", + "ppb_media_stream_audio_track_api.h", + "ppb_media_stream_audio_track_thunk.cc", + "ppb_media_stream_video_track_api.h", + "ppb_media_stream_video_track_thunk.cc", + "ppb_message_loop_api.h", + "ppb_messaging_thunk.cc", + "ppb_mouse_cursor_thunk.cc", + "ppb_mouse_lock_thunk.cc", + "ppb_net_address_api.h", + "ppb_net_address_thunk.cc", + "ppb_network_list_api.h", + "ppb_network_list_thunk.cc", + "ppb_network_monitor_api.h", + "ppb_network_monitor_thunk.cc", + "ppb_network_proxy_api.h", + "ppb_network_proxy_thunk.cc", + "ppb_output_protection_api.h", + "ppb_output_protection_private_thunk.cc", + "ppb_pdf_api.h", + "ppb_platform_verification_api.h", + "ppb_printing_api.h", + "ppb_printing_dev_thunk.cc", + "ppb_scrollbar_api.h", + "ppb_tcp_server_socket_private_api.h", + "ppb_tcp_server_socket_private_thunk.cc", + "ppb_tcp_socket_api.h", + "ppb_tcp_socket_private_api.h", + "ppb_tcp_socket_private_thunk.cc", + "ppb_tcp_socket_thunk.cc", + "ppb_text_input_thunk.cc", + "ppb_truetype_font_api.h", + "ppb_truetype_font_dev_thunk.cc", + "ppb_truetype_font_singleton_api.h", + "ppb_udp_socket_api.h", + "ppb_udp_socket_private_api.h", + "ppb_udp_socket_private_thunk.cc", + "ppb_udp_socket_thunk.cc", + "ppb_uma_private_thunk.cc", + "ppb_uma_singleton_api.h", + "ppb_url_loader_api.h", + "ppb_url_loader_thunk.cc", + "ppb_url_loader_trusted_thunk.cc", + "ppb_url_request_info_api.h", + "ppb_url_request_info_thunk.cc", + "ppb_url_response_info_api.h", + "ppb_url_response_info_thunk.cc", + "ppb_var_array_thunk.cc", + "ppb_var_dictionary_thunk.cc", + "ppb_video_capture_api.h", + "ppb_video_decoder_api.h", + "ppb_video_decoder_dev_api.h", + "ppb_video_decoder_thunk.cc", + "ppb_video_destination_private_api.h", + "ppb_video_destination_private_thunk.cc", + "ppb_video_encoder_api.h", + "ppb_video_encoder_thunk.cc", + "ppb_video_frame_api.h", + "ppb_video_frame_thunk.cc", + "ppb_video_source_private_api.h", + "ppb_video_source_private_thunk.cc", + "ppb_view_api.h", + "ppb_view_dev_thunk.cc", + "ppb_view_thunk.cc", + "ppb_websocket_api.h", + "ppb_websocket_thunk.cc", + "ppb_widget_api.h", + "ppb_widget_dev_thunk.cc", + "ppb_x509_certificate_private_api.h", + "ppb_x509_certificate_private_thunk.cc", + "ppb_zoom_dev_thunk.cc", + "thunk.h", + ] + + if (!is_nacl) { + sources += [ + "ppb_audio_input_dev_thunk.cc", + "ppb_broker_thunk.cc", + "ppb_browser_font_trusted_thunk.cc", + "ppb_buffer_thunk.cc", + "ppb_char_set_thunk.cc", + "ppb_content_decryptor_private_thunk.cc", + "ppb_flash_clipboard_thunk.cc", + "ppb_flash_device_id_thunk.cc", + "ppb_flash_drm_thunk.cc", + "ppb_flash_file_fileref_thunk.cc", + "ppb_flash_file_modulelocal_thunk.cc", + "ppb_flash_font_file_thunk.cc", + "ppb_flash_fullscreen_thunk.cc", + "ppb_flash_menu_thunk.cc", + "ppb_flash_message_loop_thunk.cc", + "ppb_flash_thunk.cc", + "ppb_gles_chromium_texture_mapping_thunk.cc", + "ppb_pdf_thunk.cc", + "ppb_platform_verification_private_thunk.cc", + "ppb_scrollbar_thunk.cc", + "ppb_url_util_thunk.cc", + "ppb_video_capture_thunk.cc", + "ppb_video_decoder_dev_thunk.cc", + ] + } + + # We exclude a few more things for nacl_win64, to avoid pulling in more + # dependencies. + # TODO(GYP) this isn't correct. This should only be specifically for the + # nacl_win64 build (cross-compiled for a 32-bit Chrome), rather than all + # 64-bit builds. + # See also //ppapi/shared_impl + if (is_win && current_cpu == "x64" && current_toolchain != default_toolchain) { + sources += [ + "ppb_graphics_3d_thunk.cc", + "ppb_host_resolver_private_thunk.cc", + "ppb_tcp_server_socket_private_thunk.cc", + "ppb_tcp_socket_private_thunk.cc", + "ppb_udp_socket_private_thunk.cc", + "ppb_x509_certificate_private_thunk.cc", + ] + } + + defines = [ + # This target goes in the same library as shared_impl (in GYP they are the + # same). + "PPAPI_SHARED_IMPLEMENTATION", + + "PPAPI_THUNK_IMPLEMENTATION", + ] +} diff --git a/chromium/ppapi/thunk/interfaces_ppb_private.h b/chromium/ppapi/thunk/interfaces_ppb_private.h index e4aff229127..fffe667c1da 100644 --- a/chromium/ppapi/thunk/interfaces_ppb_private.h +++ b/chromium/ppapi/thunk/interfaces_ppb_private.h @@ -23,8 +23,8 @@ PROXIED_IFACE(PPB_BROKER_TRUSTED_INTERFACE_0_3, PPB_BrokerTrusted_0_3) PROXIED_IFACE(PPB_BROWSERFONT_TRUSTED_INTERFACE_1_0, PPB_BrowserFont_Trusted_1_0) -PROXIED_IFACE(PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_12, - PPB_ContentDecryptor_Private_0_12) +PROXIED_IFACE(PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_14, + PPB_ContentDecryptor_Private_0_14) PROXIED_IFACE(PPB_CHARSET_TRUSTED_INTERFACE_1_0, PPB_CharSet_Trusted_1_0) PROXIED_IFACE(PPB_FILECHOOSER_TRUSTED_INTERFACE_0_5, @@ -45,10 +45,6 @@ PROXIED_IFACE(PPB_PDF_INTERFACE, PROXIED_IFACE(PPB_PLATFORMVERIFICATION_PRIVATE_INTERFACE_0_2, PPB_PlatformVerification_Private_0_2) #endif -PROXIED_IFACE(PPB_TALK_PRIVATE_INTERFACE_1_0, - PPB_Talk_Private_1_0) -PROXIED_IFACE(PPB_TALK_PRIVATE_INTERFACE_2_0, - PPB_Talk_Private_2_0) PROXIED_IFACE(PPB_URLLOADERTRUSTED_INTERFACE_0_3, PPB_URLLoaderTrusted_0_3) diff --git a/chromium/ppapi/thunk/interfaces_ppb_private_no_permissions.h b/chromium/ppapi/thunk/interfaces_ppb_private_no_permissions.h index 6c224fe57bf..297648f6ec6 100644 --- a/chromium/ppapi/thunk/interfaces_ppb_private_no_permissions.h +++ b/chromium/ppapi/thunk/interfaces_ppb_private_no_permissions.h @@ -10,6 +10,11 @@ // These interfaces don't require private permissions. However, they only work // for whitelisted origins. +PROXIED_IFACE(PPB_CAMERACAPABILITIES_PRIVATE_INTERFACE_0_1, + PPB_CameraCapabilities_Private_0_1) +PROXIED_IFACE(PPB_CAMERADEVICE_PRIVATE_INTERFACE_0_1, + PPB_CameraDevice_Private_0_1) + PROXIED_IFACE(PPB_HOSTRESOLVER_PRIVATE_INTERFACE_0_1, PPB_HostResolver_Private_0_1) PROXIED_IFACE(PPB_TCPSERVERSOCKET_PRIVATE_INTERFACE_0_1, diff --git a/chromium/ppapi/thunk/interfaces_ppb_public_dev_channel.h b/chromium/ppapi/thunk/interfaces_ppb_public_dev_channel.h index a91d112a96b..a832da44f92 100644 --- a/chromium/ppapi/thunk/interfaces_ppb_public_dev_channel.h +++ b/chromium/ppapi/thunk/interfaces_ppb_public_dev_channel.h @@ -10,10 +10,11 @@ // Interfaces go here. PROXIED_IFACE(PPB_COMPOSITOR_INTERFACE_0_1, PPB_Compositor_0_1) PROXIED_IFACE(PPB_COMPOSITORLAYER_INTERFACE_0_1, PPB_CompositorLayer_0_1) -PROXIED_IFACE(PPB_FILEMAPPING_INTERFACE_0_1, PPB_FileMapping_0_1) -PROXIED_IFACE(PPB_MESSAGING_INTERFACE_1_1_DEPRECATED, - PPB_Messaging_1_1_Deprecated) +PROXIED_IFACE(PPB_COMPOSITORLAYER_INTERFACE_0_2, PPB_CompositorLayer_0_2) +PROXIED_IFACE(PPB_UDPSOCKET_INTERFACE_1_2, PPB_UDPSocket_1_2) PROXIED_IFACE(PPB_VIDEODECODER_INTERFACE_0_1, PPB_VideoDecoder_0_1) +PROXIED_IFACE(PPB_VIDEOENCODER_INTERFACE_0_1, PPB_VideoEncoder_0_1) +PROXIED_IFACE(PPB_VIDEOENCODER_INTERFACE_0_2, PPB_VideoEncoder_0_2) // Note, PPB_TraceEvent is special. We don't want to actually make it stable, // but we want developers to be able to leverage it when running Chrome Dev or diff --git a/chromium/ppapi/thunk/interfaces_ppb_public_stable.h b/chromium/ppapi/thunk/interfaces_ppb_public_stable.h index a95d50576fc..0f430c7c2d8 100644 --- a/chromium/ppapi/thunk/interfaces_ppb_public_stable.h +++ b/chromium/ppapi/thunk/interfaces_ppb_public_stable.h @@ -86,9 +86,11 @@ PROXIED_IFACE(PPB_NETWORKMONITOR_INTERFACE_1_0, PPB_NetworkMonitor_1_0) PROXIED_IFACE(PPB_NETWORKPROXY_INTERFACE_1_0, PPB_NetworkProxy_1_0) PROXIED_IFACE(PPB_TCPSOCKET_INTERFACE_1_0, PPB_TCPSocket_1_0) PROXIED_IFACE(PPB_TCPSOCKET_INTERFACE_1_1, PPB_TCPSocket_1_1) +PROXIED_IFACE(PPB_TCPSOCKET_INTERFACE_1_2, PPB_TCPSocket_1_2) PROXIED_IFACE(PPB_TEXTINPUTCONTROLLER_INTERFACE_1_0, PPB_TextInputController_1_0) PROXIED_IFACE(PPB_UDPSOCKET_INTERFACE_1_0, PPB_UDPSocket_1_0) +PROXIED_IFACE(PPB_UDPSOCKET_INTERFACE_1_1, PPB_UDPSocket_1_1) PROXIED_IFACE(PPB_URLLOADER_INTERFACE_1_0, PPB_URLLoader_1_0) PROXIED_IFACE(PPB_URLREQUESTINFO_INTERFACE_1_0, PPB_URLRequestInfo_1_0) PROXIED_IFACE(PPB_URLRESPONSEINFO_INTERFACE_1_0, PPB_URLResponseInfo_1_0) diff --git a/chromium/ppapi/thunk/ppb_camera_capabilities_api.h b/chromium/ppapi/thunk/ppb_camera_capabilities_api.h new file mode 100644 index 00000000000..34d51274a76 --- /dev/null +++ b/chromium/ppapi/thunk/ppb_camera_capabilities_api.h @@ -0,0 +1,26 @@ +// Copyright 2015 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_THUNK_PPB_CAMERA_CAPABILITIES_API_H_ +#define PPAPI_THUNK_PPB_CAMERA_CAPABILITIES_API_H_ + +#include "ppapi/c/private/ppb_camera_capabilities_private.h" +#include "ppapi/thunk/ppapi_thunk_export.h" + +namespace ppapi { + +namespace thunk { + +class PPAPI_THUNK_EXPORT PPB_CameraCapabilities_API { + public: + virtual ~PPB_CameraCapabilities_API() {} + virtual void GetSupportedVideoCaptureFormats( + uint32_t* array_size, + PP_VideoCaptureFormat** formats) = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_PPB_CAMERA_CAPABILITIES_API_H_ diff --git a/chromium/ppapi/thunk/ppb_camera_capabilities_private_thunk.cc b/chromium/ppapi/thunk/ppb_camera_capabilities_private_thunk.cc index baebc8248ab..85a64bbf6d2 100644 --- a/chromium/ppapi/thunk/ppb_camera_capabilities_private_thunk.cc +++ b/chromium/ppapi/thunk/ppb_camera_capabilities_private_thunk.cc @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// From private/ppb_camera_capabilities_private.idl modified Wed Nov 5 14:29:15 -// 2014. +// From private/ppb_camera_capabilities_private.idl modified Thu Feb 19 09:06:18 +// 2015. #include "ppapi/c/pp_errors.h" #include "ppapi/c/private/ppb_camera_capabilities_private.h" @@ -17,45 +17,27 @@ namespace thunk { namespace { -PP_Resource Create(PP_Instance instance) { - VLOG(4) << "PPB_CameraCapabilities_Private::Create()"; - EnterResourceCreation enter(instance); - if (enter.failed()) - return 0; - return enter.functions()->CreateCameraCapabilitiesPrivate(instance); -} - PP_Bool IsCameraCapabilities(PP_Resource resource) { VLOG(4) << "PPB_CameraCapabilities_Private::IsCameraCapabilities()"; EnterResource<PPB_CameraCapabilities_API> enter(resource, false); return PP_FromBool(enter.succeeded()); } -void GetSupportedPreviewSizes(PP_Resource capabilities, - int32_t* array_size, - struct PP_Size** preview_sizes) { - VLOG(4) << "PPB_CameraCapabilities_Private::GetSupportedPreviewSizes()"; - EnterResource<PPB_CameraCapabilities_API> enter(capabilities, true); - if (enter.failed()) - return; - enter.object()->GetSupportedPreviewSizes(array_size, preview_sizes); -} - -void GetSupportedJpegSizes(PP_Resource capabilities, - int32_t* array_size, - struct PP_Size** jpeg_sizes) { - VLOG(4) << "PPB_CameraCapabilities_Private::GetSupportedJpegSizes()"; +void GetSupportedVideoCaptureFormats(PP_Resource capabilities, + uint32_t* array_size, + struct PP_VideoCaptureFormat** formats) { + VLOG(4) + << "PPB_CameraCapabilities_Private::GetSupportedVideoCaptureFormats()"; EnterResource<PPB_CameraCapabilities_API> enter(capabilities, true); if (enter.failed()) return; - enter.object()->GetSupportedJpegSizes(array_size, jpeg_sizes); + enter.object()->GetSupportedVideoCaptureFormats(array_size, formats); } const PPB_CameraCapabilities_Private_0_1 - g_ppb_cameracapabilities_private_thunk_0_1 = {&Create, - &IsCameraCapabilities, - &GetSupportedPreviewSizes, - &GetSupportedJpegSizes}; + g_ppb_cameracapabilities_private_thunk_0_1 = { + &IsCameraCapabilities, + &GetSupportedVideoCaptureFormats}; } // namespace diff --git a/chromium/ppapi/thunk/ppb_camera_device_api.h b/chromium/ppapi/thunk/ppb_camera_device_api.h new file mode 100644 index 00000000000..29e6a27c34a --- /dev/null +++ b/chromium/ppapi/thunk/ppb_camera_device_api.h @@ -0,0 +1,33 @@ +// Copyright 2015 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_THUNK_PPB_CAMERA_DEVICE_API_H_ +#define PPAPI_THUNK_PPB_CAMERA_DEVICE_API_H_ + +#include <string> + +#include "ppapi/c/private/ppb_camera_device_private.h" +#include "ppapi/thunk/ppapi_thunk_export.h" + +namespace ppapi { + +class TrackedCallback; + +namespace thunk { + +class PPAPI_THUNK_EXPORT PPB_CameraDevice_API { + public: + virtual ~PPB_CameraDevice_API() {} + virtual int32_t Open(PP_Var device_id, + const scoped_refptr<TrackedCallback>& callback) = 0; + virtual void Close() = 0; + virtual int32_t GetCameraCapabilities( + PP_Resource* capabilities, + const scoped_refptr<TrackedCallback>& callback) = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_PPB_CAMERA_DEVICE_API_H_ diff --git a/chromium/ppapi/thunk/ppb_camera_device_private_thunk.cc b/chromium/ppapi/thunk/ppb_camera_device_private_thunk.cc new file mode 100644 index 00000000000..94b3129dded --- /dev/null +++ b/chromium/ppapi/thunk/ppb_camera_device_private_thunk.cc @@ -0,0 +1,74 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// From private/ppb_camera_device_private.idl modified Wed Feb 18 16:44:52 2015. + +#include "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/private/ppb_camera_device_private.h" +#include "ppapi/shared_impl/tracked_callback.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppapi_thunk_export.h" +#include "ppapi/thunk/ppb_camera_device_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Resource Create(PP_Instance instance) { + VLOG(4) << "PPB_CameraDevice_Private::Create()"; + EnterResourceCreation enter(instance); + if (enter.failed()) + return 0; + return enter.functions()->CreateCameraDevicePrivate(instance); +} + +PP_Bool IsCameraDevice(PP_Resource resource) { + VLOG(4) << "PPB_CameraDevice_Private::IsCameraDevice()"; + EnterResource<PPB_CameraDevice_API> enter(resource, false); + return PP_FromBool(enter.succeeded()); +} + +int32_t Open(PP_Resource camera_device, + struct PP_Var device_id, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_CameraDevice_Private::Open()"; + EnterResource<PPB_CameraDevice_API> enter(camera_device, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->Open(device_id, enter.callback())); +} + +void Close(PP_Resource camera_device) { + VLOG(4) << "PPB_CameraDevice_Private::Close()"; + EnterResource<PPB_CameraDevice_API> enter(camera_device, true); + if (enter.failed()) + return; + enter.object()->Close(); +} + +int32_t GetCameraCapabilities(PP_Resource camera_device, + PP_Resource* capabilities, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_CameraDevice_Private::GetCameraCapabilities()"; + EnterResource<PPB_CameraDevice_API> enter(camera_device, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult( + enter.object()->GetCameraCapabilities(capabilities, enter.callback())); +} + +const PPB_CameraDevice_Private_0_1 g_ppb_cameradevice_private_thunk_0_1 = + {&Create, &IsCameraDevice, &Open, &Close, &GetCameraCapabilities}; + +} // namespace + +PPAPI_THUNK_EXPORT const PPB_CameraDevice_Private_0_1* +GetPPB_CameraDevice_Private_0_1_Thunk() { + return &g_ppb_cameradevice_private_thunk_0_1; +} + +} // namespace thunk +} // namespace ppapi diff --git a/chromium/ppapi/thunk/ppb_compositor_layer_thunk.cc b/chromium/ppapi/thunk/ppb_compositor_layer_thunk.cc index d30ecd28837..03afa5fbcdb 100644 --- a/chromium/ppapi/thunk/ppb_compositor_layer_thunk.cc +++ b/chromium/ppapi/thunk/ppb_compositor_layer_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. -// From ppb_compositor_layer.idl modified Thu Sep 18 11:36:39 2014. +// From ppb_compositor_layer.idl modified Thu Jan 29 16:28:15 2015. #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" @@ -41,7 +41,7 @@ int32_t SetTexture_0_1(PP_Resource layer, uint32_t texture, const struct PP_Size* size, struct PP_CompletionCallback cc) { - VLOG(4) << "PPB_CompositorLayer::SetTexture()"; + VLOG(4) << "PPB_CompositorLayer::SetTexture_0_1()"; EnterResource<PPB_CompositorLayer_API> enter(layer, cc, true); if (enter.failed()) return enter.retval(); diff --git a/chromium/ppapi/thunk/ppb_content_decryptor_private_thunk.cc b/chromium/ppapi/thunk/ppb_content_decryptor_private_thunk.cc index fc601d6996e..abce20b7793 100644 --- a/chromium/ppapi/thunk/ppb_content_decryptor_private_thunk.cc +++ b/chromium/ppapi/thunk/ppb_content_decryptor_private_thunk.cc @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// From private/ppb_content_decryptor_private.idl modified Wed Nov 5 14:29:15 -// 2014. +// From private/ppb_content_decryptor_private.idl modified Mon Mar 30 22:35:33 +// 2015. #include "ppapi/c/pp_errors.h" #include "ppapi/c/private/ppb_content_decryptor_private.h" @@ -26,24 +26,13 @@ void PromiseResolved(PP_Instance instance, uint32_t promise_id) { void PromiseResolvedWithSession(PP_Instance instance, uint32_t promise_id, - struct PP_Var web_session_id) { + struct PP_Var session_id) { VLOG(4) << "PPB_ContentDecryptor_Private::PromiseResolvedWithSession()"; EnterInstance enter(instance); if (enter.failed()) return; enter.functions()->PromiseResolvedWithSession(instance, promise_id, - web_session_id); -} - -void PromiseResolvedWithKeyIds(PP_Instance instance, - uint32_t promise_id, - struct PP_Var key_ids_array) { - VLOG(4) << "PPB_ContentDecryptor_Private::PromiseResolvedWithKeyIds()"; - EnterInstance enter(instance); - if (enter.failed()) - return; - enter.functions()->PromiseResolvedWithKeyIds(instance, promise_id, - key_ids_array); + session_id); } void PromiseRejected(PP_Instance instance, @@ -60,66 +49,62 @@ void PromiseRejected(PP_Instance instance, } void SessionMessage(PP_Instance instance, - struct PP_Var web_session_id, + struct PP_Var session_id, + PP_CdmMessageType message_type, struct PP_Var message, - struct PP_Var destination_url) { + struct PP_Var legacy_destination_url) { VLOG(4) << "PPB_ContentDecryptor_Private::SessionMessage()"; EnterInstance enter(instance); if (enter.failed()) return; - enter.functions()->SessionMessage(instance, web_session_id, message, - destination_url); + enter.functions()->SessionMessage(instance, session_id, message_type, message, + legacy_destination_url); } void SessionKeysChange(PP_Instance instance, - struct PP_Var web_session_id, - PP_Bool has_additional_usable_key) { + struct PP_Var session_id, + PP_Bool has_additional_usable_key, + uint32_t key_count, + const struct PP_KeyInformation key_information[]) { VLOG(4) << "PPB_ContentDecryptor_Private::SessionKeysChange()"; EnterInstance enter(instance); if (enter.failed()) return; - enter.functions()->SessionKeysChange(instance, web_session_id, - has_additional_usable_key); + enter.functions()->SessionKeysChange(instance, session_id, + has_additional_usable_key, key_count, + key_information); } void SessionExpirationChange(PP_Instance instance, - struct PP_Var web_session_id, + struct PP_Var session_id, PP_Time new_expiry_time) { VLOG(4) << "PPB_ContentDecryptor_Private::SessionExpirationChange()"; EnterInstance enter(instance); if (enter.failed()) return; - enter.functions()->SessionExpirationChange(instance, web_session_id, + enter.functions()->SessionExpirationChange(instance, session_id, new_expiry_time); } -void SessionReady(PP_Instance instance, struct PP_Var web_session_id) { - VLOG(4) << "PPB_ContentDecryptor_Private::SessionReady()"; - EnterInstance enter(instance); - if (enter.failed()) - return; - enter.functions()->SessionReady(instance, web_session_id); -} - -void SessionClosed(PP_Instance instance, struct PP_Var web_session_id) { +void SessionClosed(PP_Instance instance, struct PP_Var session_id) { VLOG(4) << "PPB_ContentDecryptor_Private::SessionClosed()"; EnterInstance enter(instance); if (enter.failed()) return; - enter.functions()->SessionClosed(instance, web_session_id); + enter.functions()->SessionClosed(instance, session_id); } -void SessionError(PP_Instance instance, - struct PP_Var web_session_id, - PP_CdmExceptionCode exception_code, - uint32_t system_code, - struct PP_Var error_description) { - VLOG(4) << "PPB_ContentDecryptor_Private::SessionError()"; +void LegacySessionError(PP_Instance instance, + struct PP_Var session_id, + PP_CdmExceptionCode exception_code, + uint32_t system_code, + struct PP_Var error_description) { + VLOG(4) << "PPB_ContentDecryptor_Private::LegacySessionError()"; EnterInstance enter(instance); if (enter.failed()) return; - enter.functions()->SessionError(instance, web_session_id, exception_code, - system_code, error_description); + enter.functions()->LegacySessionError(instance, session_id, exception_code, + system_code, error_description); } void DeliverBlock(PP_Instance instance, @@ -189,17 +174,15 @@ void DeliverSamples( decrypted_sample_info); } -const PPB_ContentDecryptor_Private_0_12 - g_ppb_contentdecryptor_private_thunk_0_12 = {&PromiseResolved, +const PPB_ContentDecryptor_Private_0_14 + g_ppb_contentdecryptor_private_thunk_0_14 = {&PromiseResolved, &PromiseResolvedWithSession, - &PromiseResolvedWithKeyIds, &PromiseRejected, &SessionMessage, &SessionKeysChange, &SessionExpirationChange, - &SessionReady, &SessionClosed, - &SessionError, + &LegacySessionError, &DeliverBlock, &DecoderInitializeDone, &DecoderDeinitializeDone, @@ -209,9 +192,9 @@ const PPB_ContentDecryptor_Private_0_12 } // namespace -PPAPI_THUNK_EXPORT const PPB_ContentDecryptor_Private_0_12* -GetPPB_ContentDecryptor_Private_0_12_Thunk() { - return &g_ppb_contentdecryptor_private_thunk_0_12; +PPAPI_THUNK_EXPORT const PPB_ContentDecryptor_Private_0_14* +GetPPB_ContentDecryptor_Private_0_14_Thunk() { + return &g_ppb_contentdecryptor_private_thunk_0_14; } } // namespace thunk diff --git a/chromium/ppapi/thunk/ppb_file_chooser_dev_thunk.cc b/chromium/ppapi/thunk/ppb_file_chooser_dev_thunk.cc index e0d824b7709..d41d87bec82 100644 --- a/chromium/ppapi/thunk/ppb_file_chooser_dev_thunk.cc +++ b/chromium/ppapi/thunk/ppb_file_chooser_dev_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. -// From dev/ppb_file_chooser_dev.idl modified Mon May 6 10:11:29 2013. +// From dev/ppb_file_chooser_dev.idl modified Fri Feb 7 08:29:41 2014. #include "ppapi/c/dev/ppb_file_chooser_dev.h" #include "ppapi/c/pp_completion_callback.h" @@ -34,7 +34,7 @@ PP_Bool IsFileChooser(PP_Resource resource) { } int32_t Show_0_5(PP_Resource chooser, struct PP_CompletionCallback callback) { - VLOG(4) << "PPB_FileChooser_Dev::Show()"; + VLOG(4) << "PPB_FileChooser_Dev::Show_0_5()"; EnterResource<PPB_FileChooser_API> enter(chooser, callback, true); if (enter.failed()) return enter.retval(); diff --git a/chromium/ppapi/thunk/ppb_file_chooser_trusted_thunk.cc b/chromium/ppapi/thunk/ppb_file_chooser_trusted_thunk.cc index b1a3ad72d13..2d95be6cb32 100644 --- a/chromium/ppapi/thunk/ppb_file_chooser_trusted_thunk.cc +++ b/chromium/ppapi/thunk/ppb_file_chooser_trusted_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. -// From trusted/ppb_file_chooser_trusted.idl modified Mon May 6 10:11:29 2013. +// From trusted/ppb_file_chooser_trusted.idl modified Fri Feb 7 08:29:41 2014. #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" @@ -21,7 +21,7 @@ int32_t ShowWithoutUserGesture_0_5(PP_Resource chooser, PP_Bool save_as, struct PP_Var suggested_file_name, struct PP_CompletionCallback callback) { - VLOG(4) << "PPB_FileChooserTrusted::ShowWithoutUserGesture()"; + VLOG(4) << "PPB_FileChooserTrusted::ShowWithoutUserGesture_0_5()"; EnterResource<PPB_FileChooser_API> enter(chooser, callback, true); if (enter.failed()) return enter.retval(); diff --git a/chromium/ppapi/thunk/ppb_file_mapping_api.h b/chromium/ppapi/thunk/ppb_file_mapping_api.h deleted file mode 100644 index 530d04b61af..00000000000 --- a/chromium/ppapi/thunk/ppb_file_mapping_api.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2014 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_THUNK_PPB_FILE_MAPPING_API_H_ -#define PPAPI_THUNK_PPB_FILE_MAPPING_API_H_ - -#include "base/basictypes.h" -#include "base/memory/ref_counted.h" -#include "ppapi/c/pp_instance.h" -#include "ppapi/c/ppb_file_mapping.h" -#include "ppapi/shared_impl/singleton_resource_id.h" -#include "ppapi/thunk/ppapi_thunk_export.h" - -namespace ppapi { - -class TrackedCallback; - -namespace thunk { - -class PPAPI_THUNK_EXPORT PPB_FileMapping_API { - public: - virtual ~PPB_FileMapping_API() {} - - virtual int32_t Map(PP_Instance instance, - PP_Resource file_io, - int64_t length, - uint32_t map_protection, - uint32_t map_flags, - int64_t offset, - void** address, - scoped_refptr<TrackedCallback> callback) = 0; - virtual int32_t Unmap(PP_Instance instance, - const void* address, - int64_t length, - scoped_refptr<TrackedCallback> callback) = 0; - virtual int64_t GetMapPageSize(PP_Instance instance) = 0; - - static const SingletonResourceID kSingletonResourceID = - FILE_MAPPING_SINGLETON_ID; -}; - -} // namespace thunk -} // namespace ppapi - -#endif // PPAPI_THUNK_PPB_FILE_MAPPING_API_H_ diff --git a/chromium/ppapi/thunk/ppb_file_mapping_thunk.cc b/chromium/ppapi/thunk/ppb_file_mapping_thunk.cc deleted file mode 100644 index 627b497b845..00000000000 --- a/chromium/ppapi/thunk/ppb_file_mapping_thunk.cc +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// From ppb_file_mapping.idl modified Mon Apr 7 08:55:47 2014. - -#include "ppapi/c/pp_completion_callback.h" -#include "ppapi/c/pp_errors.h" -#include "ppapi/c/ppb_file_mapping.h" -#include "ppapi/shared_impl/tracked_callback.h" -#include "ppapi/thunk/enter.h" -#include "ppapi/thunk/ppapi_thunk_export.h" -#include "ppapi/thunk/ppb_file_mapping_api.h" - -namespace ppapi { -namespace thunk { - -namespace { - -int32_t Map(PP_Instance instance, - PP_Resource file_io, - int64_t length, - uint32_t map_protection, - uint32_t map_flags, - int64_t offset, - void** address, - struct PP_CompletionCallback callback) { - VLOG(4) << "PPB_FileMapping::Map()"; - EnterInstanceAPI<PPB_FileMapping_API> enter(instance, callback); - if (enter.failed()) - return enter.retval(); - return enter.SetResult( - enter.functions()->Map(instance, file_io, length, map_protection, - map_flags, offset, address, enter.callback())); -} - -int32_t Unmap(PP_Instance instance, - const void* address, - int64_t length, - struct PP_CompletionCallback callback) { - VLOG(4) << "PPB_FileMapping::Unmap()"; - EnterInstanceAPI<PPB_FileMapping_API> enter(instance, callback); - if (enter.failed()) - return enter.retval(); - return enter.SetResult( - enter.functions()->Unmap(instance, address, length, enter.callback())); -} - -int64_t GetMapPageSize(PP_Instance instance) { - VLOG(4) << "PPB_FileMapping::GetMapPageSize()"; - EnterInstanceAPI<PPB_FileMapping_API> enter(instance); - if (enter.failed()) - return 0; - return enter.functions()->GetMapPageSize(instance); -} - -const PPB_FileMapping_0_1 g_ppb_filemapping_thunk_0_1 = {&Map, - &Unmap, - &GetMapPageSize}; - -} // namespace - -PPAPI_THUNK_EXPORT const PPB_FileMapping_0_1* GetPPB_FileMapping_0_1_Thunk() { - return &g_ppb_filemapping_thunk_0_1; -} - -} // namespace thunk -} // namespace ppapi diff --git a/chromium/ppapi/thunk/ppb_image_capture_config_private_thunk.cc b/chromium/ppapi/thunk/ppb_image_capture_config_private_thunk.cc deleted file mode 100644 index 98f2900cca0..00000000000 --- a/chromium/ppapi/thunk/ppb_image_capture_config_private_thunk.cc +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// From private/ppb_image_capture_config_private.idl modified Wed Nov 5 -// 14:29:15 2014. - -#include "ppapi/c/pp_errors.h" -#include "ppapi/c/private/ppb_image_capture_config_private.h" -#include "ppapi/shared_impl/tracked_callback.h" -#include "ppapi/thunk/enter.h" -#include "ppapi/thunk/ppapi_thunk_export.h" -#include "ppapi/thunk/ppb_image_capture_config_api.h" - -namespace ppapi { -namespace thunk { - -namespace { - -PP_Resource Create(PP_Instance instance) { - VLOG(4) << "PPB_ImageCaptureConfig_Private::Create()"; - EnterResourceCreation enter(instance); - if (enter.failed()) - return 0; - return enter.functions()->CreateImageCaptureConfigPrivate(instance); -} - -PP_Bool IsImageCaptureConfig(PP_Resource resource) { - VLOG(4) << "PPB_ImageCaptureConfig_Private::IsImageCaptureConfig()"; - EnterResource<PPB_ImageCaptureConfig_API> enter(resource, false); - return PP_FromBool(enter.succeeded()); -} - -void GetPreviewSize(PP_Resource config, struct PP_Size* preview_size) { - VLOG(4) << "PPB_ImageCaptureConfig_Private::GetPreviewSize()"; - EnterResource<PPB_ImageCaptureConfig_API> enter(config, true); - if (enter.failed()) - return; - enter.object()->GetPreviewSize(preview_size); -} - -void SetPreviewSize(PP_Resource config, const struct PP_Size* preview_size) { - VLOG(4) << "PPB_ImageCaptureConfig_Private::SetPreviewSize()"; - EnterResource<PPB_ImageCaptureConfig_API> enter(config, true); - if (enter.failed()) - return; - enter.object()->SetPreviewSize(preview_size); -} - -void GetJpegSize(PP_Resource config, struct PP_Size* jpeg_size) { - VLOG(4) << "PPB_ImageCaptureConfig_Private::GetJpegSize()"; - EnterResource<PPB_ImageCaptureConfig_API> enter(config, true); - if (enter.failed()) - return; - enter.object()->GetJpegSize(jpeg_size); -} - -void SetJpegSize(PP_Resource config, const struct PP_Size* jpeg_size) { - VLOG(4) << "PPB_ImageCaptureConfig_Private::SetJpegSize()"; - EnterResource<PPB_ImageCaptureConfig_API> enter(config, true); - if (enter.failed()) - return; - enter.object()->SetJpegSize(jpeg_size); -} - -const PPB_ImageCaptureConfig_Private_0_1 - g_ppb_imagecaptureconfig_private_thunk_0_1 = {&Create, - &IsImageCaptureConfig, - &GetPreviewSize, - &SetPreviewSize, - &GetJpegSize, - &SetJpegSize}; - -} // namespace - -PPAPI_THUNK_EXPORT const PPB_ImageCaptureConfig_Private_0_1* -GetPPB_ImageCaptureConfig_Private_0_1_Thunk() { - return &g_ppb_imagecaptureconfig_private_thunk_0_1; -} - -} // namespace thunk -} // namespace ppapi diff --git a/chromium/ppapi/thunk/ppb_image_capture_private_thunk.cc b/chromium/ppapi/thunk/ppb_image_capture_private_thunk.cc deleted file mode 100644 index ae88783cf5a..00000000000 --- a/chromium/ppapi/thunk/ppb_image_capture_private_thunk.cc +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// From private/ppb_image_capture_private.idl modified Wed Nov 5 14:29:15 2014. - -#include "ppapi/c/pp_completion_callback.h" -#include "ppapi/c/pp_errors.h" -#include "ppapi/c/private/ppb_image_capture_private.h" -#include "ppapi/shared_impl/tracked_callback.h" -#include "ppapi/thunk/enter.h" -#include "ppapi/thunk/ppapi_thunk_export.h" -#include "ppapi/thunk/ppb_image_capture_api.h" - -namespace ppapi { -namespace thunk { - -namespace { - -PP_Resource Create(PP_Instance instance, - struct PP_Var camera_source_id, - PPB_ImageCapture_Private_ErrorCallback error_callback, - void* user_data) { - VLOG(4) << "PPB_ImageCapture_Private::Create()"; - EnterResourceCreation enter(instance); - if (enter.failed()) - return 0; - return enter.functions()->CreateImageCapturePrivate( - instance, camera_source_id, error_callback, user_data); -} - -PP_Bool IsImageCapture(PP_Resource resource) { - VLOG(4) << "PPB_ImageCapture_Private::IsImageCapture()"; - EnterResource<PPB_ImageCapture_API> enter(resource, false); - return PP_FromBool(enter.succeeded()); -} - -int32_t Close(PP_Resource resource, struct PP_CompletionCallback callback) { - VLOG(4) << "PPB_ImageCapture_Private::Close()"; - EnterResource<PPB_ImageCapture_API> enter(resource, callback, true); - if (enter.failed()) - return enter.retval(); - return enter.SetResult(enter.object()->Close(enter.callback())); -} - -int32_t SetConfig(PP_Resource image_capture, - PP_Resource config, - struct PP_CompletionCallback callback) { - VLOG(4) << "PPB_ImageCapture_Private::SetConfig()"; - EnterResource<PPB_ImageCapture_API> enter(image_capture, callback, true); - if (enter.failed()) - return enter.retval(); - return enter.SetResult(enter.object()->SetConfig(config, enter.callback())); -} - -int32_t GetConfig(PP_Resource image_capture, - PP_Resource* config, - struct PP_CompletionCallback callback) { - VLOG(4) << "PPB_ImageCapture_Private::GetConfig()"; - EnterResource<PPB_ImageCapture_API> enter(image_capture, callback, true); - if (enter.failed()) - return enter.retval(); - return enter.SetResult(enter.object()->GetConfig(config, enter.callback())); -} - -int32_t GetCameraCapabilities(PP_Resource image_capture, - PP_Resource* capabilities, - struct PP_CompletionCallback callback) { - VLOG(4) << "PPB_ImageCapture_Private::GetCameraCapabilities()"; - EnterResource<PPB_ImageCapture_API> enter(image_capture, callback, true); - if (enter.failed()) - return enter.retval(); - return enter.SetResult( - enter.object()->GetCameraCapabilities(capabilities, enter.callback())); -} - -int32_t CaptureStillImage( - PP_Resource image_capture, - PPB_ImageCapture_Private_ShutterCallback shutter_callback, - PPB_ImageCapture_Private_PreviewCallback preview_callback, - PPB_ImageCapture_Private_JpegCallback jpeg_callback, - int64_t* sequence_id) { - VLOG(4) << "PPB_ImageCapture_Private::CaptureStillImage()"; - EnterResource<PPB_ImageCapture_API> enter(image_capture, true); - if (enter.failed()) - return enter.retval(); - return enter.object()->CaptureStillImage(shutter_callback, preview_callback, - jpeg_callback, sequence_id); -} - -const PPB_ImageCapture_Private_0_1 g_ppb_imagecapture_private_thunk_0_1 = { - &Create, - &IsImageCapture, - &Close, - &SetConfig, - &GetConfig, - &GetCameraCapabilities, - &CaptureStillImage}; - -} // namespace - -PPAPI_THUNK_EXPORT const PPB_ImageCapture_Private_0_1* -GetPPB_ImageCapture_Private_0_1_Thunk() { - return &g_ppb_imagecapture_private_thunk_0_1; -} - -} // namespace thunk -} // namespace ppapi diff --git a/chromium/ppapi/thunk/ppb_instance_api.h b/chromium/ppapi/thunk/ppb_instance_api.h index 997c32e4eea..19888c12ea1 100644 --- a/chromium/ppapi/thunk/ppb_instance_api.h +++ b/chromium/ppapi/thunk/ppb_instance_api.h @@ -7,7 +7,6 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "ppapi/c/dev/ppb_messaging_deprecated.h" #include "ppapi/c/dev/ppb_url_util_dev.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" @@ -121,11 +120,6 @@ class PPB_Instance_API { void* user_data, const PPP_MessageHandler_0_2* handler, PP_Resource message_loop) = 0; - virtual int32_t RegisterMessageHandler_1_1_Deprecated( - PP_Instance instance, - void* user_data, - const PPP_MessageHandler_0_1_Deprecated* handler, - PP_Resource message_loop) = 0; virtual void UnregisterMessageHandler(PP_Instance instance) = 0; // Mouse cursor. @@ -165,34 +159,32 @@ class PPB_Instance_API { virtual void PromiseResolved(PP_Instance instance, uint32 promise_id) = 0; virtual void PromiseResolvedWithSession(PP_Instance instance, uint32 promise_id, - PP_Var web_session_id_var) = 0; - virtual void PromiseResolvedWithKeyIds(PP_Instance instance, - uint32 promise_id, - PP_Var key_ids_var) = 0; + PP_Var session_id_var) = 0; virtual void PromiseRejected(PP_Instance instance, uint32 promise_id, PP_CdmExceptionCode exception_code, uint32 system_code, PP_Var error_description_var) = 0; virtual void SessionMessage(PP_Instance instance, - PP_Var web_session_id_var, + PP_Var session_id_var, + PP_CdmMessageType message_type, PP_Var message_var, - PP_Var destination_url_var) = 0; - virtual void SessionKeysChange(PP_Instance instance, - PP_Var web_session_id_var, - PP_Bool has_additional_usable_key) = 0; + PP_Var legacy_destination_url_var) = 0; + virtual void SessionKeysChange( + PP_Instance instance, + PP_Var session_id_var, + PP_Bool has_additional_usable_key, + uint32_t key_count, + const struct PP_KeyInformation key_information[]) = 0; virtual void SessionExpirationChange(PP_Instance instance, - PP_Var web_session_id_var, + PP_Var session_id_var, PP_Time new_expiry_time) = 0; - virtual void SessionReady(PP_Instance instance, - PP_Var web_session_id_var) = 0; - virtual void SessionClosed(PP_Instance instance, - PP_Var web_session_id_var) = 0; - virtual void SessionError(PP_Instance instance, - PP_Var web_session_id_var, - PP_CdmExceptionCode exception_code, - uint32 system_code, - PP_Var error_description_var) = 0; + virtual void SessionClosed(PP_Instance instance, PP_Var session_id_var) = 0; + virtual void LegacySessionError(PP_Instance instance, + PP_Var session_id_var, + PP_CdmExceptionCode exception_code, + uint32 system_code, + PP_Var error_description_var) = 0; virtual void DeliverBlock(PP_Instance instance, PP_Resource decrypted_block, const PP_DecryptedBlockInfo* block_info) = 0; diff --git a/chromium/ppapi/thunk/ppb_messaging_thunk.cc b/chromium/ppapi/thunk/ppb_messaging_thunk.cc index 1d5d0418287..94ba4aa1fba 100644 --- a/chromium/ppapi/thunk/ppb_messaging_thunk.cc +++ b/chromium/ppapi/thunk/ppb_messaging_thunk.cc @@ -2,9 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// From ppb_messaging.idl modified Wed Sep 10 15:41:14 2014. +// From ppb_messaging.idl modified Tue Mar 24 16:53:47 2015. -#include "ppapi/c/dev/ppb_messaging_deprecated.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/ppb_messaging.h" #include "ppapi/shared_impl/tracked_callback.h" @@ -24,32 +23,15 @@ void PostMessage(PP_Instance instance, struct PP_Var message) { enter.functions()->PostMessage(instance, message); } -int32_t RegisterMessageHandler_1_1_Deprecated( - PP_Instance instance, - void* user_data, - const struct PPP_MessageHandler_0_1_Deprecated* handler, - PP_Resource message_loop) { - VLOG(4) << "PPB_Messaging::RegisterMessageHandler_1_1()"; - EnterInstance enter(instance); - if (enter.failed()) - return enter.retval(); - return enter.functions()->RegisterMessageHandler_1_1_Deprecated(instance, - user_data, - handler, - message_loop); -} - -int32_t RegisterMessageHandler_1_2(PP_Instance instance, - void* user_data, - const struct PPP_MessageHandler_0_2* handler, - PP_Resource message_loop) { +int32_t RegisterMessageHandler(PP_Instance instance, + void* user_data, + const struct PPP_MessageHandler_0_2* handler, + PP_Resource message_loop) { VLOG(4) << "PPB_Messaging::RegisterMessageHandler()"; EnterInstance enter(instance); if (enter.failed()) return enter.retval(); - return enter.functions()->RegisterMessageHandler(instance, - user_data, - handler, + return enter.functions()->RegisterMessageHandler(instance, user_data, handler, message_loop); } @@ -61,21 +43,11 @@ void UnregisterMessageHandler(PP_Instance instance) { enter.functions()->UnregisterMessageHandler(instance); } -const PPB_Messaging_1_0 g_ppb_messaging_thunk_1_0 = { - &PostMessage -}; - -const PPB_Messaging_1_1_Deprecated g_ppb_messaging_thunk_1_1_deprecated = { - &PostMessage, - &RegisterMessageHandler_1_1_Deprecated, - &UnregisterMessageHandler -}; +const PPB_Messaging_1_0 g_ppb_messaging_thunk_1_0 = {&PostMessage}; -const PPB_Messaging_1_2 g_ppb_messaging_thunk_1_2 = { - &PostMessage, - &RegisterMessageHandler_1_2, - &UnregisterMessageHandler -}; +const PPB_Messaging_1_2 g_ppb_messaging_thunk_1_2 = {&PostMessage, + &RegisterMessageHandler, + &UnregisterMessageHandler}; } // namespace @@ -83,11 +55,6 @@ PPAPI_THUNK_EXPORT const PPB_Messaging_1_0* GetPPB_Messaging_1_0_Thunk() { return &g_ppb_messaging_thunk_1_0; } -PPAPI_THUNK_EXPORT -const PPB_Messaging_1_1_Deprecated* GetPPB_Messaging_1_1_Deprecated_Thunk() { - return &g_ppb_messaging_thunk_1_1_deprecated; -} - PPAPI_THUNK_EXPORT const PPB_Messaging_1_2* GetPPB_Messaging_1_2_Thunk() { return &g_ppb_messaging_thunk_1_2; } diff --git a/chromium/ppapi/thunk/ppb_pdf_api.h b/chromium/ppapi/thunk/ppb_pdf_api.h index a37da2b66a2..8e0f4b0b3de 100644 --- a/chromium/ppapi/thunk/ppb_pdf_api.h +++ b/chromium/ppapi/thunk/ppb_pdf_api.h @@ -34,6 +34,10 @@ class PPB_PDF_API { virtual PP_Bool IsOutOfProcess() = 0; virtual void SetSelectedText(const char* selected_text) = 0; virtual void SetLinkUnderCursor(const char* url) = 0; + virtual void GetV8ExternalSnapshotData(const char** natives_data_out, + int* natives_size_out, + const char** snapshot_data_out, + int* snapshot_size_out) = 0; static const SingletonResourceID kSingletonResourceID = PDF_SINGLETON_ID; }; diff --git a/chromium/ppapi/thunk/ppb_pdf_thunk.cc b/chromium/ppapi/thunk/ppb_pdf_thunk.cc index a8aa0806b17..fb06a90fe2b 100644 --- a/chromium/ppapi/thunk/ppb_pdf_thunk.cc +++ b/chromium/ppapi/thunk/ppb_pdf_thunk.cc @@ -161,6 +161,18 @@ void SetLinkUnderCursor(PP_Instance instance, const char* url) { enter.functions()->SetLinkUnderCursor(url); } +void GetV8ExternalSnapshotData(PP_Instance instance, + const char** natives_data_out, + int* natives_size_out, + const char** snapshot_data_out, + int* snapshot_size_out) { + EnterInstanceAPI<PPB_PDF_API> enter(instance); + if (enter.failed()) + return; + enter.functions()->GetV8ExternalSnapshotData(natives_data_out, + natives_size_out, snapshot_data_out, snapshot_size_out); +} + const PPB_PDF g_ppb_pdf_thunk = { &GetLocalizedString, &GetResourceImage, @@ -181,6 +193,7 @@ const PPB_PDF g_ppb_pdf_thunk = { &IsOutOfProcess, &SetSelectedText, &SetLinkUnderCursor, + &GetV8ExternalSnapshotData, }; } // namespace diff --git a/chromium/ppapi/thunk/ppb_talk_private_api.h b/chromium/ppapi/thunk/ppb_talk_private_api.h deleted file mode 100644 index a31cf9dcc14..00000000000 --- a/chromium/ppapi/thunk/ppb_talk_private_api.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef PPAPI_THUNK_PPB_TALK_PRIVATE_API_H_ -#define PPAPI_THUNK_PPB_TALK_PRIVATE_API_H_ - -#include "base/memory/ref_counted.h" -#include "ppapi/c/private/ppb_talk_private.h" -#include "ppapi/thunk/ppapi_thunk_export.h" - -namespace ppapi { - -class TrackedCallback; - -namespace thunk { - -class PPAPI_THUNK_EXPORT PPB_Talk_Private_API { - public: - virtual ~PPB_Talk_Private_API() {} - - virtual int32_t RequestPermission( - PP_TalkPermission permission, - scoped_refptr<TrackedCallback> callback) = 0; - virtual int32_t StartRemoting( - PP_TalkEventCallback event_callback, - void* user_data, - scoped_refptr<TrackedCallback> callback) = 0; - virtual int32_t StopRemoting( - scoped_refptr<TrackedCallback> callback) = 0; -}; - -} // namespace thunk -} // namespace ppapi - -#endif // PPAPI_THUNK_PPB_TALK_PRIVATE_API_H_ diff --git a/chromium/ppapi/thunk/ppb_talk_private_thunk.cc b/chromium/ppapi/thunk/ppb_talk_private_thunk.cc deleted file mode 100644 index 6d2325de6eb..00000000000 --- a/chromium/ppapi/thunk/ppb_talk_private_thunk.cc +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/c/pp_errors.h" -#include "ppapi/c/private/ppb_talk_private.h" -#include "ppapi/shared_impl/tracked_callback.h" -#include "ppapi/thunk/enter.h" -#include "ppapi/thunk/ppb_talk_private_api.h" -#include "ppapi/thunk/thunk.h" - -namespace ppapi { -namespace thunk { - -namespace { - -PP_Resource Create(PP_Instance instance) { - EnterResourceCreation enter(instance); - if (enter.failed()) - return 0; - return enter.functions()->CreateTalk(instance); -} - -int32_t GetPermission(PP_Resource resource, - PP_CompletionCallback callback) { - EnterResource<PPB_Talk_Private_API> enter(resource, callback, true); - if (enter.failed()) - return PP_ERROR_BADRESOURCE; - return enter.SetResult(enter.object()->RequestPermission( - PP_TALKPERMISSION_SCREENCAST, enter.callback())); -} - -int32_t RequestPermission(PP_Resource resource, - PP_TalkPermission permission, - PP_CompletionCallback callback) { - EnterResource<PPB_Talk_Private_API> enter(resource, callback, true); - if (enter.failed()) - return PP_ERROR_BADRESOURCE; - return enter.SetResult( - enter.object()->RequestPermission(permission, enter.callback())); -} - -int32_t StartRemoting(PP_Resource resource, - PP_TalkEventCallback event_callback, - void* user_data, - PP_CompletionCallback callback) { - EnterResource<PPB_Talk_Private_API> enter(resource, callback, true); - if (enter.failed()) - return PP_ERROR_BADRESOURCE; - return enter.SetResult( - enter.object()->StartRemoting(event_callback, user_data, - enter.callback())); -} - -int32_t StopRemoting(PP_Resource resource, - PP_CompletionCallback callback) { - EnterResource<PPB_Talk_Private_API> enter(resource, callback, true); - if (enter.failed()) - return PP_ERROR_BADRESOURCE; - return enter.SetResult( - enter.object()->StopRemoting(enter.callback())); -} - -const PPB_Talk_Private_1_0 g_ppb_talk_private_thunk_1_0 = { - &Create, - &GetPermission -}; - -const PPB_Talk_Private_2_0 g_ppb_talk_private_thunk_2_0 = { - &Create, - &RequestPermission, - &StartRemoting, - &StopRemoting -}; - -} // namespace - -const PPB_Talk_Private_1_0* GetPPB_Talk_Private_1_0_Thunk() { - return &g_ppb_talk_private_thunk_1_0; -} - -const PPB_Talk_Private_2_0* GetPPB_Talk_Private_2_0_Thunk() { - return &g_ppb_talk_private_thunk_2_0; -} - -} // namespace thunk -} // namespace ppapi diff --git a/chromium/ppapi/thunk/ppb_tcp_socket_api.h b/chromium/ppapi/thunk/ppb_tcp_socket_api.h index beed0c6317a..a3cefed2e3f 100644 --- a/chromium/ppapi/thunk/ppb_tcp_socket_api.h +++ b/chromium/ppapi/thunk/ppb_tcp_socket_api.h @@ -36,6 +36,9 @@ class PPAPI_THUNK_EXPORT PPB_TCPSocket_API { virtual int32_t Accept(PP_Resource* accepted_tcp_socket, scoped_refptr<TrackedCallback> callback) = 0; virtual void Close() = 0; + virtual int32_t SetOption1_1(PP_TCPSocket_Option name, + const PP_Var& value, + scoped_refptr<TrackedCallback> callback) = 0; virtual int32_t SetOption(PP_TCPSocket_Option name, const PP_Var& value, scoped_refptr<TrackedCallback> callback) = 0; diff --git a/chromium/ppapi/thunk/ppb_tcp_socket_thunk.cc b/chromium/ppapi/thunk/ppb_tcp_socket_thunk.cc index 42ae702e5e3..c73e593f520 100644 --- a/chromium/ppapi/thunk/ppb_tcp_socket_thunk.cc +++ b/chromium/ppapi/thunk/ppb_tcp_socket_thunk.cc @@ -132,6 +132,19 @@ void Close(PP_Resource tcp_socket) { enter.object()->Close(); } +int32_t SetOption1_1(PP_Resource tcp_socket, + PP_TCPSocket_Option name, + struct PP_Var value, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_TCPSocket::SetOption1_1()"; + EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->SetOption1_1(name, + value, + enter.callback())); +} + int32_t SetOption(PP_Resource tcp_socket, PP_TCPSocket_Option name, struct PP_Var value, @@ -154,7 +167,7 @@ const PPB_TCPSocket_1_0 g_ppb_tcpsocket_thunk_1_0 = { &Read, &Write, &Close, - &SetOption + &SetOption1_1 }; const PPB_TCPSocket_1_1 g_ppb_tcpsocket_thunk_1_1 = { @@ -169,6 +182,21 @@ const PPB_TCPSocket_1_1 g_ppb_tcpsocket_thunk_1_1 = { &Listen, &Accept, &Close, + &SetOption1_1 +}; + +const PPB_TCPSocket_1_2 g_ppb_tcpsocket_thunk_1_2 = { + &Create, + &IsTCPSocket, + &Bind, + &Connect, + &GetLocalAddress, + &GetRemoteAddress, + &Read, + &Write, + &Listen, + &Accept, + &Close, &SetOption }; @@ -182,5 +210,9 @@ const PPB_TCPSocket_1_1* GetPPB_TCPSocket_1_1_Thunk() { return &g_ppb_tcpsocket_thunk_1_1; } +const PPB_TCPSocket_1_2* GetPPB_TCPSocket_1_2_Thunk() { + return &g_ppb_tcpsocket_thunk_1_2; +} + } // namespace thunk } // namespace ppapi diff --git a/chromium/ppapi/thunk/ppb_text_input_thunk.cc b/chromium/ppapi/thunk/ppb_text_input_thunk.cc index a59146bd1f7..06c9cd671f3 100644 --- a/chromium/ppapi/thunk/ppb_text_input_thunk.cc +++ b/chromium/ppapi/thunk/ppb_text_input_thunk.cc @@ -15,26 +15,18 @@ namespace thunk { namespace { -COMPILE_ASSERT(int(PP_TEXTINPUT_TYPE_DEV_NONE) == int(PP_TEXTINPUT_TYPE_NONE), - mismatching_enums); -COMPILE_ASSERT(int(PP_TEXTINPUT_TYPE_DEV_TEXT) == int(PP_TEXTINPUT_TYPE_TEXT), - mismatching_enums); -COMPILE_ASSERT( - int(PP_TEXTINPUT_TYPE_DEV_PASSWORD) == int(PP_TEXTINPUT_TYPE_PASSWORD), - mismatching_enums); -COMPILE_ASSERT( - int(PP_TEXTINPUT_TYPE_DEV_SEARCH) == int(PP_TEXTINPUT_TYPE_SEARCH), - mismatching_enums); -COMPILE_ASSERT(int(PP_TEXTINPUT_TYPE_DEV_EMAIL) == int(PP_TEXTINPUT_TYPE_EMAIL), - mismatching_enums); -COMPILE_ASSERT( - int(PP_TEXTINPUT_TYPE_DEV_NUMBER) == int(PP_TEXTINPUT_TYPE_NUMBER), - mismatching_enums); -COMPILE_ASSERT( - int(PP_TEXTINPUT_TYPE_DEV_TELEPHONE) == int(PP_TEXTINPUT_TYPE_TELEPHONE), - mismatching_enums); -COMPILE_ASSERT(int(PP_TEXTINPUT_TYPE_DEV_URL) == int(PP_TEXTINPUT_TYPE_URL), - mismatching_enums); +#define STATIC_ASSERT_ENUM(a, b) \ + static_assert(int(a) == int(b), "mismatching enum values: " #a) + +STATIC_ASSERT_ENUM(PP_TEXTINPUT_TYPE_DEV_NONE, PP_TEXTINPUT_TYPE_NONE); +STATIC_ASSERT_ENUM(PP_TEXTINPUT_TYPE_DEV_TEXT, PP_TEXTINPUT_TYPE_TEXT); +STATIC_ASSERT_ENUM(PP_TEXTINPUT_TYPE_DEV_PASSWORD, PP_TEXTINPUT_TYPE_PASSWORD); +STATIC_ASSERT_ENUM(PP_TEXTINPUT_TYPE_DEV_SEARCH, PP_TEXTINPUT_TYPE_SEARCH); +STATIC_ASSERT_ENUM(PP_TEXTINPUT_TYPE_DEV_EMAIL, PP_TEXTINPUT_TYPE_EMAIL); +STATIC_ASSERT_ENUM(PP_TEXTINPUT_TYPE_DEV_NUMBER, PP_TEXTINPUT_TYPE_NUMBER); +STATIC_ASSERT_ENUM(PP_TEXTINPUT_TYPE_DEV_TELEPHONE, + PP_TEXTINPUT_TYPE_TELEPHONE); +STATIC_ASSERT_ENUM(PP_TEXTINPUT_TYPE_DEV_URL, PP_TEXTINPUT_TYPE_URL); void SetTextInputType(PP_Instance instance, PP_TextInput_Type type) { EnterInstance enter(instance); diff --git a/chromium/ppapi/thunk/ppb_udp_socket_api.h b/chromium/ppapi/thunk/ppb_udp_socket_api.h index adc2799116f..028c562eb50 100644 --- a/chromium/ppapi/thunk/ppb_udp_socket_api.h +++ b/chromium/ppapi/thunk/ppb_udp_socket_api.h @@ -31,9 +31,19 @@ class PPAPI_THUNK_EXPORT PPB_UDPSocket_API { PP_Resource addr, scoped_refptr<TrackedCallback> callback) = 0; virtual void Close() = 0; + virtual int32_t SetOption1_0(PP_UDPSocket_Option name, + const PP_Var& value, + scoped_refptr<TrackedCallback> callback) = 0; + virtual int32_t SetOption1_1(PP_UDPSocket_Option name, + const PP_Var& value, + scoped_refptr<TrackedCallback> callback) = 0; virtual int32_t SetOption(PP_UDPSocket_Option name, const PP_Var& value, scoped_refptr<TrackedCallback> callback) = 0; + virtual int32_t JoinGroup(PP_Resource group, + scoped_refptr<TrackedCallback> callback) = 0; + virtual int32_t LeaveGroup(PP_Resource group, + scoped_refptr<TrackedCallback> callback) = 0; }; } // namespace thunk diff --git a/chromium/ppapi/thunk/ppb_udp_socket_thunk.cc b/chromium/ppapi/thunk/ppb_udp_socket_thunk.cc index 7391526f682..f0d3ceeb5fa 100644 --- a/chromium/ppapi/thunk/ppb_udp_socket_thunk.cc +++ b/chromium/ppapi/thunk/ppb_udp_socket_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. -// From ppb_udp_socket.idl modified Mon Jun 24 15:10:54 2013. +// From ppb_udp_socket.idl modified Fri Mar 13 17:49:57 2015. #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" @@ -83,6 +83,30 @@ void Close(PP_Resource udp_socket) { enter.object()->Close(); } +int32_t SetOption_1_0(PP_Resource udp_socket, + PP_UDPSocket_Option name, + struct PP_Var value, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_UDPSocket::SetOption_1_0()"; + EnterResource<PPB_UDPSocket_API> enter(udp_socket, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult( + enter.object()->SetOption1_0(name, value, enter.callback())); +} + +int32_t SetOption_1_1(PP_Resource udp_socket, + PP_UDPSocket_Option name, + struct PP_Var value, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_UDPSocket::SetOption_1_1()"; + EnterResource<PPB_UDPSocket_API> enter(udp_socket, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult( + enter.object()->SetOption1_1(name, value, enter.callback())); +} + int32_t SetOption(PP_Resource udp_socket, PP_UDPSocket_Option name, struct PP_Var value, @@ -95,6 +119,26 @@ int32_t SetOption(PP_Resource udp_socket, enter.object()->SetOption(name, value, enter.callback())); } +int32_t JoinGroup(PP_Resource udp_socket, + PP_Resource group, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_UDPSocket::JoinGroup()"; + EnterResource<PPB_UDPSocket_API> enter(udp_socket, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->JoinGroup(group, enter.callback())); +} + +int32_t LeaveGroup(PP_Resource udp_socket, + PP_Resource group, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_UDPSocket::LeaveGroup()"; + EnterResource<PPB_UDPSocket_API> enter(udp_socket, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->LeaveGroup(group, enter.callback())); +} + const PPB_UDPSocket_1_0 g_ppb_udpsocket_thunk_1_0 = {&Create, &IsUDPSocket, &Bind, @@ -102,7 +146,27 @@ const PPB_UDPSocket_1_0 g_ppb_udpsocket_thunk_1_0 = {&Create, &RecvFrom, &SendTo, &Close, - &SetOption}; + &SetOption_1_0}; + +const PPB_UDPSocket_1_1 g_ppb_udpsocket_thunk_1_1 = {&Create, + &IsUDPSocket, + &Bind, + &GetBoundAddress, + &RecvFrom, + &SendTo, + &Close, + &SetOption_1_1}; + +const PPB_UDPSocket_1_2 g_ppb_udpsocket_thunk_1_2 = {&Create, + &IsUDPSocket, + &Bind, + &GetBoundAddress, + &RecvFrom, + &SendTo, + &Close, + &SetOption, + &JoinGroup, + &LeaveGroup}; } // namespace @@ -110,5 +174,13 @@ PPAPI_THUNK_EXPORT const PPB_UDPSocket_1_0* GetPPB_UDPSocket_1_0_Thunk() { return &g_ppb_udpsocket_thunk_1_0; } +PPAPI_THUNK_EXPORT const PPB_UDPSocket_1_1* GetPPB_UDPSocket_1_1_Thunk() { + return &g_ppb_udpsocket_thunk_1_1; +} + +PPAPI_THUNK_EXPORT const PPB_UDPSocket_1_2* GetPPB_UDPSocket_1_2_Thunk() { + return &g_ppb_udpsocket_thunk_1_2; +} + } // namespace thunk } // namespace ppapi diff --git a/chromium/ppapi/thunk/ppb_video_decoder_thunk.cc b/chromium/ppapi/thunk/ppb_video_decoder_thunk.cc index 14bd55a083f..511e35a745e 100644 --- a/chromium/ppapi/thunk/ppb_video_decoder_thunk.cc +++ b/chromium/ppapi/thunk/ppb_video_decoder_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. -// From ppb_video_decoder.idl modified Fri Nov 7 14:49:08 2014. +// From ppb_video_decoder.idl modified Thu Jan 29 16:28:15 2015. #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" @@ -36,7 +36,7 @@ int32_t Initialize_0_1(PP_Resource video_decoder, PP_VideoProfile profile, PP_Bool allow_software_fallback, struct PP_CompletionCallback callback) { - VLOG(4) << "PPB_VideoDecoder::Initialize()"; + VLOG(4) << "PPB_VideoDecoder::Initialize_0_1()"; EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true); if (enter.failed()) return enter.retval(); @@ -73,7 +73,7 @@ int32_t Decode(PP_Resource video_decoder, int32_t GetPicture_0_1(PP_Resource video_decoder, struct PP_VideoPicture_0_1* picture, struct PP_CompletionCallback callback) { - VLOG(4) << "PPB_VideoDecoder::GetPicture()"; + VLOG(4) << "PPB_VideoDecoder::GetPicture_0_1()"; EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true); if (enter.failed()) return enter.retval(); diff --git a/chromium/ppapi/thunk/ppb_video_encoder_api.h b/chromium/ppapi/thunk/ppb_video_encoder_api.h new file mode 100644 index 00000000000..cf9b9fa6d69 --- /dev/null +++ b/chromium/ppapi/thunk/ppb_video_encoder_api.h @@ -0,0 +1,56 @@ +// Copyright 2015 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_THUNK_PPB_VIDEO_ENCODER_API_H_ +#define PPAPI_THUNK_PPB_VIDEO_ENCODER_API_H_ + +#include "ppapi/c/pp_codecs.h" +#include "ppapi/c/ppb_video_encoder.h" +#include "ppapi/thunk/ppapi_thunk_export.h" + +namespace ppapi { + +class TrackedCallback; + +namespace thunk { + +class PPAPI_THUNK_EXPORT PPB_VideoEncoder_API { + public: + virtual ~PPB_VideoEncoder_API() {} + + virtual int32_t GetSupportedProfiles( + const PP_ArrayOutput& output, + const scoped_refptr<TrackedCallback>& callback) = 0; + virtual int32_t GetSupportedProfiles0_1( + const PP_ArrayOutput& output, + const scoped_refptr<TrackedCallback>& callback) = 0; + virtual int32_t Initialize( + PP_VideoFrame_Format input_format, + const PP_Size* input_visible_size, + PP_VideoProfile output_profile, + uint32_t initial_bitrate, + PP_HardwareAcceleration acceleration, + const scoped_refptr<TrackedCallback>& callback) = 0; + virtual int32_t GetFramesRequired() = 0; + virtual int32_t GetFrameCodedSize(PP_Size* size) = 0; + virtual int32_t GetVideoFrame( + PP_Resource* video_frame, + const scoped_refptr<TrackedCallback>& callback) = 0; + virtual int32_t Encode(PP_Resource video_frame, + PP_Bool force_keyframe, + const scoped_refptr<TrackedCallback>& callback) = 0; + virtual int32_t GetBitstreamBuffer( + PP_BitstreamBuffer* bitstream_buffer, + const scoped_refptr<TrackedCallback>& callback) = 0; + virtual void RecycleBitstreamBuffer( + const PP_BitstreamBuffer* bitstream_buffer) = 0; + virtual void RequestEncodingParametersChange(uint32_t bitrate, + uint32_t framerate) = 0; + virtual void Close() = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_PPB_VIDEO_ENCODER_API_H_ diff --git a/chromium/ppapi/thunk/ppb_video_encoder_thunk.cc b/chromium/ppapi/thunk/ppb_video_encoder_thunk.cc new file mode 100644 index 00000000000..19d93b1dfc6 --- /dev/null +++ b/chromium/ppapi/thunk/ppb_video_encoder_thunk.cc @@ -0,0 +1,192 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// From ppb_video_encoder.idl modified Fri Apr 17 10:38:38 2015. + +#include "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/ppb_video_encoder.h" +#include "ppapi/shared_impl/tracked_callback.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppapi_thunk_export.h" +#include "ppapi/thunk/ppb_video_encoder_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Resource Create(PP_Instance instance) { + VLOG(4) << "PPB_VideoEncoder::Create()"; + EnterResourceCreation enter(instance); + if (enter.failed()) + return 0; + return enter.functions()->CreateVideoEncoder(instance); +} + +PP_Bool IsVideoEncoder(PP_Resource resource) { + VLOG(4) << "PPB_VideoEncoder::IsVideoEncoder()"; + EnterResource<PPB_VideoEncoder_API> enter(resource, false); + return PP_FromBool(enter.succeeded()); +} + +int32_t GetSupportedProfiles_0_1(PP_Resource video_encoder, + struct PP_ArrayOutput output, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_VideoEncoder::GetSupportedProfiles_0_1()"; + EnterResource<PPB_VideoEncoder_API> enter(video_encoder, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult( + enter.object()->GetSupportedProfiles0_1(output, enter.callback())); +} + +int32_t GetSupportedProfiles(PP_Resource video_encoder, + struct PP_ArrayOutput output, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_VideoEncoder::GetSupportedProfiles()"; + EnterResource<PPB_VideoEncoder_API> enter(video_encoder, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult( + enter.object()->GetSupportedProfiles(output, enter.callback())); +} + +int32_t Initialize(PP_Resource video_encoder, + PP_VideoFrame_Format input_format, + const struct PP_Size* input_visible_size, + PP_VideoProfile output_profile, + uint32_t initial_bitrate, + PP_HardwareAcceleration acceleration, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_VideoEncoder::Initialize()"; + EnterResource<PPB_VideoEncoder_API> enter(video_encoder, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->Initialize(input_format, + input_visible_size, + output_profile, + initial_bitrate, + acceleration, + enter.callback())); +} + +int32_t GetFramesRequired(PP_Resource video_encoder) { + VLOG(4) << "PPB_VideoEncoder::GetFramesRequired()"; + EnterResource<PPB_VideoEncoder_API> enter(video_encoder, true); + if (enter.failed()) + return enter.retval(); + return enter.object()->GetFramesRequired(); +} + +int32_t GetFrameCodedSize(PP_Resource video_encoder, + struct PP_Size* coded_size) { + VLOG(4) << "PPB_VideoEncoder::GetFrameCodedSize()"; + EnterResource<PPB_VideoEncoder_API> enter(video_encoder, true); + if (enter.failed()) + return enter.retval(); + return enter.object()->GetFrameCodedSize(coded_size); +} + +int32_t GetVideoFrame(PP_Resource video_encoder, + PP_Resource* video_frame, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_VideoEncoder::GetVideoFrame()"; + EnterResource<PPB_VideoEncoder_API> enter(video_encoder, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult( + enter.object()->GetVideoFrame(video_frame, enter.callback())); +} + +int32_t Encode(PP_Resource video_encoder, + PP_Resource video_frame, + PP_Bool force_keyframe, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_VideoEncoder::Encode()"; + EnterResource<PPB_VideoEncoder_API> enter(video_encoder, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult( + enter.object()->Encode(video_frame, force_keyframe, enter.callback())); +} + +int32_t GetBitstreamBuffer(PP_Resource video_encoder, + struct PP_BitstreamBuffer* bitstream_buffer, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_VideoEncoder::GetBitstreamBuffer()"; + EnterResource<PPB_VideoEncoder_API> enter(video_encoder, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult( + enter.object()->GetBitstreamBuffer(bitstream_buffer, enter.callback())); +} + +void RecycleBitstreamBuffer(PP_Resource video_encoder, + const struct PP_BitstreamBuffer* bitstream_buffer) { + VLOG(4) << "PPB_VideoEncoder::RecycleBitstreamBuffer()"; + EnterResource<PPB_VideoEncoder_API> enter(video_encoder, true); + if (enter.failed()) + return; + enter.object()->RecycleBitstreamBuffer(bitstream_buffer); +} + +void RequestEncodingParametersChange(PP_Resource video_encoder, + uint32_t bitrate, + uint32_t framerate) { + VLOG(4) << "PPB_VideoEncoder::RequestEncodingParametersChange()"; + EnterResource<PPB_VideoEncoder_API> enter(video_encoder, true); + if (enter.failed()) + return; + enter.object()->RequestEncodingParametersChange(bitrate, framerate); +} + +void Close(PP_Resource video_encoder) { + VLOG(4) << "PPB_VideoEncoder::Close()"; + EnterResource<PPB_VideoEncoder_API> enter(video_encoder, true); + if (enter.failed()) + return; + enter.object()->Close(); +} + +const PPB_VideoEncoder_0_1 g_ppb_videoencoder_thunk_0_1 = { + &Create, + &IsVideoEncoder, + &GetSupportedProfiles_0_1, + &Initialize, + &GetFramesRequired, + &GetFrameCodedSize, + &GetVideoFrame, + &Encode, + &GetBitstreamBuffer, + &RecycleBitstreamBuffer, + &RequestEncodingParametersChange, + &Close}; + +const PPB_VideoEncoder_0_2 g_ppb_videoencoder_thunk_0_2 = { + &Create, + &IsVideoEncoder, + &GetSupportedProfiles, + &Initialize, + &GetFramesRequired, + &GetFrameCodedSize, + &GetVideoFrame, + &Encode, + &GetBitstreamBuffer, + &RecycleBitstreamBuffer, + &RequestEncodingParametersChange, + &Close}; + +} // namespace + +PPAPI_THUNK_EXPORT const PPB_VideoEncoder_0_1* GetPPB_VideoEncoder_0_1_Thunk() { + return &g_ppb_videoencoder_thunk_0_1; +} + +PPAPI_THUNK_EXPORT const PPB_VideoEncoder_0_2* GetPPB_VideoEncoder_0_2_Thunk() { + return &g_ppb_videoencoder_thunk_0_2; +} + +} // namespace thunk +} // namespace ppapi diff --git a/chromium/ppapi/thunk/resource_creation_api.h b/chromium/ppapi/thunk/resource_creation_api.h index 11dcc82d0c9..94311bb9fca 100644 --- a/chromium/ppapi/thunk/resource_creation_api.h +++ b/chromium/ppapi/thunk/resource_creation_api.h @@ -124,6 +124,7 @@ class ResourceCreationAPI { virtual PP_Resource CreateAudioConfig(PP_Instance instance, PP_AudioSampleRate sample_rate, uint32_t sample_frame_count) = 0; + virtual PP_Resource CreateCameraDevicePrivate(PP_Instance instance) = 0; virtual PP_Resource CreateCompositor(PP_Instance instance) = 0; virtual PP_Resource CreateFileChooser(PP_Instance instance, PP_FileChooserMode_Dev mode, @@ -171,6 +172,7 @@ class ResourceCreationAPI { virtual PP_Resource CreateUDPSocketPrivate(PP_Instance instace) = 0; virtual PP_Resource CreateVideoDecoder(PP_Instance instance) = 0; virtual PP_Resource CreateVideoDestination(PP_Instance instance) = 0; + virtual PP_Resource CreateVideoEncoder(PP_Instance instance) = 0; virtual PP_Resource CreateVideoSource(PP_Instance instance) = 0; virtual PP_Resource CreateWebSocket(PP_Instance instance) = 0; virtual PP_Resource CreateX509CertificatePrivate(PP_Instance instance) = 0; @@ -193,7 +195,6 @@ class ResourceCreationAPI { PP_Instance instance) = 0; virtual PP_Resource CreateScrollbar(PP_Instance instance, PP_Bool vertical) = 0; - virtual PP_Resource CreateTalk(PP_Instance instance) = 0; virtual PP_Resource CreateVideoCapture(PP_Instance instance) = 0; virtual PP_Resource CreateVideoDecoderDev( PP_Instance instance, diff --git a/chromium/ppapi/tools/pepper_hash_for_uma.cc b/chromium/ppapi/tools/pepper_hash_for_uma.cc index 6e38cfdd4b6..7c006a89b79 100644 --- a/chromium/ppapi/tools/pepper_hash_for_uma.cc +++ b/chromium/ppapi/tools/pepper_hash_for_uma.cc @@ -8,11 +8,21 @@ // // The hashing logic here must match the hashing logic at // ppapi/proxy/interface_list.cc. +// +// This utility can be used to generate a sorted list of hashes for all current +// PPB* interfaces by running a script to generate the interface names, e.g. +// $ grep -r "PPB_" ppapi/c | grep -o "\".*;[0-9]*\.[0-9]*\"" | tr '\n' ' ' +// and then invoking pepper_hash_for_uma on the list. The sorted output hashes +// can be compared to tools/metrics/histograms/histograms.xml to determine if +// any interfaces have been left out. #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <algorithm> +#include <vector> + #include "base/hash.h" #include "base/macros.h" @@ -25,13 +35,19 @@ int main(int argc, char **argv) { argv[0]); return 1; } + std::vector<std::pair<uint32, char*>> hashes; for (int i = 1; i < argc; i++) { uint32 data = base::Hash(argv[i], strlen(argv[i])); // Strip off the signed bit because UMA doesn't support negative values, // but takes a signed int as input. int hash = static_cast<int>(data & 0x7fffffff); - printf("<int value=\"%d\" label=\"%s\"/>\n", hash, argv[i]); + hashes.push_back(std::make_pair(hash, argv[i])); } + std::sort(hashes.begin(), hashes.end()); + for (const auto& hash : hashes) { + printf("<int value=\"%d\" label=\"%s\"/>\n", hash.first, hash.second); + } + return 0; } |