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 using namespace WTF; | 11 using namespace WTF; |
12 | 12 |
13 namespace cc { | 13 namespace cc { |
14 | 14 |
15 namespace { | 15 namespace { |
16 #ifndef NDEBUG | |
17 bool implThreadIsOverridden = false; | 16 bool implThreadIsOverridden = false; |
18 bool s_isMainThreadBlocked = false; | 17 bool s_isMainThreadBlocked = false; |
19 base::PlatformThreadId threadIDOverridenToBeImplThread; | 18 base::PlatformThreadId threadIDOverridenToBeImplThread; |
20 #endif | |
21 CCThread* s_mainThread = 0; | 19 CCThread* s_mainThread = 0; |
22 CCThread* s_implThread = 0; | 20 CCThread* s_implThread = 0; |
23 } | 21 } |
24 | 22 |
25 void CCProxy::setMainThread(CCThread* thread) | 23 void CCProxy::setMainThread(CCThread* thread) |
26 { | 24 { |
27 s_mainThread = thread; | 25 s_mainThread = thread; |
28 } | 26 } |
29 | 27 |
30 CCThread* CCProxy::mainThread() | 28 CCThread* CCProxy::mainThread() |
(...skipping 19 matching lines...) Expand all Loading... |
50 CCThread* CCProxy::currentThread() | 48 CCThread* CCProxy::currentThread() |
51 { | 49 { |
52 base::PlatformThreadId currentThreadIdentifier = base::PlatformThread::Curre
ntId(); | 50 base::PlatformThreadId currentThreadIdentifier = base::PlatformThread::Curre
ntId(); |
53 if (s_mainThread && s_mainThread->threadID() == currentThreadIdentifier) | 51 if (s_mainThread && s_mainThread->threadID() == currentThreadIdentifier) |
54 return s_mainThread; | 52 return s_mainThread; |
55 if (s_implThread && s_implThread->threadID() == currentThreadIdentifier) | 53 if (s_implThread && s_implThread->threadID() == currentThreadIdentifier) |
56 return s_implThread; | 54 return s_implThread; |
57 return 0; | 55 return 0; |
58 } | 56 } |
59 | 57 |
60 #ifndef NDEBUG | |
61 bool CCProxy::isMainThread() | 58 bool CCProxy::isMainThread() |
62 { | 59 { |
63 ASSERT(s_mainThread); | 60 if (!DCHECK_IS_ON()) |
| 61 return true; |
| 62 |
| 63 DCHECK(s_mainThread); |
64 if (implThreadIsOverridden && base::PlatformThread::CurrentId() == threadIDO
verridenToBeImplThread) | 64 if (implThreadIsOverridden && base::PlatformThread::CurrentId() == threadIDO
verridenToBeImplThread) |
65 return false; | 65 return false; |
66 return base::PlatformThread::CurrentId() == s_mainThread->threadID(); | 66 return base::PlatformThread::CurrentId() == s_mainThread->threadID(); |
67 } | 67 } |
68 | 68 |
69 bool CCProxy::isImplThread() | 69 bool CCProxy::isImplThread() |
70 { | 70 { |
| 71 if (!DCHECK_IS_ON()) |
| 72 return true; |
| 73 |
71 base::PlatformThreadId implThreadID = s_implThread ? s_implThread->threadID(
) : 0; | 74 base::PlatformThreadId implThreadID = s_implThread ? s_implThread->threadID(
) : 0; |
72 if (implThreadIsOverridden && base::PlatformThread::CurrentId() == threadIDO
verridenToBeImplThread) | 75 if (implThreadIsOverridden && base::PlatformThread::CurrentId() == threadIDO
verridenToBeImplThread) |
73 return true; | 76 return true; |
74 return base::PlatformThread::CurrentId() == implThreadID; | 77 return base::PlatformThread::CurrentId() == implThreadID; |
75 } | 78 } |
76 | 79 |
77 void CCProxy::setCurrentThreadIsImplThread(bool isImplThread) | 80 void CCProxy::setCurrentThreadIsImplThread(bool isImplThread) |
78 { | 81 { |
| 82 if (!DCHECK_IS_ON()) |
| 83 return; |
| 84 |
79 implThreadIsOverridden = isImplThread; | 85 implThreadIsOverridden = isImplThread; |
80 if (isImplThread) | 86 if (isImplThread) |
81 threadIDOverridenToBeImplThread = base::PlatformThread::CurrentId(); | 87 threadIDOverridenToBeImplThread = base::PlatformThread::CurrentId(); |
82 } | 88 } |
83 | 89 |
84 bool CCProxy::isMainThreadBlocked() | 90 bool CCProxy::isMainThreadBlocked() |
85 { | 91 { |
| 92 if (!DCHECK_IS_ON()) |
| 93 return true; |
86 return s_isMainThreadBlocked; | 94 return s_isMainThreadBlocked; |
87 } | 95 } |
88 | 96 |
89 void CCProxy::setMainThreadBlocked(bool isMainThreadBlocked) | 97 void CCProxy::setMainThreadBlocked(bool isMainThreadBlocked) |
90 { | 98 { |
| 99 if (!DCHECK_IS_ON()) |
| 100 return; |
91 s_isMainThreadBlocked = isMainThreadBlocked; | 101 s_isMainThreadBlocked = isMainThreadBlocked; |
92 } | 102 } |
93 #endif | |
94 | 103 |
95 CCProxy::CCProxy() | 104 CCProxy::CCProxy() |
96 { | 105 { |
97 ASSERT(isMainThread()); | 106 DCHECK(isMainThread()); |
98 } | 107 } |
99 | 108 |
100 CCProxy::~CCProxy() | 109 CCProxy::~CCProxy() |
101 { | 110 { |
102 ASSERT(isMainThread()); | 111 DCHECK(isMainThread()); |
103 } | 112 } |
104 | 113 |
105 } | 114 } |
OLD | NEW |