| Index: ppapi/proxy/ppb_instance_proxy.cc
|
| diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc
|
| index 1a99b470a8c3ea20c61d8a1d00335aa0068028d8..0f5e9bb00fea442aba526453d4b0281e8d26ea19 100644
|
| --- a/ppapi/proxy/ppb_instance_proxy.cc
|
| +++ b/ppapi/proxy/ppb_instance_proxy.cc
|
| @@ -9,6 +9,7 @@
|
| #include "ppapi/c/ppb_instance.h"
|
| #include "ppapi/c/ppb_messaging.h"
|
| #include "ppapi/c/ppb_mouse_lock.h"
|
| +#include "ppapi/proxy/enter_proxy.h"
|
| #include "ppapi/proxy/host_dispatcher.h"
|
| #include "ppapi/proxy/plugin_dispatcher.h"
|
| #include "ppapi/proxy/plugin_resource_tracker.h"
|
| @@ -41,7 +42,8 @@ InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher) {
|
| } // namespace
|
|
|
| PPB_Instance_Proxy::PPB_Instance_Proxy(Dispatcher* dispatcher)
|
| - : InterfaceProxy(dispatcher) {
|
| + : InterfaceProxy(dispatcher),
|
| + callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
|
| }
|
|
|
| PPB_Instance_Proxy::~PPB_Instance_Proxy() {
|
| @@ -68,6 +70,7 @@ bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) {
|
|
|
| bool handled = true;
|
| IPC_BEGIN_MESSAGE_MAP(PPB_Instance_Proxy, msg)
|
| + // Plugin -> Host messages.
|
| IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetWindowObject,
|
| OnMsgGetWindowObject)
|
| IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetOwnerElementObject,
|
| @@ -112,6 +115,11 @@ bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) {
|
| OnMsgGetDocumentURL)
|
| IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginInstanceURL,
|
| OnMsgGetPluginInstanceURL)
|
| +
|
| + // Host -> Plugin messages.
|
| + IPC_MESSAGE_HANDLER(PpapiMsg_PPBInstance_MouseLockComplete,
|
| + OnMsgMouseLockComplete)
|
| +
|
| IPC_MESSAGE_UNHANDLED(handled = false)
|
| IPC_END_MESSAGE_MAP()
|
| return handled;
|
| @@ -366,8 +374,17 @@ int32_t PPB_Instance_Proxy::LockMouse(PP_Instance instance,
|
| if (!callback.func)
|
| return PP_ERROR_BADARGUMENT;
|
|
|
| + // Save the mouse callback on the instance data.
|
| + InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())->
|
| + GetInstanceData(instance);
|
| + if (!data)
|
| + return PP_ERROR_BADARGUMENT;
|
| + if (data->mouse_lock_callback.func)
|
| + return PP_ERROR_INPROGRESS; // Already have a pending callback.
|
| + data->mouse_lock_callback = callback;
|
| +
|
| dispatcher()->Send(new PpapiHostMsg_PPBInstance_LockMouse(
|
| - INTERFACE_ID_PPB_INSTANCE, instance, SendCallback(callback)));
|
| + INTERFACE_ID_PPB_INSTANCE, instance));
|
| return PP_OK_COMPLETIONPENDING;
|
| }
|
|
|
| @@ -518,15 +535,12 @@ void PPB_Instance_Proxy::OnMsgPostMessage(PP_Instance instance,
|
| enter.functions()->PostMessage(instance, message.Get(dispatcher()));
|
| }
|
|
|
| -void PPB_Instance_Proxy::OnMsgLockMouse(PP_Instance instance,
|
| - uint32_t serialized_callback) {
|
| - EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, true);
|
| - if (enter.failed())
|
| - return;
|
| - PP_CompletionCallback callback = ReceiveCallback(serialized_callback);
|
| - int32_t result = enter.functions()->LockMouse(instance, callback);
|
| - if (result != PP_OK_COMPLETIONPENDING)
|
| - PP_RunCompletionCallback(&callback, result);
|
| +void PPB_Instance_Proxy::OnMsgLockMouse(PP_Instance instance) {
|
| + EnterHostFunctionForceCallback<PPB_Instance_FunctionAPI> enter(
|
| + instance, callback_factory_,
|
| + &PPB_Instance_Proxy::MouseLockCompleteInHost, instance);
|
| + if (enter.succeeded())
|
| + enter.SetResult(enter.functions()->LockMouse(instance, enter.callback()));
|
| }
|
|
|
| void PPB_Instance_Proxy::OnMsgUnlockMouse(PP_Instance instance) {
|
| @@ -584,5 +598,25 @@ void PPB_Instance_Proxy::OnMsgGetPluginInstanceURL(
|
| }
|
| }
|
|
|
| +void PPB_Instance_Proxy::OnMsgMouseLockComplete(PP_Instance instance,
|
| + int32_t result) {
|
| + // Save the mouse callback on the instance data.
|
| + InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())->
|
| + GetInstanceData(instance);
|
| + if (!data)
|
| + return; // Instance was probably deleted.
|
| + if (!data->mouse_lock_callback.func) {
|
| + NOTREACHED();
|
| + return;
|
| + }
|
| + PP_RunAndClearCompletionCallback(&data->mouse_lock_callback, result);
|
| +}
|
| +
|
| +void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result,
|
| + PP_Instance instance) {
|
| + dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete(
|
| + INTERFACE_ID_PPB_INSTANCE, instance, result));
|
| +}
|
| +
|
| } // namespace proxy
|
| } // namespace ppapi
|
|
|