| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 BASE_LOCK_IMPL_H_ | 5 #ifndef BASE_LOCK_IMPL_H_ |
| 6 #define BASE_LOCK_IMPL_H_ | 6 #define BASE_LOCK_IMPL_H_ |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 void Unlock(); | 41 void Unlock(); |
| 42 | 42 |
| 43 // Return the native underlying lock. | 43 // Return the native underlying lock. |
| 44 // TODO(awalker): refactor lock and condition variables so that this is | 44 // TODO(awalker): refactor lock and condition variables so that this is |
| 45 // unnecessary. | 45 // unnecessary. |
| 46 OSLockType* os_lock() { return &os_lock_; } | 46 OSLockType* os_lock() { return &os_lock_; } |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 OSLockType os_lock_; | 49 OSLockType os_lock_; |
| 50 | 50 |
| 51 #if !defined(NDEBUG) && defined(OS_WIN) |
| 52 // All private data is implicitly protected by lock_. |
| 53 // Be VERY careful to only access members under that lock. |
| 54 int32 recursion_count_shadow_; |
| 55 bool recursion_used_; // Allow debugging to continued after a DCHECK(). |
| 56 #endif // NDEBUG |
| 57 |
| 51 DISALLOW_COPY_AND_ASSIGN(LockImpl); | 58 DISALLOW_COPY_AND_ASSIGN(LockImpl); |
| 52 }; | 59 }; |
| 53 | 60 |
| 54 class AutoLockImpl { | 61 class AutoLockImpl { |
| 55 public: | 62 public: |
| 56 AutoLockImpl(LockImpl* lock_impl) | 63 AutoLockImpl(LockImpl* lock_impl) |
| 57 : lock_impl_(lock_impl) { | 64 : lock_impl_(lock_impl) { |
| 58 lock_impl_->Lock(); | 65 lock_impl_->Lock(); |
| 59 } | 66 } |
| 60 | 67 |
| 61 ~AutoLockImpl() { | 68 ~AutoLockImpl() { |
| 62 lock_impl_->Unlock(); | 69 lock_impl_->Unlock(); |
| 63 } | 70 } |
| 64 | 71 |
| 65 private: | 72 private: |
| 66 DISALLOW_EVIL_CONSTRUCTORS(AutoLockImpl); | 73 DISALLOW_EVIL_CONSTRUCTORS(AutoLockImpl); |
| 67 | 74 |
| 68 LockImpl* lock_impl_; | 75 LockImpl* lock_impl_; |
| 69 }; | 76 }; |
| 70 | 77 |
| 71 #endif // BASE_LOCK_IMPL_H_ | 78 #endif // BASE_LOCK_IMPL_H_ |
| 72 | 79 |
| OLD | NEW |