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

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: Apply Dana's code review suggestions 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 317499c3721c2785caa6febe3ca1a45f4d4b3624..49a67762c3df2c538acdc855df9619ad1c34d6af 100644
--- a/cc/proxy.cc
+++ b/cc/proxy.cc
@@ -6,72 +6,63 @@
#include "cc/proxy.h"
+#include "webkit/compositor_bindings/ccthread_impl.h"
jamesr 2012/10/25 19:42:39 this doesn't seem right at all - everything you ne
#include "cc/thread_task.h"
namespace cc {
-namespace {
-#ifndef NDEBUG
-bool implThreadIsOverridden = false;
-bool s_isMainThreadBlocked = false;
-base::PlatformThreadId threadIDOverridenToBeImplThread;
-#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();
}
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
{
base::PlatformThreadId currentThreadIdentifier = base::PlatformThread::CurrentId();
- if (s_mainThread && s_mainThread->threadID() == currentThreadIdentifier)
- return s_mainThread;
- if (s_implThread && s_implThread->threadID() == currentThreadIdentifier)
- return s_implThread;
+ if (mainThread() && mainThread()->threadID() == currentThreadIdentifier)
+ return mainThread();
+ if (implThread() && implThread()->threadID() == currentThreadIdentifier)
+ return implThread();
return 0;
}
-bool Proxy::isMainThread()
+bool Proxy::isMainThread() const
{
#ifndef NDEBUG
- DCHECK(s_mainThread);
- if (implThreadIsOverridden && base::PlatformThread::CurrentId() == threadIDOverridenToBeImplThread)
+ DCHECK(mainThread());
+ if (m_implThreadIsOverridden && base::PlatformThread::CurrentId() == m_threadIDOverridenToBeImplThread)
return false;
- return base::PlatformThread::CurrentId() == s_mainThread->threadID();
+ return base::PlatformThread::CurrentId() == mainThread()->threadID();
#else
return true;
#endif
}
-bool Proxy::isImplThread()
+bool Proxy::isImplThread() const
{
#ifndef NDEBUG
- base::PlatformThreadId implThreadID = s_implThread ? s_implThread->threadID() : 0;
- if (implThreadIsOverridden && base::PlatformThread::CurrentId() == threadIDOverridenToBeImplThread)
+ base::PlatformThreadId implThreadID = implThread() ? implThread()->threadID() : 0;
+ if (m_implThreadIsOverridden && base::PlatformThread::CurrentId() == m_threadIDOverridenToBeImplThread)
return true;
return base::PlatformThread::CurrentId() == implThreadID;
#else
@@ -82,16 +73,16 @@ bool Proxy::isImplThread()
#ifndef NDEBUG
void Proxy::setCurrentThreadIsImplThread(bool isImplThread)
{
- implThreadIsOverridden = isImplThread;
+ m_implThreadIsOverridden = isImplThread;
if (isImplThread)
- threadIDOverridenToBeImplThread = base::PlatformThread::CurrentId();
+ m_threadIDOverridenToBeImplThread = base::PlatformThread::CurrentId();
}
#endif
-bool Proxy::isMainThreadBlocked()
+bool Proxy::isMainThreadBlocked() const
{
#ifndef NDEBUG
- return s_isMainThreadBlocked;
+ return m_isMainThreadBlocked;
#else
return true;
#endif
@@ -100,13 +91,19 @@ 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(WebKit::CCThreadImpl::createForCurrentThread())
jamesr 2012/10/25 19:42:39 If this is the only call you need from CCThreadImp
+ , m_implThread(implThread)
+#ifndef NDEBUG
+ , m_implThreadIsOverridden(false)
+ , m_isMainThreadBlocked(false)
+#endif
{
- DCHECK(isMainThread());
+ DCHECK(!m_implThread || m_mainThread->threadID() != m_implThread->threadID());
}
Proxy::~Proxy()

Powered by Google App Engine
This is Rietveld 408576698