summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/test/ppapi/ppapi_test.cc3
-rw-r--r--content/browser/ppapi_plugin_process_host.cc1
-rw-r--r--content/ppapi_plugin/ppapi_thread.cc2
-rw-r--r--ppapi/proxy/plugin_globals.cc17
-rw-r--r--ppapi/proxy/plugin_globals.h6
-rw-r--r--webkit/plugins/plugin_switches.cc3
-rw-r--r--webkit/plugins/plugin_switches.h1
7 files changed, 29 insertions, 4 deletions
diff --git a/chrome/test/ppapi/ppapi_test.cc b/chrome/test/ppapi/ppapi_test.cc
index 0728fc0..5da65af 100644
--- a/chrome/test/ppapi/ppapi_test.cc
+++ b/chrome/test/ppapi/ppapi_test.cc
@@ -133,6 +133,9 @@ void PPAPITestBase::SetUpCommandLine(CommandLine* command_line) {
// Smooth scrolling confuses the scrollbar test.
command_line->AppendSwitch(switches::kDisableSmoothScrolling);
+
+ // Enable threading since we test that feature.
+ command_line->AppendSwitch(switches::kEnablePepperThreading);
}
void PPAPITestBase::SetUpOnMainThread() {
diff --git a/content/browser/ppapi_plugin_process_host.cc b/content/browser/ppapi_plugin_process_host.cc
index e064e7d..e333ff0 100644
--- a/content/browser/ppapi_plugin_process_host.cc
+++ b/content/browser/ppapi_plugin_process_host.cc
@@ -237,6 +237,7 @@ bool PpapiPluginProcessHost::Init(const PepperPluginInfo& info) {
// going to explode.
static const char* kPluginForwardSwitches[] = {
switches::kDisableSeccompFilterSandbox,
+ switches::kEnablePepperThreading,
#if defined(OS_MACOSX)
switches::kEnableSandboxLogging,
#endif
diff --git a/content/ppapi_plugin/ppapi_thread.cc b/content/ppapi_plugin/ppapi_thread.cc
index 7ee63f6..782f804 100644
--- a/content/ppapi_plugin/ppapi_thread.cc
+++ b/content/ppapi_plugin/ppapi_thread.cc
@@ -61,6 +61,8 @@ PpapiThread::PpapiThread(const CommandLine& command_line, bool is_broker)
globals->set_plugin_proxy_delegate(this);
globals->set_command_line(
command_line.GetSwitchValueASCII(switches::kPpapiFlashArgs));
+ globals->set_enable_threading(
+ command_line.HasSwitch(switches::kEnablePepperThreading));
webkit_platform_support_.reset(new PpapiWebKitPlatformSupportImpl);
WebKit::initialize(webkit_platform_support_.get());
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_;
diff --git a/webkit/plugins/plugin_switches.cc b/webkit/plugins/plugin_switches.cc
index bb1b3b4..98a43c2 100644
--- a/webkit/plugins/plugin_switches.cc
+++ b/webkit/plugins/plugin_switches.cc
@@ -15,6 +15,9 @@ const char kDisablePepper3d[] = "disable-pepper-3d";
// "Command-line" arguments for the PPAPI Flash; used for debugging options.
const char kPpapiFlashArgs[] = "ppapi-flash-args";
+// Set to true to allow threadsafety support in native Pepper plugins.
+const char kEnablePepperThreading[] = "enable-pepper-threading";
+
#if defined(OS_WIN)
// Used by the plugins_test when testing the older WMP plugin to force the new
// plugin to not get loaded.
diff --git a/webkit/plugins/plugin_switches.h b/webkit/plugins/plugin_switches.h
index 08ed5ae..ac3a8c5 100644
--- a/webkit/plugins/plugin_switches.h
+++ b/webkit/plugins/plugin_switches.h
@@ -13,6 +13,7 @@ namespace switches {
WEBKIT_PLUGINS_EXPORT extern const char kDebugPluginLoading[];
WEBKIT_PLUGINS_EXPORT extern const char kDisablePepper3d[];
WEBKIT_PLUGINS_EXPORT extern const char kPpapiFlashArgs[];
+WEBKIT_PLUGINS_EXPORT extern const char kEnablePepperThreading[];
#if defined(OS_WIN)
WEBKIT_PLUGINS_EXPORT extern const char kUseOldWMPPlugin[];