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

Side by Side Diff: base/lock_impl.h

Issue 42402: Test was examining a variable without first acquiring a required Lock.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « base/lock.h ('k') | base/lock_impl_win.cc » ('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 (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 29 matching lines...) Expand all
40 // Release the lock. This must only be called by the lock's holder: after 40 // Release the lock. This must only be called by the lock's holder: after
41 // a successful call to Try, or a call to Lock. 41 // a successful call to Try, or a call to Lock.
42 void Unlock(); 42 void Unlock();
43 43
44 // Debug-only method that will DCHECK() if the lock is not acquired by the 44 // Debug-only method that will DCHECK() if the lock is not acquired by the
45 // current thread. In non-debug builds, no check is performed. 45 // current thread. In non-debug builds, no check is performed.
46 // Because linux and mac condition variables modify the underlyning lock 46 // Because linux and mac condition variables modify the underlyning lock
47 // through the os_lock() method, runtime assertions can not be done on those 47 // through the os_lock() method, runtime assertions can not be done on those
48 // builds. 48 // builds.
49 #if defined(NDEBUG) || !defined(OS_WIN) 49 #if defined(NDEBUG) || !defined(OS_WIN)
50 void AssertAcquired() {} 50 void AssertAcquired() const {}
51 #else 51 #else
52 void AssertAcquired(); 52 void AssertAcquired() const;
53 #endif 53 #endif
54 54
55 // Return the native underlying lock. Not supported for Windows builds. 55 // Return the native underlying lock. Not supported for Windows builds.
56 // TODO(awalker): refactor lock and condition variables so that this is 56 // TODO(awalker): refactor lock and condition variables so that this is
57 // unnecessary. 57 // unnecessary.
58 #if !defined(OS_WIN) 58 #if !defined(OS_WIN)
59 OSLockType* os_lock() { return &os_lock_; } 59 OSLockType* os_lock() { return &os_lock_; }
60 #endif 60 #endif
61 61
62 private: 62 private:
63 OSLockType os_lock_; 63 OSLockType os_lock_;
64 64
65 #if !defined(NDEBUG) && defined(OS_WIN) 65 #if !defined(NDEBUG) && defined(OS_WIN)
66 // All private data is implicitly protected by lock_. 66 // All private data is implicitly protected by lock_.
67 // Be VERY careful to only access members under that lock. 67 // Be VERY careful to only access members under that lock.
68 PlatformThreadId owning_thread_id_; 68 PlatformThreadId owning_thread_id_;
69 int32 recursion_count_shadow_; 69 int32 recursion_count_shadow_;
70 bool recursion_used_; // Allow debugging to continued after a DCHECK(). 70 bool recursion_used_; // Allow debugging to continued after a DCHECK().
71 #endif // NDEBUG 71 #endif // NDEBUG
72 72
73 DISALLOW_COPY_AND_ASSIGN(LockImpl); 73 DISALLOW_COPY_AND_ASSIGN(LockImpl);
74 }; 74 };
75 75
76 76
77 #endif // BASE_LOCK_IMPL_H_ 77 #endif // BASE_LOCK_IMPL_H_
OLDNEW
« no previous file with comments | « base/lock.h ('k') | base/lock_impl_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698