Skip to content

Commit

Permalink
Add global lock for Enter* classes. Add ScopedProxyLock for non-thunk…
Browse files Browse the repository at this point in the history
… proxies. Add multi-threading test for PPB_Var.

BUG=92909
TEST=None yet

Review URL: http://codereview.chromium.org/8016008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104931 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
dmichael@chromium.org committed Oct 11, 2011
1 parent 339651d commit 67c125d
Show file tree
Hide file tree
Showing 11 changed files with 389 additions and 44 deletions.
9 changes: 9 additions & 0 deletions build/common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@
# Webrtc compilation is enabled by default. Set to 0 to disable.
'enable_webrtc%': 1,

# PPAPI by default does not support plugins making calls off the main
# thread. Set to 1 to turn on experimental support for out-of-process
# plugins to make call of the main thread.
'enable_pepper_threading%': 0,

# XInput2 multitouch support is disabled by default (use_xi2_mt=0).
# Setting to non-zero value enables XI2 MT. When XI2 MT is enabled,
# the input value also defines the required XI2 minor minimum version.
Expand Down Expand Up @@ -345,6 +350,7 @@
'use_gnome_keyring%': '<(use_gnome_keyring)',
'linux_fpic%': '<(linux_fpic)',
'enable_flapper_hacks%': '<(enable_flapper_hacks)',
'enable_pepper_threading%': '<(enable_pepper_threading)',
'chromeos%': '<(chromeos)',
'touchui%': '<(touchui)',
'use_virtual_keyboard%': '<(use_virtual_keyboard)',
Expand Down Expand Up @@ -975,6 +981,9 @@
['enable_flapper_hacks==1', {
'defines': ['ENABLE_FLAPPER_HACKS=1'],
}],
['enable_pepper_threading==1', {
'defines': ['ENABLE_PEPPER_THREADING'],
}],
['configuration_policy==1', {
'defines': ['ENABLE_CONFIGURATION_POLICY'],
}],
Expand Down
2 changes: 2 additions & 0 deletions ppapi/ppapi_shared.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
'shared_impl/ppapi_preferences.h',
'shared_impl/ppp_instance_combined.cc',
'shared_impl/ppp_instance_combined.h',
'shared_impl/proxy_lock.cc',
'shared_impl/proxy_lock.h',
'shared_impl/resource.cc',
'shared_impl/resource.h',
'shared_impl/resource_tracker.cc',
Expand Down
9 changes: 9 additions & 0 deletions ppapi/proxy/plugin_resource_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/serialized_var.h"
#include "ppapi/shared_impl/proxy_lock.h"
#include "ppapi/shared_impl/resource.h"
#include "ppapi/shared_impl/tracker_base.h"
#include "ppapi/shared_impl/var.h"
Expand All @@ -29,9 +30,17 @@ TrackerBase* GetTrackerBase() {

PluginResourceTracker::PluginResourceTracker()
: var_tracker_test_override_(NULL) {
#ifdef ENABLE_PEPPER_THREADING
// Set the global proxy lock, since the plugin-side of the proxy needs to be
// synchronized.
ppapi::ProxyLock::Set(&proxy_lock_);
#endif
}

PluginResourceTracker::~PluginResourceTracker() {
#ifdef ENABLE_PEPPER_THREADING
ppapi::ProxyLock::Reset();
#endif
}

// static
Expand Down
4 changes: 4 additions & 0 deletions ppapi/proxy/plugin_resource_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <utility>

#include "base/compiler_specific.h"
#include "base/synchronization/lock.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_stdint.h"
Expand Down Expand Up @@ -91,6 +92,9 @@ class PPAPI_PROXY_EXPORT PluginResourceTracker : public TrackerBase,
typedef std::map<HostResource, PP_Resource> HostResourceMap;
HostResourceMap host_resource_map_;

// The global lock for the plugin side of the proxy.
base::Lock proxy_lock_;

DISALLOW_COPY_AND_ASSIGN(PluginResourceTracker);
};

Expand Down
3 changes: 3 additions & 0 deletions ppapi/proxy/ppb_core_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/plugin_resource_tracker.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/shared_impl/proxy_lock.h"
#include "ppapi/shared_impl/time_conversion.h"

namespace ppapi {
Expand All @@ -32,10 +33,12 @@ base::MessageLoopProxy* GetMainThreadMessageLoop() {
}

void AddRefResource(PP_Resource resource) {
ppapi::ProxyAutoLock lock;
PluginResourceTracker::GetInstance()->AddRefResource(resource);
}

void ReleaseResource(PP_Resource resource) {
ppapi::ProxyAutoLock lock;
PluginResourceTracker::GetInstance()->ReleaseResource(resource);
}

Expand Down
5 changes: 5 additions & 0 deletions ppapi/proxy/ppb_var_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "ppapi/c/ppb_var.h"
#include "ppapi/proxy/plugin_resource_tracker.h"
#include "ppapi/proxy/plugin_var_tracker.h"
#include "ppapi/shared_impl/proxy_lock.h"
#include "ppapi/shared_impl/var.h"

namespace ppapi {
Expand All @@ -18,18 +19,22 @@ namespace {
// PPP_Var plugin --------------------------------------------------------------

void AddRefVar(PP_Var var) {
ppapi::ProxyAutoLock lock;
PluginResourceTracker::GetInstance()->var_tracker().AddRefVar(var);
}

void ReleaseVar(PP_Var var) {
ppapi::ProxyAutoLock lock;
PluginResourceTracker::GetInstance()->var_tracker().ReleaseVar(var);
}

PP_Var VarFromUtf8(PP_Module module, const char* data, uint32_t len) {
ppapi::ProxyAutoLock lock;
return StringVar::StringToPPVar(module, data, len);
}

const char* VarToUtf8(PP_Var var, uint32_t* len) {
ppapi::ProxyAutoLock lock;
StringVar* str = StringVar::FromPPVar(var);
if (str) {
*len = static_cast<uint32_t>(str->value().size());
Expand Down
Loading

0 comments on commit 67c125d

Please sign in to comment.