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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetCursor( | 428 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetCursor( |
429 API_ID_PPB_INSTANCE, instance, static_cast<int32_t>(type), | 429 API_ID_PPB_INSTANCE, instance, static_cast<int32_t>(type), |
430 image_host_resource, hot_spot ? *hot_spot : PP_MakePoint(0, 0))); | 430 image_host_resource, hot_spot ? *hot_spot : PP_MakePoint(0, 0))); |
431 return PP_TRUE; | 431 return PP_TRUE; |
432 #else // defined(OS_NACL) | 432 #else // defined(OS_NACL) |
433 return PP_FALSE; | 433 return PP_FALSE; |
434 #endif | 434 #endif |
435 } | 435 } |
436 | 436 |
437 int32_t PPB_Instance_Proxy::LockMouse(PP_Instance instance, | 437 int32_t PPB_Instance_Proxy::LockMouse(PP_Instance instance, |
438 PP_CompletionCallback callback) { | 438 scoped_refptr<TrackedCallback> callback) { |
439 if (!callback.func) | |
440 return PP_ERROR_BADARGUMENT; | |
441 | |
442 // Save the mouse callback on the instance data. | 439 // Save the mouse callback on the instance data. |
443 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> | 440 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> |
444 GetInstanceData(instance); | 441 GetInstanceData(instance); |
445 if (!data) | 442 if (!data) |
446 return PP_ERROR_BADARGUMENT; | 443 return PP_ERROR_BADARGUMENT; |
447 if (data->mouse_lock_callback.func) | 444 if (TrackedCallback::IsPending(data->mouse_lock_callback)) |
448 return PP_ERROR_INPROGRESS; // Already have a pending callback. | 445 return PP_ERROR_INPROGRESS; // Already have a pending callback. |
449 data->mouse_lock_callback = callback; | 446 data->mouse_lock_callback = callback; |
450 | 447 |
451 dispatcher()->Send(new PpapiHostMsg_PPBInstance_LockMouse( | 448 dispatcher()->Send(new PpapiHostMsg_PPBInstance_LockMouse( |
452 API_ID_PPB_INSTANCE, instance)); | 449 API_ID_PPB_INSTANCE, instance)); |
453 return PP_OK_COMPLETIONPENDING; | 450 return PP_OK_COMPLETIONPENDING; |
454 } | 451 } |
455 | 452 |
456 void PPB_Instance_Proxy::UnlockMouse(PP_Instance instance) { | 453 void PPB_Instance_Proxy::UnlockMouse(PP_Instance instance) { |
457 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UnlockMouse( | 454 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UnlockMouse( |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 // Need to be careful to always issue the callback. | 629 // Need to be careful to always issue the callback. |
633 pp::CompletionCallback cb = callback_factory_.NewCallback( | 630 pp::CompletionCallback cb = callback_factory_.NewCallback( |
634 &PPB_Instance_Proxy::MouseLockCompleteInHost, instance); | 631 &PPB_Instance_Proxy::MouseLockCompleteInHost, instance); |
635 | 632 |
636 EnterInstanceNoLock enter(instance); | 633 EnterInstanceNoLock enter(instance); |
637 if (enter.failed()) { | 634 if (enter.failed()) { |
638 cb.Run(PP_ERROR_BADARGUMENT); | 635 cb.Run(PP_ERROR_BADARGUMENT); |
639 return; | 636 return; |
640 } | 637 } |
641 int32_t result = enter.functions()->LockMouse(instance, | 638 int32_t result = enter.functions()->LockMouse(instance, |
642 cb.pp_completion_callback()); | 639 enter.callback()); |
643 if (result != PP_OK_COMPLETIONPENDING) | 640 if (result != PP_OK_COMPLETIONPENDING) |
644 cb.Run(result); | 641 cb.Run(result); |
645 } | 642 } |
646 | 643 |
647 void PPB_Instance_Proxy::OnHostMsgUnlockMouse(PP_Instance instance) { | 644 void PPB_Instance_Proxy::OnHostMsgUnlockMouse(PP_Instance instance) { |
648 EnterInstanceNoLock enter(instance); | 645 EnterInstanceNoLock enter(instance); |
649 if (enter.succeeded()) | 646 if (enter.succeeded()) |
650 enter.functions()->UnlockMouse(instance); | 647 enter.functions()->UnlockMouse(instance); |
651 } | 648 } |
652 | 649 |
(...skipping 22 matching lines...) Expand all Loading... |
675 } | 672 } |
676 | 673 |
677 void PPB_Instance_Proxy::OnHostMsgDocumentCanAccessDocument(PP_Instance active, | 674 void PPB_Instance_Proxy::OnHostMsgDocumentCanAccessDocument(PP_Instance active, |
678 PP_Instance target, | 675 PP_Instance target, |
679 PP_Bool* result) { | 676 PP_Bool* result) { |
680 EnterInstanceNoLock enter(active); | 677 EnterInstanceNoLock enter(active); |
681 if (enter.succeeded()) | 678 if (enter.succeeded()) |
682 *result = enter.functions()->DocumentCanAccessDocument(active, target); | 679 *result = enter.functions()->DocumentCanAccessDocument(active, target); |
683 } | 680 } |
684 | 681 |
685 void PPB_Instance_Proxy::OnHostMsgGetDocumentURL(PP_Instance instance, | 682 void PPB_Instance_Proxy::OnHostMsgGetDocumentURL( |
686 SerializedVarReturnValue result
) { | 683 PP_Instance instance, |
| 684 SerializedVarReturnValue result) { |
687 EnterInstanceNoLock enter(instance); | 685 EnterInstanceNoLock enter(instance); |
688 if (enter.succeeded()) { | 686 if (enter.succeeded()) { |
689 result.Return(dispatcher(), | 687 result.Return(dispatcher(), |
690 enter.functions()->GetDocumentURL(instance, NULL)); | 688 enter.functions()->GetDocumentURL(instance, NULL)); |
691 } | 689 } |
692 } | 690 } |
693 | 691 |
694 void PPB_Instance_Proxy::OnHostMsgGetPluginInstanceURL( | 692 void PPB_Instance_Proxy::OnHostMsgGetPluginInstanceURL( |
695 PP_Instance instance, | 693 PP_Instance instance, |
696 SerializedVarReturnValue result) { | 694 SerializedVarReturnValue result) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 } | 747 } |
750 } | 748 } |
751 | 749 |
752 void PPB_Instance_Proxy::OnPluginMsgMouseLockComplete(PP_Instance instance, | 750 void PPB_Instance_Proxy::OnPluginMsgMouseLockComplete(PP_Instance instance, |
753 int32_t result) { | 751 int32_t result) { |
754 // Save the mouse callback on the instance data. | 752 // Save the mouse callback on the instance data. |
755 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> | 753 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> |
756 GetInstanceData(instance); | 754 GetInstanceData(instance); |
757 if (!data) | 755 if (!data) |
758 return; // Instance was probably deleted. | 756 return; // Instance was probably deleted. |
759 if (!data->mouse_lock_callback.func) { | 757 if (TrackedCallback::IsPending(data->mouse_lock_callback)) { |
760 NOTREACHED(); | 758 NOTREACHED(); |
761 return; | 759 return; |
762 } | 760 } |
763 PP_RunAndClearCompletionCallback(&data->mouse_lock_callback, result); | 761 TrackedCallback::ClearAndRun(&(data->mouse_lock_callback), result); |
764 } | 762 } |
765 | 763 |
766 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result, | 764 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result, |
767 PP_Instance instance) { | 765 PP_Instance instance) { |
768 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete( | 766 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete( |
769 API_ID_PPB_INSTANCE, instance, result)); | 767 API_ID_PPB_INSTANCE, instance, result)); |
770 } | 768 } |
771 | 769 |
772 } // namespace proxy | 770 } // namespace proxy |
773 } // namespace ppapi | 771 } // namespace ppapi |
OLD | NEW |