Index: cc/proxy.h |
diff --git a/cc/proxy.h b/cc/proxy.h |
index daddadeeb10ed45e697faa59f50b8cc283dccd5d..78093b937ab49dba9b38d46197dda8bf881c14c6 100644 |
--- a/cc/proxy.h |
+++ b/cc/proxy.h |
@@ -7,6 +7,8 @@ |
#include "base/basictypes.h" |
#include "base/logging.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/threading/platform_thread.h" |
#include <public/WebCompositorOutputSurface.h> |
namespace cc { |
@@ -21,15 +23,24 @@ struct RendererCapabilities; |
// the compositor over to the compositor implementation. |
class Proxy { |
public: |
- static void setMainThread(Thread*); |
- static Thread* mainThread(); |
- |
- static bool hasImplThread(); |
- static void setImplThread(Thread*); |
- static Thread* implThread(); |
+ Thread* mainThread() const; |
+ bool hasImplThread() const; |
+ Thread* implThread() const; |
// Returns 0 if the current thread is neither the main thread nor the impl thread. |
- static Thread* currentThread(); |
+ Thread* currentThread() const; |
+ |
+ // Debug hooks |
+ bool isMainThread() const; |
+ bool isImplThread() const; |
+ bool isMainThreadBlocked() const; |
+ void setMainThread(Thread*); |
+ void setImplThread(Thread*); |
+#ifndef NDEBUG |
+ void setMainThreadBlocked(bool); |
+ void setCurrentThreadIsImplThread(bool); |
+#endif |
+ |
virtual ~Proxy(); |
@@ -81,46 +92,46 @@ public: |
virtual void acquireLayerTextures() = 0; |
- // Debug hooks |
- static bool isMainThread(); |
- static bool isImplThread(); |
- static bool isMainThreadBlocked(); |
-#ifndef NDEBUG |
- static void setMainThreadBlocked(bool); |
-#endif |
- |
// Testing hooks |
virtual void loseContext() = 0; |
-#ifndef NDEBUG |
- static void setCurrentThreadIsImplThread(bool); |
-#endif |
- |
protected: |
- Proxy(); |
+ explicit Proxy(Thread* implThread); |
friend class DebugScopedSetImplThread; |
+ friend class DebugScopedSetMainThread; |
friend class DebugScopedSetMainThreadBlocked; |
private: |
DISALLOW_COPY_AND_ASSIGN(Proxy); |
+ |
+ scoped_ptr<Thread> m_mainThread; |
+ scoped_ptr<Thread> m_implThread; |
+#ifndef NDEBUG |
+ bool m_implThreadIsOverridden; |
+ bool m_isMainThreadBlocked; |
+ base::PlatformThreadId m_threadIDOverridenToBeImplThread; |
+#endif |
}; |
class DebugScopedSetMainThreadBlocked { |
public: |
- DebugScopedSetMainThreadBlocked() |
+ DebugScopedSetMainThreadBlocked(Proxy* proxy) |
+ : m_proxy(proxy) |
{ |
#ifndef NDEBUG |
- DCHECK(!Proxy::isMainThreadBlocked()); |
- Proxy::setMainThreadBlocked(true); |
+ DCHECK(!m_proxy->isMainThreadBlocked()); |
+ m_proxy->setMainThreadBlocked(true); |
#endif |
} |
~DebugScopedSetMainThreadBlocked() |
{ |
#ifndef NDEBUG |
- DCHECK(Proxy::isMainThreadBlocked()); |
- Proxy::setMainThreadBlocked(false); |
+ DCHECK(m_proxy->isMainThreadBlocked()); |
+ m_proxy->setMainThreadBlocked(false); |
#endif |
} |
+private: |
+ Proxy* m_proxy; |
}; |
} |