| Index: content/common/gpu/client/context_provider_command_buffer.cc
|
| diff --git a/content/common/gpu/client/context_provider_command_buffer.cc b/content/common/gpu/client/context_provider_command_buffer.cc
|
| index ba9f0ebfbed6a6f75196c29a7bf89da933557773..17e6b04204c9007de78e168b6d654ac2cacc4261 100644
|
| --- a/content/common/gpu/client/context_provider_command_buffer.cc
|
| +++ b/content/common/gpu/client/context_provider_command_buffer.cc
|
| @@ -59,18 +59,8 @@ ContextProviderCommandBuffer::ContextProviderCommandBuffer(
|
| }
|
|
|
| ContextProviderCommandBuffer::~ContextProviderCommandBuffer() {
|
| - DCHECK(main_thread_checker_.CalledOnValidThread() ||
|
| - context_thread_checker_.CalledOnValidThread());
|
| -
|
| base::AutoLock lock(main_thread_lock_);
|
| -
|
| - // Destroy references to the context3d_ before leaking it.
|
| - if (context3d_->GetCommandBufferProxy()) {
|
| - context3d_->GetCommandBufferProxy()->SetLock(nullptr);
|
| - context3d_->GetCommandBufferProxy()->SetMemoryAllocationChangedCallback(
|
| - CommandBufferProxyImpl::MemoryAllocationChangedCallback());
|
| - }
|
| - lost_context_callback_proxy_.reset();
|
| + DestroyWithMainThreadLockAcquired();
|
| }
|
|
|
|
|
| @@ -78,6 +68,13 @@ CommandBufferProxyImpl* ContextProviderCommandBuffer::GetCommandBufferProxy() {
|
| return context3d_->GetCommandBufferProxy();
|
| }
|
|
|
| +void ContextProviderCommandBuffer::Destroy() {
|
| + DCHECK(context_thread_checker_.CalledOnValidThread());
|
| +
|
| + base::AutoLock lock(main_thread_lock_);
|
| + DestroyWithMainThreadLockAcquired();
|
| +}
|
| +
|
| WebGraphicsContext3DCommandBufferImpl*
|
| ContextProviderCommandBuffer::WebContext3D() {
|
| DCHECK(context3d_);
|
| @@ -247,4 +244,24 @@ void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback(
|
| }
|
| }
|
|
|
| +bool ContextProviderCommandBuffer::HasBeenDestroyed() {
|
| + DCHECK(context_thread_checker_.CalledOnValidThread());
|
| + return destroyed_;
|
| +}
|
| +
|
| +void ContextProviderCommandBuffer::DestroyWithMainThreadLockAcquired() {
|
| + main_thread_lock_.AssertAcquired();
|
| +
|
| + if (context3d_ && context3d_->GetCommandBufferProxy()) {
|
| + context3d_->GetCommandBufferProxy()->SetLock(nullptr);
|
| + context3d_->GetCommandBufferProxy()->SetMemoryAllocationChangedCallback(
|
| + CommandBufferProxyImpl::MemoryAllocationChangedCallback());
|
| + }
|
| + lost_context_callback_proxy_.reset();
|
| + gr_context_.reset();
|
| + context3d_.reset();
|
| +
|
| + destroyed_ = true;
|
| +}
|
| +
|
| } // namespace content
|
|
|