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"
10 #include <wtf/MainThread.h>
18 bool implThreadIsOverridden
= false;
19 bool s_isMainThreadBlocked
= false;
20 base::PlatformThreadId threadIDOverridenToBeImplThread
;
22 CCThread
* s_mainThread
= 0;
23 CCThread
* s_implThread
= 0;
26 void CCProxy::setMainThread(CCThread
* thread
)
28 s_mainThread
= thread
;
31 CCThread
* CCProxy::mainThread()
36 bool CCProxy::hasImplThread()
41 void CCProxy::setImplThread(CCThread
* thread
)
43 s_implThread
= thread
;
46 CCThread
* CCProxy::implThread()
51 CCThread
* CCProxy::currentThread()
53 base::PlatformThreadId currentThreadIdentifier
= base::PlatformThread::CurrentId();
54 if (s_mainThread
&& s_mainThread
->threadID() == currentThreadIdentifier
)
56 if (s_implThread
&& s_implThread
->threadID() == currentThreadIdentifier
)
62 bool CCProxy::isMainThread()
65 if (implThreadIsOverridden
&& base::PlatformThread::CurrentId() == threadIDOverridenToBeImplThread
)
67 return base::PlatformThread::CurrentId() == s_mainThread
->threadID();
70 bool CCProxy::isImplThread()
72 base::PlatformThreadId implThreadID
= s_implThread
? s_implThread
->threadID() : 0;
73 if (implThreadIsOverridden
&& base::PlatformThread::CurrentId() == threadIDOverridenToBeImplThread
)
75 return base::PlatformThread::CurrentId() == implThreadID
;
78 void CCProxy::setCurrentThreadIsImplThread(bool isImplThread
)
80 implThreadIsOverridden
= isImplThread
;
82 threadIDOverridenToBeImplThread
= base::PlatformThread::CurrentId();
85 bool CCProxy::isMainThreadBlocked()
87 return s_isMainThreadBlocked
;
90 void CCProxy::setMainThreadBlocked(bool isMainThreadBlocked
)
92 s_isMainThreadBlocked
= isMainThreadBlocked
;
98 ASSERT(isMainThread());
103 ASSERT(isMainThread());