Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: ppapi/proxy/ppb_instance_proxy.cc

Issue 10699045: Fix PPB_MouseLock.LockMouse crash and add tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: change in response to Dave's suggestions. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 EnterInstanceNoLock enter(instance); 638 EnterInstanceNoLock enter(instance);
639 if (enter.succeeded()) 639 if (enter.succeeded())
640 enter.functions()->PostMessage(instance, message.Get(dispatcher())); 640 enter.functions()->PostMessage(instance, message.Get(dispatcher()));
641 } 641 }
642 642
643 void PPB_Instance_Proxy::OnHostMsgLockMouse(PP_Instance instance) { 643 void PPB_Instance_Proxy::OnHostMsgLockMouse(PP_Instance instance) {
644 // Need to be careful to always issue the callback. 644 // Need to be careful to always issue the callback.
645 pp::CompletionCallback cb = callback_factory_.NewCallback( 645 pp::CompletionCallback cb = callback_factory_.NewCallback(
646 &PPB_Instance_Proxy::MouseLockCompleteInHost, instance); 646 &PPB_Instance_Proxy::MouseLockCompleteInHost, instance);
647 647
648 EnterInstanceNoLock enter(instance); 648 EnterInstanceNoLock enter(instance, cb.pp_completion_callback());
649 if (enter.failed()) { 649 if (enter.succeeded())
650 cb.Run(PP_ERROR_BADARGUMENT); 650 enter.SetResult(enter.functions()->LockMouse(instance, enter.callback()));
651 return;
652 }
653 int32_t result = enter.functions()->LockMouse(instance,
654 enter.callback());
655 if (result != PP_OK_COMPLETIONPENDING)
656 cb.Run(result);
657 } 651 }
658 652
659 void PPB_Instance_Proxy::OnHostMsgUnlockMouse(PP_Instance instance) { 653 void PPB_Instance_Proxy::OnHostMsgUnlockMouse(PP_Instance instance) {
660 EnterInstanceNoLock enter(instance); 654 EnterInstanceNoLock enter(instance);
661 if (enter.succeeded()) 655 if (enter.succeeded())
662 enter.functions()->UnlockMouse(instance); 656 enter.functions()->UnlockMouse(instance);
663 } 657 }
664 658
665 void PPB_Instance_Proxy::OnHostMsgGetDefaultPrintSettings( 659 void PPB_Instance_Proxy::OnHostMsgGetDefaultPrintSettings(
666 PP_Instance instance, 660 PP_Instance instance,
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 } 779 }
786 } 780 }
787 781
788 void PPB_Instance_Proxy::OnPluginMsgMouseLockComplete(PP_Instance instance, 782 void PPB_Instance_Proxy::OnPluginMsgMouseLockComplete(PP_Instance instance,
789 int32_t result) { 783 int32_t result) {
790 // Save the mouse callback on the instance data. 784 // Save the mouse callback on the instance data.
791 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> 785 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())->
792 GetInstanceData(instance); 786 GetInstanceData(instance);
793 if (!data) 787 if (!data)
794 return; // Instance was probably deleted. 788 return; // Instance was probably deleted.
795 if (TrackedCallback::IsPending(data->mouse_lock_callback)) { 789 if (!TrackedCallback::IsPending(data->mouse_lock_callback)) {
796 NOTREACHED(); 790 NOTREACHED();
797 return; 791 return;
798 } 792 }
799 TrackedCallback::ClearAndRun(&(data->mouse_lock_callback), result); 793 TrackedCallback::ClearAndRun(&(data->mouse_lock_callback), result);
800 } 794 }
801 795
802 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result, 796 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result,
803 PP_Instance instance) { 797 PP_Instance instance) {
804 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete( 798 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete(
805 API_ID_PPB_INSTANCE, instance, result)); 799 API_ID_PPB_INSTANCE, instance, result));
806 } 800 }
807 801
808 } // namespace proxy 802 } // namespace proxy
809 } // namespace ppapi 803 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698