Index: cc/thread_proxy.cc |
diff --git a/cc/thread_proxy.cc b/cc/thread_proxy.cc |
index e759bcf035f3cdfe638c7e4ae2386c929fbaf022..f9ac23ec2055142e5435004c35587f6ca20f0be9 100644 |
--- a/cc/thread_proxy.cc |
+++ b/cc/thread_proxy.cc |
@@ -13,7 +13,6 @@ |
#include "cc/layer_tree_host.h" |
#include "cc/output_surface.h" |
#include "cc/scheduler.h" |
-#include "cc/scoped_thread_proxy.h" |
#include "cc/thread.h" |
#include "third_party/WebKit/Source/Platform/chromium/public/WebSharedGraphicsContext3D.h" |
@@ -45,7 +44,7 @@ ThreadProxy::ThreadProxy(LayerTreeHost* layerTreeHost, scoped_ptr<Thread> implTh |
, m_inCompositeAndReadback(false) |
, m_manageTilesPending(false) |
, m_weakFactoryOnImplThread(ALLOW_THIS_IN_INITIALIZER_LIST(this)) |
- , m_mainThreadProxy(ScopedThreadProxy::create(Proxy::mainThread())) |
+ , m_weakFactory(ALLOW_THIS_IN_INITIALIZER_LIST(this)) |
, m_beginFrameCompletionEventOnImplThread(0) |
, m_readbackRequestOnImplThread(0) |
, m_commitCompletionEventOnImplThread(0) |
@@ -310,7 +309,7 @@ void ThreadProxy::onSwapBuffersCompleteOnImplThread() |
DCHECK(isImplThread()); |
TRACE_EVENT0("cc", "ThreadProxy::onSwapBuffersCompleteOnImplThread"); |
m_schedulerOnImplThread->didSwapBuffersComplete(); |
- m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::didCompleteSwapBuffers, base::Unretained(this))); |
+ Proxy::mainThread()->postTask(base::Bind(&ThreadProxy::didCompleteSwapBuffers, m_mainThreadWeakPtr)); |
} |
void ThreadProxy::onVSyncParametersChanged(base::TimeTicks timebase, base::TimeDelta interval) |
@@ -361,7 +360,7 @@ void ThreadProxy::postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animati |
{ |
DCHECK(isImplThread()); |
TRACE_EVENT0("cc", "ThreadProxy::postAnimationEventsToMainThreadOnImplThread"); |
- m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::setAnimationEvents, base::Unretained(this), base::Passed(events.Pass()), wallClockTime)); |
+ Proxy::mainThread()->postTask(base::Bind(&ThreadProxy::setAnimationEvents, m_mainThreadWeakPtr, base::Passed(events.Pass()), wallClockTime)); |
} |
bool ThreadProxy::reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int priorityCutoff) |
@@ -416,7 +415,7 @@ void ThreadProxy::setDeferCommits(bool deferCommits) |
TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::setDeferCommits", this); |
if (!m_deferCommits && m_pendingDeferredCommit) |
- m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::beginFrame, base::Unretained(this), base::Passed(m_pendingDeferredCommit.Pass()))); |
+ Proxy::mainThread()->postTask(base::Bind(&ThreadProxy::beginFrame, m_mainThreadWeakPtr, base::Passed(m_pendingDeferredCommit.Pass()))); |
} |
bool ThreadProxy::commitRequested() const |
@@ -449,6 +448,8 @@ void ThreadProxy::start() |
Proxy::implThread()->postTask(base::Bind(&ThreadProxy::initializeImplOnImplThread, base::Unretained(this), &completion, handler.release())); |
completion.wait(); |
+ m_mainThreadWeakPtr = m_weakFactory.GetWeakPtr(); |
+ |
m_started = true; |
} |
@@ -467,7 +468,7 @@ void ThreadProxy::stop() |
completion.wait(); |
} |
- m_mainThreadProxy->shutdown(); // Stop running tasks posted to us. |
+ m_weakFactory.InvalidateWeakPtrs(); |
DCHECK(!m_layerTreeHostImpl.get()); // verify that the impl deleted. |
m_layerTreeHost = 0; |
@@ -521,7 +522,7 @@ void ThreadProxy::scheduledActionBeginFrame() |
beginFrameState->implTransform = m_layerTreeHostImpl->implTransform(); |
DCHECK_GT(m_layerTreeHostImpl->memoryAllocationLimitBytes(), 0u); |
beginFrameState->memoryAllocationLimitBytes = m_layerTreeHostImpl->memoryAllocationLimitBytes(); |
- m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::beginFrame, base::Unretained(this), base::Passed(beginFrameState.Pass()))); |
+ Proxy::mainThread()->postTask(base::Bind(&ThreadProxy::beginFrame, m_mainThreadWeakPtr, base::Passed(beginFrameState.Pass()))); |
if (m_beginFrameCompletionEventOnImplThread) { |
m_beginFrameCompletionEventOnImplThread->signal(); |
@@ -720,7 +721,7 @@ void ThreadProxy::scheduledActionCommit() |
void ThreadProxy::scheduledActionBeginContextRecreation() |
{ |
DCHECK(isImplThread()); |
- m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::beginContextRecreation, base::Unretained(this))); |
+ Proxy::mainThread()->postTask(base::Bind(&ThreadProxy::beginContextRecreation, m_mainThreadWeakPtr)); |
} |
ScheduledActionDrawAndSwapResult ThreadProxy::scheduledActionDrawAndSwapInternal(bool forcedDraw) |
@@ -778,7 +779,7 @@ ScheduledActionDrawAndSwapResult ThreadProxy::scheduledActionDrawAndSwapInternal |
// Tell the main thread that the the newly-commited frame was drawn. |
if (m_nextFrameIsNewlyCommittedFrameOnImplThread) { |
m_nextFrameIsNewlyCommittedFrameOnImplThread = false; |
- m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::didCommitAndDrawFrame, base::Unretained(this))); |
+ Proxy::mainThread()->postTask(base::Bind(&ThreadProxy::didCommitAndDrawFrame, m_mainThreadWeakPtr)); |
} |
return result; |