| 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 "ppapi/c/pp_errors.h" | 7 #include "ppapi/c/pp_errors.h" |
| 8 #include "ppapi/c/pp_time.h" | 8 #include "ppapi/c/pp_time.h" |
| 9 #include "ppapi/c/pp_var.h" | 9 #include "ppapi/c/pp_var.h" |
| 10 #include "ppapi/c/ppb_audio_config.h" | 10 #include "ppapi/c/ppb_audio_config.h" |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 image_host_resource = cursor_image->host_resource(); | 429 image_host_resource = cursor_image->host_resource(); |
| 430 } | 430 } |
| 431 | 431 |
| 432 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetCursor( | 432 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetCursor( |
| 433 API_ID_PPB_INSTANCE, instance, static_cast<int32_t>(type), | 433 API_ID_PPB_INSTANCE, instance, static_cast<int32_t>(type), |
| 434 image_host_resource, hot_spot ? *hot_spot : PP_MakePoint(0, 0))); | 434 image_host_resource, hot_spot ? *hot_spot : PP_MakePoint(0, 0))); |
| 435 return PP_TRUE; | 435 return PP_TRUE; |
| 436 } | 436 } |
| 437 | 437 |
| 438 int32_t PPB_Instance_Proxy::LockMouse(PP_Instance instance, | 438 int32_t PPB_Instance_Proxy::LockMouse(PP_Instance instance, |
| 439 PP_CompletionCallback callback) { | 439 ApiCallbackType callback) { |
| 440 if (!callback.func) | |
| 441 return PP_ERROR_BADARGUMENT; | |
| 442 | |
| 443 // Save the mouse callback on the instance data. | 440 // Save the mouse callback on the instance data. |
| 444 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> | 441 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> |
| 445 GetInstanceData(instance); | 442 GetInstanceData(instance); |
| 446 if (!data) | 443 if (!data) |
| 447 return PP_ERROR_BADARGUMENT; | 444 return PP_ERROR_BADARGUMENT; |
| 448 if (data->mouse_lock_callback.func) | 445 if (TrackedCallback::IsPending(data->mouse_lock_callback)) |
| 449 return PP_ERROR_INPROGRESS; // Already have a pending callback. | 446 return PP_ERROR_INPROGRESS; // Already have a pending callback. |
| 450 data->mouse_lock_callback = callback; | 447 data->mouse_lock_callback = callback; |
| 451 | 448 |
| 452 dispatcher()->Send(new PpapiHostMsg_PPBInstance_LockMouse( | 449 dispatcher()->Send(new PpapiHostMsg_PPBInstance_LockMouse( |
| 453 API_ID_PPB_INSTANCE, instance)); | 450 API_ID_PPB_INSTANCE, instance)); |
| 454 return PP_OK_COMPLETIONPENDING; | 451 return PP_OK_COMPLETIONPENDING; |
| 455 } | 452 } |
| 456 | 453 |
| 457 void PPB_Instance_Proxy::UnlockMouse(PP_Instance instance) { | 454 void PPB_Instance_Proxy::UnlockMouse(PP_Instance instance) { |
| 458 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UnlockMouse( | 455 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UnlockMouse( |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 } | 681 } |
| 685 } | 682 } |
| 686 | 683 |
| 687 void PPB_Instance_Proxy::OnPluginMsgMouseLockComplete(PP_Instance instance, | 684 void PPB_Instance_Proxy::OnPluginMsgMouseLockComplete(PP_Instance instance, |
| 688 int32_t result) { | 685 int32_t result) { |
| 689 // Save the mouse callback on the instance data. | 686 // Save the mouse callback on the instance data. |
| 690 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> | 687 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> |
| 691 GetInstanceData(instance); | 688 GetInstanceData(instance); |
| 692 if (!data) | 689 if (!data) |
| 693 return; // Instance was probably deleted. | 690 return; // Instance was probably deleted. |
| 694 if (!data->mouse_lock_callback.func) { | 691 if (TrackedCallback::IsPending(data->mouse_lock_callback)) { |
| 695 NOTREACHED(); | 692 NOTREACHED(); |
| 696 return; | 693 return; |
| 697 } | 694 } |
| 698 PP_RunAndClearCompletionCallback(&data->mouse_lock_callback, result); | 695 TrackedCallback::ClearAndRun(&(data->mouse_lock_callback), result); |
| 699 } | 696 } |
| 700 | 697 |
| 701 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result, | 698 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result, |
| 702 PP_Instance instance) { | 699 PP_Instance instance) { |
| 703 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete( | 700 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete( |
| 704 API_ID_PPB_INSTANCE, instance, result)); | 701 API_ID_PPB_INSTANCE, instance, result)); |
| 705 } | 702 } |
| 706 | 703 |
| 707 } // namespace proxy | 704 } // namespace proxy |
| 708 } // namespace ppapi | 705 } // namespace ppapi |
| OLD | NEW |