diff options
author | nfullagar@google.com <nfullagar@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-02 00:09:07 +0000 |
---|---|---|
committer | nfullagar@google.com <nfullagar@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-02 00:09:07 +0000 |
commit | 867b76d63d12736535ab4519ba706d08fbd3ad77 (patch) | |
tree | c254f26d3a37cbf1a3bf95f5d81e85b296914f80 /ppapi | |
parent | acfd49c7e6f6ffbcb4b74aa35cc7d7926cd47771 (diff) | |
download | chromium_src-867b76d63d12736535ab4519ba706d08fbd3ad77.zip chromium_src-867b76d63d12736535ab4519ba706d08fbd3ad77.tar.gz chromium_src-867b76d63d12736535ab4519ba706d08fbd3ad77.tar.bz2 |
Change trusted shared memory interface to match audio.
- shm handle uint64_t -> int
- more unification of shm size from int32_t -> uint32_t
- GetNativeMemoryHandle() -> GetSharedMemory()
BUG=none
TEST=src/ppapi/examples/
Review URL: http://codereview.chromium.org/5410001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67910 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/c/dev/ppb_buffer_dev.h | 6 | ||||
-rw-r--r-- | ppapi/c/trusted/ppb_image_data_trusted.h | 14 | ||||
-rw-r--r-- | ppapi/cpp/dev/buffer_dev.cc | 2 | ||||
-rw-r--r-- | ppapi/cpp/dev/buffer_dev.h | 6 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.cc | 1 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages_internal.h | 6 | ||||
-rw-r--r-- | ppapi/proxy/ppb_buffer_proxy.cc | 22 | ||||
-rw-r--r-- | ppapi/proxy/ppb_buffer_proxy.h | 4 | ||||
-rw-r--r-- | ppapi/proxy/ppb_image_data_proxy.cc | 20 | ||||
-rw-r--r-- | ppapi/proxy/ppb_image_data_proxy.h | 2 | ||||
-rw-r--r-- | ppapi/tests/test_buffer.cc | 2 |
11 files changed, 45 insertions, 40 deletions
diff --git a/ppapi/c/dev/ppb_buffer_dev.h b/ppapi/c/dev/ppb_buffer_dev.h index cf43aa6..9906967 100644 --- a/ppapi/c/dev/ppb_buffer_dev.h +++ b/ppapi/c/dev/ppb_buffer_dev.h @@ -10,13 +10,13 @@ #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" -#define PPB_BUFFER_DEV_INTERFACE "PPB_Buffer(Dev);0.2" +#define PPB_BUFFER_DEV_INTERFACE "PPB_Buffer(Dev);0.3" struct PPB_Buffer_Dev { // Allocates a buffer of the given size in bytes. The return value will have // a non-zero ID on success, or zero on failure. Failure means the module // handle was invalid. The buffer will be initialized to contain zeroes. - PP_Resource (*Create)(PP_Module module, int32_t size_in_bytes); + PP_Resource (*Create)(PP_Module module, uint32_t size_in_bytes); // Returns PP_TRUE if the given resource is a Buffer. Returns PP_FALSE if the // resource is invalid or some type other than a Buffer. @@ -24,7 +24,7 @@ struct PPB_Buffer_Dev { // Gets the size of the buffer. Returns PP_TRUE on success, PP_FALSE // if the resource is not a buffer. On failure, |*size_in_bytes| is not set. - PP_Bool (*Describe)(PP_Resource resource, int32_t* size_in_bytes); + PP_Bool (*Describe)(PP_Resource resource, uint32_t* size_in_bytes); // Maps this buffer into the plugin address space and returns a pointer to the // beginning of the data. diff --git a/ppapi/c/trusted/ppb_image_data_trusted.h b/ppapi/c/trusted/ppb_image_data_trusted.h index 7f3b410..bbc944d 100644 --- a/ppapi/c/trusted/ppb_image_data_trusted.h +++ b/ppapi/c/trusted/ppb_image_data_trusted.h @@ -8,17 +8,19 @@ #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_resource.h" -#define PPB_IMAGEDATA_TRUSTED_INTERFACE "PPB_ImageDataTrusted;0.2" +#define PPB_IMAGEDATA_TRUSTED_INTERFACE "PPB_ImageDataTrusted;0.3" struct PPB_ImageDataTrusted { /** * Returns the internal shared memory pointer associated with the given - * ImageData resource. Used for proxying. Returns the handle or 0 on failure. - * On success, the size in bytes of the shared memory region will be placed - * into |*byte_count|. + * ImageData resource. Used for proxying. Returns PP_OK on success, or + * PP_ERROR_* on failure. On success, the size in bytes of the shared + * memory region will be placed into |*byte_count|, and the handle for + * the shared memory in |*handle|. */ - uint64_t (*GetNativeMemoryHandle)(PP_Resource image_data, - uint32_t* byte_count); + int32_t (*GetSharedMemory)(PP_Resource image_data, + int* handle, + uint32_t* byte_count); }; #endif // PPAPI_C_TRUSTED_PPB_IMAGE_DATA_TRUSTED_H_ diff --git a/ppapi/cpp/dev/buffer_dev.cc b/ppapi/cpp/dev/buffer_dev.cc index 57ebed7..839ab8d 100644 --- a/ppapi/cpp/dev/buffer_dev.cc +++ b/ppapi/cpp/dev/buffer_dev.cc @@ -26,7 +26,7 @@ Buffer_Dev::Buffer_Dev(const Buffer_Dev& other) size_(other.size_) { } -Buffer_Dev::Buffer_Dev(int32_t size) : data_(NULL), size_(0) { +Buffer_Dev::Buffer_Dev(uint32_t size) : data_(NULL), size_(0) { if (!buffer_f) return; diff --git a/ppapi/cpp/dev/buffer_dev.h b/ppapi/cpp/dev/buffer_dev.h index 7497a6f..8459147 100644 --- a/ppapi/cpp/dev/buffer_dev.h +++ b/ppapi/cpp/dev/buffer_dev.h @@ -18,19 +18,19 @@ class Buffer_Dev : public Resource { // Allocates a new Buffer in the browser with the given size. The // resulting object will be is_null() if the allocation failed. - explicit Buffer_Dev(int32_t size); + explicit Buffer_Dev(uint32_t size); ~Buffer_Dev(); Buffer_Dev& operator=(const Buffer_Dev& other); void swap(Buffer_Dev& other); - int32_t size() const { return size_; } + uint32_t size() const { return size_; } void* data() const { return data_; } private: void* data_; - int32_t size_; + uint32_t size_; }; } // namespace pp diff --git a/ppapi/proxy/ppapi_messages.cc b/ppapi/proxy/ppapi_messages.cc index c4bbc76..da3601f 100644 --- a/ppapi/proxy/ppapi_messages.cc +++ b/ppapi/proxy/ppapi_messages.cc @@ -12,4 +12,3 @@ // This actually defines the implementations of all the IPC message functions. #define MESSAGES_INTERNAL_IMPL_FILE "ppapi/proxy/ppapi_messages_internal.h" #include "ipc/ipc_message_impl_macros.h" - diff --git a/ppapi/proxy/ppapi_messages_internal.h b/ppapi/proxy/ppapi_messages_internal.h index e80586a..22d8a52 100644 --- a/ppapi/proxy/ppapi_messages_internal.h +++ b/ppapi/proxy/ppapi_messages_internal.h @@ -145,9 +145,9 @@ IPC_BEGIN_MESSAGES(PpapiHost) // PPB_Buffer. IPC_SYNC_MESSAGE_ROUTED2_2(PpapiHostMsg_PPBBuffer_Create, PP_Module /* module */, - int32_t /* size */, + uint32_t /* size */, PP_Resource /* result_resource */, - uint64_t /* result_shm_handle */) + int32_t /* result_shm_handle */) // PPB_Core. IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBCore_AddRefResource, PP_Resource) @@ -317,7 +317,7 @@ IPC_BEGIN_MESSAGES(PpapiHost) PP_Bool /* init_to_zero */, PP_Resource /* result_resource */, std::string /* image_data_desc */, - uint64_t /* result_shm_handle */) + int32_t /* result_shm_handle */) // PPB_Instance. IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBInstance_GetWindowObject, diff --git a/ppapi/proxy/ppb_buffer_proxy.cc b/ppapi/proxy/ppb_buffer_proxy.cc index 610ef0b..4decffd 100644 --- a/ppapi/proxy/ppb_buffer_proxy.cc +++ b/ppapi/proxy/ppb_buffer_proxy.cc @@ -20,27 +20,27 @@ namespace proxy { class Buffer : public PluginResource { public: - Buffer(uint64_t memory_handle, int32_t size); + Buffer(int memory_handle, uint32_t size); virtual ~Buffer(); // Resource overrides. virtual Buffer* AsBuffer() { return this; } - int32_t size() const { return size_; } + uint32_t size() const { return size_; } void* Map(); void Unmap(); private: - uint64_t memory_handle_; - int32_t size_; + int memory_handle_; + uint32_t size_; void* mapped_data_; DISALLOW_COPY_AND_ASSIGN(Buffer); }; -Buffer::Buffer(uint64_t memory_handle, int32_t size) +Buffer::Buffer(int memory_handle, uint32_t size) : memory_handle_(memory_handle), size_(size), mapped_data_(NULL) { @@ -61,9 +61,9 @@ void Buffer::Unmap() { namespace { -PP_Resource Create(PP_Module module_id, int32_t size) { +PP_Resource Create(PP_Module module_id, uint32_t size) { PP_Resource result = 0; - uint64_t shm_handle = -1; + int32_t shm_handle = -1; PluginDispatcher::Get()->Send( new PpapiHostMsg_PPBBuffer_Create( INTERFACE_ID_PPB_BUFFER, module_id, size, @@ -71,7 +71,7 @@ PP_Resource Create(PP_Module module_id, int32_t size) { if (!result) return 0; - linked_ptr<Buffer> object(new Buffer(shm_handle, size)); + linked_ptr<Buffer> object(new Buffer(static_cast<int>(shm_handle), size)); PluginDispatcher::Get()->plugin_resource_tracker()->AddResource( result, object); return result; @@ -82,7 +82,7 @@ PP_Bool IsBuffer(PP_Resource resource) { return BoolToPPBool(!!object); } -PP_Bool Describe(PP_Resource resource, int32_t* size_in_bytes) { +PP_Bool Describe(PP_Resource resource, uint32_t* size_in_bytes) { Buffer* object = PluginResource::GetAs<Buffer>(resource); if (!object) { *size_in_bytes = 0; @@ -139,9 +139,9 @@ void PPB_Buffer_Proxy::OnMessageReceived(const IPC::Message& msg) { } void PPB_Buffer_Proxy::OnMsgCreate(PP_Module module, - int32_t size, + uint32_t size, PP_Resource* result_resource, - uint64_t* result_shm_handle) { + int* result_shm_handle) { *result_resource = ppb_buffer_target()->Create(module, size); // TODO(brettw) set the shm handle from a trusted interface. *result_shm_handle = 0; diff --git a/ppapi/proxy/ppb_buffer_proxy.h b/ppapi/proxy/ppb_buffer_proxy.h index e1bedf9..d273193 100644 --- a/ppapi/proxy/ppb_buffer_proxy.h +++ b/ppapi/proxy/ppb_buffer_proxy.h @@ -30,9 +30,9 @@ class PPB_Buffer_Proxy : public InterfaceProxy { private: // Message handlers. void OnMsgCreate(PP_Module module, - int32_t size, + uint32_t size, PP_Resource* result_resource, - uint64_t* result_shm_handle); + int* result_shm_handle); }; } // namespace proxy diff --git a/ppapi/proxy/ppb_image_data_proxy.cc b/ppapi/proxy/ppb_image_data_proxy.cc index 54032ee..a3ffe71 100644 --- a/ppapi/proxy/ppb_image_data_proxy.cc +++ b/ppapi/proxy/ppb_image_data_proxy.cc @@ -11,6 +11,7 @@ #include "base/logging.h" #include "build/build_config.h" #include "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_errors.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/ppb_image_data.h" #include "ppapi/c/trusted/ppb_image_data_trusted.h" @@ -27,7 +28,7 @@ namespace proxy { class ImageData : public PluginResource { public: - ImageData(const PP_ImageDataDesc& desc, uint64_t memory_handle); + ImageData(const PP_ImageDataDesc& desc, int memory_handle); virtual ~ImageData(); // Resource overrides. @@ -40,7 +41,7 @@ class ImageData : public PluginResource { private: PP_ImageDataDesc desc_; - uint64_t memory_handle_; + int memory_handle_; void* mapped_data_; @@ -48,7 +49,7 @@ class ImageData : public PluginResource { }; ImageData::ImageData(const PP_ImageDataDesc& desc, - uint64_t memory_handle) + int memory_handle) : desc_(desc), memory_handle_(memory_handle), mapped_data_(NULL) { @@ -61,7 +62,7 @@ ImageData::~ImageData() { void* ImageData::Map() { #if defined(OS_LINUX) // On linux, the memory handle is a SysV shared memory segment. - int shmkey = static_cast<int>(memory_handle_); + int shmkey = memory_handle_; void* address = shmat(shmkey, NULL, 0); // Mark for deletion in case we crash so the kernel will clean it up. shmctl(shmkey, IPC_RMID, 0); @@ -110,7 +111,7 @@ PP_Resource Create(PP_Module module_id, PP_Bool init_to_zero) { PP_Resource result = 0; std::string image_data_desc; - uint64_t shm_handle = -1; + int shm_handle = -1; PluginDispatcher::Get()->Send( new PpapiHostMsg_PPBImageData_Create( INTERFACE_ID_PPB_IMAGE_DATA, module_id, format, *size, init_to_zero, @@ -210,7 +211,7 @@ void PPB_ImageData_Proxy::OnMsgCreate(PP_Module module, PP_Bool init_to_zero, PP_Resource* result, std::string* image_data_desc, - uint64_t* result_shm_handle) { + int* result_shm_handle) { *result = ppb_image_data_target()->Create( module, static_cast<PP_ImageDataFormat>(format), &size, init_to_zero); *result_shm_handle = 0; @@ -227,8 +228,11 @@ void PPB_ImageData_Proxy::OnMsgCreate(PP_Module module, reinterpret_cast<const PPB_ImageDataTrusted*>( dispatcher()->GetLocalInterface(PPB_IMAGEDATA_TRUSTED_INTERFACE)); uint32_t byte_count = 0; - if (trusted) - *result_shm_handle = trusted->GetNativeMemoryHandle(*result, &byte_count); + if (trusted) { + int32_t handle; + if (trusted->GetSharedMemory(*result, &handle, &byte_count) == PP_OK) + *result_shm_handle = static_cast<int>(handle); + } } } diff --git a/ppapi/proxy/ppb_image_data_proxy.h b/ppapi/proxy/ppb_image_data_proxy.h index fadfcc5..a61a3a7 100644 --- a/ppapi/proxy/ppb_image_data_proxy.h +++ b/ppapi/proxy/ppb_image_data_proxy.h @@ -42,7 +42,7 @@ class PPB_ImageData_Proxy : public InterfaceProxy { PP_Bool init_to_zero, PP_Resource* result, std::string* image_data_desc, - uint64_t* result_shm_handle); + int* result_shm_handle); }; } // namespace proxy diff --git a/ppapi/tests/test_buffer.cc b/ppapi/tests/test_buffer.cc index c920271..bcef727 100644 --- a/ppapi/tests/test_buffer.cc +++ b/ppapi/tests/test_buffer.cc @@ -43,7 +43,7 @@ std::string TestBuffer::TestInitToZero() { // Now check that everything is 0. unsigned char* bytes = static_cast<unsigned char *>(buffer.data()); - for (int index = 0; index < buffer.size(); index++) { + for (uint32_t index = 0; index < buffer.size(); index++) { if (bytes[index] != 0) return "Buffer isn't entirely zero"; } |