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

Unified Diff: cc/proxy.cc

Issue 11369071: A speculative Revert for r165872 - Remove static thread pointers from CC, attempt 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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
« no previous file with comments | « cc/proxy.h ('k') | cc/quad_culler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/proxy.cc
===================================================================
--- cc/proxy.cc (revision 165906)
+++ cc/proxy.cc (working copy)
@@ -7,52 +7,70 @@
#include "cc/proxy.h"
#include "cc/thread.h"
-#include "cc/thread_impl.h"
namespace cc {
-Thread* Proxy::mainThread() const
+namespace {
+#ifndef NDEBUG
+bool implThreadIsOverridden = false;
+bool s_isMainThreadBlocked = false;
+#endif
+Thread* s_mainThread = 0;
+Thread* s_implThread = 0;
+}
+
+void Proxy::setMainThread(Thread* thread)
{
- return m_mainThread.get();
+ s_mainThread = thread;
}
-bool Proxy::hasImplThread() const
+Thread* Proxy::mainThread()
{
- return m_implThread;
+ return s_mainThread;
}
-Thread* Proxy::implThread() const
+bool Proxy::hasImplThread()
{
- return m_implThread.get();
+ return s_implThread;
}
-Thread* Proxy::currentThread() const
+void Proxy::setImplThread(Thread* thread)
{
- if (mainThread() && mainThread()->belongsToCurrentThread())
- return mainThread();
- if (implThread() && implThread()->belongsToCurrentThread())
- return implThread();
+ s_implThread = thread;
+}
+
+Thread* Proxy::implThread()
+{
+ return s_implThread;
+}
+
+Thread* Proxy::currentThread()
+{
+ if (s_mainThread && s_mainThread->belongsToCurrentThread())
+ return s_mainThread;
+ if (s_implThread && s_implThread->belongsToCurrentThread())
+ return s_implThread;
return 0;
}
-bool Proxy::isMainThread() const
+bool Proxy::isMainThread()
{
#ifndef NDEBUG
- DCHECK(mainThread());
- if (m_implThreadIsOverridden)
+ DCHECK(s_mainThread);
+ if (implThreadIsOverridden)
return false;
- return mainThread()->belongsToCurrentThread();
+ return s_mainThread->belongsToCurrentThread();
#else
return true;
#endif
}
-bool Proxy::isImplThread() const
+bool Proxy::isImplThread()
{
#ifndef NDEBUG
- if (m_implThreadIsOverridden)
+ if (implThreadIsOverridden)
return true;
- return implThread() && implThread()->belongsToCurrentThread();
+ return s_implThread && s_implThread->belongsToCurrentThread();
#else
return true;
#endif
@@ -61,14 +79,14 @@
#ifndef NDEBUG
void Proxy::setCurrentThreadIsImplThread(bool isImplThread)
{
- m_implThreadIsOverridden = isImplThread;
+ implThreadIsOverridden = isImplThread;
}
#endif
-bool Proxy::isMainThreadBlocked() const
+bool Proxy::isMainThreadBlocked()
{
#ifndef NDEBUG
- return m_isMainThreadBlocked;
+ return s_isMainThreadBlocked;
#else
return true;
#endif
@@ -77,18 +95,13 @@
#ifndef NDEBUG
void Proxy::setMainThreadBlocked(bool isMainThreadBlocked)
{
- m_isMainThreadBlocked = isMainThreadBlocked;
+ s_isMainThreadBlocked = isMainThreadBlocked;
}
#endif
-Proxy::Proxy(scoped_ptr<Thread> implThread)
- : m_mainThread(ThreadImpl::createForCurrentThread())
- , m_implThread(implThread.Pass())
-#ifndef NDEBUG
- , m_implThreadIsOverridden(false)
- , m_isMainThreadBlocked(false)
-#endif
+Proxy::Proxy()
{
+ DCHECK(isMainThread());
}
Proxy::~Proxy()
« no previous file with comments | « cc/proxy.h ('k') | cc/quad_culler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698