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

Unified Diff: base/threading/non_thread_safe.h

Issue 10636044: Enable base::NonThreadSafe when DCHECK_ALWAYS_ON is set (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add back IWYU violation, address separately Created 8 years, 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/non_thread_safe.h
diff --git a/base/threading/non_thread_safe.h b/base/threading/non_thread_safe.h
index da7b52815c0aba06d4d4a12001bfa22aa6e11783..de78dfcecbe53417517983183572b51423c791a0 100644
--- a/base/threading/non_thread_safe.h
+++ b/base/threading/non_thread_safe.h
@@ -6,13 +6,28 @@
#define BASE_THREADING_NON_THREAD_SAFE_H_
#pragma once
-// Classes deriving from NonThreadSafe may need to supress MSVC warning 4275:
+// Classes deriving from NonThreadSafe may need to suppress MSVC warning 4275:
// non dll-interface class 'Bar' used as base for dll-interface class 'Foo'.
// There is a specific macro to do it: NON_EXPORTED_BASE(), defined in
// compiler_specific.h
#include "base/compiler_specific.h"
-#ifndef NDEBUG
+// Apart from debug builds, we also enable the NonThreadSafe checks in
+// builds with DCHECK_ALWAYS_ON so that trybots and waterfall bots
+// with this define will get the same level of thread checking as
+// debug bots.
+//
+// Note that this does not perfectly match situations where DCHECK is
+// enabled. For example a non-official release build may have
+// DCHECK_ALWAYS_ON undefined (and therefore NonThreadSafe would be
+// disabled) but have DCHECKs enabled at runtime.
jam 2012/06/26 01:56:30 nit: instead of copying the comment, I would just
+#if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
+#define ENABLE_NON_THREAD_SAFE 1
+#else
+#define ENABLE_NON_THREAD_SAFE 0
+#endif
+
+#if ENABLE_NON_THREAD_SAFE
#include "base/threading/non_thread_safe_impl.h"
#endif
@@ -53,15 +68,15 @@ class NonThreadSafeDoNothing {
// to have a base::ThreadChecker as a member, rather than inherit from
// NonThreadSafe. For more details about when to choose one over the other, see
// the documentation for base::ThreadChecker.
-//
-// In Release mode, CalledOnValidThread will always return true.
-#ifndef NDEBUG
+#if ENABLE_NON_THREAD_SAFE
class NonThreadSafe : public NonThreadSafeImpl {
};
#else
class NonThreadSafe : public NonThreadSafeDoNothing {
};
-#endif // NDEBUG
+#endif // ENABLE_NON_THREAD_SAFE
+
+#undef ENABLE_NON_THREAD_SAFE
} // namespace base
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698