summaryrefslogtreecommitdiffstats
path: root/ppapi/proxy/plugin_dispatcher.cc
diff options
context:
space:
mode:
authordmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-14 18:05:39 +0000
committerdmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-14 18:05:39 +0000
commit2ef706e47ff06fb0509f660475e12392f6b40a72 (patch)
tree79af67b204457912f3735619d8a2c52b6edf903e /ppapi/proxy/plugin_dispatcher.cc
parentbd9ea1bc4abd3dea19674737d963d6a50272ad45 (diff)
downloadchromium_src-2ef706e47ff06fb0509f660475e12392f6b40a72.zip
chromium_src-2ef706e47ff06fb0509f660475e12392f6b40a72.tar.gz
chromium_src-2ef706e47ff06fb0509f660475e12392f6b40a72.tar.bz2
PPAPI: Add unlocking for PPP calls and callbacks. Add more locking.
With this patch, ppapi_tests pass locally when building with enable_pepper_threading=1. (They didn't before). TODO: Test more calls off the main thread, make sync completion callbacks work. BUG=92909 TEST= Review URL: http://codereview.chromium.org/9391006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121901 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy/plugin_dispatcher.cc')
-rw-r--r--ppapi/proxy/plugin_dispatcher.cc20
1 files changed, 16 insertions, 4 deletions
diff --git a/ppapi/proxy/plugin_dispatcher.cc b/ppapi/proxy/plugin_dispatcher.cc
index efe0803..bfa7917 100644
--- a/ppapi/proxy/plugin_dispatcher.cc
+++ b/ppapi/proxy/plugin_dispatcher.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -25,6 +25,7 @@
#include "ppapi/proxy/ppb_instance_proxy.h"
#include "ppapi/proxy/ppp_class_proxy.h"
#include "ppapi/proxy/resource_creation_proxy.h"
+#include "ppapi/shared_impl/proxy_lock.h"
#include "ppapi/shared_impl/resource.h"
#if defined(OS_POSIX)
@@ -52,8 +53,11 @@ InstanceData::InstanceData()
InstanceData::~InstanceData() {
// Run any pending mouse lock callback to prevent leaks.
- if (mouse_lock_callback.func)
- PP_RunAndClearCompletionCallback(&mouse_lock_callback, PP_ERROR_ABORTED);
+ if (mouse_lock_callback.func) {
+ CallWhileUnlocked(PP_RunAndClearCompletionCallback,
+ &mouse_lock_callback,
+ static_cast<int32_t>(PP_ERROR_ABORTED));
+ }
}
PluginDispatcher::PluginDispatcher(base::ProcessHandle remote_process_handle,
@@ -164,17 +168,25 @@ bool PluginDispatcher::Send(IPC::Message* msg) {
"Class", IPC_MESSAGE_ID_CLASS(msg->type()),
"Line", IPC_MESSAGE_ID_LINE(msg->type()));
// We always want plugin->renderer messages to arrive in-order. If some sync
- // and some async messages are send in response to a synchronous
+ // and some async messages are sent in response to a synchronous
// renderer->plugin call, the sync reply will be processed before the async
// reply, and everything will be confused.
//
// Allowing all async messages to unblock the renderer means more reentrancy
// there but gives correct ordering.
msg->set_unblock(true);
+ if (msg->is_sync()) {
+ // Synchronous messages might be re-entrant, so we need to drop the lock.
+ ProxyAutoUnlock unlock;
+ return Dispatcher::Send(msg);
+ }
return Dispatcher::Send(msg);
}
bool PluginDispatcher::OnMessageReceived(const IPC::Message& msg) {
+ // We need to grab the proxy lock to ensure that we don't collide with the
+ // plugin making pepper calls on a different thread.
+ ProxyAutoLock lock;
TRACE_EVENT2("ppapi proxy", "PluginDispatcher::OnMessageReceived",
"Class", IPC_MESSAGE_ID_CLASS(msg.type()),
"Line", IPC_MESSAGE_ID_LINE(msg.type()));