| 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_TREES_SINGLE_THREAD_PROXY_H_ | 5 #ifndef CC_TREES_SINGLE_THREAD_PROXY_H_ |
| 6 #define CC_TREES_SINGLE_THREAD_PROXY_H_ | 6 #define CC_TREES_SINGLE_THREAD_PROXY_H_ |
| 7 | 7 |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/cancelable_callback.h" | 10 #include "base/cancelable_callback.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 172 |
| 173 base::WeakPtrFactory<SingleThreadProxy> weak_factory_; | 173 base::WeakPtrFactory<SingleThreadProxy> weak_factory_; |
| 174 | 174 |
| 175 DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy); | 175 DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy); |
| 176 }; | 176 }; |
| 177 | 177 |
| 178 // For use in the single-threaded case. In debug builds, it pretends that the | 178 // For use in the single-threaded case. In debug builds, it pretends that the |
| 179 // code is running on the impl thread to satisfy assertion checks. | 179 // code is running on the impl thread to satisfy assertion checks. |
| 180 class DebugScopedSetImplThread { | 180 class DebugScopedSetImplThread { |
| 181 public: | 181 public: |
| 182 explicit DebugScopedSetImplThread(Proxy* proxy) : proxy_(proxy) { | 182 explicit DebugScopedSetImplThread(ThreadVerifier* thread_verifier) |
| 183 : thread_verifier_(thread_verifier) { |
| 183 #if DCHECK_IS_ON() | 184 #if DCHECK_IS_ON() |
| 184 previous_value_ = proxy_->impl_thread_is_overridden_; | 185 previous_value_ = thread_verifier_->impl_thread_is_overridden_; |
| 185 proxy_->SetCurrentThreadIsImplThread(true); | 186 thread_verifier_->SetCurrentThreadIsImplThread(true); |
| 186 #endif | 187 #endif |
| 187 } | 188 } |
| 188 ~DebugScopedSetImplThread() { | 189 ~DebugScopedSetImplThread() { |
| 189 #if DCHECK_IS_ON() | 190 #if DCHECK_IS_ON() |
| 190 proxy_->SetCurrentThreadIsImplThread(previous_value_); | 191 thread_verifier_->SetCurrentThreadIsImplThread(previous_value_); |
| 191 #endif | 192 #endif |
| 192 } | 193 } |
| 193 | 194 |
| 194 private: | 195 private: |
| 195 bool previous_value_; | 196 bool previous_value_; |
| 196 Proxy* proxy_; | 197 ThreadVerifier* thread_verifier_; |
| 197 | 198 |
| 198 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThread); | 199 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThread); |
| 199 }; | 200 }; |
| 200 | 201 |
| 201 // For use in the single-threaded case. In debug builds, it pretends that the | 202 // For use in the single-threaded case. In debug builds, it pretends that the |
| 202 // code is running on the main thread to satisfy assertion checks. | 203 // code is running on the main thread to satisfy assertion checks. |
| 203 class DebugScopedSetMainThread { | 204 class DebugScopedSetMainThread { |
| 204 public: | 205 public: |
| 205 explicit DebugScopedSetMainThread(Proxy* proxy) : proxy_(proxy) { | 206 explicit DebugScopedSetMainThread(ThreadVerifier* thread_verifier) |
| 207 : thread_verifier_(thread_verifier) { |
| 206 #if DCHECK_IS_ON() | 208 #if DCHECK_IS_ON() |
| 207 previous_value_ = proxy_->impl_thread_is_overridden_; | 209 previous_value_ = thread_verifier_->impl_thread_is_overridden_; |
| 208 proxy_->SetCurrentThreadIsImplThread(false); | 210 thread_verifier_->SetCurrentThreadIsImplThread(false); |
| 209 #endif | 211 #endif |
| 210 } | 212 } |
| 211 ~DebugScopedSetMainThread() { | 213 ~DebugScopedSetMainThread() { |
| 212 #if DCHECK_IS_ON() | 214 #if DCHECK_IS_ON() |
| 213 proxy_->SetCurrentThreadIsImplThread(previous_value_); | 215 thread_verifier_->SetCurrentThreadIsImplThread(previous_value_); |
| 214 #endif | 216 #endif |
| 215 } | 217 } |
| 216 | 218 |
| 217 private: | 219 private: |
| 218 bool previous_value_; | 220 bool previous_value_; |
| 219 Proxy* proxy_; | 221 ThreadVerifier* thread_verifier_; |
| 220 | 222 |
| 221 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetMainThread); | 223 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetMainThread); |
| 222 }; | 224 }; |
| 223 | 225 |
| 224 // For use in the single-threaded case. In debug builds, it pretends that the | 226 // For use in the single-threaded case. In debug builds, it pretends that the |
| 225 // code is running on the impl thread and that the main thread is blocked to | 227 // code is running on the impl thread and that the main thread is blocked to |
| 226 // satisfy assertion checks | 228 // satisfy assertion checks |
| 227 class DebugScopedSetImplThreadAndMainThreadBlocked { | 229 class DebugScopedSetImplThreadAndMainThreadBlocked { |
| 228 public: | 230 public: |
| 229 explicit DebugScopedSetImplThreadAndMainThreadBlocked(Proxy* proxy) | 231 explicit DebugScopedSetImplThreadAndMainThreadBlocked( |
| 230 : impl_thread_(proxy), main_thread_blocked_(proxy) {} | 232 ThreadVerifier* thread_verifier) |
| 233 : impl_thread_(thread_verifier), main_thread_blocked_(thread_verifier) {} |
| 231 | 234 |
| 232 private: | 235 private: |
| 233 DebugScopedSetImplThread impl_thread_; | 236 DebugScopedSetImplThread impl_thread_; |
| 234 DebugScopedSetMainThreadBlocked main_thread_blocked_; | 237 DebugScopedSetMainThreadBlocked main_thread_blocked_; |
| 235 | 238 |
| 236 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThreadAndMainThreadBlocked); | 239 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThreadAndMainThreadBlocked); |
| 237 }; | 240 }; |
| 238 | 241 |
| 239 } // namespace cc | 242 } // namespace cc |
| 240 | 243 |
| 241 #endif // CC_TREES_SINGLE_THREAD_PROXY_H_ | 244 #endif // CC_TREES_SINGLE_THREAD_PROXY_H_ |
| OLD | NEW |