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/c/pp_errors.h" | 5 #include "ppapi/c/pp_errors.h" |
6 #include "ppapi/c/ppb_mouse_lock.h" | 6 #include "ppapi/c/ppb_mouse_lock.h" |
7 #include "ppapi/thunk/common.h" | |
8 #include "ppapi/thunk/enter.h" | 7 #include "ppapi/thunk/enter.h" |
9 #include "ppapi/thunk/ppb_instance_api.h" | 8 #include "ppapi/thunk/ppb_instance_api.h" |
10 #include "ppapi/thunk/thunk.h" | 9 #include "ppapi/thunk/thunk.h" |
11 | 10 |
12 namespace ppapi { | 11 namespace ppapi { |
13 namespace thunk { | 12 namespace thunk { |
14 | 13 |
15 namespace { | 14 namespace { |
16 | 15 |
17 int32_t LockMouse(PP_Instance instance, PP_CompletionCallback callback) { | 16 int32_t LockMouse(PP_Instance instance, PP_CompletionCallback callback) { |
18 EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true); | 17 EnterFunction<PPB_Instance_FunctionAPI> enter(instance, callback, true); |
19 if (enter.failed()) | 18 if (enter.failed()) |
20 return MayForceCallback(callback, PP_ERROR_BADARGUMENT); | 19 return enter.retval(); |
21 int32_t result = enter.functions()->LockMouse(instance, callback); | 20 return enter.SetResult(enter.functions()->LockMouse(instance, callback)); |
22 return MayForceCallback(callback, result); | |
23 } | 21 } |
24 | 22 |
25 void UnlockMouse(PP_Instance instance) { | 23 void UnlockMouse(PP_Instance instance) { |
26 EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true); | 24 EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true); |
27 if (enter.failed()) | 25 if (enter.failed()) |
28 return; | 26 return; |
29 enter.functions()->UnlockMouse(instance); | 27 enter.functions()->UnlockMouse(instance); |
30 } | 28 } |
31 | 29 |
32 const PPB_MouseLock g_ppb_mouse_lock_thunk = { | 30 const PPB_MouseLock g_ppb_mouse_lock_thunk = { |
33 &LockMouse, | 31 &LockMouse, |
34 &UnlockMouse | 32 &UnlockMouse |
35 }; | 33 }; |
36 | 34 |
37 } // namespace | 35 } // namespace |
38 | 36 |
39 const PPB_MouseLock_1_0* GetPPB_MouseLock_1_0_Thunk() { | 37 const PPB_MouseLock_1_0* GetPPB_MouseLock_1_0_Thunk() { |
40 return &g_ppb_mouse_lock_thunk; | 38 return &g_ppb_mouse_lock_thunk; |
41 } | 39 } |
42 | 40 |
43 } // namespace thunk | 41 } // namespace thunk |
44 } // namespace ppapi | 42 } // namespace ppapi |
OLD | NEW |