diff options
author | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-05 07:17:46 +0000 |
---|---|---|
committer | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-05 07:17:46 +0000 |
commit | 068d7ef6aed7f5a7bdaf1e8d28b422c547be294d (patch) | |
tree | a66fd6a12e3a9ae7ef16c66043fd4e4bebe4d28c /cc/proxy.cc | |
parent | 2bddc10a9e71bd3e7d7f010b46ec96c7ab623336 (diff) | |
download | chromium_src-068d7ef6aed7f5a7bdaf1e8d28b422c547be294d.zip chromium_src-068d7ef6aed7f5a7bdaf1e8d28b422c547be294d.tar.gz chromium_src-068d7ef6aed7f5a7bdaf1e8d28b422c547be294d.tar.bz2 |
A speculative Revert for r165872 - Remove static thread pointers from CC, attempt 2
BUG=152904
Review URL: https://chromiumcodereview.appspot.com/11232051
TBR=aelias@chromium.org
Review URL: https://codereview.chromium.org/11369071
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165907 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/proxy.cc')
-rw-r--r-- | cc/proxy.cc | 73 |
1 files changed, 43 insertions, 30 deletions
diff --git a/cc/proxy.cc b/cc/proxy.cc index 46ef19f..7b738aa 100644 --- a/cc/proxy.cc +++ b/cc/proxy.cc @@ -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) +{ + s_mainThread = thread; +} + +Thread* Proxy::mainThread() { - return m_mainThread.get(); + return s_mainThread; } -bool Proxy::hasImplThread() const +bool Proxy::hasImplThread() { - return m_implThread; + return s_implThread; } -Thread* Proxy::implThread() const +void Proxy::setImplThread(Thread* thread) { - return m_implThread.get(); + s_implThread = thread; } -Thread* Proxy::currentThread() const +Thread* Proxy::implThread() { - if (mainThread() && mainThread()->belongsToCurrentThread()) - return mainThread(); - if (implThread() && implThread()->belongsToCurrentThread()) - return 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 @@ bool Proxy::isImplThread() const #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 @@ bool Proxy::isMainThreadBlocked() const #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() |