1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
9 #include "CCThreadTask.h"
17 bool implThreadIsOverridden
= false;
18 bool s_isMainThreadBlocked
= false;
19 base::PlatformThreadId threadIDOverridenToBeImplThread
;
21 CCThread
* s_mainThread
= 0;
22 CCThread
* s_implThread
= 0;
25 void CCProxy::setMainThread(CCThread
* thread
)
27 s_mainThread
= thread
;
30 CCThread
* CCProxy::mainThread()
35 bool CCProxy::hasImplThread()
40 void CCProxy::setImplThread(CCThread
* thread
)
42 s_implThread
= thread
;
45 CCThread
* CCProxy::implThread()
50 CCThread
* CCProxy::currentThread()
52 base::PlatformThreadId currentThreadIdentifier
= base::PlatformThread::CurrentId();
53 if (s_mainThread
&& s_mainThread
->threadID() == currentThreadIdentifier
)
55 if (s_implThread
&& s_implThread
->threadID() == currentThreadIdentifier
)
61 bool CCProxy::isMainThread()
64 if (implThreadIsOverridden
&& base::PlatformThread::CurrentId() == threadIDOverridenToBeImplThread
)
66 return base::PlatformThread::CurrentId() == s_mainThread
->threadID();
69 bool CCProxy::isImplThread()
71 base::PlatformThreadId implThreadID
= s_implThread
? s_implThread
->threadID() : 0;
72 if (implThreadIsOverridden
&& base::PlatformThread::CurrentId() == threadIDOverridenToBeImplThread
)
74 return base::PlatformThread::CurrentId() == implThreadID
;
77 void CCProxy::setCurrentThreadIsImplThread(bool isImplThread
)
79 implThreadIsOverridden
= isImplThread
;
81 threadIDOverridenToBeImplThread
= base::PlatformThread::CurrentId();
84 bool CCProxy::isMainThreadBlocked()
86 return s_isMainThreadBlocked
;
89 void CCProxy::setMainThreadBlocked(bool isMainThreadBlocked
)
91 s_isMainThreadBlocked
= isMainThreadBlocked
;
97 ASSERT(isMainThread());
102 ASSERT(isMainThread());