void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion, PassOwnPtr<CCTextureUpdateQueue> queue, bool contentsTexturesWereDeleted)
{
    TRACE_EVENT0("cc", "CCThreadProxy::beginFrameCompleteOnImplThread");
    ASSERT(!m_commitCompletionEventOnImplThread);
    ASSERT(isImplThread());
    ASSERT(m_schedulerOnImplThread);
    ASSERT(m_schedulerOnImplThread->commitPending());

    if (!m_layerTreeHostImpl) {
        TRACE_EVENT0("cc", "EarlyOut_NoLayerTree");
        completion->signal();
        return;
    }

    if (!contentsTexturesWereDeleted && m_layerTreeHostImpl->contentsTexturesPurged()) {
        // We purged the content textures on the impl thread between the time we
        // posted the beginFrame task and now, meaning we have a bunch of
        // uploads that are now invalid. Clear the uploads (they all go to
        // content textures), and kick another commit to fill them again.
        queue->clearUploads();
        setNeedsCommitOnImplThread();
    } else
        m_resetContentsTexturesPurgedAfterCommitOnImplThread = true;

    m_currentTextureUpdateControllerOnImplThread = CCTextureUpdateController::create(CCProxy::implThread(), queue, m_layerTreeHostImpl->resourceProvider(), m_layerTreeHostImpl->renderer()->textureCopier(), m_layerTreeHostImpl->renderer()->textureUploader());
    m_commitCompletionEventOnImplThread = completion;

    m_schedulerOnImplThread->beginFrameComplete();
}