summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-06 01:11:54 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-06 01:11:54 +0000
commit5a8a8063c387f18f9f090d31cf385d65b048254b (patch)
tree77c00436b58f770922074f9dfe3e637dd7c0ab3c
parent7001d5cc79cbe7f1faacacd5748431f3d7a859c6 (diff)
downloadchromium_src-5a8a8063c387f18f9f090d31cf385d65b048254b.zip
chromium_src-5a8a8063c387f18f9f090d31cf385d65b048254b.tar.gz
chromium_src-5a8a8063c387f18f9f090d31cf385d65b048254b.tar.bz2
Make kAllowedToAccessOnNonjoinableThread debug-only.
This is only used in !NDEBUG builds, and making the variable only available there makes it harder to break -Wunused-const-variable builds with custom traits. Follow-up to r255159. BUG=349521,307668 R=fischman@chromium.org Review URL: https://codereview.chromium.org/187903007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255194 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/android/build_info.cc2
-rw-r--r--base/lazy_instance.h4
-rw-r--r--base/memory/singleton.h4
3 files changed, 10 insertions, 0 deletions
diff --git a/base/android/build_info.cc b/base/android/build_info.cc
index 9f7361d..a1755af 100644
--- a/base/android/build_info.cc
+++ b/base/android/build_info.cc
@@ -37,7 +37,9 @@ struct BuildInfoSingletonTraits {
}
static const bool kRegisterAtExit = false;
+#ifndef NDEBUG
static const bool kAllowedToAccessOnNonjoinableThread = true;
+#endif
};
BuildInfo::BuildInfo(JNIEnv* env)
diff --git a/base/lazy_instance.h b/base/lazy_instance.h
index 3935780..05a7c5d 100644
--- a/base/lazy_instance.h
+++ b/base/lazy_instance.h
@@ -57,7 +57,9 @@ namespace base {
template <typename Type>
struct DefaultLazyInstanceTraits {
static const bool kRegisterOnExit = true;
+#ifndef NDEBUG
static const bool kAllowedToAccessOnNonjoinableThread = false;
+#endif
static Type* New(void* instance) {
DCHECK_EQ(reinterpret_cast<uintptr_t>(instance) & (ALIGNOF(Type) - 1), 0u)
@@ -89,7 +91,9 @@ namespace internal {
template <typename Type>
struct LeakyLazyInstanceTraits {
static const bool kRegisterOnExit = false;
+#ifndef NDEBUG
static const bool kAllowedToAccessOnNonjoinableThread = true;
+#endif
static Type* New(void* instance) {
ANNOTATE_SCOPED_MEMORY_LEAK;
diff --git a/base/memory/singleton.h b/base/memory/singleton.h
index 0d4fc89..355aad0 100644
--- a/base/memory/singleton.h
+++ b/base/memory/singleton.h
@@ -63,10 +63,12 @@ struct DefaultSingletonTraits {
// exit. See below for the required call that makes this happen.
static const bool kRegisterAtExit = true;
+#ifndef NDEBUG
// Set to false to disallow access on a non-joinable thread. This is
// different from kRegisterAtExit because StaticMemorySingletonTraits allows
// access on non-joinable threads, and gracefully handles this.
static const bool kAllowedToAccessOnNonjoinableThread = false;
+#endif
};
@@ -76,7 +78,9 @@ struct DefaultSingletonTraits {
template<typename Type>
struct LeakySingletonTraits : public DefaultSingletonTraits<Type> {
static const bool kRegisterAtExit = false;
+#ifndef NDEBUG
static const bool kAllowedToAccessOnNonjoinableThread = true;
+#endif
};