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 14 matching lines...) Expand all Loading... |
25 #include "ppapi/thunk/enter.h" | 25 #include "ppapi/thunk/enter.h" |
26 #include "ppapi/thunk/thunk.h" | 26 #include "ppapi/thunk/thunk.h" |
27 | 27 |
28 // Windows headers interfere with this file. | 28 // Windows headers interfere with this file. |
29 #ifdef PostMessage | 29 #ifdef PostMessage |
30 #undef PostMessage | 30 #undef PostMessage |
31 #endif | 31 #endif |
32 | 32 |
33 using ppapi::thunk::EnterInstanceNoLock; | 33 using ppapi::thunk::EnterInstanceNoLock; |
34 using ppapi::thunk::EnterResourceNoLock; | 34 using ppapi::thunk::EnterResourceNoLock; |
35 using ppapi::thunk::PPB_Instance_FunctionAPI; | 35 using ppapi::thunk::PPB_Instance_API; |
36 | 36 |
37 namespace ppapi { | 37 namespace ppapi { |
38 namespace proxy { | 38 namespace proxy { |
39 | 39 |
40 namespace { | 40 namespace { |
41 | 41 |
42 InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher) { | 42 InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher) { |
43 return new PPB_Instance_Proxy(dispatcher); | 43 return new PPB_Instance_Proxy(dispatcher); |
44 } | 44 } |
45 | 45 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 149 |
150 // Host -> Plugin messages. | 150 // Host -> Plugin messages. |
151 IPC_MESSAGE_HANDLER(PpapiMsg_PPBInstance_MouseLockComplete, | 151 IPC_MESSAGE_HANDLER(PpapiMsg_PPBInstance_MouseLockComplete, |
152 OnPluginMsgMouseLockComplete) | 152 OnPluginMsgMouseLockComplete) |
153 | 153 |
154 IPC_MESSAGE_UNHANDLED(handled = false) | 154 IPC_MESSAGE_UNHANDLED(handled = false) |
155 IPC_END_MESSAGE_MAP() | 155 IPC_END_MESSAGE_MAP() |
156 return handled; | 156 return handled; |
157 } | 157 } |
158 | 158 |
159 PPB_Instance_FunctionAPI* PPB_Instance_Proxy::AsPPB_Instance_FunctionAPI() { | |
160 return this; | |
161 } | |
162 | |
163 PP_Bool PPB_Instance_Proxy::BindGraphics(PP_Instance instance, | 159 PP_Bool PPB_Instance_Proxy::BindGraphics(PP_Instance instance, |
164 PP_Resource device) { | 160 PP_Resource device) { |
165 Resource* object = | 161 Resource* object = |
166 PpapiGlobals::Get()->GetResourceTracker()->GetResource(device); | 162 PpapiGlobals::Get()->GetResourceTracker()->GetResource(device); |
167 if (!object || object->pp_instance() != instance) | 163 if (!object || object->pp_instance() != instance) |
168 return PP_FALSE; | 164 return PP_FALSE; |
169 | 165 |
170 PP_Bool result = PP_FALSE; | 166 PP_Bool result = PP_FALSE; |
171 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics( | 167 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics( |
172 API_ID_PPB_INSTANCE, instance, object->host_resource(), | 168 API_ID_PPB_INSTANCE, instance, object->host_resource(), |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 | 622 |
627 void PPB_Instance_Proxy::OnHostMsgPostMessage( | 623 void PPB_Instance_Proxy::OnHostMsgPostMessage( |
628 PP_Instance instance, | 624 PP_Instance instance, |
629 SerializedVarReceiveInput message) { | 625 SerializedVarReceiveInput message) { |
630 EnterInstanceNoLock enter(instance); | 626 EnterInstanceNoLock enter(instance); |
631 if (enter.succeeded()) | 627 if (enter.succeeded()) |
632 enter.functions()->PostMessage(instance, message.Get(dispatcher())); | 628 enter.functions()->PostMessage(instance, message.Get(dispatcher())); |
633 } | 629 } |
634 | 630 |
635 void PPB_Instance_Proxy::OnHostMsgLockMouse(PP_Instance instance) { | 631 void PPB_Instance_Proxy::OnHostMsgLockMouse(PP_Instance instance) { |
636 EnterHostFunctionForceCallback<PPB_Instance_FunctionAPI> enter( | 632 // Need to be careful to always issue the callback. |
637 instance, | 633 pp::CompletionCallback cb = callback_factory_.NewCallback( |
638 callback_factory_.NewCallback( | 634 &PPB_Instance_Proxy::MouseLockCompleteInHost, instance); |
639 &PPB_Instance_Proxy::MouseLockCompleteInHost, | 635 |
640 instance)); | 636 EnterInstanceNoLock enter(instance); |
641 if (enter.succeeded()) | 637 if (enter.failed()) { |
642 enter.SetResult(enter.functions()->LockMouse(instance, enter.callback())); | 638 cb.Run(PP_ERROR_BADARGUMENT); |
| 639 return; |
| 640 } |
| 641 int32_t result = enter.functions()->LockMouse(instance, |
| 642 cb.pp_completion_callback()); |
| 643 if (result != PP_OK_COMPLETIONPENDING) |
| 644 cb.Run(result); |
643 } | 645 } |
644 | 646 |
645 void PPB_Instance_Proxy::OnHostMsgUnlockMouse(PP_Instance instance) { | 647 void PPB_Instance_Proxy::OnHostMsgUnlockMouse(PP_Instance instance) { |
646 EnterInstanceNoLock enter(instance); | 648 EnterInstanceNoLock enter(instance); |
647 if (enter.succeeded()) | 649 if (enter.succeeded()) |
648 enter.functions()->UnlockMouse(instance); | 650 enter.functions()->UnlockMouse(instance); |
649 } | 651 } |
650 | 652 |
651 #if !defined(OS_NACL) | 653 #if !defined(OS_NACL) |
652 void PPB_Instance_Proxy::OnHostMsgResolveRelativeToDocument( | 654 void PPB_Instance_Proxy::OnHostMsgResolveRelativeToDocument( |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 } | 764 } |
763 | 765 |
764 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result, | 766 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result, |
765 PP_Instance instance) { | 767 PP_Instance instance) { |
766 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete( | 768 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete( |
767 API_ID_PPB_INSTANCE, instance, result)); | 769 API_ID_PPB_INSTANCE, instance, result)); |
768 } | 770 } |
769 | 771 |
770 } // namespace proxy | 772 } // namespace proxy |
771 } // namespace ppapi | 773 } // namespace ppapi |
OLD | NEW |