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

Unified Diff: cc/proxy.h

Issue 11232051: Remove static thread pointers from CC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase to 165064 Created 8 years, 2 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/proxy.h
diff --git a/cc/proxy.h b/cc/proxy.h
index a0a53a3984d74af1e8de37613cf0a55658fc1bb4..915a9453948aaa9336e62646581bdb1984bcb0cb 100644
--- a/cc/proxy.h
+++ b/cc/proxy.h
@@ -8,6 +8,7 @@
#include "base/basictypes.h"
#include "base/logging.h"
#include "base/time.h"
+#include "base/memory/scoped_ptr.h"
#include <public/WebCompositorOutputSurface.h>
namespace cc {
@@ -22,15 +23,23 @@ 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*);
jamesr 2012/10/31 04:42:13 hmm, why do we need a setter for the main thread?
+ void setImplThread(Thread*);
jamesr 2012/10/31 04:42:13 since these setters transfer ownership, they shoul
aelias_OOO_until_Jul13 2012/10/31 06:15:30 The setters were unused residue. I deleted both o
+#ifndef NDEBUG
+ void setMainThreadBlocked(bool);
+ void setCurrentThreadIsImplThread(bool);
+#endif
virtual ~Proxy();
@@ -86,46 +95,45 @@ 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;
+#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;
};
}

Powered by Google App Engine
This is Rietveld 408576698