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