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

Unified Diff: cc/proxy.cc

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.cc
diff --git a/cc/proxy.cc b/cc/proxy.cc
index 7b738aa5a5bd891ccfb5826cf51c579fb6d323e0..21abc47395b1a502d123096521e58dceddf18ae7 100644
--- a/cc/proxy.cc
+++ b/cc/proxy.cc
@@ -7,70 +7,62 @@
#include "cc/proxy.h"
#include "cc/thread.h"
+#include "cc/thread_impl.h"
namespace cc {
-namespace {
-#ifndef NDEBUG
-bool implThreadIsOverridden = false;
-bool s_isMainThreadBlocked = false;
-#endif
-Thread* s_mainThread = 0;
-Thread* s_implThread = 0;
-}
-
void Proxy::setMainThread(Thread* thread)
{
- s_mainThread = thread;
+ m_mainThread.reset(thread);
}
-Thread* Proxy::mainThread()
+Thread* Proxy::mainThread() const
{
- return s_mainThread;
+ return m_mainThread.get();
}
-bool Proxy::hasImplThread()
+bool Proxy::hasImplThread() const
{
- return s_implThread;
+ return !!m_implThread.get();
jamesr 2012/10/31 04:42:13 return m_implThread; will do the right thing
}
void Proxy::setImplThread(Thread* thread)
{
- s_implThread = thread;
+ m_implThread.reset(thread);
}
-Thread* Proxy::implThread()
+Thread* Proxy::implThread() const
{
- return s_implThread;
+ return m_implThread.get();
}
-Thread* Proxy::currentThread()
+Thread* Proxy::currentThread() const
{
- if (s_mainThread && s_mainThread->belongsToCurrentThread())
- return s_mainThread;
- if (s_implThread && s_implThread->belongsToCurrentThread())
- return s_implThread;
+ if (mainThread() && mainThread()->belongsToCurrentThread())
+ return mainThread();
+ if (implThread() && implThread()->belongsToCurrentThread())
+ return implThread();
return 0;
}
-bool Proxy::isMainThread()
+bool Proxy::isMainThread() const
{
#ifndef NDEBUG
- DCHECK(s_mainThread);
- if (implThreadIsOverridden)
+ DCHECK(mainThread());
+ if (m_implThreadIsOverridden)
return false;
- return s_mainThread->belongsToCurrentThread();
+ return mainThread()->belongsToCurrentThread();
#else
return true;
#endif
}
-bool Proxy::isImplThread()
+bool Proxy::isImplThread() const
{
#ifndef NDEBUG
- if (implThreadIsOverridden)
+ if (m_implThreadIsOverridden)
return true;
- return s_implThread && s_implThread->belongsToCurrentThread();
+ return implThread() && implThread()->belongsToCurrentThread();
#else
return true;
#endif
@@ -79,14 +71,14 @@ bool Proxy::isImplThread()
#ifndef NDEBUG
void Proxy::setCurrentThreadIsImplThread(bool isImplThread)
{
- implThreadIsOverridden = isImplThread;
+ m_implThreadIsOverridden = isImplThread;
}
#endif
-bool Proxy::isMainThreadBlocked()
+bool Proxy::isMainThreadBlocked() const
{
#ifndef NDEBUG
- return s_isMainThreadBlocked;
+ return m_isMainThreadBlocked;
#else
return true;
#endif
@@ -95,13 +87,18 @@ bool Proxy::isMainThreadBlocked()
#ifndef NDEBUG
void Proxy::setMainThreadBlocked(bool isMainThreadBlocked)
{
- s_isMainThreadBlocked = isMainThreadBlocked;
+ m_isMainThreadBlocked = isMainThreadBlocked;
}
#endif
-Proxy::Proxy()
+Proxy::Proxy(Thread* implThread)
+ : m_mainThread(ThreadImpl::createForCurrentThread())
+ , m_implThread(implThread)
+#ifndef NDEBUG
+ , m_implThreadIsOverridden(false)
+ , m_isMainThreadBlocked(false)
+#endif
{
- DCHECK(isMainThread());
}
Proxy::~Proxy()

Powered by Google App Engine
This is Rietveld 408576698