Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(609)

Unified Diff: content/common/gpu/client/context_provider_command_buffer.cc

Issue 1317743002: cc: Implement shared worker contexts. (v1) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: surfaces_context_provider fix Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698