| 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 WEBKIT_PLUGINS_PPAPI_PPB_BUFFER_IMPL_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_BUFFER_IMPL_H_ |
| 6 #define WEBKIT_PLUGINS_PPAPI_PPB_BUFFER_IMPL_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_PPB_BUFFER_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/shared_memory.h" | 11 #include "base/shared_memory.h" |
| 12 #include "ppapi/thunk/ppb_buffer_api.h" | 12 #include "ppapi/thunk/ppb_buffer_api.h" |
| 13 #include "ppapi/thunk/ppb_buffer_trusted_api.h" | |
| 14 #include "ppapi/shared_impl/resource.h" | 13 #include "ppapi/shared_impl/resource.h" |
| 15 #include "webkit/plugins/webkit_plugins_export.h" | 14 #include "webkit/plugins/webkit_plugins_export.h" |
| 16 | 15 |
| 17 namespace webkit { | 16 namespace webkit { |
| 18 namespace ppapi { | 17 namespace ppapi { |
| 19 | 18 |
| 20 class WEBKIT_PLUGINS_EXPORT PPB_Buffer_Impl : | 19 class WEBKIT_PLUGINS_EXPORT PPB_Buffer_Impl : |
| 21 public ::ppapi::Resource, | 20 public ::ppapi::Resource, |
| 22 public ::ppapi::thunk::PPB_Buffer_API, | 21 public ::ppapi::thunk::PPB_Buffer_API { |
| 23 public ::ppapi::thunk::PPB_BufferTrusted_API { | |
| 24 public: | 22 public: |
| 25 virtual ~PPB_Buffer_Impl(); | 23 virtual ~PPB_Buffer_Impl(); |
| 26 | 24 |
| 27 static PP_Resource Create(PP_Instance instance, uint32_t size); | 25 static PP_Resource Create(PP_Instance instance, uint32_t size); |
| 28 static scoped_refptr<PPB_Buffer_Impl> CreateResource(PP_Instance instance, | 26 static scoped_refptr<PPB_Buffer_Impl> CreateResource(PP_Instance instance, |
| 29 uint32_t size); | 27 uint32_t size); |
| 30 | 28 |
| 31 virtual PPB_Buffer_Impl* AsPPB_Buffer_Impl(); | 29 virtual PPB_Buffer_Impl* AsPPB_Buffer_Impl(); |
| 32 | 30 |
| 33 base::SharedMemory* shared_memory() const { return shared_memory_.get(); } | 31 base::SharedMemory* shared_memory() const { return shared_memory_.get(); } |
| 34 uint32_t size() const { return size_; } | 32 uint32_t size() const { return size_; } |
| 35 | 33 |
| 36 // Resource overrides. | 34 // Resource overrides. |
| 37 virtual ::ppapi::thunk::PPB_Buffer_API* AsPPB_Buffer_API() OVERRIDE; | 35 virtual ::ppapi::thunk::PPB_Buffer_API* AsPPB_Buffer_API() OVERRIDE; |
| 38 virtual ::ppapi::thunk::PPB_BufferTrusted_API* AsPPB_BufferTrusted_API(); | |
| 39 | 36 |
| 40 // PPB_Buffer_API implementation. | 37 // PPB_Buffer_API implementation. |
| 41 virtual PP_Bool Describe(uint32_t* size_in_bytes) OVERRIDE; | 38 virtual PP_Bool Describe(uint32_t* size_in_bytes) OVERRIDE; |
| 42 virtual PP_Bool IsMapped() OVERRIDE; | 39 virtual PP_Bool IsMapped() OVERRIDE; |
| 43 virtual void* Map() OVERRIDE; | 40 virtual void* Map() OVERRIDE; |
| 44 virtual void Unmap() OVERRIDE; | 41 virtual void Unmap() OVERRIDE; |
| 45 | 42 |
| 46 // PPB_BufferTrusted_API implementation. | 43 // Trusted. |
| 47 virtual int32_t GetSharedMemory(int* handle) OVERRIDE; | 44 virtual int32_t GetSharedMemory(int* handle) OVERRIDE; |
| 48 | 45 |
| 49 private: | 46 private: |
| 50 explicit PPB_Buffer_Impl(PP_Instance instance); | 47 explicit PPB_Buffer_Impl(PP_Instance instance); |
| 51 bool Init(uint32_t size); | 48 bool Init(uint32_t size); |
| 52 | 49 |
| 53 scoped_ptr<base::SharedMemory> shared_memory_; | 50 scoped_ptr<base::SharedMemory> shared_memory_; |
| 54 uint32_t size_; | 51 uint32_t size_; |
| 55 int map_count_; | 52 int map_count_; |
| 56 | 53 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 76 void* data_; | 73 void* data_; |
| 77 uint32_t size_; | 74 uint32_t size_; |
| 78 | 75 |
| 79 DISALLOW_COPY_AND_ASSIGN(BufferAutoMapper); | 76 DISALLOW_COPY_AND_ASSIGN(BufferAutoMapper); |
| 80 }; | 77 }; |
| 81 | 78 |
| 82 } // namespace ppapi | 79 } // namespace ppapi |
| 83 } // namespace webkit | 80 } // namespace webkit |
| 84 | 81 |
| 85 #endif // WEBKIT_PLUGINS_PPAPI_PPB_BUFFER_IMPL_H_ | 82 #endif // WEBKIT_PLUGINS_PPAPI_PPB_BUFFER_IMPL_H_ |
| OLD | NEW |