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

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: Fix ODR violation 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 | base/threading/non_thread_safe_unittest.cc » ('j') | 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 be3026909a8d68d85980715283f037b599668a1e..a104ae3d298391e68fdc9a80d6801a2e71d87177 100644
--- a/base/threading/non_thread_safe.h
+++ b/base/threading/non_thread_safe.h
@@ -6,13 +6,20 @@
#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
+// See comment at top of thread_checker.h
+#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
@@ -54,13 +61,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
-typedef NonThreadSafeImpl NonThreadSafe;
+#if ENABLE_NON_THREAD_SAFE
+class NonThreadSafe : public NonThreadSafeImpl {
+};
#else
-typedef NonThreadSafeDoNothing NonThreadSafe;
-#endif // NDEBUG
+class NonThreadSafe : public NonThreadSafeDoNothing {
+};
+#endif // ENABLE_NON_THREAD_SAFE
+
+#undef ENABLE_NON_THREAD_SAFE
} // namespace base
« no previous file with comments | « no previous file | base/threading/non_thread_safe_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698