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