Chromium Code Reviews| Index: cc/scoped_thread_proxy.h |
| diff --git a/cc/scoped_thread_proxy.h b/cc/scoped_thread_proxy.h |
| index c4c658d1ac3a6d33c2d2daaa139da77402d0a946..f095285a1766f8b0d3953ff8ab3a8625d42c446a 100644 |
| --- a/cc/scoped_thread_proxy.h |
| +++ b/cc/scoped_thread_proxy.h |
| @@ -5,12 +5,11 @@ |
| #ifndef CCScopedThreadProxy_h |
| #define CCScopedThreadProxy_h |
| +#include "base/memory/ref_counted.h" |
| +#include "base/callback.h" |
| +#include "cc/thread.h" |
| +#include "base/location.h" |
| #include "base/logging.h" |
| -#include "base/threading/platform_thread.h" |
| -#include "cc/thread_task.h" |
| -#include <wtf/OwnPtr.h> |
| -#include <wtf/PassOwnPtr.h> |
| -#include <wtf/ThreadSafeRefCounted.h> |
| namespace cc { |
| @@ -24,49 +23,28 @@ namespace cc { |
| // Implementation note: Unlike ScopedRunnableMethodFactory in Chromium, pending tasks are not cancelled by actually |
| // destroying the proxy. Instead each pending task holds a reference to the proxy to avoid maintaining an explicit |
| // list of outstanding tasks. |
| -class ScopedThreadProxy : public ThreadSafeRefCounted<ScopedThreadProxy> { |
| +class ScopedThreadProxy : public base::RefCounted<ScopedThreadProxy> { |
|
enne (OOO)
2012/10/29 17:40:42
Sanity checking: this doesn't need to be thread-sa
|
| public: |
| - static PassRefPtr<ScopedThreadProxy> create(Thread* targetThread) |
| + static scoped_refptr<ScopedThreadProxy> create(cc::Thread* targetThread) |
| { |
| - DCHECK(base::PlatformThread::CurrentId() == targetThread->threadID()); |
| - return adoptRef(new ScopedThreadProxy(targetThread)); |
| + DCHECK(targetThread->belongsToCurrentThread()); |
| + return make_scoped_refptr(new ScopedThreadProxy(targetThread)); |
| } |
| - ~ScopedThreadProxy(); |
| - |
| // Can be called from any thread. Posts a task to the target thread that runs unless |
| // shutdown() is called before it runs. |
| - void postTask(PassOwnPtr<Thread::Task> task) |
| - { |
| - ref(); |
| - m_targetThread->postTask(createThreadTask(this, &ScopedThreadProxy::runTaskIfNotShutdown, task)); |
| - } |
| + void postTask(const tracked_objects::Location& location, base::Closure cb); |
| - void shutdown() |
| - { |
| - DCHECK(base::PlatformThread::CurrentId() == m_targetThread->threadID()); |
| - DCHECK(!m_shutdown); |
| - m_shutdown = true; |
| - } |
| + void shutdown(); |
| private: |
| - explicit ScopedThreadProxy(Thread* targetThread); |
| + explicit ScopedThreadProxy(cc::Thread* targetThread); |
| + friend class base::RefCounted<ScopedThreadProxy>; |
| + ~ScopedThreadProxy(); |
| - void runTaskIfNotShutdown(PassOwnPtr<Thread::Task> popTask) |
| - { |
| - OwnPtr<Thread::Task> task = popTask; |
| - // If our shutdown flag is set, it's possible that m_targetThread has already been destroyed so don't |
| - // touch it. |
| - if (m_shutdown) { |
| - deref(); |
| - return; |
| - } |
| - DCHECK(base::PlatformThread::CurrentId() == m_targetThread->threadID()); |
| - task->performTask(); |
| - deref(); |
| - } |
| + void runTaskIfNotShutdown(base::Closure cb); |
| - Thread* m_targetThread; |
| + cc::Thread* m_targetThread; |
| bool m_shutdown; // Only accessed on the target thread |
| }; |