| Index: base/threading/non_thread_safe.h
|
| diff --git a/base/threading/non_thread_safe.h b/base/threading/non_thread_safe.h
|
| index 868a031e2f6984258e59687daaaa08379f3a1430..68206c3195cf11a5b7e36f14fec5d17bc50ec36e 100644
|
| --- a/base/threading/non_thread_safe.h
|
| +++ b/base/threading/non_thread_safe.h
|
| @@ -10,9 +10,12 @@
|
|
|
| namespace base {
|
|
|
| -// A helper class used to help verify that methods of a class are
|
| -// called from the same thread. One can inherit from this class and use
|
| -// CalledOnValidThread() to verify.
|
| +class NonThreadSafeImpl;
|
| +class NonThreadSafeDoNothing;
|
| +
|
| +// NonThreadSafe is a helper class used to help verify that methods of a
|
| +// class are called from the same thread. One can inherit from this class
|
| +// and use CalledOnValidThread() to verify.
|
| //
|
| // This is intended to be used with classes that appear to be thread safe, but
|
| // aren't. For example, a service or a singleton like the preferences system.
|
| @@ -29,9 +32,20 @@ namespace base {
|
| // In Release mode, CalledOnValidThread will always return true.
|
| //
|
| #ifndef NDEBUG
|
| -class NonThreadSafe {
|
| +typedef NonThreadSafeImpl NonThreadSafe;
|
| +#else
|
| +typedef NonThreadSafeDoNothing NonThreadSafe;
|
| +#endif // NDEBUG
|
| +
|
| +// Full implementation of NonThreadSafe, for debug mode or for occasional
|
| +// temporary use in release mode e.g. when you need to CHECK on a thread
|
| +// bug that only occurs in the wild.
|
| +//
|
| +// Note: You should almost always use the NonThreadSafe typedef to get
|
| +// the right version of the class.
|
| +class NonThreadSafeImpl {
|
| public:
|
| - ~NonThreadSafe();
|
| + ~NonThreadSafeImpl();
|
|
|
| bool CalledOnValidThread() const;
|
|
|
| @@ -44,11 +58,14 @@ class NonThreadSafe {
|
| void DetachFromThread();
|
|
|
| private:
|
| - ThreadChecker thread_checker_;
|
| + ThreadCheckerImpl thread_checker_;
|
| };
|
| -#else
|
| -// Do nothing in release mode.
|
| -class NonThreadSafe {
|
| +
|
| +// Do nothing implementation of NonThreadSafe, for release mode.
|
| +//
|
| +// Note: You should almost always use the NonThreadSafe typedef to get
|
| +// the right version of the class.
|
| +class NonThreadSafeDoNothing {
|
| public:
|
| bool CalledOnValidThread() const {
|
| return true;
|
| @@ -57,7 +74,6 @@ class NonThreadSafe {
|
| protected:
|
| void DetachFromThread() {}
|
| };
|
| -#endif // NDEBUG
|
|
|
| } // namespace base
|
|
|
|
|