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" |
(...skipping 106 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 |