diff options
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/proxy/plugin_globals.cc | 17 | ||||
-rw-r--r-- | ppapi/proxy/plugin_globals.h | 6 |
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_; |