summaryrefslogtreecommitdiffstats
path: root/ppapi/proxy/ppb_instance_proxy.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-21 19:49:20 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-21 19:49:20 +0000
commit0f41c011f5323674c1619f78c05fd63529f1c760 (patch)
tree9d7b51e2323c73ac589d42ff18f5d12af75ceac0 /ppapi/proxy/ppb_instance_proxy.cc
parente4a638f76ada2aaacd46f0adb2037e28dffc3648 (diff)
downloadchromium_src-0f41c011f5323674c1619f78c05fd63529f1c760.zip
chromium_src-0f41c011f5323674c1619f78c05fd63529f1c760.tar.gz
chromium_src-0f41c011f5323674c1619f78c05fd63529f1c760.tar.bz2
Revert 106717 - Revert 106677 (caused several PPAPI test timeouts, see http://crbug.com/101154)
- Remove the proxy callback tracker. This doesn't properly delete callbacks when the corresponding resource goes away. This can lead to leaks or crashes in the plugin when the callback is triggered unexpectedly. BUG=http://crbug.com/86279 Review URL: http://codereview.chromium.org/8226009 TBR=brettw@chromium.org Review URL: http://codereview.chromium.org/8364040 TBR=thakis@chromium.org Review URL: http://codereview.chromium.org/8371008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106764 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy/ppb_instance_proxy.cc')
-rw-r--r--ppapi/proxy/ppb_instance_proxy.cc56
1 files changed, 45 insertions, 11 deletions
diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc
index 998ae8b..28bb17e 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/ppapi_messages.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;
@@ -362,8 +370,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(
- API_ID_PPB_INSTANCE, instance, SendCallback(callback)));
+ API_ID_PPB_INSTANCE, instance));
return PP_OK_COMPLETIONPENDING;
}
@@ -514,15 +531,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) {
@@ -580,5 +594,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(
+ API_ID_PPB_INSTANCE, instance, result));
+}
+
} // namespace proxy
} // namespace ppapi