OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "CCProxy.h" | 7 #include "CCProxy.h" |
8 | 8 |
9 #include "CCThreadTask.h" | 9 #include "CCThreadTask.h" |
10 | 10 |
11 namespace cc { | 11 namespace cc { |
12 | 12 |
13 namespace { | 13 namespace { |
14 #ifndef NDEBUG | 14 #ifndef NDEBUG |
15 bool implThreadIsOverridden = false; | 15 bool implThreadIsOverridden = false; |
16 bool s_isMainThreadBlocked = false; | 16 bool s_isMainThreadBlocked = false; |
17 base::PlatformThreadId threadIDOverridenToBeImplThread; | 17 base::PlatformThreadId threadIDOverridenToBeImplThread; |
18 #endif | 18 #endif |
19 CCThread* s_mainThread = 0; | 19 Thread* s_mainThread = 0; |
20 CCThread* s_implThread = 0; | 20 Thread* s_implThread = 0; |
21 } | 21 } |
22 | 22 |
23 void CCProxy::setMainThread(CCThread* thread) | 23 void Proxy::setMainThread(Thread* thread) |
24 { | 24 { |
25 s_mainThread = thread; | 25 s_mainThread = thread; |
26 } | 26 } |
27 | 27 |
28 CCThread* CCProxy::mainThread() | 28 Thread* Proxy::mainThread() |
29 { | 29 { |
30 return s_mainThread; | 30 return s_mainThread; |
31 } | 31 } |
32 | 32 |
33 bool CCProxy::hasImplThread() | 33 bool Proxy::hasImplThread() |
34 { | 34 { |
35 return s_implThread; | 35 return s_implThread; |
36 } | 36 } |
37 | 37 |
38 void CCProxy::setImplThread(CCThread* thread) | 38 void Proxy::setImplThread(Thread* thread) |
39 { | 39 { |
40 s_implThread = thread; | 40 s_implThread = thread; |
41 } | 41 } |
42 | 42 |
43 CCThread* CCProxy::implThread() | 43 Thread* Proxy::implThread() |
44 { | 44 { |
45 return s_implThread; | 45 return s_implThread; |
46 } | 46 } |
47 | 47 |
48 CCThread* CCProxy::currentThread() | 48 Thread* Proxy::currentThread() |
49 { | 49 { |
50 base::PlatformThreadId currentThreadIdentifier = base::PlatformThread::Curre
ntId(); | 50 base::PlatformThreadId currentThreadIdentifier = base::PlatformThread::Curre
ntId(); |
51 if (s_mainThread && s_mainThread->threadID() == currentThreadIdentifier) | 51 if (s_mainThread && s_mainThread->threadID() == currentThreadIdentifier) |
52 return s_mainThread; | 52 return s_mainThread; |
53 if (s_implThread && s_implThread->threadID() == currentThreadIdentifier) | 53 if (s_implThread && s_implThread->threadID() == currentThreadIdentifier) |
54 return s_implThread; | 54 return s_implThread; |
55 return 0; | 55 return 0; |
56 } | 56 } |
57 | 57 |
58 #ifndef NDEBUG | 58 #ifndef NDEBUG |
59 bool CCProxy::isMainThread() | 59 bool Proxy::isMainThread() |
60 { | 60 { |
61 ASSERT(s_mainThread); | 61 ASSERT(s_mainThread); |
62 if (implThreadIsOverridden && base::PlatformThread::CurrentId() == threadIDO
verridenToBeImplThread) | 62 if (implThreadIsOverridden && base::PlatformThread::CurrentId() == threadIDO
verridenToBeImplThread) |
63 return false; | 63 return false; |
64 return base::PlatformThread::CurrentId() == s_mainThread->threadID(); | 64 return base::PlatformThread::CurrentId() == s_mainThread->threadID(); |
65 } | 65 } |
66 | 66 |
67 bool CCProxy::isImplThread() | 67 bool Proxy::isImplThread() |
68 { | 68 { |
69 base::PlatformThreadId implThreadID = s_implThread ? s_implThread->threadID(
) : 0; | 69 base::PlatformThreadId implThreadID = s_implThread ? s_implThread->threadID(
) : 0; |
70 if (implThreadIsOverridden && base::PlatformThread::CurrentId() == threadIDO
verridenToBeImplThread) | 70 if (implThreadIsOverridden && base::PlatformThread::CurrentId() == threadIDO
verridenToBeImplThread) |
71 return true; | 71 return true; |
72 return base::PlatformThread::CurrentId() == implThreadID; | 72 return base::PlatformThread::CurrentId() == implThreadID; |
73 } | 73 } |
74 | 74 |
75 void CCProxy::setCurrentThreadIsImplThread(bool isImplThread) | 75 void Proxy::setCurrentThreadIsImplThread(bool isImplThread) |
76 { | 76 { |
77 implThreadIsOverridden = isImplThread; | 77 implThreadIsOverridden = isImplThread; |
78 if (isImplThread) | 78 if (isImplThread) |
79 threadIDOverridenToBeImplThread = base::PlatformThread::CurrentId(); | 79 threadIDOverridenToBeImplThread = base::PlatformThread::CurrentId(); |
80 } | 80 } |
81 | 81 |
82 bool CCProxy::isMainThreadBlocked() | 82 bool Proxy::isMainThreadBlocked() |
83 { | 83 { |
84 return s_isMainThreadBlocked; | 84 return s_isMainThreadBlocked; |
85 } | 85 } |
86 | 86 |
87 void CCProxy::setMainThreadBlocked(bool isMainThreadBlocked) | 87 void Proxy::setMainThreadBlocked(bool isMainThreadBlocked) |
88 { | 88 { |
89 s_isMainThreadBlocked = isMainThreadBlocked; | 89 s_isMainThreadBlocked = isMainThreadBlocked; |
90 } | 90 } |
91 #endif | 91 #endif |
92 | 92 |
93 CCProxy::CCProxy() | 93 Proxy::Proxy() |
94 { | 94 { |
95 ASSERT(isMainThread()); | 95 ASSERT(isMainThread()); |
96 } | 96 } |
97 | 97 |
98 CCProxy::~CCProxy() | 98 Proxy::~Proxy() |
99 { | 99 { |
100 ASSERT(isMainThread()); | 100 ASSERT(isMainThread()); |
101 } | 101 } |
102 | 102 |
103 } | 103 } |
OLD | NEW |