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 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 CCThread* CCProxy::currentThread() | 48 CCThread* CCProxy::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 | |
59 bool CCProxy::isMainThread() | 58 bool CCProxy::isMainThread() |
60 { | 59 { |
61 ASSERT(s_mainThread); | 60 #ifndef NDEBUG |
| 61 DCHECK(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 #else |
| 66 return true; |
| 67 #endif |
65 } | 68 } |
66 | 69 |
67 bool CCProxy::isImplThread() | 70 bool CCProxy::isImplThread() |
68 { | 71 { |
| 72 #ifndef NDEBUG |
69 base::PlatformThreadId implThreadID = s_implThread ? s_implThread->threadID(
) : 0; | 73 base::PlatformThreadId implThreadID = s_implThread ? s_implThread->threadID(
) : 0; |
70 if (implThreadIsOverridden && base::PlatformThread::CurrentId() == threadIDO
verridenToBeImplThread) | 74 if (implThreadIsOverridden && base::PlatformThread::CurrentId() == threadIDO
verridenToBeImplThread) |
71 return true; | 75 return true; |
72 return base::PlatformThread::CurrentId() == implThreadID; | 76 return base::PlatformThread::CurrentId() == implThreadID; |
| 77 #else |
| 78 return true; |
| 79 #endif |
73 } | 80 } |
74 | 81 |
| 82 #ifndef NDEBUG |
75 void CCProxy::setCurrentThreadIsImplThread(bool isImplThread) | 83 void CCProxy::setCurrentThreadIsImplThread(bool isImplThread) |
76 { | 84 { |
77 implThreadIsOverridden = isImplThread; | 85 implThreadIsOverridden = isImplThread; |
78 if (isImplThread) | 86 if (isImplThread) |
79 threadIDOverridenToBeImplThread = base::PlatformThread::CurrentId(); | 87 threadIDOverridenToBeImplThread = base::PlatformThread::CurrentId(); |
80 } | 88 } |
| 89 #endif |
81 | 90 |
82 bool CCProxy::isMainThreadBlocked() | 91 bool CCProxy::isMainThreadBlocked() |
83 { | 92 { |
| 93 #ifndef NDEBUG |
84 return s_isMainThreadBlocked; | 94 return s_isMainThreadBlocked; |
| 95 #else |
| 96 return true; |
| 97 #endif |
85 } | 98 } |
86 | 99 |
| 100 #ifndef NDEBUG |
87 void CCProxy::setMainThreadBlocked(bool isMainThreadBlocked) | 101 void CCProxy::setMainThreadBlocked(bool isMainThreadBlocked) |
88 { | 102 { |
89 s_isMainThreadBlocked = isMainThreadBlocked; | 103 s_isMainThreadBlocked = isMainThreadBlocked; |
90 } | 104 } |
91 #endif | 105 #endif |
92 | 106 |
93 CCProxy::CCProxy() | 107 CCProxy::CCProxy() |
94 { | 108 { |
95 ASSERT(isMainThread()); | 109 DCHECK(isMainThread()); |
96 } | 110 } |
97 | 111 |
98 CCProxy::~CCProxy() | 112 CCProxy::~CCProxy() |
99 { | 113 { |
100 ASSERT(isMainThread()); | 114 DCHECK(isMainThread()); |
101 } | 115 } |
102 | 116 |
103 } | 117 } |
OLD | NEW |