PPAPI/NaCl: Make NaClIPCAdapter transfer handles more generally
This does a couple of things:
- It defines a new wrapper for passing any kind of handle through the PPAPI proxy (SerializedHandle).
- It updates nacl_ipc_adapter to have a more general way to pick apart messages based on their static types (which include the types of all the params).
- It adds support for PPB_Graphics2D and PPB_Graphics3D to the NaCl IPC proxy (e.g., NaCl SDK examples pi_generator and tumbler work in the new proxy with this patch).
The downside is it requires pulling parts of ppapi/shared_impl and ppapi/proxy in to the NaCl Win64 build.
BUG=116317
TEST=
Review URL: https://chromiumcodereview.appspot.com/10828023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@153531 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/ppapi/native_client/native_client.gyp b/ppapi/native_client/native_client.gyp
index f43ad734..cdace08 100644
--- a/ppapi/native_client/native_client.gyp
+++ b/ppapi/native_client/native_client.gyp
@@ -215,6 +215,7 @@
'-Wl,--start-group',
'-lirt_browser',
'-lppapi_proxy_untrusted',
+ '-lppapi_ipc_untrusted',
'-lppapi_shared_untrusted',
'-lgles2_implementation_untrusted',
'-lgles2_cmd_helper_untrusted',
@@ -265,6 +266,7 @@
# once native_client/build/untrusted.gypi no longer needs them.
'extra_deps64': [
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libppapi_proxy_untrusted.a',
+ '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libppapi_ipc_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libppapi_shared_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libgles2_implementation_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libcommand_buffer_client_untrusted.a',
@@ -283,6 +285,7 @@
],
'extra_deps32': [
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libppapi_proxy_untrusted.a',
+ '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libppapi_ipc_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libppapi_shared_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libgles2_implementation_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libcommand_buffer_client_untrusted.a',
@@ -301,6 +304,7 @@
],
'extra_deps_newlib64': [
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libppapi_proxy_untrusted.a',
+ '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libppapi_ipc_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libppapi_shared_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libgles2_implementation_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libcommand_buffer_client_untrusted.a',
@@ -319,6 +323,7 @@
],
'extra_deps_newlib32': [
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libppapi_proxy_untrusted.a',
+ '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libppapi_ipc_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libppapi_shared_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libgles2_implementation_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libcommand_buffer_client_untrusted.a',
@@ -337,6 +342,7 @@
],
'extra_deps_glibc64': [
'<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libppapi_proxy_untrusted.a',
+ '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libppapi_ipc_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libppapi_shared_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libgles2_implementation_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libcommand_buffer_client_untrusted.a',
@@ -355,6 +361,7 @@
],
'extra_deps_glibc32': [
'<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libppapi_proxy_untrusted.a',
+ '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libppapi_ipc_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libppapi_shared_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libgles2_implementation_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libcommand_buffer_client_untrusted.a',
@@ -373,6 +380,7 @@
],
'extra_deps_arm': [
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libppapi_proxy_untrusted.a',
+ '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libppapi_ipc_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libppapi_shared_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libgles2_implementation_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libcommand_buffer_client_untrusted.a',
@@ -392,6 +400,7 @@
},
'dependencies': [
'../ppapi_ipc_proxy_untrusted.gyp:ppapi_proxy_untrusted',
+ '../ppapi_ipc_untrusted.gyp:ppapi_ipc_untrusted',
'../ppapi_shared_untrusted.gyp:ppapi_shared_untrusted',
'../../gpu/command_buffer/command_buffer_untrusted.gyp:gles2_utils_untrusted',
'../../gpu/gpu_untrusted.gyp:command_buffer_client_untrusted',
diff --git a/ppapi/ppapi_host.gypi b/ppapi/ppapi_host.gypi
index 8357033..079125e2 100644
--- a/ppapi/ppapi_host.gypi
+++ b/ppapi/ppapi_host.gypi
@@ -10,6 +10,7 @@
'dependencies': [
'ppapi.gyp:ppapi_c',
'ppapi_internal.gyp:ppapi_proxy',
+ 'ppapi_internal.gyp:ppapi_ipc',
'ppapi_internal.gyp:ppapi_shared',
'../base/base.gyp:base',
'../ipc/ipc.gyp:ipc',
diff --git a/ppapi/ppapi_internal.gyp b/ppapi/ppapi_internal.gyp
index 8eed2eb..93dc5a0 100644
--- a/ppapi/ppapi_internal.gyp
+++ b/ppapi/ppapi_internal.gyp
@@ -26,6 +26,7 @@
'includes': [
'ppapi_sources.gypi',
'ppapi_host.gypi',
+ 'ppapi_ipc.gypi',
'ppapi_proxy.gypi',
'ppapi_shared.gypi',
'ppapi_tests.gypi',
@@ -35,6 +36,9 @@
'target_name': 'ppapi_shared',
'type': '<(component)',
'variables': {
+ # Set the ppapi_shared_target variable, so that we will pull in the
+ # sources from ppapi_shared.gypi (and only from there). We follow the
+ # same pattern for the other targets defined within this file.
'ppapi_shared_target': 1,
},
'dependencies': [
@@ -68,28 +72,160 @@
}],
],
},
- {
- 'target_name': 'ppapi_proxy',
- 'type': '<(component)',
- 'variables': {
- 'ppapi_proxy_target': 1,
- },
- 'dependencies': [
- '../base/base.gyp:base',
- '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
- '../gpu/gpu.gyp:gles2_implementation',
- '../gpu/gpu.gyp:gpu_ipc',
- '../ipc/ipc.gyp:ipc',
- '../skia/skia.gyp:skia',
- '../ui/surface/surface.gyp:surface',
- 'ppapi.gyp:ppapi_c',
- 'ppapi_shared',
+ ],
+ 'conditions': [
+ ['component=="static_library"', {
+ # In a static build, build ppapi_ipc separately.
+ 'targets': [
+ {
+ 'target_name': 'ppapi_ipc',
+ 'type': 'static_library',
+ 'variables': {
+ 'ppapi_ipc_target': 1,
+ },
+ 'dependencies': [
+ '../base/base.gyp:base',
+ '../gpu/gpu.gyp:gpu_ipc',
+ '../ipc/ipc.gyp:ipc',
+ '../skia/skia.gyp:skia',
+ 'ppapi.gyp:ppapi_c',
+ 'ppapi_shared',
+ ],
+ 'all_dependent_settings': {
+ 'include_dirs': [
+ '..',
+ ],
+ },
+ },
+ {
+ 'target_name': 'ppapi_proxy',
+ 'type': 'static_library',
+ 'variables': {
+ 'ppapi_proxy_target': 1,
+ },
+ 'dependencies': [
+ '../base/base.gyp:base',
+ '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
+ '../gpu/gpu.gyp:gles2_implementation',
+ '../gpu/gpu.gyp:gpu_ipc',
+ '../media/media.gyp:shared_memory_support',
+ '../ipc/ipc.gyp:ipc',
+ '../skia/skia.gyp:skia',
+ '../ui/surface/surface.gyp:surface',
+ 'ppapi.gyp:ppapi_c',
+ 'ppapi_shared',
+ 'ppapi_ipc',
+ ],
+ 'all_dependent_settings': {
+ 'include_dirs': [
+ '..',
+ ],
+ },
+ },
],
- 'all_dependent_settings': {
- 'include_dirs': [
- '..',
- ],
- },
},
- ]
+ { # component != static_library
+ # In the component build, we'll just build ppapi_ipc in to ppapi_proxy.
+ 'targets': [
+ {
+ 'target_name': 'ppapi_proxy',
+ 'type': 'shared_library',
+ 'variables': {
+ # Setting both variables means we pull in the sources from both
+ # ppapi_ipc.gypi and ppapi_proxy.gypi.
+ 'ppapi_ipc_target': 1,
+ 'ppapi_proxy_target': 1,
+ },
+ 'dependencies': [
+ '../base/base.gyp:base',
+ '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
+ '../gpu/gpu.gyp:gles2_implementation',
+ '../gpu/gpu.gyp:gpu_ipc',
+ '../media/media.gyp:shared_memory_support',
+ '../ipc/ipc.gyp:ipc',
+ '../skia/skia.gyp:skia',
+ '../ui/surface/surface.gyp:surface',
+ 'ppapi.gyp:ppapi_c',
+ 'ppapi_shared',
+ ],
+ 'all_dependent_settings': {
+ 'include_dirs': [
+ '..',
+ ],
+ },
+ },
+ {
+ # In component build, this is just a phony target that makes sure
+ # ppapi_proxy is built, since that's where the ipc sources go in the
+ # component build.
+ 'target_name': 'ppapi_ipc',
+ 'type': 'none',
+ 'dependencies': [
+ 'ppapi_proxy',
+ ],
+ },
+ ],
+ }],
+ ['disable_nacl!=1' and 'OS=="win"', {
+ # In windows builds, we also want to define some targets to build in
+ # 64-bit mode for use by nacl64.exe (the NaCl helper process for 64-bit
+ # Windows).
+ 'targets': [
+ {
+ 'target_name': 'ppapi_shared_win64',
+ 'type': '<(component)',
+ 'variables': {
+ 'nacl_win64_target': 1,
+ 'ppapi_shared_target': 1,
+ },
+ 'dependencies': [
+ 'ppapi.gyp:ppapi_c',
+ '../base/base.gyp:base_nacl_win64',
+ '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations_win64',
+ ],
+ 'defines': [
+ '<@(nacl_win64_defines)',
+ ],
+ 'export_dependent_settings': [
+ '../base/base.gyp:base_nacl_win64',
+ ],
+ 'configurations': {
+ 'Common_Base': {
+ 'msvs_target_platform': 'x64',
+ },
+ },
+ },
+ {
+ 'target_name': 'ppapi_ipc_win64',
+ 'type': 'static_library',
+ 'variables': {
+ 'nacl_win64_target': 1,
+ 'ppapi_ipc_target': 1,
+ },
+ 'dependencies': [
+ '../base/base.gyp:base_nacl_win64',
+ '../ipc/ipc.gyp:ipc_win64',
+ '../gpu/gpu.gyp:gpu_ipc_win64',
+ 'ppapi.gyp:ppapi_c',
+ 'ppapi_shared_win64',
+ ],
+ 'export_dependent_settings': [
+ '../gpu/gpu.gyp:gpu_ipc_win64',
+ ],
+ 'defines': [
+ '<@(nacl_win64_defines)',
+ ],
+ 'all_dependent_settings': {
+ 'include_dirs': [
+ '..',
+ ],
+ },
+ 'configurations': {
+ 'Common_Base': {
+ 'msvs_target_platform': 'x64',
+ },
+ },
+ }],
+ }],
+ ],
}
diff --git a/ppapi/ppapi_ipc.gypi b/ppapi/ppapi_ipc.gypi
new file mode 100644
index 0000000..926e0e2
--- /dev/null
+++ b/ppapi/ppapi_ipc.gypi
@@ -0,0 +1,44 @@
+# 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.
+
+{
+ 'target_defaults': {
+ 'variables': {
+ 'nacl_win64_target': 0,
+ 'ppapi_ipc_target': 0,
+ },
+ 'target_conditions': [
+ # This part is shared between the targets defined below.
+ ['ppapi_ipc_target==1', {
+ 'sources': [
+ 'proxy/pepper_file_messages.cc',
+ 'proxy/pepper_file_messages.h',
+ 'proxy/ppapi_messages.cc',
+ 'proxy/ppapi_messages.h',
+ 'proxy/ppapi_param_traits.cc',
+ 'proxy/ppapi_param_traits.h',
+ 'proxy/resource_message_params.cc',
+ 'proxy/resource_message_params.h',
+ 'proxy/serialized_flash_menu.cc',
+ 'proxy/serialized_flash_menu.h',
+ 'proxy/serialized_structs.cc',
+ 'proxy/serialized_structs.h',
+ 'proxy/serialized_var.cc',
+ 'proxy/serialized_var.h',
+ 'proxy/var_serialization_rules.h',
+ ],
+ 'include_dirs': [
+ '..',
+ ],
+ 'target_conditions': [
+ ['>(nacl_untrusted_build)==1' or '>(nacl_win64_target)==1', {
+ 'sources!': [
+ 'proxy/serialized_flash_menu.cc',
+ ],
+ }],
+ ],
+ }],
+ ],
+ },
+}
diff --git a/ppapi/ppapi_ipc_proxy_untrusted.gyp b/ppapi/ppapi_ipc_proxy_untrusted.gyp
index 8454a9f..9111d3a 100644
--- a/ppapi/ppapi_ipc_proxy_untrusted.gyp
+++ b/ppapi/ppapi_ipc_proxy_untrusted.gyp
@@ -2,6 +2,11 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+# This file is named ppapi_ipc_proxy_untrusted.gyp instead of
+# ppapi_proxy_untrusted.gyp, because there is already a file with that name in
+# ppapi/native_client/src/shared/ppapi_proxy. This causes problems on Mac when
+# generating for XCode. TODO(dmichael): This file should probably be renamed to
+# ppapi_proxy_untrusted.gyp when we remove the SRPC NaCl proxy.
{
'variables': {
'chromium_code': 1,
@@ -41,6 +46,7 @@
'../gpu/gpu_untrusted.gyp:gpu_ipc_untrusted',
'../ipc/ipc_untrusted.gyp:ipc_untrusted',
'../ppapi/ppapi_shared_untrusted.gyp:ppapi_shared_untrusted',
+ '../ppapi/ppapi_ipc_untrusted.gyp:ppapi_ipc_untrusted',
],
},
],
diff --git a/ppapi/ppapi_ipc_untrusted.gyp b/ppapi/ppapi_ipc_untrusted.gyp
new file mode 100644
index 0000000..ec6fdf907
--- /dev/null
+++ b/ppapi/ppapi_ipc_untrusted.gyp
@@ -0,0 +1,44 @@
+# 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.
+
+{
+ 'variables': {
+ 'chromium_code': 1,
+ },
+ 'includes': [
+ '../native_client/build/untrusted.gypi',
+ 'ppapi_ipc.gypi',
+ ],
+ 'conditions': [
+ ['disable_nacl==0 and disable_nacl_untrusted==0', {
+ 'targets': [
+ {
+ 'target_name': 'ppapi_ipc_untrusted',
+ 'type': 'none',
+ 'variables': {
+ 'ppapi_ipc_target': 1,
+ 'nacl_win64_target': 0,
+ 'nacl_untrusted_build': 1,
+ 'nlib_target': 'libppapi_ipc_untrusted.a',
+ 'build_glibc': 0,
+ 'build_newlib': 1,
+ },
+ 'defines': [
+ 'NACL_PPAPI_IPC_PROXY',
+ ],
+ 'include_dirs': [
+ '..',
+ ],
+ 'dependencies': [
+ '../native_client/tools.gyp:prep_toolchain',
+ '../base/base_untrusted.gyp:base_untrusted',
+ '../gpu/gpu_untrusted.gyp:gpu_ipc_untrusted',
+ '../ipc/ipc_untrusted.gyp:ipc_untrusted',
+ '../ppapi/ppapi_shared_untrusted.gyp:ppapi_shared_untrusted',
+ ],
+ },
+ ],
+ }],
+ ],
+}
diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi
index 6bf1d88..388a3eeb 100644
--- a/ppapi/ppapi_proxy.gypi
+++ b/ppapi/ppapi_proxy.gypi
@@ -37,8 +37,6 @@
'proxy/interface_list.h',
'proxy/interface_proxy.cc',
'proxy/interface_proxy.h',
- 'proxy/pepper_file_messages.cc',
- 'proxy/pepper_file_messages.h',
'proxy/plugin_array_buffer_var.cc',
'proxy/plugin_array_buffer_var.h',
'proxy/plugin_dispatcher.cc',
@@ -56,12 +54,8 @@
'proxy/plugin_var_serialization_rules.h',
'proxy/plugin_var_tracker.cc',
'proxy/plugin_var_tracker.h',
- 'proxy/ppapi_messages.cc',
- 'proxy/ppapi_messages.h',
'proxy/ppapi_command_buffer_proxy.h',
'proxy/ppapi_command_buffer_proxy.cc',
- 'proxy/ppapi_param_traits.cc',
- 'proxy/ppapi_param_traits.h',
'proxy/ppb_audio_input_proxy.cc',
'proxy/ppb_audio_input_proxy.h',
'proxy/ppb_audio_proxy.cc',
@@ -157,14 +151,6 @@
'proxy/proxy_object_var.h',
'proxy/resource_creation_proxy.cc',
'proxy/resource_creation_proxy.h',
- 'proxy/resource_message_params.cc',
- 'proxy/resource_message_params.h',
- 'proxy/serialized_flash_menu.cc',
- 'proxy/serialized_flash_menu.h',
- 'proxy/serialized_structs.cc',
- 'proxy/serialized_structs.h',
- 'proxy/serialized_var.cc',
- 'proxy/serialized_var.h',
'proxy/var_serialization_rules.h',
],
'defines': [
@@ -199,7 +185,6 @@
'proxy/ppp_content_decryptor_private_proxy.cc',
'proxy/ppp_instance_private_proxy.cc',
'proxy/ppp_video_decoder_proxy.cc',
- 'proxy/serialized_flash_menu.cc',
],
}],
],
diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi
index 06f6e00e..a003a05 100644
--- a/ppapi/ppapi_shared.gypi
+++ b/ppapi/ppapi_shared.gypi
@@ -28,6 +28,7 @@
'shared_impl/file_path.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',
@@ -244,7 +245,7 @@
'..',
],
'target_conditions': [
- ['>(nacl_untrusted_build)==1', {
+ ['>(nacl_untrusted_build)==1 or >(nacl_win64_target)==1', {
'sources!': [
'shared_impl/ppb_audio_input_shared.cc',
'shared_impl/ppb_url_util_shared.cc',
@@ -300,6 +301,15 @@
'thunk/ppb_x509_certificate_private_thunk.cc',
],
}],
+ # We exclude a few more things for nacl_win64, to avoid pulling in more dependencies.
+ ['>(nacl_win64_target)==1', {
+ 'sources!': [
+ 'shared_impl/ppb_audio_shared.cc',
+ 'shared_impl/ppb_graphics_3d_shared.cc',
+ 'shared_impl/ppb_opengles2_shared.cc',
+ 'thunk/ppb_graphics_3d_thunk.cc',
+ ],
+ }],
],
}],
],
diff --git a/ppapi/ppapi_shared_untrusted.gyp b/ppapi/ppapi_shared_untrusted.gyp
index 0e3033ce..2897337 100644
--- a/ppapi/ppapi_shared_untrusted.gyp
+++ b/ppapi/ppapi_shared_untrusted.gyp
@@ -18,6 +18,7 @@
'type': 'none',
'variables': {
'ppapi_shared_target': 1,
+ 'nacl_win64_target': 0,
'nacl_untrusted_build': 1,
'nlib_target': 'libppapi_shared_untrusted.a',
'build_glibc': 0,
diff --git a/ppapi/proxy/DEPS b/ppapi/proxy/DEPS
index 4fd421d..1a3c174 100644
--- a/ppapi/proxy/DEPS
+++ b/ppapi/proxy/DEPS
@@ -2,6 +2,7 @@
"+base",
"+ipc",
"+gpu",
+ "+media/audio",
"+skia",
"+ui/surface",
diff --git a/ppapi/proxy/plugin_array_buffer_var.cc b/ppapi/proxy/plugin_array_buffer_var.cc
index 6d16cfe..c9d302f 100644
--- a/ppapi/proxy/plugin_array_buffer_var.cc
+++ b/ppapi/proxy/plugin_array_buffer_var.cc
@@ -28,7 +28,7 @@
}
uint32 PluginArrayBufferVar::ByteLength() {
- return buffer_.size();
+ return static_cast<uint32>(buffer_.size());
}
} // namespace ppapi
diff --git a/ppapi/proxy/plugin_dispatcher_unittest.cc b/ppapi/proxy/plugin_dispatcher_unittest.cc
index a2999d002..821ecad 100644
--- a/ppapi/proxy/plugin_dispatcher_unittest.cc
+++ b/ppapi/proxy/plugin_dispatcher_unittest.cc
@@ -74,7 +74,10 @@
EXPECT_FALSE(HasTargetProxy(API_ID_PPB_AUDIO));
PpapiMsg_PPBAudio_NotifyAudioStreamCreated audio_msg(
API_ID_PPB_AUDIO, HostResource(), 0,
- IPC::PlatformFileForTransit(), base::SharedMemoryHandle(), 0);
+ ppapi::proxy::SerializedHandle(
+ ppapi::proxy::SerializedHandle::SOCKET),
+ ppapi::proxy::SerializedHandle(
+ ppapi::proxy::SerializedHandle::SHARED_MEMORY));
plugin_dispatcher()->OnMessageReceived(audio_msg);
EXPECT_TRUE(HasTargetProxy(API_ID_PPB_AUDIO));
}
diff --git a/ppapi/proxy/ppapi_command_buffer_proxy.cc b/ppapi/proxy/ppapi_command_buffer_proxy.cc
index 91cd268..282a8765 100644
--- a/ppapi/proxy/ppapi_command_buffer_proxy.cc
+++ b/ppapi/proxy/ppapi_command_buffer_proxy.cc
@@ -225,27 +225,29 @@
// Assuming we are in the renderer process, the service is responsible for
// duplicating the handle. This might not be true for NaCl.
- base::SharedMemoryHandle handle;
- uint32 size;
+ ppapi::proxy::SerializedHandle handle(
+ ppapi::proxy::SerializedHandle::SHARED_MEMORY);
if (!Send(new PpapiHostMsg_PPBGraphics3D_GetTransferBuffer(
- ppapi::API_ID_PPB_GRAPHICS_3D, resource_, id, &handle, &size))) {
+ ppapi::API_ID_PPB_GRAPHICS_3D, resource_, id, &handle))) {
return gpu::Buffer();
}
+ if (!handle.is_shmem())
+ return gpu::Buffer();
// Cache the transfer buffer shared memory object client side.
scoped_ptr<base::SharedMemory> shared_memory(
- new base::SharedMemory(handle, false));
+ new base::SharedMemory(handle.shmem(), false));
// Map the shared memory on demand.
if (!shared_memory->memory()) {
- if (!shared_memory->Map(size)) {
+ if (!shared_memory->Map(handle.size())) {
return gpu::Buffer();
}
}
gpu::Buffer buffer;
buffer.ptr = shared_memory->memory();
- buffer.size = size;
+ buffer.size = handle.size();
buffer.shared_memory = shared_memory.release();
transfer_buffers_[id] = buffer;
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index a5a9cfb..8ba5760 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -230,7 +230,7 @@
IPC_STRUCT_TRAITS_MEMBER(expected_last_modified_time)
IPC_STRUCT_TRAITS_END()
-#if !defined(OS_NACL)
+#if !defined(OS_NACL) && !defined(NACL_WIN64)
IPC_STRUCT_TRAITS_BEGIN(ppapi::proxy::PPPVideoCapture_Buffer)
IPC_STRUCT_TRAITS_MEMBER(resource)
IPC_STRUCT_TRAITS_MEMBER(handle)
@@ -294,7 +294,7 @@
std::string /* interface_name */,
bool /* result */)
-#if !defined(OS_NACL)
+#if !defined(OS_NACL) && !defined(NACL_WIN64)
// Network state notification from the browser for implementing
// PPP_NetworkState_Dev.
IPC_MESSAGE_CONTROL1(PpapiMsg_SetNetworkState,
@@ -365,7 +365,7 @@
PP_Instance /* instance */,
IPC::PlatformFileForTransit /* handle */,
int32_t /* result */)
-#endif // !defined(OS_NACL)
+#endif // !defined(OS_NACL) && !defined(NACL_WIN64)
// PPB_Audio.
@@ -376,24 +376,22 @@
//
// The handler of this message should always close all of the handles passed
// in, since some could be valid even in the error case.
-IPC_MESSAGE_ROUTED5(PpapiMsg_PPBAudio_NotifyAudioStreamCreated,
+IPC_MESSAGE_ROUTED4(PpapiMsg_PPBAudio_NotifyAudioStreamCreated,
ppapi::HostResource /* audio_id */,
int32_t /* result_code (will be != PP_OK on failure) */,
- IPC::PlatformFileForTransit /* socket_handle */,
- base::SharedMemoryHandle /* handle */,
- int32_t /* length */)
+ ppapi::proxy::SerializedHandle /* socket_handle */,
+ ppapi::proxy::SerializedHandle /* handle */)
// PPB_AudioInput_Dev.
IPC_MESSAGE_ROUTED3(PpapiMsg_PPBAudioInput_EnumerateDevicesACK,
ppapi::HostResource /* audio_input */,
int32_t /* result */,
std::vector<ppapi::DeviceRefData> /* devices */)
-IPC_MESSAGE_ROUTED5(PpapiMsg_PPBAudioInput_OpenACK,
+IPC_MESSAGE_ROUTED4(PpapiMsg_PPBAudioInput_OpenACK,
ppapi::HostResource /* audio_input */,
int32_t /* result_code (will be != PP_OK on failure) */,
- IPC::PlatformFileForTransit /* socket_handle */,
- base::SharedMemoryHandle /* handle */,
- int32_t /* length */)
+ ppapi::proxy::SerializedHandle /* socket_handle */,
+ ppapi::proxy::SerializedHandle /* handle */)
// PPB_FileIO.
IPC_MESSAGE_ROUTED2(PpapiMsg_PPBFileIO_GeneralComplete,
@@ -580,7 +578,7 @@
IPC_MESSAGE_ROUTED2(PpapiMsg_PPBURLLoader_CallbackComplete,
ppapi::HostResource /* loader */,
int32_t /* result */)
-#if !defined(OS_NACL)
+#if !defined(OS_NACL) && !defined(NACL_WIN64)
// PPB_Broker.
IPC_MESSAGE_ROUTED3(
PpapiMsg_PPBBroker_ConnectComplete,
@@ -756,7 +754,7 @@
IPC_MESSAGE_ROUTED2(PpapiMsg_PPPVideoDecoder_NotifyError,
ppapi::HostResource /* video_decoder */,
PP_VideoDecodeError_Dev /* error */)
-#endif // !defined(OS_NACL)
+#endif // !defined(OS_NACL) && !defined(NACL_WIN64)
// -----------------------------------------------------------------------------
// These are from the plugin to the renderer.
@@ -939,11 +937,10 @@
IPC_SYNC_MESSAGE_ROUTED2_0(PpapiHostMsg_PPBGraphics3D_DestroyTransferBuffer,
ppapi::HostResource /* context */,
int32 /* id */)
-IPC_SYNC_MESSAGE_ROUTED2_2(PpapiHostMsg_PPBGraphics3D_GetTransferBuffer,
+IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBGraphics3D_GetTransferBuffer,
ppapi::HostResource /* context */,
int32 /* id */,
- base::SharedMemoryHandle /* transfer_buffer */,
- uint32 /* size */)
+ ppapi::proxy::SerializedHandle /* transfer_buffer */)
IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBGraphics3D_SwapBuffers,
ppapi::HostResource /* graphics_3d */)
@@ -963,7 +960,7 @@
PP_Bool /* init_to_zero */,
ppapi::HostResource /* result_resource */,
std::string /* image_data_desc */,
- base::SharedMemoryHandle /* result */)
+ ppapi::proxy::SerializedHandle /* result */)
// PPB_Instance.
IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBInstance_GetWindowObject,
@@ -1156,7 +1153,7 @@
int64 /* object_data */,
ppapi::proxy::SerializedVar /* result */)
-#if !defined(OS_NACL)
+#if !defined(OS_NACL) && !defined(NACL_WIN64)
// PPB_Broker.
IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBBroker_Create,
PP_Instance /* instance */,
@@ -1165,11 +1162,12 @@
ppapi::HostResource /* broker */)
// PPB_Buffer.
-IPC_SYNC_MESSAGE_ROUTED2_2(PpapiHostMsg_PPBBuffer_Create,
- PP_Instance /* instance */,
- uint32_t /* size */,
- ppapi::HostResource /* result_resource */,
- base::SharedMemoryHandle /* result_shm_handle */)
+IPC_SYNC_MESSAGE_ROUTED2_2(
+ PpapiHostMsg_PPBBuffer_Create,
+ PP_Instance /* instance */,
+ uint32_t /* size */,
+ ppapi::HostResource /* result_resource */,
+ ppapi::proxy::SerializedHandle /* result_shm_handle */)
// PPB_ContentDecryptor_Dev messages handled in PPB_Instance_Proxy.
IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBInstance_NeedKey,
@@ -1480,7 +1478,7 @@
IPC_SYNC_MESSAGE_CONTROL0_1(PpapiHostMsg_PPBFont_GetFontFamilies,
std::string /* result */)
-#endif // !defined(OS_NACL)
+#endif // !defined(OS_NACL) && !defined(NACL_WIN64)
//-----------------------------------------------------------------------------
// Resource call/reply messages.
diff --git a/ppapi/proxy/ppapi_param_traits.cc b/ppapi/proxy/ppapi_param_traits.cc
index 87ce4fc1e..bcb2df0 100644
--- a/ppapi/proxy/ppapi_param_traits.cc
+++ b/ppapi/proxy/ppapi_param_traits.cc
@@ -312,7 +312,62 @@
std::string* l) {
}
-#if !defined(OS_NACL)
+// SerializedHandle ------------------------------------------------------------
+
+// static
+void ParamTraits<ppapi::proxy::SerializedHandle>::Write(Message* m,
+ const param_type& p) {
+ ppapi::proxy::SerializedHandle::WriteHeader(p.header(), m);
+ switch (p.type()) {
+ case ppapi::proxy::SerializedHandle::SHARED_MEMORY:
+ ParamTraits<base::SharedMemoryHandle>::Write(m, p.shmem());
+ break;
+ case ppapi::proxy::SerializedHandle::SOCKET:
+ ParamTraits<IPC::PlatformFileForTransit>::Write(m, p.descriptor());
+ break;
+ case ppapi::proxy::SerializedHandle::INVALID:
+ break;
+ // No default so the compiler will warn on new types.
+ }
+}
+
+// static
+bool ParamTraits<ppapi::proxy::SerializedHandle>::Read(const Message* m,
+ PickleIterator* iter,
+ param_type* r) {
+ ppapi::proxy::SerializedHandle::Header header;
+ if (!ppapi::proxy::SerializedHandle::ReadHeader(iter, &header))
+ return false;
+ switch (header.type) {
+ case ppapi::proxy::SerializedHandle::SHARED_MEMORY: {
+ base::SharedMemoryHandle handle;
+ if (ParamTraits<base::SharedMemoryHandle>::Read(m, iter, &handle)) {
+ r->set_shmem(handle, header.size);
+ return true;
+ }
+ break;
+ }
+ case ppapi::proxy::SerializedHandle::SOCKET: {
+ IPC::PlatformFileForTransit socket;
+ if (ParamTraits<IPC::PlatformFileForTransit>::Read(m, iter, &socket)) {
+ r->set_socket(socket);
+ return true;
+ }
+ break;
+ }
+ case ppapi::proxy::SerializedHandle::INVALID:
+ return true;
+ // No default so the compiler will warn us if a new type is added.
+ }
+ return false;
+}
+
+// static
+void ParamTraits<ppapi::proxy::SerializedHandle>::Log(const param_type& p,
+ std::string* l) {
+}
+
+#if !defined(OS_NACL) && !defined(NACL_WIN64)
// PPBFlash_DrawGlyphs_Params --------------------------------------------------
// static
void ParamTraits<ppapi::proxy::PPBFlash_DrawGlyphs_Params>::Write(
@@ -507,6 +562,6 @@
void ParamTraits<ppapi::PPB_X509Certificate_Fields>::Log(const param_type& p,
std::string* l) {
}
-#endif // !defined(OS_NACL)
+#endif // !defined(OS_NACL) && !defined(NACL_WIN64)
} // namespace IPC
diff --git a/ppapi/proxy/ppapi_param_traits.h b/ppapi/proxy/ppapi_param_traits.h
index 5b12f60..399513c 100644
--- a/ppapi/proxy/ppapi_param_traits.h
+++ b/ppapi/proxy/ppapi_param_traits.h
@@ -32,6 +32,7 @@
struct SerializedDirEntry;
struct SerializedFontDescription;
class SerializedFlashMenu;
+class SerializedHandle;
class SerializedVar;
} // namespace proxy
@@ -114,6 +115,14 @@
};
template<>
+struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::proxy::SerializedHandle> {
+ typedef ppapi::proxy::SerializedHandle param_type;
+ static void Write(Message* m, const param_type& p);
+ static bool Read(const Message* m, PickleIterator* iter, param_type* r);
+ static void Log(const param_type& p, std::string* l);
+};
+
+template<>
struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::HostResource> {
typedef ppapi::HostResource param_type;
static void Write(Message* m, const param_type& p);
@@ -147,7 +156,7 @@
static void Log(const param_type& p, std::string* l);
};
-#if !defined(OS_NACL)
+#if !defined(OS_NACL) && !defined(NACL_WIN64)
template<>
struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::proxy::SerializedFlashMenu> {
typedef ppapi::proxy::SerializedFlashMenu param_type;
@@ -163,7 +172,8 @@
static bool Read(const Message* m, PickleIterator* iter, param_type* r);
static void Log(const param_type& p, std::string* l);
};
-#endif // !defined(OS_NACL)
+#endif // !defined(OS_NACL) && !defined(NACL_WIN64)
+
} // namespace IPC
diff --git a/ppapi/proxy/ppapi_proxy_export.h b/ppapi/proxy/ppapi_proxy_export.h
index 6b1e83b..be86da4 100644
--- a/ppapi/proxy/ppapi_proxy_export.h
+++ b/ppapi/proxy/ppapi_proxy_export.h
@@ -5,7 +5,7 @@
#ifndef PPAPI_PROXY_PPAPI_PROXY_EXPORT_H_
#define PPAPI_PROXY_PPAPI_PROXY_EXPORT_H_
-#if defined(COMPONENT_BUILD)
+#if defined(COMPONENT_BUILD) && !defined(NACL_WIN64)
#if defined(WIN32)
#if defined(PPAPI_PROXY_IMPLEMENTATION)
@@ -22,7 +22,7 @@
#endif
#endif
-#else // defined(COMPONENT_BUILD)
+#else // defined(COMPONENT_BUILD) && !defined(NACL_WIN64)
#define PPAPI_PROXY_EXPORT
#endif
diff --git a/ppapi/proxy/ppb_audio_input_proxy.cc b/ppapi/proxy/ppb_audio_input_proxy.cc
index 011e332..dfc2d0c1 100644
--- a/ppapi/proxy/ppb_audio_input_proxy.cc
+++ b/ppapi/proxy/ppb_audio_input_proxy.cc
@@ -5,6 +5,7 @@
#include "ppapi/proxy/ppb_audio_input_proxy.h"
#include "base/compiler_specific.h"
+#include "media/audio/shared_memory_util.h"
#include "ppapi/c/dev/ppb_audio_input_dev.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_audio_config.h"
@@ -286,21 +287,27 @@
void PPB_AudioInput_Proxy::OnMsgOpenACK(
const HostResource& audio_input,
int32_t result,
- IPC::PlatformFileForTransit socket_handle,
- base::SharedMemoryHandle handle,
- uint32_t length) {
+ const ppapi::proxy::SerializedHandle& socket_handle,
+ const ppapi::proxy::SerializedHandle& handle) {
+ CHECK(socket_handle.is_socket());
+ CHECK(handle.is_shmem());
EnterPluginFromHostResource<PPB_AudioInput_API> enter(audio_input);
if (enter.failed()) {
// The caller may still have given us these handles in the failure case.
// The easiest way to clean these up is to just put them in the objects
// and then close them. This failure case is not performance critical.
base::SyncSocket temp_socket(
- IPC::PlatformFileForTransitToPlatformFile(socket_handle));
- base::SharedMemory temp_mem(handle, false);
+ IPC::PlatformFileForTransitToPlatformFile(
+ socket_handle.descriptor()));
+ base::SharedMemory temp_mem(handle.shmem(), false);
} else {
+ // See the comment above about how we must call
+ // TotalSharedMemorySizeInBytes to get the actual size of the buffer. Here,
+ // we must call PacketSizeInBytes to get back the size of the audio buffer,
+ // excluding the bytes that audio uses for book-keeping.
static_cast<AudioInput*>(enter.object())->OnOpenComplete(
- result, handle, length,
- IPC::PlatformFileForTransitToPlatformFile(socket_handle));
+ result, handle.shmem(), media::PacketSizeInBytes(handle.size()),
+ IPC::PlatformFileForTransitToPlatformFile(socket_handle.descriptor()));
}
}
@@ -316,15 +323,28 @@
void PPB_AudioInput_Proxy::OpenACKInHost(int32_t result,
const HostResource& audio_input) {
- IPC::PlatformFileForTransit socket_handle =
- IPC::InvalidPlatformFileForTransit();
- base::SharedMemoryHandle shared_memory = IPC::InvalidPlatformFileForTransit();
- uint32_t shared_memory_length = 0;
+ ppapi::proxy::SerializedHandle socket_handle(
+ ppapi::proxy::SerializedHandle::SOCKET);
+ ppapi::proxy::SerializedHandle shared_memory(
+ ppapi::proxy::SerializedHandle::SHARED_MEMORY);
if (result == PP_OK) {
- result = GetAudioInputConnectedHandles(audio_input, &socket_handle,
- &shared_memory,
- &shared_memory_length);
+ IPC::PlatformFileForTransit temp_socket;
+ base::SharedMemoryHandle temp_shmem;
+ uint32_t audio_buffer_size;
+ result = GetAudioInputConnectedHandles(audio_input, &temp_socket,
+ &temp_shmem, &audio_buffer_size);
+ if (result == PP_OK) {
+ socket_handle.set_socket(temp_socket);
+ // Note that we must call TotalSharedMemorySizeInBytes because
+ // Audio allocates extra space in shared memory for book-keeping, so the
+ // actual size of the shared memory buffer is larger than
+ // audio_buffer_length. When sending to NaCl, NaClIPCAdapter expects this
+ // size to match the size of the full shared memory buffer.
+ shared_memory.set_shmem(
+ temp_shmem,
+ media::TotalSharedMemorySizeInBytes(audio_buffer_size));
+ }
}
// Send all the values, even on error. This simplifies some of our cleanup
@@ -334,7 +354,7 @@
// (in OnMsgOpenACK), even in the failure case.
dispatcher()->Send(new PpapiMsg_PPBAudioInput_OpenACK(
API_ID_PPB_AUDIO_INPUT_DEV, audio_input, result, socket_handle,
- shared_memory, shared_memory_length));
+ shared_memory));
}
int32_t PPB_AudioInput_Proxy::GetAudioInputConnectedHandles(
diff --git a/ppapi/proxy/ppb_audio_input_proxy.h b/ppapi/proxy/ppb_audio_input_proxy.h
index f1fac75f..ea259fd0 100644
--- a/ppapi/proxy/ppb_audio_input_proxy.h
+++ b/ppapi/proxy/ppb_audio_input_proxy.h
@@ -17,6 +17,7 @@
#include "ppapi/c/ppb_audio_config.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/proxy_completion_callback_factory.h"
+#include "ppapi/proxy/serialized_structs.h"
#include "ppapi/utility/completion_callback_factory.h"
namespace ppapi {
@@ -63,9 +64,8 @@
const std::vector<ppapi::DeviceRefData>& devices);
void OnMsgOpenACK(const ppapi::HostResource& audio_input,
int32_t result,
- IPC::PlatformFileForTransit socket_handle,
- base::SharedMemoryHandle handle,
- uint32_t length);
+ const ppapi::proxy::SerializedHandle& socket_handle,
+ const ppapi::proxy::SerializedHandle& handle);
void EnumerateDevicesACKInHost(int32_t result,
const ppapi::HostResource& audio_input);
diff --git a/ppapi/proxy/ppb_audio_proxy.cc b/ppapi/proxy/ppb_audio_proxy.cc
index f60ac81..bc83be3 100644
--- a/ppapi/proxy/ppb_audio_proxy.cc
+++ b/ppapi/proxy/ppb_audio_proxy.cc
@@ -6,6 +6,7 @@
#include "base/compiler_specific.h"
#include "base/threading/simple_thread.h"
+#include "media/audio/shared_memory_util.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_audio.h"
#include "ppapi/c/ppb_audio_config.h"
@@ -238,13 +239,13 @@
IPC::PlatformFileForTransit socket_handle =
IPC::InvalidPlatformFileForTransit();
base::SharedMemoryHandle shared_memory = IPC::InvalidPlatformFileForTransit();
- uint32_t shared_memory_length = 0;
+ uint32_t audio_buffer_length = 0;
int32_t result_code = result;
if (result_code == PP_OK) {
result_code = GetAudioConnectedHandles(resource, &socket_handle,
&shared_memory,
- &shared_memory_length);
+ &audio_buffer_length);
}
// Send all the values, even on error. This simplifies some of our cleanup
@@ -252,9 +253,18 @@
// inconvenient to clean up. Our IPC code will automatically handle this for
// us, as long as the remote side always closes the handles it receives
// (in OnMsgNotifyAudioStreamCreated), even in the failure case.
+ ppapi::proxy::SerializedHandle fd_wrapper(socket_handle);
+
+ // Note that we must call TotalSharedMemorySizeInBytes because
+ // Audio allocates extra space in shared memory for book-keeping, so the
+ // actual size of the shared memory buffer is larger than audio_buffer_length.
+ // When sending to NaCl, NaClIPCAdapter expects this size to match the size
+ // of the full shared memory buffer.
+ ppapi::proxy::SerializedHandle handle_wrapper(
+ shared_memory,
+ media::TotalSharedMemorySizeInBytes(audio_buffer_length));
dispatcher()->Send(new PpapiMsg_PPBAudio_NotifyAudioStreamCreated(
- API_ID_PPB_AUDIO, resource, result_code, socket_handle,
- shared_memory, shared_memory_length));
+ API_ID_PPB_AUDIO, resource, result_code, fd_wrapper, handle_wrapper));
}
int32_t PPB_Audio_Proxy::GetAudioConnectedHandles(
@@ -299,21 +309,27 @@
void PPB_Audio_Proxy::OnMsgNotifyAudioStreamCreated(
const HostResource& audio_id,
int32_t result_code,
- IPC::PlatformFileForTransit socket_handle,
- base::SharedMemoryHandle handle,
- uint32_t length) {
+ ppapi::proxy::SerializedHandle socket_handle,
+ ppapi::proxy::SerializedHandle handle) {
+ CHECK(socket_handle.is_socket());
+ CHECK(handle.is_shmem());
EnterPluginFromHostResource<PPB_Audio_API> enter(audio_id);
if (enter.failed() || result_code != PP_OK) {
// The caller may still have given us these handles in the failure case.
// The easiest way to clean these up is to just put them in the objects
// and then close them. This failure case is not performance critical.
base::SyncSocket temp_socket(
- IPC::PlatformFileForTransitToPlatformFile(socket_handle));
- base::SharedMemory temp_mem(handle, false);
+ IPC::PlatformFileForTransitToPlatformFile(socket_handle.descriptor()));
+ base::SharedMemory temp_mem(handle.shmem(), false);
} else {
+ // See the comment above about how we must call
+ // TotalSharedMemorySizeInBytes to get the actual size of the buffer. Here,
+ // we must call PacketSizeInBytes to get back the size of the audio buffer,
+ // excluding the bytes that audio uses for book-keeping.
static_cast<Audio*>(enter.object())->SetStreamInfo(
- enter.resource()->pp_instance(), handle, length,
- IPC::PlatformFileForTransitToPlatformFile(socket_handle));
+ enter.resource()->pp_instance(), handle.shmem(),
+ media::PacketSizeInBytes(handle.size()),
+ IPC::PlatformFileForTransitToPlatformFile(socket_handle.descriptor()));
}
}
diff --git a/ppapi/proxy/ppb_audio_proxy.h b/ppapi/proxy/ppb_audio_proxy.h
index b516925..2f85a83 100644
--- a/ppapi/proxy/ppb_audio_proxy.h
+++ b/ppapi/proxy/ppb_audio_proxy.h
@@ -17,6 +17,7 @@
#include "ppapi/c/ppb_audio_config.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/proxy_completion_callback_factory.h"
+#include "ppapi/proxy/serialized_structs.h"
#include "ppapi/utility/completion_callback_factory.h"
namespace ppapi {
@@ -51,11 +52,11 @@
void OnMsgStartOrStop(const ppapi::HostResource& audio_id, bool play);
// Renderer->plugin message handlers.
- void OnMsgNotifyAudioStreamCreated(const ppapi::HostResource& audio_id,
- int32_t result_code,
- IPC::PlatformFileForTransit socket_handle,
- base::SharedMemoryHandle handle,
- uint32_t length);
+ void OnMsgNotifyAudioStreamCreated(
+ const ppapi::HostResource& audio_id,
+ int32_t result_code,
+ ppapi::proxy::SerializedHandle socket_handle,
+ ppapi::proxy::SerializedHandle handle);
void AudioChannelConnected(int32_t result,
const ppapi::HostResource& resource);
diff --git a/ppapi/proxy/ppb_buffer_proxy.cc b/ppapi/proxy/ppb_buffer_proxy.cc
index 6c4561d..813d3405 100644
--- a/ppapi/proxy/ppb_buffer_proxy.cc
+++ b/ppapi/proxy/ppb_buffer_proxy.cc
@@ -75,14 +75,14 @@
return 0;
HostResource result;
- base::SharedMemoryHandle shm_handle = base::SharedMemory::NULLHandle();
+ ppapi::proxy::SerializedHandle shm_handle;
dispatcher->Send(new PpapiHostMsg_PPBBuffer_Create(
- API_ID_PPB_BUFFER, instance, size,
- &result, &shm_handle));
- if (result.is_null() || !base::SharedMemory::IsHandleValid(shm_handle))
+ API_ID_PPB_BUFFER, instance, size, &result, &shm_handle));
+ if (result.is_null() || !shm_handle.IsHandleValid() ||
+ !shm_handle.is_shmem())
return 0;
- return AddProxyResource(result, shm_handle, size);
+ return AddProxyResource(result, shm_handle.shmem(), size);
}
// static
@@ -107,9 +107,9 @@
PP_Instance instance,
uint32_t size,
HostResource* result_resource,
- base::SharedMemoryHandle* result_shm_handle) {
+ ppapi::proxy::SerializedHandle* result_shm_handle) {
// Overwritten below on success.
- *result_shm_handle = base::SharedMemory::NULLHandle();
+ result_shm_handle->set_null_shmem();
HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
if (!dispatcher)
return;
@@ -142,7 +142,8 @@
#else
#error Not implemented.
#endif
- *result_shm_handle = dispatcher->ShareHandleWithRemote(platform_file, false);
+ result_shm_handle->set_shmem(
+ dispatcher->ShareHandleWithRemote(platform_file, false), size);
}
} // namespace proxy
diff --git a/ppapi/proxy/ppb_buffer_proxy.h b/ppapi/proxy/ppb_buffer_proxy.h
index cc8f5982..41f5e19 100644
--- a/ppapi/proxy/ppb_buffer_proxy.h
+++ b/ppapi/proxy/ppb_buffer_proxy.h
@@ -8,6 +8,7 @@
#include "base/shared_memory.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/proxy/interface_proxy.h"
+#include "ppapi/proxy/serialized_structs.h"
#include "ppapi/shared_impl/resource.h"
#include "ppapi/thunk/ppb_buffer_api.h"
@@ -62,7 +63,7 @@
void OnMsgCreate(PP_Instance instance,
uint32_t size,
HostResource* result_resource,
- base::SharedMemoryHandle* result_shm_handle);
+ ppapi::proxy::SerializedHandle* result_shm_handle);
};
} // namespace proxy
diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.cc b/ppapi/proxy/ppb_graphics_3d_proxy.cc
index 25bcd44f..a5612c4 100644
--- a/ppapi/proxy/ppb_graphics_3d_proxy.cc
+++ b/ppapi/proxy/ppb_graphics_3d_proxy.cc
@@ -316,18 +316,17 @@
void PPB_Graphics3D_Proxy::OnMsgGetTransferBuffer(
const HostResource& context,
int32 id,
- base::SharedMemoryHandle* transfer_buffer,
- uint32* size) {
- *transfer_buffer = base::SharedMemory::NULLHandle();
- *size = 0;
+ ppapi::proxy::SerializedHandle* transfer_buffer) {
+ transfer_buffer->set_null_shmem();
EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
int shm_handle = 0;
uint32_t shm_size = 0;
if (enter.succeeded() &&
enter.object()->GetTransferBuffer(id, &shm_handle, &shm_size)) {
- *transfer_buffer = TransportSHMHandleFromInt(dispatcher(), shm_handle);
- *size = shm_size;
+ transfer_buffer->set_shmem(
+ TransportSHMHandleFromInt(dispatcher(), shm_handle),
+ shm_size);
}
}
diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.h b/ppapi/proxy/ppb_graphics_3d_proxy.h
index d16053c8..a27da48 100644
--- a/ppapi/proxy/ppb_graphics_3d_proxy.h
+++ b/ppapi/proxy/ppb_graphics_3d_proxy.h
@@ -13,6 +13,7 @@
#include "ppapi/c/pp_instance.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/proxy_completion_callback_factory.h"
+#include "ppapi/proxy/serialized_structs.h"
#include "ppapi/shared_impl/ppb_graphics_3d_shared.h"
#include "ppapi/shared_impl/resource.h"
#include "ppapi/utility/completion_callback_factory.h"
@@ -96,8 +97,7 @@
int32 id);
void OnMsgGetTransferBuffer(const HostResource& context,
int32 id,
- base::SharedMemoryHandle* transfer_buffer,
- uint32* size);
+ ppapi::proxy::SerializedHandle* transfer_buffer);
void OnMsgSwapBuffers(const HostResource& context);
// Renderer->plugin message handlers.
void OnMsgSwapBuffersACK(const HostResource& context,
diff --git a/ppapi/proxy/ppb_image_data_proxy.cc b/ppapi/proxy/ppb_image_data_proxy.cc
index d7c621d..eca9749 100644
--- a/ppapi/proxy/ppb_image_data_proxy.cc
+++ b/ppapi/proxy/ppb_image_data_proxy.cc
@@ -326,7 +326,7 @@
map_count_(0),
used_in_replace_contents_(false) {
}
-#endif // !defined(OS_NACL)
+#endif // else, !defined(OS_NACL)
ImageData::~ImageData() {
}
@@ -465,10 +465,13 @@
HostResource result;
std::string image_data_desc;
#if defined(OS_NACL)
- base::SharedMemoryHandle image_handle = base::SharedMemory::NULLHandle();
+ ppapi::proxy::SerializedHandle image_handle_wrapper;
dispatcher->Send(new PpapiHostMsg_PPBImageData_CreateNaCl(
kApiID, instance, format, size, init_to_zero,
- &result, &image_data_desc, &image_handle));
+ &result, &image_data_desc, &image_handle_wrapper));
+ if (!image_handle_wrapper.is_shmem())
+ return 0;
+ base::SharedMemoryHandle image_handle = image_handle_wrapper.shmem();
#else
ImageHandle image_handle = ImageData::NullHandle();
dispatcher->Send(new PpapiHostMsg_PPBImageData_Create(
@@ -554,13 +557,13 @@
PP_Bool init_to_zero,
HostResource* result,
std::string* image_data_desc,
- base::SharedMemoryHandle* result_image_handle) {
+ ppapi::proxy::SerializedHandle* result_image_handle) {
#if defined(OS_NACL)
// This message should never be received in untrusted code. To minimize the
// size of the IRT, we just don't handle it.
return;
#else
- *result_image_handle = base::SharedMemory::NULLHandle();
+ result_image_handle->set_null_shmem();
HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
if (!dispatcher)
return;
@@ -588,7 +591,6 @@
uint32_t byte_count;
if (enter_resource.object()->GetSharedMemory(&local_fd, &byte_count) != PP_OK)
return;
-
// TODO(dmichael): Change trusted interface to return a PP_FileHandle, those
// casts are ugly.
base::PlatformFile platform_file =
@@ -599,8 +601,9 @@
#else
#error Not implemented.
#endif // defined(OS_WIN)
- *result_image_handle =
- dispatcher->ShareHandleWithRemote(platform_file, false);
+ result_image_handle->set_shmem(
+ dispatcher->ShareHandleWithRemote(platform_file, false),
+ byte_count);
#endif // defined(OS_NACL)
}
diff --git a/ppapi/proxy/ppb_image_data_proxy.h b/ppapi/proxy/ppb_image_data_proxy.h
index 046c1ce..3c44ddac 100644
--- a/ppapi/proxy/ppb_image_data_proxy.h
+++ b/ppapi/proxy/ppb_image_data_proxy.h
@@ -124,7 +124,7 @@
PP_Bool init_to_zero,
HostResource* result,
std::string* image_data_desc,
- base::SharedMemoryHandle* result_image_handle);
+ ppapi::proxy::SerializedHandle* result_image_handle);
// Host->Plugin message handlers.
void OnPluginMsgNotifyUnusedImageData(const HostResource& old_image_data);
diff --git a/ppapi/proxy/serialized_structs.cc b/ppapi/proxy/serialized_structs.cc
index bd17e4dd..5e0989fde 100644
--- a/ppapi/proxy/serialized_structs.cc
+++ b/ppapi/proxy/serialized_structs.cc
@@ -1,9 +1,10 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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/serialized_structs.h"
+#include "base/pickle.h"
#include "ppapi/c/dev/ppb_font_dev.h"
#include "ppapi/c/pp_file_info.h"
#include "ppapi/c/pp_rect.h"
@@ -78,5 +79,83 @@
PPBFlash_DrawGlyphs_Params::~PPBFlash_DrawGlyphs_Params() {}
+SerializedHandle::SerializedHandle()
+ : type_(INVALID),
+ shm_handle_(base::SharedMemory::NULLHandle()),
+ size_(0),
+ descriptor_(IPC::InvalidPlatformFileForTransit()) {
+}
+
+SerializedHandle::SerializedHandle(Type type_param)
+ : type_(type_param),
+ shm_handle_(base::SharedMemory::NULLHandle()),
+ size_(0),
+ descriptor_(IPC::InvalidPlatformFileForTransit()) {
+}
+
+SerializedHandle::SerializedHandle(const base::SharedMemoryHandle& handle,
+ uint32_t size)
+ : type_(SHARED_MEMORY),
+ shm_handle_(handle),
+ size_(size),
+ descriptor_(IPC::InvalidPlatformFileForTransit()) {
+}
+
+SerializedHandle::SerializedHandle(
+ const IPC::PlatformFileForTransit& socket_descriptor)
+ : type_(SOCKET),
+ shm_handle_(base::SharedMemory::NULLHandle()),
+ size_(0),
+ descriptor_(socket_descriptor) {
+}
+
+bool SerializedHandle::IsHandleValid() const {
+ if (type_ == SHARED_MEMORY)
+ return base::SharedMemory::IsHandleValid(shm_handle_);
+ else if (type_ == SOCKET)
+ return (IPC::InvalidPlatformFileForTransit() == descriptor_);
+ return false;
+}
+
+// static
+bool SerializedHandle::WriteHeader(const Header& hdr, Pickle* pickle) {
+ if (!pickle->WriteInt(hdr.type))
+ return false;
+ if (hdr.type == SHARED_MEMORY) {
+ if (!pickle->WriteUInt32(hdr.size))
+ return false;
+ }
+ return true;
+}
+
+// static
+bool SerializedHandle::ReadHeader(PickleIterator* iter, Header* hdr) {
+ *hdr = Header(INVALID, 0);
+ int type = 0;
+ if (!iter->ReadInt(&type))
+ return false;
+ bool valid_type = false;
+ switch (type) {
+ case SHARED_MEMORY: {
+ uint32_t size = 0;
+ if (!iter->ReadUInt32(&size))
+ return false;
+ hdr->size = size;
+ valid_type = true;
+ break;
+ }
+ case SOCKET:
+ valid_type = true;
+ break;
+ case INVALID:
+ valid_type = true;
+ break;
+ // No default so the compiler will warn us if a new type is added.
+ }
+ if (valid_type)
+ hdr->type = Type(type);
+ return valid_type;
+}
+
} // namespace proxy
} // namespace ppapi
diff --git a/ppapi/proxy/serialized_structs.h b/ppapi/proxy/serialized_structs.h
index 31744495..7ad8456 100644
--- a/ppapi/proxy/serialized_structs.h
+++ b/ppapi/proxy/serialized_structs.h
@@ -8,6 +8,7 @@
#include <string>
#include <vector>
+#include "base/logging.h"
#include "base/shared_memory.h"
#include "build/build_config.h"
#include "ipc/ipc_platform_file.h"
@@ -18,6 +19,7 @@
#include "ppapi/proxy/serialized_var.h"
#include "ppapi/shared_impl/host_resource.h"
+class Pickle;
struct PP_FontDescription_Dev;
namespace ppapi {
@@ -101,6 +103,96 @@
base::SharedMemoryHandle handle;
};
+// We put all our handles in a unified structure to make it easy to translate
+// them in NaClIPCAdapter for use in NaCl.
+class PPAPI_PROXY_EXPORT SerializedHandle {
+ public:
+ enum Type { INVALID, SHARED_MEMORY, SOCKET };
+ struct Header {
+ Header() : type(INVALID), size(0) {}
+ Header(Type type_arg, uint32_t size_arg)
+ : type(type_arg), size(size_arg) {
+ }
+ Type type;
+ uint32_t size;
+ };
+
+ SerializedHandle();
+ // Create an invalid handle of the given type.
+ explicit SerializedHandle(Type type);
+
+ // Create a shared memory handle.
+ SerializedHandle(const base::SharedMemoryHandle& handle, uint32_t size);
+
+ // Create a socket handle.
+ // TODO(dmichael): If we have other ways to use FDs later, this would be
+ // ambiguous.
+ explicit SerializedHandle(
+ const IPC::PlatformFileForTransit& socket_descriptor);
+
+ Type type() const { return type_; }
+ bool is_shmem() const { return type_ == SHARED_MEMORY; }
+ bool is_socket() const { return type_ == SOCKET; }
+ const base::SharedMemoryHandle& shmem() const {
+ DCHECK(is_shmem());
+ return shm_handle_;
+ }
+ uint32_t size() const {
+ DCHECK(is_shmem());
+ return size_;
+ }
+ const IPC::PlatformFileForTransit& descriptor() const {
+ DCHECK(is_socket());
+ return descriptor_;
+ }
+ void set_shmem(const base::SharedMemoryHandle& handle, uint32_t size) {
+ type_ = SHARED_MEMORY;
+ shm_handle_ = handle;
+ size_ = size;
+
+ descriptor_ = IPC::InvalidPlatformFileForTransit();
+ }
+ void set_socket(const IPC::PlatformFileForTransit& socket) {
+ type_ = SOCKET;
+ descriptor_ = socket;
+
+ shm_handle_ = base::SharedMemory::NULLHandle();
+ size_ = 0;
+ }
+ void set_null_shmem() {
+ set_shmem(base::SharedMemory::NULLHandle(), 0);
+ }
+ void set_null_socket() {
+ set_socket(IPC::InvalidPlatformFileForTransit());
+ }
+ bool IsHandleValid() const;
+
+ Header header() const {
+ return Header(type_, size_);
+ }
+
+ // Write/Read a Header, which contains all the data except the handle. This
+ // allows us to write the handle in a platform-specific way, as is necessary
+ // in NaClIPCAdapter to share handles with NaCl from Windows.
+ static bool WriteHeader(const Header& hdr, Pickle* pickle);
+ static bool ReadHeader(PickleIterator* iter, Header* hdr);
+
+ private:
+ // The kind of handle we're holding.
+ Type type_;
+
+ // We hold more members than we really need; we can't easily use a union,
+ // because we hold non-POD types. But these types are pretty light-weight. If
+ // we add more complex things later, we should come up with a more memory-
+ // efficient strategy.
+ // These are valid if type == SHARED_MEMORY.
+ base::SharedMemoryHandle shm_handle_;
+ uint32_t size_;
+
+ // This is valid if type == SOCKET.
+ IPC::PlatformFileForTransit descriptor_;
+};
+
// TODO(tomfinegan): This is identical to PPPVideoCapture_Buffer, maybe replace
// both with a single type?
struct PPPDecryptor_Buffer {
diff --git a/ppapi/proxy/serialized_var.cc b/ppapi/proxy/serialized_var.cc
index e648406a..ad416db24 100644
--- a/ppapi/proxy/serialized_var.cc
+++ b/ppapi/proxy/serialized_var.cc
@@ -249,7 +249,8 @@
}
case PP_VARTYPE_ARRAY_BUFFER: {
var_ = PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar(
- raw_var_data_->data.size(), raw_var_data_->data.data());
+ static_cast<uint32>(raw_var_data_->data.size()),
+ raw_var_data_->data.data());
break;
}
default:
diff --git a/ppapi/shared_impl/host_resource.cc b/ppapi/shared_impl/host_resource.cc
new file mode 100644
index 0000000..031a5f0
--- /dev/null
+++ b/ppapi/shared_impl/host_resource.cc
@@ -0,0 +1,25 @@
+// 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/shared_impl/host_resource.h"
+
+namespace ppapi {
+
+HostResource::HostResource() : instance_(0), host_resource_(0) {
+}
+
+// static
+HostResource HostResource::MakeInstanceOnly(PP_Instance instance) {
+ HostResource resource;
+ resource.SetHostResource(instance, 0);
+ return resource;
+}
+
+void HostResource::SetHostResource(PP_Instance instance, PP_Resource resource) {
+ instance_ = instance;
+ host_resource_ = resource;
+}
+
+} // namespace ppapi
+
diff --git a/ppapi/shared_impl/host_resource.h b/ppapi/shared_impl/host_resource.h
index b614546..c98d2d6 100644
--- a/ppapi/shared_impl/host_resource.h
+++ b/ppapi/shared_impl/host_resource.h
@@ -20,8 +20,7 @@
// All HostResources respresent IDs valid in the host.
class PPAPI_SHARED_EXPORT HostResource {
public:
- HostResource() : instance_(0), host_resource_(0) {
- }
+ HostResource();
bool is_null() const {
return !host_resource_;
@@ -31,21 +30,14 @@
// resource in the host. Yet these resources still need an instance to be
// associated with. This function creates a HostResource with the given
// instances and a 0 host resource ID for these cases.
- static HostResource MakeInstanceOnly(PP_Instance instance) {
- HostResource resource;
- resource.SetHostResource(instance, 0);
- return resource;
- }
+ static HostResource MakeInstanceOnly(PP_Instance instance);
// Sets and retrieves the internal PP_Resource which is valid for the host
// (a.k.a. renderer, as opposed to the plugin) process.
//
// DO NOT CALL THESE FUNCTIONS IN THE PLUGIN SIDE OF THE PROXY. The values
// will be invalid. See the class comment above.
- void SetHostResource(PP_Instance instance, PP_Resource resource) {
- instance_ = instance;
- host_resource_ = resource;
- }
+ void SetHostResource(PP_Instance instance, PP_Resource resource);
PP_Resource host_resource() const {
return host_resource_;
}
diff --git a/ppapi/shared_impl/ppb_audio_shared.h b/ppapi/shared_impl/ppb_audio_shared.h
index 8858e5c..ed3a5c2 100644
--- a/ppapi/shared_impl/ppb_audio_shared.h
+++ b/ppapi/shared_impl/ppb_audio_shared.h
@@ -60,6 +60,7 @@
// into user code.
static void SetThreadFunctions(const struct PP_ThreadFunctions* functions);
#endif
+
private:
// Starts execution of the audio thread.
void StartThread();
diff --git a/ppapi/shared_impl/ppb_device_ref_shared.cc b/ppapi/shared_impl/ppb_device_ref_shared.cc
index 15a3a7bf..73a9a7c 100644
--- a/ppapi/shared_impl/ppb_device_ref_shared.cc
+++ b/ppapi/shared_impl/ppb_device_ref_shared.cc
@@ -58,7 +58,8 @@
}
}
PPB_ResourceArray_Shared* array_object =
- new PPB_ResourceArray_Shared(type, instance, elements.get(), size);
+ new PPB_ResourceArray_Shared(type, instance, elements.get(),
+ static_cast<uint32_t>(size));
for (size_t index = 0; index < size; ++index)
PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(elements[index]);
diff --git a/ppapi/shared_impl/ppb_image_data_shared.cc b/ppapi/shared_impl/ppb_image_data_shared.cc
index deec2ac..abdea60e 100644
--- a/ppapi/shared_impl/ppb_image_data_shared.cc
+++ b/ppapi/shared_impl/ppb_image_data_shared.cc
@@ -4,9 +4,10 @@
#include "ppapi/shared_impl/ppb_image_data_shared.h"
+#include "base/logging.h"
#include "build/build_config.h"
-#if !defined(OS_NACL)
+#if !defined(OS_NACL) && !defined(NACL_WIN64)
#include "third_party/skia/include/core/SkTypes.h"
#endif
@@ -14,18 +15,23 @@
// static
PP_ImageDataFormat PPB_ImageData_Shared::GetNativeImageDataFormat() {
-#if !defined(OS_NACL)
- if (SK_B32_SHIFT == 0)
+#if defined(OS_NACL)
+ // In NaCl, just default to something. If we're wrong, it will be converted
+ // later.
+ // TODO(dmichael): Really proxy this.
+ return PP_IMAGEDATAFORMAT_BGRA_PREMUL;
+#elif defined(NACL_WIN64)
+ // In the NaCl Win64 helper, this shouldn't be called. If we start building
+ // Chrome on Windows 64 for realz, we should really implement this.
+ NOTIMPLEMENTED();
+ return PP_IMAGEDATAFORMAT_BGRA_PREMUL;
+#else
+ return PP_IMAGEDATAFORMAT_BGRA_PREMUL; if (SK_B32_SHIFT == 0)
return PP_IMAGEDATAFORMAT_BGRA_PREMUL;
else if (SK_R32_SHIFT == 0)
return PP_IMAGEDATAFORMAT_RGBA_PREMUL;
else
return PP_IMAGEDATAFORMAT_BGRA_PREMUL; // Default to something on failure.
-#else
- // In NaCl, just default to something. If we're wrong, it will be converted
- // later.
- // TODO(dmichael): Really proxy this.
- return PP_IMAGEDATAFORMAT_BGRA_PREMUL;
#endif
}
diff --git a/ppapi/shared_impl/ppb_input_event_shared.cc b/ppapi/shared_impl/ppb_input_event_shared.cc
index 0d7ebb9..4cd918d1 100644
--- a/ppapi/shared_impl/ppb_input_event_shared.cc
+++ b/ppapi/shared_impl/ppb_input_event_shared.cc
@@ -111,7 +111,7 @@
uint32_t PPB_InputEvent_Shared::GetIMESegmentNumber() {
if (data_.composition_segment_offsets.empty())
return 0;
- return data_.composition_segment_offsets.size() - 1;
+ return static_cast<uint32_t>(data_.composition_segment_offsets.size() - 1);
}
uint32_t PPB_InputEvent_Shared::GetIMESegmentOffset(uint32_t index) {
@@ -151,11 +151,11 @@
uint32_t PPB_InputEvent_Shared::GetTouchCount(PP_TouchListType list) {
switch (list) {
case PP_TOUCHLIST_TYPE_TOUCHES:
- return data_.touches.size();
+ return static_cast<uint32_t>(data_.touches.size());
case PP_TOUCHLIST_TYPE_CHANGEDTOUCHES:
- return data_.changed_touches.size();
+ return static_cast<uint32_t>(data_.changed_touches.size());
case PP_TOUCHLIST_TYPE_TARGETTOUCHES:
- return data_.target_touches.size();
+ return static_cast<uint32_t>(data_.target_touches.size());
}
return 0;
diff --git a/ppapi/shared_impl/ppb_network_list_private_shared.cc b/ppapi/shared_impl/ppb_network_list_private_shared.cc
index 6f8c67c..0430289 100644
--- a/ppapi/shared_impl/ppb_network_list_private_shared.cc
+++ b/ppapi/shared_impl/ppb_network_list_private_shared.cc
@@ -58,7 +58,7 @@
}
uint32_t PPB_NetworkList_Private_Shared::GetCount() {
- return list_->list().size();
+ return static_cast<uint32_t>(list_->list().size());
}
PP_Var PPB_NetworkList_Private_Shared::GetName(uint32_t index) {
@@ -91,7 +91,7 @@
count, static_cast<uint32_t>(list_->list().at(index).addresses.size()));
memcpy(addresses, &(list_->list().at(index).addresses[0]),
sizeof(PP_NetAddress_Private) * count);
- return list_->list().at(index).addresses.size();
+ return static_cast<int32_t>(list_->list().at(index).addresses.size());
}
PP_Var PPB_NetworkList_Private_Shared::GetDisplayName(uint32_t index) {
diff --git a/ppapi/shared_impl/var.cc b/ppapi/shared_impl/var.cc
index da7a2cb..2e63dbe 100644
--- a/ppapi/shared_impl/var.cc
+++ b/ppapi/shared_impl/var.cc
@@ -137,7 +137,7 @@
// static
PP_Var StringVar::StringToPPVar(const std::string& var) {
- return StringToPPVar(var.c_str(), var.size());
+ return StringToPPVar(var.c_str(), static_cast<uint32>(var.size()));
}
// static