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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
622 | 618 |
623 void PPB_Instance_Proxy::OnHostMsgPostMessage( | 619 void PPB_Instance_Proxy::OnHostMsgPostMessage( |
624 PP_Instance instance, | 620 PP_Instance instance, |
625 SerializedVarReceiveInput message) { | 621 SerializedVarReceiveInput message) { |
626 EnterInstanceNoLock enter(instance); | 622 EnterInstanceNoLock enter(instance); |
627 if (enter.succeeded()) | 623 if (enter.succeeded()) |
628 enter.functions()->PostMessage(instance, message.Get(dispatcher())); | 624 enter.functions()->PostMessage(instance, message.Get(dispatcher())); |
629 } | 625 } |
630 | 626 |
631 void PPB_Instance_Proxy::OnHostMsgLockMouse(PP_Instance instance) { | 627 void PPB_Instance_Proxy::OnHostMsgLockMouse(PP_Instance instance) { |
632 EnterHostFunctionForceCallback<PPB_Instance_FunctionAPI> enter( | 628 // Need to be careful to always issue the callback. |
633 instance, | 629 pp::CompletionCallback cb = callback_factory_.NewCallback( |
brettw
2012/04/21 19:50:01
This changed because I deleted EnterHostFunctionFo
| |
634 callback_factory_.NewCallback( | 630 &PPB_Instance_Proxy::MouseLockCompleteInHost, instance); |
635 &PPB_Instance_Proxy::MouseLockCompleteInHost, | 631 |
636 instance)); | 632 EnterInstanceNoLock enter(instance); |
637 if (enter.succeeded()) | 633 if (enter.failed()) { |
638 enter.SetResult(enter.functions()->LockMouse(instance, enter.callback())); | 634 cb.Run(PP_ERROR_BADARGUMENT); |
635 return; | |
636 } | |
637 int32_t result = enter.functions()->LockMouse(instance, | |
638 cb.pp_completion_callback()); | |
639 if (result != PP_OK_COMPLETIONPENDING) | |
640 cb.Run(result); | |
639 } | 641 } |
640 | 642 |
641 void PPB_Instance_Proxy::OnHostMsgUnlockMouse(PP_Instance instance) { | 643 void PPB_Instance_Proxy::OnHostMsgUnlockMouse(PP_Instance instance) { |
642 EnterInstanceNoLock enter(instance); | 644 EnterInstanceNoLock enter(instance); |
643 if (enter.succeeded()) | 645 if (enter.succeeded()) |
644 enter.functions()->UnlockMouse(instance); | 646 enter.functions()->UnlockMouse(instance); |
645 } | 647 } |
646 | 648 |
647 #if !defined(OS_NACL) | 649 #if !defined(OS_NACL) |
648 void PPB_Instance_Proxy::OnHostMsgResolveRelativeToDocument( | 650 void PPB_Instance_Proxy::OnHostMsgResolveRelativeToDocument( |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
758 } | 760 } |
759 | 761 |
760 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result, | 762 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result, |
761 PP_Instance instance) { | 763 PP_Instance instance) { |
762 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete( | 764 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete( |
763 API_ID_PPB_INSTANCE, instance, result)); | 765 API_ID_PPB_INSTANCE, instance, result)); |
764 } | 766 } |
765 | 767 |
766 } // namespace proxy | 768 } // namespace proxy |
767 } // namespace ppapi | 769 } // namespace ppapi |
OLD | NEW |