Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: cc/proxy.cc

Issue 11232051: Remove static thread pointers from CC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« cc/proxy.h ('K') | « cc/proxy.h ('k') | cc/rate_limiter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ccthread_impl.h"
9 #include "cc/thread_task.h" 10 #include "cc/thread_task.h"
10 11
11 namespace cc { 12 namespace cc {
12 13
13 namespace { 14 void CCProxy::setMainThread(CCThread* thread)
14 #ifndef NDEBUG 15 {
15 bool implThreadIsOverridden = false; 16 m_compositorSupportState->mainThread = thread;
16 bool s_isMainThreadBlocked = false;
17 base::PlatformThreadId threadIDOverridenToBeImplThread;
18 #endif
19 CCThread* s_mainThread = 0;
20 CCThread* s_implThread = 0;
21 } 17 }
22 18
23 void CCProxy::setMainThread(CCThread* thread) 19 CCThread* CCProxy::mainThread() const
24 { 20 {
25 s_mainThread = thread; 21 return m_compositorSupportState->mainThread;
26 } 22 }
27 23
28 CCThread* CCProxy::mainThread() 24 bool CCProxy::hasImplThread() const
29 { 25 {
30 return s_mainThread; 26 return !!m_compositorSupportState->implThread;
31 }
32
33 bool CCProxy::hasImplThread()
34 {
35 return s_implThread;
36 } 27 }
37 28
38 void CCProxy::setImplThread(CCThread* thread) 29 void CCProxy::setImplThread(CCThread* thread)
39 { 30 {
40 s_implThread = thread; 31 m_compositorSupportState->implThread = thread;
41 } 32 }
42 33
43 CCThread* CCProxy::implThread() 34 CCThread* CCProxy::implThread() const
44 { 35 {
45 return s_implThread; 36 return m_compositorSupportState->implThread;
46 } 37 }
47 38
48 CCThread* CCProxy::currentThread() 39 CCThread* CCProxy::currentThread() const
49 { 40 {
50 base::PlatformThreadId currentThreadIdentifier = base::PlatformThread::Curre ntId(); 41 base::PlatformThreadId currentThreadIdentifier = base::PlatformThread::Curre ntId();
51 if (s_mainThread && s_mainThread->threadID() == currentThreadIdentifier) 42 if (mainThread() && mainThread()->threadID() == currentThreadIdentifier)
52 return s_mainThread; 43 return mainThread();
53 if (s_implThread && s_implThread->threadID() == currentThreadIdentifier) 44 if (implThread() && implThread()->threadID() == currentThreadIdentifier)
54 return s_implThread; 45 return implThread();
55 return 0; 46 return 0;
56 } 47 }
57 48
58 bool CCProxy::isMainThread() 49 bool CCProxy::isMainThread() const
59 { 50 {
60 #ifndef NDEBUG 51 #ifndef NDEBUG
61 DCHECK(s_mainThread); 52 DCHECK(mainThread());
62 if (implThreadIsOverridden && base::PlatformThread::CurrentId() == threadIDO verridenToBeImplThread) 53 if (m_implThreadIsOverridden && base::PlatformThread::CurrentId() == m_threa dIDOverridenToBeImplThread)
63 return false; 54 return false;
64 return base::PlatformThread::CurrentId() == s_mainThread->threadID(); 55 return base::PlatformThread::CurrentId() == mainThread()->threadID();
65 #else 56 #else
66 return true; 57 return true;
67 #endif 58 #endif
68 } 59 }
69 60
70 bool CCProxy::isImplThread() 61 bool CCProxy::isImplThread() const
71 { 62 {
72 #ifndef NDEBUG 63 #ifndef NDEBUG
73 base::PlatformThreadId implThreadID = s_implThread ? s_implThread->threadID( ) : 0; 64 base::PlatformThreadId implThreadID = implThread() ? implThread()->threadID( ) : 0;
74 if (implThreadIsOverridden && base::PlatformThread::CurrentId() == threadIDO verridenToBeImplThread) 65 if (m_implThreadIsOverridden && base::PlatformThread::CurrentId() == m_threa dIDOverridenToBeImplThread)
75 return true; 66 return true;
76 return base::PlatformThread::CurrentId() == implThreadID; 67 return base::PlatformThread::CurrentId() == implThreadID;
77 #else 68 #else
78 return true; 69 return true;
79 #endif 70 #endif
80 } 71 }
81 72
82 #ifndef NDEBUG 73 #ifndef NDEBUG
83 void CCProxy::setCurrentThreadIsImplThread(bool isImplThread) 74 void CCProxy::setCurrentThreadIsImplThread(bool isImplThread)
84 { 75 {
85 implThreadIsOverridden = isImplThread; 76 m_implThreadIsOverridden = isImplThread;
86 if (isImplThread) 77 if (isImplThread)
87 threadIDOverridenToBeImplThread = base::PlatformThread::CurrentId(); 78 m_threadIDOverridenToBeImplThread = base::PlatformThread::CurrentId();
88 } 79 }
89 #endif 80 #endif
90 81
91 bool CCProxy::isMainThreadBlocked() 82 bool CCProxy::isMainThreadBlocked() const
92 { 83 {
93 #ifndef NDEBUG 84 #ifndef NDEBUG
94 return s_isMainThreadBlocked; 85 return m_isMainThreadBlocked;
95 #else 86 #else
96 return true; 87 return true;
97 #endif 88 #endif
98 } 89 }
99 90
100 #ifndef NDEBUG 91 #ifndef NDEBUG
101 void CCProxy::setMainThreadBlocked(bool isMainThreadBlocked) 92 void CCProxy::setMainThreadBlocked(bool isMainThreadBlocked)
102 { 93 {
103 s_isMainThreadBlocked = isMainThreadBlocked; 94 m_isMainThreadBlocked = isMainThreadBlocked;
104 } 95 }
105 #endif 96 #endif
106 97
107 CCProxy::CCProxy() 98 CCProxy::CCProxy(CompositorSupportState* compositorSupportState)
99 : m_compositorSupportState(compositorSupportState)
100 #ifndef NDEBUG
101 , m_implThreadIsOverridden(false)
102 , m_isMainThreadBlocked(false)
103 #endif
108 { 104 {
109 DCHECK(isMainThread());
110 } 105 }
111 106
112 CCProxy::~CCProxy() 107 CCProxy::~CCProxy()
113 { 108 {
114 DCHECK(isMainThread()); 109 DCHECK(isMainThread());
115 } 110 }
116 111
117 } 112 }
OLDNEW
« cc/proxy.h ('K') | « cc/proxy.h ('k') | cc/rate_limiter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698