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

Unified Diff: base/threading/thread_checker.h

Issue 6599004: Modify ThreadChecker and NonThreadSafe so that their functionality is (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update copyright year for new/moved files Created 9 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/threading/non_thread_safe_unittest.cc ('k') | base/threading/thread_checker_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/thread_checker.h
diff --git a/base/threading/thread_checker.h b/base/threading/thread_checker.h
index 712b5b56f03efeb429dd9231bfc8807a99c0dc32..33b6764e966b269bfceadeba4ad94b8ce4d0bc32 100644
--- a/base/threading/thread_checker.h
+++ b/base/threading/thread_checker.h
@@ -7,22 +7,34 @@
#pragma once
#ifndef NDEBUG
-#include "base/synchronization/lock.h"
-#include "base/threading/platform_thread.h"
-#endif // NDEBUG
+#include "base/threading/thread_checker_impl.h"
+#endif
namespace base {
+// Do nothing implementation, for use in release mode.
+//
+// Note: You should almost always use the ThreadChecker class to get the
+// right version for your build configuration.
+class ThreadCheckerDoNothing {
+ public:
+ bool CalledOnValidThread() const {
+ return true;
+ }
+
+ void DetachFromThread() {}
+};
+
// Before using this class, please consider using NonThreadSafe as it
// makes it much easier to determine the nature of your class.
//
-// A helper class used to help verify that some methods of a class are
-// called from the same thread. One can inherit from this class and use
-// CalledOnValidThread() to verify.
+// ThreadChecker is a helper class used to help verify that some methods of a
+// class are called from the same thread. One can inherit from this class and
+// use CalledOnValidThread() to verify.
//
-// Inheriting from class indicates that one must be careful when using the class
-// with multiple threads. However, it is up to the class document to indicate
-// how it can be used with threads.
+// Inheriting from class indicates that one must be careful when using the
+// class with multiple threads. However, it is up to the class document to
+// indicate how it can be used with threads.
//
// Example:
// class MyClass : public ThreadChecker {
@@ -34,37 +46,11 @@ namespace base {
// }
//
// In Release mode, CalledOnValidThread will always return true.
-//
#ifndef NDEBUG
-class ThreadChecker {
- public:
- ThreadChecker();
- ~ThreadChecker();
-
- bool CalledOnValidThread() const;
-
- // Changes the thread that is checked for in CalledOnValidThread. This may
- // be useful when an object may be created on one thread and then used
- // exclusively on another thread.
- void DetachFromThread();
-
- private:
- void EnsureThreadIdAssigned() const;
-
- mutable base::Lock lock_;
- // This is mutable so that CalledOnValidThread can set it.
- // It's guarded by |lock_|.
- mutable PlatformThreadId valid_thread_id_;
+class ThreadChecker : public ThreadCheckerImpl {
};
#else
-// Do nothing in release mode.
-class ThreadChecker {
- public:
- bool CalledOnValidThread() const {
- return true;
- }
-
- void DetachFromThread() {}
+class ThreadChecker : public ThreadCheckerDoNothing {
};
#endif // NDEBUG
« no previous file with comments | « base/threading/non_thread_safe_unittest.cc ('k') | base/threading/thread_checker_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698