summaryrefslogtreecommitdiffstats
path: root/ppapi/proxy
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-20 03:40:57 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-20 03:40:57 +0000
commit2ba8d10b3ee068b2c29550a7976b593abc0a090a (patch)
treef05f9132041c7e615cdaa57e2bef2fddc8c76116 /ppapi/proxy
parent19728484e137b776941a198e4d52e75022dca1bd (diff)
downloadchromium_src-2ba8d10b3ee068b2c29550a7976b593abc0a090a.zip
chromium_src-2ba8d10b3ee068b2c29550a7976b593abc0a090a.tar.gz
chromium_src-2ba8d10b3ee068b2c29550a7976b593abc0a090a.tar.bz2
Put pepper threading support behind a command line flag.
Also, fix deadlock for sync browser messages by unlocking. BUG=161429 Review URL: https://chromiumcodereview.appspot.com/11412053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168714 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy')
-rw-r--r--ppapi/proxy/plugin_globals.cc17
-rw-r--r--ppapi/proxy/plugin_globals.h6
2 files changed, 19 insertions, 4 deletions
diff --git a/ppapi/proxy/plugin_globals.cc b/ppapi/proxy/plugin_globals.cc
index 75369d0..79e7383 100644
--- a/ppapi/proxy/plugin_globals.cc
+++ b/ppapi/proxy/plugin_globals.cc
@@ -20,6 +20,12 @@ PluginGlobals::PluginGlobals()
callback_tracker_(new CallbackTracker),
loop_for_main_thread_(
new MessageLoopResource(MessageLoopResource::ForMainThread())) {
+#if defined(ENABLE_PEPPER_THREADING)
+ enable_threading_ = true;
+#else
+ enable_threading_ = false;
+#endif
+
DCHECK(!plugin_globals_);
plugin_globals_ = this;
}
@@ -28,6 +34,11 @@ PluginGlobals::PluginGlobals(ForTest for_test)
: ppapi::PpapiGlobals(for_test),
plugin_proxy_delegate_(NULL),
callback_tracker_(new CallbackTracker) {
+#if defined(ENABLE_PEPPER_THREADING)
+ enable_threading_ = true;
+#else
+ enable_threading_ = false;
+#endif
DCHECK(!plugin_globals_);
}
@@ -80,11 +91,9 @@ void PluginGlobals::PreCacheFontForFlash(const void* logfontw) {
}
base::Lock* PluginGlobals::GetProxyLock() {
-#ifdef ENABLE_PEPPER_THREADING
- return &proxy_lock_;
-#else
+ if (enable_threading_)
+ return &proxy_lock_;
return NULL;
-#endif
}
void PluginGlobals::LogWithSource(PP_Instance instance,
diff --git a/ppapi/proxy/plugin_globals.h b/ppapi/proxy/plugin_globals.h
index 215ad63..c8bf113 100644
--- a/ppapi/proxy/plugin_globals.h
+++ b/ppapi/proxy/plugin_globals.h
@@ -100,6 +100,10 @@ class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals {
// The embedder should call this function when the command line is known.
void set_command_line(const std::string& c) { command_line_ = c; }
+ // Sets whether threadsafety is supported. Defaults to whether the
+ // ENABLE_PEPPER_THREADING build flag is set.
+ void set_enable_threading(bool enable) { enable_threading_ = enable; }
+
private:
// PpapiGlobals overrides.
virtual bool IsPluginGlobals() const OVERRIDE;
@@ -110,6 +114,8 @@ class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals {
PluginResourceTracker plugin_resource_tracker_;
PluginVarTracker plugin_var_tracker_;
scoped_refptr<CallbackTracker> callback_tracker_;
+
+ bool enable_threading_; // Indicates whether we'll use the lock.
base::Lock proxy_lock_;
scoped_ptr<base::ThreadLocalStorage::Slot> msg_loop_slot_;