| 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 "cc/proxy.h" | 7 #include "cc/proxy.h" |
| 8 | 8 |
| 9 #include "cc/thread_task.h" | 9 #include "cc/thread.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; | |
| 18 #endif | 17 #endif |
| 19 Thread* s_mainThread = 0; | 18 Thread* s_mainThread = 0; |
| 20 Thread* s_implThread = 0; | 19 Thread* s_implThread = 0; |
| 21 } | 20 } |
| 22 | 21 |
| 23 void Proxy::setMainThread(Thread* thread) | 22 void Proxy::setMainThread(Thread* thread) |
| 24 { | 23 { |
| 25 s_mainThread = thread; | 24 s_mainThread = thread; |
| 26 } | 25 } |
| 27 | 26 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 40 s_implThread = thread; | 39 s_implThread = thread; |
| 41 } | 40 } |
| 42 | 41 |
| 43 Thread* Proxy::implThread() | 42 Thread* Proxy::implThread() |
| 44 { | 43 { |
| 45 return s_implThread; | 44 return s_implThread; |
| 46 } | 45 } |
| 47 | 46 |
| 48 Thread* Proxy::currentThread() | 47 Thread* Proxy::currentThread() |
| 49 { | 48 { |
| 50 base::PlatformThreadId currentThreadIdentifier = base::PlatformThread::Curre
ntId(); | 49 if (s_mainThread && s_mainThread->belongsToCurrentThread()) |
| 51 if (s_mainThread && s_mainThread->threadID() == currentThreadIdentifier) | |
| 52 return s_mainThread; | 50 return s_mainThread; |
| 53 if (s_implThread && s_implThread->threadID() == currentThreadIdentifier) | 51 if (s_implThread && s_implThread->belongsToCurrentThread()) |
| 54 return s_implThread; | 52 return s_implThread; |
| 55 return 0; | 53 return 0; |
| 56 } | 54 } |
| 57 | 55 |
| 58 bool Proxy::isMainThread() | 56 bool Proxy::isMainThread() |
| 59 { | 57 { |
| 60 #ifndef NDEBUG | 58 #ifndef NDEBUG |
| 61 DCHECK(s_mainThread); | 59 DCHECK(s_mainThread); |
| 62 if (implThreadIsOverridden && base::PlatformThread::CurrentId() == threadIDO
verridenToBeImplThread) | 60 if (implThreadIsOverridden) |
| 63 return false; | 61 return false; |
| 64 return base::PlatformThread::CurrentId() == s_mainThread->threadID(); | 62 return s_mainThread->belongsToCurrentThread(); |
| 65 #else | 63 #else |
| 66 return true; | 64 return true; |
| 67 #endif | 65 #endif |
| 68 } | 66 } |
| 69 | 67 |
| 70 bool Proxy::isImplThread() | 68 bool Proxy::isImplThread() |
| 71 { | 69 { |
| 72 #ifndef NDEBUG | 70 #ifndef NDEBUG |
| 73 base::PlatformThreadId implThreadID = s_implThread ? s_implThread->threadID(
) : 0; | 71 if (implThreadIsOverridden) |
| 74 if (implThreadIsOverridden && base::PlatformThread::CurrentId() == threadIDO
verridenToBeImplThread) | |
| 75 return true; | 72 return true; |
| 76 return base::PlatformThread::CurrentId() == implThreadID; | 73 return s_implThread && s_implThread->belongsToCurrentThread(); |
| 77 #else | 74 #else |
| 78 return true; | 75 return true; |
| 79 #endif | 76 #endif |
| 80 } | 77 } |
| 81 | 78 |
| 82 #ifndef NDEBUG | 79 #ifndef NDEBUG |
| 83 void Proxy::setCurrentThreadIsImplThread(bool isImplThread) | 80 void Proxy::setCurrentThreadIsImplThread(bool isImplThread) |
| 84 { | 81 { |
| 85 implThreadIsOverridden = isImplThread; | 82 implThreadIsOverridden = isImplThread; |
| 86 if (isImplThread) | |
| 87 threadIDOverridenToBeImplThread = base::PlatformThread::CurrentId(); | |
| 88 } | 83 } |
| 89 #endif | 84 #endif |
| 90 | 85 |
| 91 bool Proxy::isMainThreadBlocked() | 86 bool Proxy::isMainThreadBlocked() |
| 92 { | 87 { |
| 93 #ifndef NDEBUG | 88 #ifndef NDEBUG |
| 94 return s_isMainThreadBlocked; | 89 return s_isMainThreadBlocked; |
| 95 #else | 90 #else |
| 96 return true; | 91 return true; |
| 97 #endif | 92 #endif |
| (...skipping 10 matching lines...) Expand all Loading... |
| 108 { | 103 { |
| 109 DCHECK(isMainThread()); | 104 DCHECK(isMainThread()); |
| 110 } | 105 } |
| 111 | 106 |
| 112 Proxy::~Proxy() | 107 Proxy::~Proxy() |
| 113 { | 108 { |
| 114 DCHECK(isMainThread()); | 109 DCHECK(isMainThread()); |
| 115 } | 110 } |
| 116 | 111 |
| 117 } | 112 } |
| OLD | NEW |