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