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

Unified Diff: cc/output/context_provider.h

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: cc/output/context_provider.h
diff --git a/cc/output/context_provider.h b/cc/output/context_provider.h
index c024e02328e9a3930b7593e54b986bdff3566ae5..b3e721498334dee5b1e85d9db09d0cf81f8f8284 100644
--- a/cc/output/context_provider.h
+++ b/cc/output/context_provider.h
@@ -32,16 +32,20 @@ class ContextProvider : public base::RefCountedThreadSafe<ContextProvider> {
explicit ScopedContextLock(ContextProvider* context_provider)
: context_provider_(context_provider),
context_lock_(*context_provider_->GetLock()) {
- // Allow current thread to bind to |context_provider|.
+ // Allow current thread to use |context_provider_|.
context_provider_->DetachFromThread();
}
~ScopedContextLock() {
- // Allow a different thread to bind to |context_provider|.
+ // Allow usage by thread for which |context_provider_| is bound to.
context_provider_->DetachFromThread();
}
+ // Returns a raw pointer to the GLES2Interface or null if context has been
+ // destroyed.
gpu::gles2::GLES2Interface* ContextGL() {
- return context_provider_->ContextGL();
+ return context_provider_->HasBeenDestroyed()
+ ? nullptr
+ : context_provider_->ContextGL();
}
private:
@@ -107,6 +111,9 @@ class ContextProvider : public base::RefCountedThreadSafe<ContextProvider> {
virtual void SetMemoryPolicyChangedCallback(
const MemoryPolicyChangedCallback& memory_policy_changed_callback) = 0;
+ // Return true if the context inside the provider is no longer valid.
+ virtual bool HasBeenDestroyed() = 0;
piman 2015/09/04 22:19:13 Can this be combined with DestroyedOnMainThread? I
+
protected:
friend class base::RefCountedThreadSafe<ContextProvider>;
virtual ~ContextProvider() {}

Powered by Google App Engine
This is Rietveld 408576698