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