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 "ppapi/shared_impl/resource.h" | 13 #include "ppapi/shared_impl/resource.h" |
14 | 14 |
15 struct PPB_Buffer_Dev; | |
16 | |
17 namespace webkit { | 15 namespace webkit { |
18 namespace ppapi { | 16 namespace ppapi { |
19 | 17 |
20 class PPB_Buffer_Impl : public ::ppapi::Resource, | 18 class PPB_Buffer_Impl : public ::ppapi::Resource, |
21 public ::ppapi::thunk::PPB_Buffer_API, | 19 public ::ppapi::thunk::PPB_Buffer_API, |
22 public ::ppapi::thunk::PPB_BufferTrusted_API { | 20 public ::ppapi::thunk::PPB_BufferTrusted_API { |
23 public: | 21 public: |
24 virtual ~PPB_Buffer_Impl(); | 22 virtual ~PPB_Buffer_Impl(); |
25 | 23 |
26 static PP_Resource Create(PP_Instance instance, uint32_t size); | 24 static PP_Resource Create(PP_Instance instance, uint32_t size); |
(...skipping 24 matching lines...) Expand all Loading... |
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 |
57 // Ensures that the given buffer is mapped, and returns it to its previous | 55 // Ensures that the given buffer is mapped, and returns it to its previous |
58 // mapped state in the destructor. | 56 // mapped state in the destructor. |
59 class BufferAutoMapper { | 57 class BufferAutoMapper { |
60 public: | 58 public: |
61 BufferAutoMapper(::ppapi::thunk::PPB_Buffer_API* api); | 59 explicit BufferAutoMapper(::ppapi::thunk::PPB_Buffer_API* api); |
62 ~BufferAutoMapper(); | 60 ~BufferAutoMapper(); |
63 | 61 |
64 // Will be NULL on failure to map. | 62 // Will be NULL on failure to map. |
65 void* data() { return data_; } | 63 void* data() { return data_; } |
66 uint32_t size() { return size_; } | 64 uint32_t size() { return size_; } |
67 | 65 |
68 private: | 66 private: |
69 ::ppapi::thunk::PPB_Buffer_API* api_; | 67 ::ppapi::thunk::PPB_Buffer_API* api_; |
70 | 68 |
71 bool needs_unmap_; | 69 bool needs_unmap_; |
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 // WEBKIT_PLUGINS_PPAPI_PPB_BUFFER_IMPL_H_ |
OLD | NEW |