| 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_instance_proxy.h" | 5 #include "ppapi/proxy/ppb_instance_proxy.h" |
| 6 | 6 |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
| 10 #include "ppapi/c/pp_time.h" | 10 #include "ppapi/c/pp_time.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 IPC_END_MESSAGE_MAP() | 196 IPC_END_MESSAGE_MAP() |
| 197 return handled; | 197 return handled; |
| 198 } | 198 } |
| 199 | 199 |
| 200 PP_Bool PPB_Instance_Proxy::BindGraphics(PP_Instance instance, | 200 PP_Bool PPB_Instance_Proxy::BindGraphics(PP_Instance instance, |
| 201 PP_Resource device) { | 201 PP_Resource device) { |
| 202 // If device is 0, pass a null HostResource. This signals the host to unbind | 202 // If device is 0, pass a null HostResource. This signals the host to unbind |
| 203 // all devices. | 203 // all devices. |
| 204 HostResource host_resource; | 204 HostResource host_resource; |
| 205 PP_Resource pp_resource = 0; | 205 PP_Resource pp_resource = 0; |
| 206 PP_Bool result = PP_FALSE; | |
| 207 if (device) { | 206 if (device) { |
| 208 Resource* resource = | 207 Resource* resource = |
| 209 PpapiGlobals::Get()->GetResourceTracker()->GetResource(device); | 208 PpapiGlobals::Get()->GetResourceTracker()->GetResource(device); |
| 210 if (!resource || resource->pp_instance() != instance) | 209 if (!resource || resource->pp_instance() != instance) |
| 211 return PP_FALSE; | 210 return PP_FALSE; |
| 212 host_resource = resource->host_resource(); | 211 host_resource = resource->host_resource(); |
| 213 pp_resource = resource->pp_resource(); | 212 pp_resource = resource->pp_resource(); |
| 214 } else { | 213 } else { |
| 215 // Passing 0 means unbinding all devices. | 214 // Passing 0 means unbinding all devices. |
| 216 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics( | 215 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics( |
| 217 API_ID_PPB_INSTANCE, instance, 0, &result)); | 216 API_ID_PPB_INSTANCE, instance, 0)); |
| 218 return result; | 217 return PP_TRUE; |
| 219 } | 218 } |
| 220 | 219 |
| 221 // We need to pass different resource to Graphics 2D and 3D right now. Once | 220 // We need to pass different resource to Graphics 2D and 3D right now. Once |
| 222 // 3D is migrated to the new design, we should be able to unify this. | 221 // 3D is migrated to the new design, we should be able to unify this. |
| 223 EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false); | 222 EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false); |
| 224 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); | 223 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); |
| 225 if (enter_2d.succeeded()) { | 224 if (enter_2d.succeeded()) { |
| 226 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics( | 225 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics( |
| 227 API_ID_PPB_INSTANCE, instance, pp_resource, | 226 API_ID_PPB_INSTANCE, instance, pp_resource)); |
| 228 &result)); | 227 return PP_TRUE; |
| 229 } else if (enter_3d.succeeded()) { | 228 } else if (enter_3d.succeeded()) { |
| 230 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics( | 229 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics( |
| 231 API_ID_PPB_INSTANCE, instance, host_resource.host_resource(), | 230 API_ID_PPB_INSTANCE, instance, host_resource.host_resource())); |
| 232 &result)); | 231 return PP_TRUE; |
| 233 } | 232 } |
| 234 return result; | 233 return PP_FALSE; |
| 235 } | 234 } |
| 236 | 235 |
| 237 PP_Bool PPB_Instance_Proxy::IsFullFrame(PP_Instance instance) { | 236 PP_Bool PPB_Instance_Proxy::IsFullFrame(PP_Instance instance) { |
| 238 PP_Bool result = PP_FALSE; | 237 PP_Bool result = PP_FALSE; |
| 239 dispatcher()->Send(new PpapiHostMsg_PPBInstance_IsFullFrame( | 238 dispatcher()->Send(new PpapiHostMsg_PPBInstance_IsFullFrame( |
| 240 API_ID_PPB_INSTANCE, instance, &result)); | 239 API_ID_PPB_INSTANCE, instance, &result)); |
| 241 return result; | 240 return result; |
| 242 } | 241 } |
| 243 | 242 |
| 244 const ViewData* PPB_Instance_Proxy::GetViewData(PP_Instance instance) { | 243 const ViewData* PPB_Instance_Proxy::GetViewData(PP_Instance instance) { |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 PP_Instance instance, | 802 PP_Instance instance, |
| 804 SerializedVarReturnValue result) { | 803 SerializedVarReturnValue result) { |
| 805 EnterInstanceNoLock enter(instance); | 804 EnterInstanceNoLock enter(instance); |
| 806 if (enter.succeeded()) { | 805 if (enter.succeeded()) { |
| 807 result.Return(dispatcher(), | 806 result.Return(dispatcher(), |
| 808 enter.functions()->GetOwnerElementObject(instance)); | 807 enter.functions()->GetOwnerElementObject(instance)); |
| 809 } | 808 } |
| 810 } | 809 } |
| 811 | 810 |
| 812 void PPB_Instance_Proxy::OnHostMsgBindGraphics(PP_Instance instance, | 811 void PPB_Instance_Proxy::OnHostMsgBindGraphics(PP_Instance instance, |
| 813 PP_Resource device, | 812 PP_Resource device) { |
| 814 PP_Bool* result) { | 813 // Note that we ignroe the return value here. Otherwise, this would need to |
| 814 // be a slow sync call, and the plugin side of the proxy will have already |
| 815 // validated the resources, so we shouldn't see errors here that weren't |
| 816 // already caught. |
| 815 EnterInstanceNoLock enter(instance); | 817 EnterInstanceNoLock enter(instance); |
| 816 if (enter.succeeded()) { | 818 if (enter.succeeded()) |
| 817 *result = enter.functions()->BindGraphics(instance, device); | 819 enter.functions()->BindGraphics(instance, device); |
| 818 } | |
| 819 } | 820 } |
| 820 | 821 |
| 821 void PPB_Instance_Proxy::OnHostMsgGetAudioHardwareOutputSampleRate( | 822 void PPB_Instance_Proxy::OnHostMsgGetAudioHardwareOutputSampleRate( |
| 822 PP_Instance instance, uint32_t* result) { | 823 PP_Instance instance, uint32_t* result) { |
| 823 EnterInstanceNoLock enter(instance); | 824 EnterInstanceNoLock enter(instance); |
| 824 if (enter.succeeded()) | 825 if (enter.succeeded()) |
| 825 *result = enter.functions()->GetAudioHardwareOutputSampleRate(instance); | 826 *result = enter.functions()->GetAudioHardwareOutputSampleRate(instance); |
| 826 } | 827 } |
| 827 | 828 |
| 828 void PPB_Instance_Proxy::OnHostMsgGetAudioHardwareOutputBufferSize( | 829 void PPB_Instance_Proxy::OnHostMsgGetAudioHardwareOutputBufferSize( |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 PP_Instance instance) { | 1194 PP_Instance instance) { |
| 1194 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> | 1195 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> |
| 1195 GetInstanceData(instance); | 1196 GetInstanceData(instance); |
| 1196 if (!data) | 1197 if (!data) |
| 1197 return; // Instance was probably deleted. | 1198 return; // Instance was probably deleted. |
| 1198 data->should_do_request_surrounding_text = false; | 1199 data->should_do_request_surrounding_text = false; |
| 1199 } | 1200 } |
| 1200 | 1201 |
| 1201 } // namespace proxy | 1202 } // namespace proxy |
| 1202 } // namespace ppapi | 1203 } // namespace ppapi |
| OLD | NEW |