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

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: invalidate weak ptrs when detaching context from thread 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..5379e5bd6044aaedb530a44c9a215e68379ec1f5 100644
--- a/content/common/gpu/client/context_provider_command_buffer.cc
+++ b/content/common/gpu/client/context_provider_command_buffer.cc
@@ -109,6 +109,12 @@ bool ContextProviderCommandBuffer::BindToCurrentThread() {
}
void ContextProviderCommandBuffer::DetachFromThread() {
+ DCHECK(context3d_);
+ // Invalidate any weak pointers used by the context3d_ to ensure that it's
+ // safe to use and destroy it on a different thread. There's no guarantee
+ // that callbacks such as ContextLost will be delivered after this has been
danakj 2015/09/03 18:09:58 Can you add this to the ContextProvider::DetachFro
+ // called.
+ context3d_->InvalidateWeakPtrsOnCurrentThread();
context_thread_checker_.DetachFromThread();
}
@@ -182,7 +188,9 @@ void ContextProviderCommandBuffer::DeleteCachedResources() {
}
void ContextProviderCommandBuffer::OnLostContext() {
- DCHECK(context_thread_checker_.CalledOnValidThread());
+ // Note: no thread check here as this should not change the thread for which
+ // this context is currently bound. e.g. a worker context might be unbound
+ // and this should not result in it being bound to the current thread.
{
base::AutoLock lock(main_thread_lock_);
if (destroyed_)
@@ -197,8 +205,9 @@ void ContextProviderCommandBuffer::OnLostContext() {
void ContextProviderCommandBuffer::OnMemoryAllocationChanged(
const gpu::MemoryAllocation& allocation) {
- DCHECK(context_thread_checker_.CalledOnValidThread());
-
+ // Note: no thread check here as this should not change the thread for which
+ // this context is currently bound. e.g. a worker context might be unbound
+ // and this should not result in it being bound to the current thread.
if (memory_policy_changed_callback_.is_null())
return;

Powered by Google App Engine
This is Rietveld 408576698