Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(442)

Side by Side Diff: webkit/plugins/ppapi/ppb_buffer_impl.h

Issue 20165002: Move webkit/plugins/ppapi to content/renderer/pepper. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: more more clang fun Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/plugins/ppapi/ppb_broker_impl.cc ('k') | webkit/plugins/ppapi/ppb_buffer_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_BUFFER_IMPL_H_
6 #define WEBKIT_PLUGINS_PPAPI_PPB_BUFFER_IMPL_H_
7
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/shared_memory.h"
12 #include "ppapi/shared_impl/resource.h"
13 #include "ppapi/thunk/ppb_buffer_api.h"
14 #include "webkit/plugins/webkit_plugins_export.h"
15
16 namespace webkit {
17 namespace ppapi {
18
19 class WEBKIT_PLUGINS_EXPORT PPB_Buffer_Impl :
20 public ::ppapi::Resource,
21 public ::ppapi::thunk::PPB_Buffer_API {
22 public:
23 virtual ~PPB_Buffer_Impl();
24
25 static PP_Resource Create(PP_Instance instance, uint32_t size);
26 static scoped_refptr<PPB_Buffer_Impl> CreateResource(PP_Instance instance,
27 uint32_t size);
28
29 virtual PPB_Buffer_Impl* AsPPB_Buffer_Impl();
30
31 base::SharedMemory* shared_memory() const { return shared_memory_.get(); }
32 uint32_t size() const { return size_; }
33
34 // Resource overrides.
35 virtual ::ppapi::thunk::PPB_Buffer_API* AsPPB_Buffer_API() OVERRIDE;
36
37 // PPB_Buffer_API implementation.
38 virtual PP_Bool Describe(uint32_t* size_in_bytes) OVERRIDE;
39 virtual PP_Bool IsMapped() OVERRIDE;
40 virtual void* Map() OVERRIDE;
41 virtual void Unmap() OVERRIDE;
42
43 // Trusted.
44 virtual int32_t GetSharedMemory(int* handle) OVERRIDE;
45
46 private:
47 explicit PPB_Buffer_Impl(PP_Instance instance);
48 bool Init(uint32_t size);
49
50 scoped_ptr<base::SharedMemory> shared_memory_;
51 uint32_t size_;
52 int map_count_;
53
54 DISALLOW_COPY_AND_ASSIGN(PPB_Buffer_Impl);
55 };
56
57 // Ensures that the given buffer is mapped, and returns it to its previous
58 // mapped state in the destructor.
59 class BufferAutoMapper {
60 public:
61 explicit BufferAutoMapper(::ppapi::thunk::PPB_Buffer_API* api);
62 ~BufferAutoMapper();
63
64 // Will be NULL on failure to map.
65 void* data() { return data_; }
66 uint32_t size() { return size_; }
67
68 private:
69 ::ppapi::thunk::PPB_Buffer_API* api_;
70
71 bool needs_unmap_;
72
73 void* data_;
74 uint32_t size_;
75
76 DISALLOW_COPY_AND_ASSIGN(BufferAutoMapper);
77 };
78
79 } // namespace ppapi
80 } // namespace webkit
81
82 #endif // WEBKIT_PLUGINS_PPAPI_PPB_BUFFER_IMPL_H_
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_broker_impl.cc ('k') | webkit/plugins/ppapi/ppb_buffer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698