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 #include "ppapi/proxy/ppb_buffer_proxy.h" | 5 #include "ppapi/proxy/ppb_buffer_proxy.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "ppapi/c/pp_completion_callback.h" | 11 #include "ppapi/c/pp_completion_callback.h" |
12 #include "ppapi/c/pp_errors.h" | 12 #include "ppapi/c/pp_errors.h" |
13 #include "ppapi/c/pp_resource.h" | 13 #include "ppapi/c/pp_resource.h" |
14 #include "ppapi/c/dev/ppb_buffer_dev.h" | 14 #include "ppapi/c/dev/ppb_buffer_dev.h" |
15 #include "ppapi/proxy/host_dispatcher.h" | 15 #include "ppapi/proxy/host_dispatcher.h" |
16 #include "ppapi/proxy/plugin_dispatcher.h" | 16 #include "ppapi/proxy/plugin_dispatcher.h" |
17 #include "ppapi/proxy/plugin_resource.h" | 17 #include "ppapi/proxy/plugin_resource.h" |
Ami GONE FROM CHROMIUM
2011/08/02 00:49:08
drop?
vrk (LEFT CHROMIUM)
2011/08/03 19:04:30
Done.
| |
18 #include "ppapi/proxy/ppapi_messages.h" | 18 #include "ppapi/proxy/ppapi_messages.h" |
19 #include "ppapi/thunk/enter.h" | 19 #include "ppapi/thunk/enter.h" |
20 #include "ppapi/thunk/ppb_buffer_api.h" | |
21 #include "ppapi/thunk/ppb_buffer_trusted_api.h" | 20 #include "ppapi/thunk/ppb_buffer_trusted_api.h" |
22 #include "ppapi/thunk/thunk.h" | 21 #include "ppapi/thunk/thunk.h" |
23 | 22 |
24 namespace pp { | 23 namespace pp { |
25 namespace proxy { | 24 namespace proxy { |
26 | 25 |
27 namespace { | 26 namespace { |
28 | 27 |
29 InterfaceProxy* CreateBufferProxy(Dispatcher* dispatcher, | 28 InterfaceProxy* CreateBufferProxy(Dispatcher* dispatcher, |
30 const void* target_interface) { | 29 const void* target_interface) { |
31 return new PPB_Buffer_Proxy(dispatcher, target_interface); | 30 return new PPB_Buffer_Proxy(dispatcher, target_interface); |
32 } | 31 } |
33 | 32 |
34 } // namespace | 33 } // namespace |
35 | 34 |
36 class Buffer : public ppapi::thunk::PPB_Buffer_API, | |
37 public PluginResource { | |
38 public: | |
39 Buffer(const HostResource& resource, | |
40 const base::SharedMemoryHandle& shm_handle, | |
41 uint32_t size); | |
42 virtual ~Buffer(); | |
43 | |
44 // Resource overrides. | |
45 virtual Buffer* AsBuffer() OVERRIDE; | |
46 | |
47 // ResourceObjectBase overrides. | |
48 virtual ppapi::thunk::PPB_Buffer_API* AsPPB_Buffer_API() OVERRIDE; | |
49 | |
50 // PPB_Buffer_API implementation. | |
51 virtual PP_Bool Describe(uint32_t* size_in_bytes) OVERRIDE; | |
52 virtual PP_Bool IsMapped() OVERRIDE; | |
53 virtual void* Map() OVERRIDE; | |
54 virtual void Unmap() OVERRIDE; | |
55 | |
56 private: | |
57 base::SharedMemory shm_; | |
58 uint32_t size_; | |
59 void* mapped_data_; | |
60 int map_count_; | |
61 | |
62 DISALLOW_COPY_AND_ASSIGN(Buffer); | |
63 }; | |
64 | |
65 Buffer::Buffer(const HostResource& resource, | 35 Buffer::Buffer(const HostResource& resource, |
66 const base::SharedMemoryHandle& shm_handle, | 36 const base::SharedMemoryHandle& shm_handle, |
67 uint32_t size) | 37 uint32_t size) |
68 : PluginResource(resource), | 38 : PluginResource(resource), |
69 shm_(shm_handle, false), | 39 shm_(shm_handle, false), |
70 size_(size), | 40 size_(size), |
71 mapped_data_(NULL), | 41 mapped_data_(NULL), |
72 map_count_(0) { | 42 map_count_(0) { |
73 } | 43 } |
74 | 44 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
185 #elif defined(OS_POSIX) | 155 #elif defined(OS_POSIX) |
186 local_fd; | 156 local_fd; |
187 #else | 157 #else |
188 #error Not implemented. | 158 #error Not implemented. |
189 #endif | 159 #endif |
190 *result_shm_handle = dispatcher->ShareHandleWithRemote(platform_file, false); | 160 *result_shm_handle = dispatcher->ShareHandleWithRemote(platform_file, false); |
191 } | 161 } |
192 | 162 |
193 } // namespace proxy | 163 } // namespace proxy |
194 } // namespace pp | 164 } // namespace pp |
OLD | NEW |