summaryrefslogtreecommitdiffstats
path: root/cc/scoped_thread_proxy.h
diff options
context:
space:
mode:
Diffstat (limited to 'cc/scoped_thread_proxy.h')
-rw-r--r--cc/scoped_thread_proxy.h46
1 files changed, 11 insertions, 35 deletions
diff --git a/cc/scoped_thread_proxy.h b/cc/scoped_thread_proxy.h
index 023eaba..b48f276 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/logging.h"
#include "base/memory/ref_counted.h"
-#include "base/threading/platform_thread.h"
-#include "cc/thread_task.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
+#include "base/callback.h"
+#include "cc/thread.h"
+#include "base/location.h"
+#include "base/logging.h"
namespace cc {
@@ -26,49 +25,26 @@ namespace cc {
// list of outstanding tasks.
class ScopedThreadProxy : public base::RefCountedThreadSafe<ScopedThreadProxy> {
public:
- static scoped_refptr<ScopedThreadProxy> create(Thread* targetThread)
+ static scoped_refptr<ScopedThreadProxy> create(cc::Thread* targetThread)
{
- DCHECK(base::PlatformThread::CurrentId() == targetThread->threadID());
+ DCHECK(targetThread->belongsToCurrentThread());
return make_scoped_refptr(new ScopedThreadProxy(targetThread));
}
-
// 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)
- {
- AddRef();
- 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(cc::Thread* targetThread);
friend class base::RefCountedThreadSafe<ScopedThreadProxy>;
~ScopedThreadProxy();
- explicit ScopedThreadProxy(Thread* targetThread);
-
- 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) {
- Release();
- return;
- }
- DCHECK(base::PlatformThread::CurrentId() == m_targetThread->threadID());
- task->performTask();
- Release();
- }
+ void runTaskIfNotShutdown(base::Closure cb);
- Thread* m_targetThread;
+ cc::Thread* m_targetThread;
bool m_shutdown; // Only accessed on the target thread
};