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

Unified Diff: ppapi/proxy/ppb_instance_proxy.cc

Issue 8371008: Revert 106717 - Revert 106677 (caused several PPAPI test timeouts, see http://crbug.com/101154) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/proxy/ppb_instance_proxy.h ('k') | ppapi/proxy/ppb_url_loader_proxy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/ppb_instance_proxy.cc
===================================================================
--- ppapi/proxy/ppb_instance_proxy.cc (revision 106763)
+++ ppapi/proxy/ppb_instance_proxy.cc (working copy)
@@ -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/ppapi_messages.h"
@@ -41,7 +42,8 @@
} // 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 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 @@
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;
@@ -362,8 +370,17 @@
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(
- API_ID_PPB_INSTANCE, instance, SendCallback(callback)));
+ API_ID_PPB_INSTANCE, instance));
return PP_OK_COMPLETIONPENDING;
}
@@ -514,15 +531,12 @@
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) {
@@ -580,5 +594,25 @@
}
}
+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(
+ API_ID_PPB_INSTANCE, instance, result));
+}
+
} // namespace proxy
} // namespace ppapi
« no previous file with comments | « ppapi/proxy/ppb_instance_proxy.h ('k') | ppapi/proxy/ppb_url_loader_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698