OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ppapi_messages.h" | 17 #include "ppapi/proxy/ppapi_messages.h" |
18 #include "ppapi/thunk/enter.h" | 18 #include "ppapi/thunk/enter.h" |
19 #include "ppapi/thunk/ppb_buffer_trusted_api.h" | 19 #include "ppapi/thunk/ppb_buffer_trusted_api.h" |
yzshen1
2013/03/20 17:08:38
This needs to be changed, right?
teravest
2013/03/20 17:12:42
Done.
| |
20 #include "ppapi/thunk/resource_creation_api.h" | 20 #include "ppapi/thunk/resource_creation_api.h" |
21 #include "ppapi/thunk/thunk.h" | 21 #include "ppapi/thunk/thunk.h" |
22 | 22 |
23 namespace ppapi { | 23 namespace ppapi { |
24 namespace proxy { | 24 namespace proxy { |
25 | 25 |
26 Buffer::Buffer(const HostResource& resource, | 26 Buffer::Buffer(const HostResource& resource, |
27 const base::SharedMemoryHandle& shm_handle, | 27 const base::SharedMemoryHandle& shm_handle, |
28 uint32_t size) | 28 uint32_t size) |
29 : Resource(OBJECT_IS_PROXY, resource), | 29 : Resource(OBJECT_IS_PROXY, resource), |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 return; | 117 return; |
118 | 118 |
119 thunk::EnterResourceCreation enter(instance); | 119 thunk::EnterResourceCreation enter(instance); |
120 if (enter.failed()) | 120 if (enter.failed()) |
121 return; | 121 return; |
122 PP_Resource local_buffer_resource = enter.functions()->CreateBuffer(instance, | 122 PP_Resource local_buffer_resource = enter.functions()->CreateBuffer(instance, |
123 size); | 123 size); |
124 if (local_buffer_resource == 0) | 124 if (local_buffer_resource == 0) |
125 return; | 125 return; |
126 | 126 |
127 thunk::EnterResourceNoLock<thunk::PPB_BufferTrusted_API> trusted_buffer( | 127 thunk::EnterResourceNoLock<thunk::PPB_Buffer_API> trusted_buffer( |
128 local_buffer_resource, false); | 128 local_buffer_resource, false); |
129 if (trusted_buffer.failed()) | 129 if (trusted_buffer.failed()) |
130 return; | 130 return; |
131 int local_fd; | 131 int local_fd; |
132 if (trusted_buffer.object()->GetSharedMemory(&local_fd) != PP_OK) | 132 if (trusted_buffer.object()->GetSharedMemory(&local_fd) != PP_OK) |
133 return; | 133 return; |
134 | 134 |
135 result_resource->SetHostResource(instance, local_buffer_resource); | 135 result_resource->SetHostResource(instance, local_buffer_resource); |
136 | 136 |
137 // TODO(piman/brettw): Change trusted interface to return a PP_FileHandle, | 137 // TODO(piman/brettw): Change trusted interface to return a PP_FileHandle, |
138 // those casts are ugly. | 138 // those casts are ugly. |
139 base::PlatformFile platform_file = | 139 base::PlatformFile platform_file = |
140 #if defined(OS_WIN) | 140 #if defined(OS_WIN) |
141 reinterpret_cast<HANDLE>(static_cast<intptr_t>(local_fd)); | 141 reinterpret_cast<HANDLE>(static_cast<intptr_t>(local_fd)); |
142 #elif defined(OS_POSIX) | 142 #elif defined(OS_POSIX) |
143 local_fd; | 143 local_fd; |
144 #else | 144 #else |
145 #error Not implemented. | 145 #error Not implemented. |
146 #endif | 146 #endif |
147 result_shm_handle->set_shmem( | 147 result_shm_handle->set_shmem( |
148 dispatcher->ShareHandleWithRemote(platform_file, false), size); | 148 dispatcher->ShareHandleWithRemote(platform_file, false), size); |
149 } | 149 } |
150 | 150 |
151 } // namespace proxy | 151 } // namespace proxy |
152 } // namespace ppapi | 152 } // namespace ppapi |
OLD | NEW |