| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PPAPI_PPB_BUFFER_PROXY_H_ | 5 #ifndef PPAPI_PPB_BUFFER_PROXY_H_ |
| 6 #define PPAPI_PPB_BUFFER_PROXY_H_ | 6 #define PPAPI_PPB_BUFFER_PROXY_H_ |
| 7 | 7 |
| 8 #include "base/shared_memory.h" | 8 #include "base/shared_memory.h" |
| 9 #include "ppapi/c/pp_instance.h" | 9 #include "ppapi/c/pp_instance.h" |
| 10 #include "ppapi/proxy/interface_proxy.h" | 10 #include "ppapi/proxy/interface_proxy.h" |
| 11 #include "ppapi/shared_impl/resource.h" | 11 #include "ppapi/shared_impl/resource.h" |
| 12 #include "ppapi/thunk/ppb_buffer_api.h" | 12 #include "ppapi/thunk/ppb_buffer_api.h" |
| 13 | 13 |
| 14 struct PPB_Buffer_Dev; | 14 struct PPB_Buffer_Dev; |
| 15 | 15 |
| 16 namespace ppapi { | 16 namespace ppapi { |
| 17 |
| 17 class HostResource; | 18 class HostResource; |
| 18 } | |
| 19 | 19 |
| 20 namespace pp { | |
| 21 namespace proxy { | 20 namespace proxy { |
| 22 | 21 |
| 23 class Buffer : public ppapi::thunk::PPB_Buffer_API, | 22 class Buffer : public thunk::PPB_Buffer_API, public Resource { |
| 24 public ppapi::Resource { | |
| 25 public: | 23 public: |
| 26 Buffer(const ppapi::HostResource& resource, | 24 Buffer(const HostResource& resource, |
| 27 const base::SharedMemoryHandle& shm_handle, | 25 const base::SharedMemoryHandle& shm_handle, |
| 28 uint32_t size); | 26 uint32_t size); |
| 29 virtual ~Buffer(); | 27 virtual ~Buffer(); |
| 30 | 28 |
| 31 // Resource overrides. | 29 // Resource overrides. |
| 32 virtual ppapi::thunk::PPB_Buffer_API* AsPPB_Buffer_API() OVERRIDE; | 30 virtual thunk::PPB_Buffer_API* AsPPB_Buffer_API() OVERRIDE; |
| 33 | 31 |
| 34 // PPB_Buffer_API implementation. | 32 // PPB_Buffer_API implementation. |
| 35 virtual PP_Bool Describe(uint32_t* size_in_bytes) OVERRIDE; | 33 virtual PP_Bool Describe(uint32_t* size_in_bytes) OVERRIDE; |
| 36 virtual PP_Bool IsMapped() OVERRIDE; | 34 virtual PP_Bool IsMapped() OVERRIDE; |
| 37 virtual void* Map() OVERRIDE; | 35 virtual void* Map() OVERRIDE; |
| 38 virtual void Unmap() OVERRIDE; | 36 virtual void Unmap() OVERRIDE; |
| 39 | 37 |
| 40 private: | 38 private: |
| 41 base::SharedMemory shm_; | 39 base::SharedMemory shm_; |
| 42 uint32_t size_; | 40 uint32_t size_; |
| 43 void* mapped_data_; | 41 void* mapped_data_; |
| 44 int map_count_; | 42 int map_count_; |
| 45 | 43 |
| 46 DISALLOW_COPY_AND_ASSIGN(Buffer); | 44 DISALLOW_COPY_AND_ASSIGN(Buffer); |
| 47 }; | 45 }; |
| 48 | 46 |
| 49 class PPB_Buffer_Proxy : public InterfaceProxy { | 47 class PPB_Buffer_Proxy : public InterfaceProxy { |
| 50 public: | 48 public: |
| 51 PPB_Buffer_Proxy(Dispatcher* dispatcher, const void* target_interface); | 49 PPB_Buffer_Proxy(Dispatcher* dispatcher, const void* target_interface); |
| 52 virtual ~PPB_Buffer_Proxy(); | 50 virtual ~PPB_Buffer_Proxy(); |
| 53 | 51 |
| 54 static const Info* GetInfo(); | 52 static const Info* GetInfo(); |
| 55 | 53 |
| 56 static PP_Resource CreateProxyResource(PP_Instance instance, | 54 static PP_Resource CreateProxyResource(PP_Instance instance, |
| 57 uint32_t size); | 55 uint32_t size); |
| 58 static PP_Resource AddProxyResource(const ppapi::HostResource& resource, | 56 static PP_Resource AddProxyResource(const HostResource& resource, |
| 59 base::SharedMemoryHandle shm_handle, | 57 base::SharedMemoryHandle shm_handle, |
| 60 uint32_t size); | 58 uint32_t size); |
| 61 | 59 |
| 62 const PPB_Buffer_Dev* ppb_buffer_target() const { | 60 const PPB_Buffer_Dev* ppb_buffer_target() const { |
| 63 return static_cast<const PPB_Buffer_Dev*>(target_interface()); | 61 return static_cast<const PPB_Buffer_Dev*>(target_interface()); |
| 64 } | 62 } |
| 65 | 63 |
| 66 // InterfaceProxy implementation. | 64 // InterfaceProxy implementation. |
| 67 virtual bool OnMessageReceived(const IPC::Message& msg); | 65 virtual bool OnMessageReceived(const IPC::Message& msg); |
| 68 | 66 |
| 69 private: | 67 private: |
| 70 // Message handlers. | 68 // Message handlers. |
| 71 void OnMsgCreate(PP_Instance instance, | 69 void OnMsgCreate(PP_Instance instance, |
| 72 uint32_t size, | 70 uint32_t size, |
| 73 ppapi::HostResource* result_resource, | 71 HostResource* result_resource, |
| 74 base::SharedMemoryHandle* result_shm_handle); | 72 base::SharedMemoryHandle* result_shm_handle); |
| 75 }; | 73 }; |
| 76 | 74 |
| 77 } // namespace proxy | 75 } // namespace proxy |
| 78 } // namespace pp | 76 } // namespace ppapi |
| 79 | 77 |
| 80 #endif // PPAPI_PPB_BUFFER_PROXY_H_ | 78 #endif // PPAPI_PPB_BUFFER_PROXY_H_ |
| OLD | NEW |