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/base | |
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/base')
-rw-r--r-- | remoting/base/plugin_message_loop_proxy.cc | 15 | ||||
-rw-r--r-- | remoting/base/plugin_message_loop_proxy.h | 4 |
2 files changed, 11 insertions, 8 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_; |