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 #ifndef CC_SINGLE_THREAD_PROXY_H_ | 5 #ifndef CC_SINGLE_THREAD_PROXY_H_ |
6 #define CC_SINGLE_THREAD_PROXY_H_ | 6 #define CC_SINGLE_THREAD_PROXY_H_ |
7 | 7 |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 bool m_nextFrameIsNewlyCommittedFrame; | 84 bool m_nextFrameIsNewlyCommittedFrame; |
85 | 85 |
86 base::TimeDelta m_totalCommitTime; | 86 base::TimeDelta m_totalCommitTime; |
87 size_t m_totalCommitCount; | 87 size_t m_totalCommitCount; |
88 }; | 88 }; |
89 | 89 |
90 // For use in the single-threaded case. In debug builds, it pretends that the | 90 // For use in the single-threaded case. In debug builds, it pretends that the |
91 // code is running on the impl thread to satisfy assertion checks. | 91 // code is running on the impl thread to satisfy assertion checks. |
92 class DebugScopedSetImplThread { | 92 class DebugScopedSetImplThread { |
93 public: | 93 public: |
94 explicit DebugScopedSetImplThread(Proxy* proxy) | 94 DebugScopedSetImplThread() |
95 : m_proxy(proxy) | |
96 { | 95 { |
97 #ifndef NDEBUG | 96 #ifndef NDEBUG |
98 m_previousValue = m_proxy->m_implThreadIsOverridden; | 97 Proxy::setCurrentThreadIsImplThread(true); |
99 m_proxy->setCurrentThreadIsImplThread(true); | |
100 #endif | 98 #endif |
101 } | 99 } |
102 ~DebugScopedSetImplThread() | 100 ~DebugScopedSetImplThread() |
103 { | 101 { |
104 #ifndef NDEBUG | 102 #ifndef NDEBUG |
105 m_proxy->setCurrentThreadIsImplThread(m_previousValue); | 103 Proxy::setCurrentThreadIsImplThread(false); |
106 #endif | 104 #endif |
107 } | 105 } |
108 private: | |
109 bool m_previousValue; | |
110 Proxy* m_proxy; | |
111 }; | 106 }; |
112 | 107 |
113 // For use in the single-threaded case. In debug builds, it pretends that the | 108 // For use in the single-threaded case. In debug builds, it pretends that the |
114 // code is running on the main thread to satisfy assertion checks. | 109 // code is running on the main thread to satisfy assertion checks. |
115 class DebugScopedSetMainThread { | 110 class DebugScopedSetMainThread { |
116 public: | 111 public: |
117 explicit DebugScopedSetMainThread(Proxy* proxy) | 112 DebugScopedSetMainThread() |
118 : m_proxy(proxy) | |
119 { | 113 { |
120 #ifndef NDEBUG | 114 #ifndef NDEBUG |
121 m_previousValue = m_proxy->m_implThreadIsOverridden; | 115 Proxy::setCurrentThreadIsImplThread(false); |
122 m_proxy->setCurrentThreadIsImplThread(false); | |
123 #endif | 116 #endif |
124 } | 117 } |
125 ~DebugScopedSetMainThread() | 118 ~DebugScopedSetMainThread() |
126 { | 119 { |
127 #ifndef NDEBUG | 120 #ifndef NDEBUG |
128 m_proxy->setCurrentThreadIsImplThread(m_previousValue); | 121 Proxy::setCurrentThreadIsImplThread(true); |
129 #endif | 122 #endif |
130 } | 123 } |
131 private: | |
132 bool m_previousValue; | |
133 Proxy* m_proxy; | |
134 }; | 124 }; |
135 | 125 |
136 // For use in the single-threaded case. In debug builds, it pretends that the | 126 // For use in the single-threaded case. In debug builds, it pretends that the |
137 // code is running on the impl thread and that the main thread is blocked to | 127 // code is running on the impl thread and that the main thread is blocked to |
138 // satisfy assertion checks | 128 // satisfy assertion checks |
139 class DebugScopedSetImplThreadAndMainThreadBlocked { | 129 class DebugScopedSetImplThreadAndMainThreadBlocked { |
140 public: | |
141 explicit DebugScopedSetImplThreadAndMainThreadBlocked(Proxy* proxy) | |
142 : m_implThread(proxy) | |
143 , m_mainThreadBlocked(proxy) | |
144 { | |
145 } | |
146 private: | 130 private: |
147 DebugScopedSetImplThread m_implThread; | 131 DebugScopedSetImplThread m_implThread; |
148 DebugScopedSetMainThreadBlocked m_mainThreadBlocked; | 132 DebugScopedSetMainThreadBlocked m_mainThreadBlocked; |
149 }; | 133 }; |
150 | 134 |
151 } // namespace cc | 135 } // namespace cc |
152 | 136 |
153 #endif // CC_SINGLE_THREAD_PROXY_H_ | 137 #endif // CC_SINGLE_THREAD_PROXY_H_ |
OLD | NEW |