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_NON_THREAD_SAFE_H__ | 5 #ifndef BASE_NON_THREAD_SAFE_H__ |
6 #define BASE_NON_THREAD_SAFE_H__ | 6 #define BASE_NON_THREAD_SAFE_H__ |
7 | 7 |
8 #include "base/logging.h" | |
9 #include "base/platform_thread.h" | 8 #include "base/platform_thread.h" |
10 | 9 |
11 // A helper class used to help verify that methods of a class are | 10 // A helper class used to help verify that methods of a class are |
12 // called from the same thread. One can inherit from this class and use | 11 // called from the same thread. One can inherit from this class and use |
13 // CalledOnValidThread() to verify. | 12 // CalledOnValidThread() to verify. |
14 // | 13 // |
15 // This is intended to be used with classes that appear to be thread safe, but | 14 // This is intended to be used with classes that appear to be thread safe, but |
16 // aren't. For example, a service or a singleton like the preferences system. | 15 // aren't. For example, a service or a singleton like the preferences system. |
17 // | 16 // |
18 // Example: | 17 // Example: |
(...skipping 25 matching lines...) Expand all Loading... |
44 NonThreadSafe() {} | 43 NonThreadSafe() {} |
45 ~NonThreadSafe() {} | 44 ~NonThreadSafe() {} |
46 | 45 |
47 bool CalledOnValidThread() const { | 46 bool CalledOnValidThread() const { |
48 return true; | 47 return true; |
49 } | 48 } |
50 }; | 49 }; |
51 #endif // NDEBUG | 50 #endif // NDEBUG |
52 | 51 |
53 #endif // BASE_NON_THREAD_SAFE_H__ | 52 #endif // BASE_NON_THREAD_SAFE_H__ |
OLD | NEW |