diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-30 02:19:37 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-30 02:19:37 +0000 |
commit | 79e876254da7fed4dbc98f47f5e0e5d8108cdac1 (patch) | |
tree | a82de66fd0df740a2b38e999165d71d3f709d908 /remoting | |
parent | ebe7144744692a08114ffc270989547746ff4770 (diff) | |
download | chromium_src-79e876254da7fed4dbc98f47f5e0e5d8108cdac1.zip chromium_src-79e876254da7fed4dbc98f47f5e0e5d8108cdac1.tar.gz chromium_src-79e876254da7fed4dbc98f47f5e0e5d8108cdac1.tar.bz2 |
Fix PluginMessageLoopProxy::BelingsToCurrentThread() to always return correct result.
BUG=
TEST=Host plugin doesn't DCHECK when shutting down.
Review URL: http://codereview.chromium.org/8086015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103412 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/base/plugin_message_loop_proxy.cc | 15 | ||||
-rw-r--r-- | remoting/base/plugin_message_loop_proxy.h | 4 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_plugin_thread_delegate.cc | 4 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_plugin_thread_delegate.h | 2 | ||||
-rw-r--r-- | remoting/host/plugin/host_plugin.cc | 8 |
5 files changed, 12 insertions, 21 deletions
diff --git a/remoting/base/plugin_message_loop_proxy.cc b/remoting/base/plugin_message_loop_proxy.cc index 9022a78..3a8b48e 100644 --- a/remoting/base/plugin_message_loop_proxy.cc +++ b/remoting/base/plugin_message_loop_proxy.cc @@ -9,7 +9,8 @@ namespace remoting { PluginMessageLoopProxy::PluginMessageLoopProxy(Delegate* delegate) - : delegate_(delegate) { + : plugin_thread_id_(base::PlatformThread::CurrentId()), + delegate_(delegate) { } PluginMessageLoopProxy::~PluginMessageLoopProxy() { @@ -18,7 +19,7 @@ PluginMessageLoopProxy::~PluginMessageLoopProxy() { void PluginMessageLoopProxy::Detach() { base::AutoLock auto_lock(lock_); if (delegate_) { - DCHECK(delegate_->IsPluginThread()); + DCHECK(BelongsToCurrentThread()); delegate_ = NULL; } } @@ -95,11 +96,10 @@ bool PluginMessageLoopProxy::PostNonNestableDelayedTask( } bool PluginMessageLoopProxy::BelongsToCurrentThread() { - base::AutoLock auto_lock(lock_); - if (!delegate_) - return false; - - return delegate_->IsPluginThread(); + // In pepper plugins ideally we should use pp::Core::IsMainThread, + // but it is problematic becase we would need to keep reference to + // Core somewhere, e.g. make the delegate ref-counted. + return base::PlatformThread::CurrentId() == plugin_thread_id_; } // static @@ -110,6 +110,7 @@ void PluginMessageLoopProxy::TaskSpringboard(void* data) { } void PluginMessageLoopProxy::RunTaskIf(Task* task) { + DCHECK(BelongsToCurrentThread()); // |delegate_| can be changed only from our thread, so it's safe to // access it without acquiring |lock_|. if (delegate_) diff --git a/remoting/base/plugin_message_loop_proxy.h b/remoting/base/plugin_message_loop_proxy.h index 04a77b5..0f53498 100644 --- a/remoting/base/plugin_message_loop_proxy.h +++ b/remoting/base/plugin_message_loop_proxy.h @@ -9,6 +9,7 @@ #include "base/compiler_specific.h" #include "base/message_loop_proxy.h" #include "base/synchronization/lock.h" +#include "base/threading/platform_thread.h" namespace remoting { @@ -22,7 +23,6 @@ class PluginMessageLoopProxy : public base::MessageLoopProxy { virtual bool RunOnPluginThread( int delay_ms, void(function)(void*), void* data) = 0; - virtual bool IsPluginThread() = 0; }; // Caller keeps ownership of delegate. @@ -70,6 +70,8 @@ class PluginMessageLoopProxy : public base::MessageLoopProxy { void RunTaskIf(Task* task); void RunClosureIf(const base::Closure& task); + base::PlatformThreadId plugin_thread_id_; + // |lock_| must be acquired when accessing |delegate_|. base::Lock lock_; Delegate* delegate_; diff --git a/remoting/client/plugin/pepper_plugin_thread_delegate.cc b/remoting/client/plugin/pepper_plugin_thread_delegate.cc index b91fef3..730c09e 100644 --- a/remoting/client/plugin/pepper_plugin_thread_delegate.cc +++ b/remoting/client/plugin/pepper_plugin_thread_delegate.cc @@ -28,8 +28,4 @@ bool PepperPluginThreadDelegate::RunOnPluginThread( return true; } -bool PepperPluginThreadDelegate::IsPluginThread() { - return core_->IsMainThread(); -} - } // namespace remoting diff --git a/remoting/client/plugin/pepper_plugin_thread_delegate.h b/remoting/client/plugin/pepper_plugin_thread_delegate.h index 38f1359..a111e6d6 100644 --- a/remoting/client/plugin/pepper_plugin_thread_delegate.h +++ b/remoting/client/plugin/pepper_plugin_thread_delegate.h @@ -28,8 +28,6 @@ class PepperPluginThreadDelegate : public PluginMessageLoopProxy::Delegate { virtual bool RunOnPluginThread( int delay_ms, void(CDECL function)(void*), void* data) OVERRIDE; - virtual bool IsPluginThread() OVERRIDE; - private: pp::Core* core_; }; diff --git a/remoting/host/plugin/host_plugin.cc b/remoting/host/plugin/host_plugin.cc index 4c88551..12bb780 100644 --- a/remoting/host/plugin/host_plugin.cc +++ b/remoting/host/plugin/host_plugin.cc @@ -70,8 +70,7 @@ class HostNPPlugin : public remoting::PluginMessageLoopProxy::Delegate { // content in the window. HostNPPlugin(NPP instance, uint16 mode) : instance_(instance), - scriptable_object_(NULL), - np_thread_id_(base::PlatformThread::CurrentId()) { + scriptable_object_(NULL) { } ~HostNPPlugin() { @@ -167,10 +166,6 @@ class HostNPPlugin : public remoting::PluginMessageLoopProxy::Delegate { return true; } - virtual bool IsPluginThread() OVERRIDE { - return np_thread_id_ == base::PlatformThread::CurrentId(); - } - static void NPDelayedTaskSpringboard(NPP npp, uint32_t timer_id) { HostNPPlugin* self = reinterpret_cast<HostNPPlugin*>(npp->pdata); DelayedTask task; @@ -336,7 +331,6 @@ class HostNPPlugin : public remoting::PluginMessageLoopProxy::Delegate { NPP instance_; NPObject* scriptable_object_; - base::PlatformThreadId np_thread_id_; std::map<uint32_t, DelayedTask> timers_; base::Lock timers_lock_; }; |