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..34d2d8b17f494d6cabd056662825bd4bcb274d1f 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() { |
piman
2015/09/04 22:19:13
I think you need to acquire main_thread_lock_ here
|
+ DCHECK(context_thread_checker_.CalledOnValidThread()); |
+ return destroyed_; |
+} |
+ |
+void ContextProviderCommandBuffer::DestroyWithMainThreadLockAcquired() { |
+ main_thread_lock_.AssertAcquired(); |
+ |
+ if (context3d_->GetCommandBufferProxy()) { |
piman
2015/09/04 22:19:13
Can we assert that if there is a context lock, it
|
+ context3d_->GetCommandBufferProxy()->SetLock(nullptr); |
+ context3d_->GetCommandBufferProxy()->SetMemoryAllocationChangedCallback( |
+ CommandBufferProxyImpl::MemoryAllocationChangedCallback()); |
+ } |
+ lost_context_callback_proxy_.reset(); |
+ gr_context_.reset(); |
+ context3d_.reset(); |
+ |
+ destroyed_ = true; |
+} |
+ |
} // namespace content |