| Index: cc/scoped_thread_proxy.cc
|
| diff --git a/cc/scoped_thread_proxy.cc b/cc/scoped_thread_proxy.cc
|
| index a181270384c4b7555c90e95d74625383bace6eb2..9391e3bb8f009e9a0d25a5a5dcfe22a91737f0b4 100644
|
| --- a/cc/scoped_thread_proxy.cc
|
| +++ b/cc/scoped_thread_proxy.cc
|
| @@ -6,9 +6,11 @@
|
|
|
| #include "cc/scoped_thread_proxy.h"
|
|
|
| +#include "base/bind.h"
|
| +
|
| namespace cc {
|
|
|
| -ScopedThreadProxy::ScopedThreadProxy(Thread* targetThread)
|
| +ScopedThreadProxy::ScopedThreadProxy(cc::Thread* targetThread)
|
| : m_targetThread(targetThread)
|
| , m_shutdown(false)
|
| {
|
| @@ -18,4 +20,27 @@ ScopedThreadProxy::~ScopedThreadProxy()
|
| {
|
| }
|
|
|
| +void ScopedThreadProxy::postTask(const tracked_objects::Location& location, base::Closure cb)
|
| +{
|
| + m_targetThread->postTask(base::Bind(&ScopedThreadProxy::runTaskIfNotShutdown, this, cb));
|
| +}
|
| +
|
| +void ScopedThreadProxy::shutdown()
|
| +{
|
| + DCHECK(m_targetThread->belongsToCurrentThread());
|
| + DCHECK(!m_shutdown);
|
| + m_shutdown = true;
|
| +}
|
| +
|
| +void ScopedThreadProxy::runTaskIfNotShutdown(base::Closure cb)
|
| +{
|
| + // If our shutdown flag is set, it's possible that m_targetThread has already been destroyed so don't
|
| + // touch it.
|
| + if (m_shutdown) {
|
| + return;
|
| + }
|
| + DCHECK(m_targetThread->belongsToCurrentThread());
|
| + cb.Run();
|
| +}
|
| +
|
| }
|
|
|