summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-26 01:56:19 +0000
committerfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-26 01:56:19 +0000
commit67f92bc3e4a932b3a12693c0517653f08af87a83 (patch)
treea0715e22db3af318f69ceb02abf5c07983b4ac1d /base
parent0f23fd7440d40e701c1dc455f41dc3127f71cb02 (diff)
downloadchromium_src-67f92bc3e4a932b3a12693c0517653f08af87a83.zip
chromium_src-67f92bc3e4a932b3a12693c0517653f08af87a83.tar.gz
chromium_src-67f92bc3e4a932b3a12693c0517653f08af87a83.tar.bz2
Convert all remaining explicit LeakyLazyInstanceTraits users to ::Leaky
and hide LeakyLazyInstanceTraits in base::internal to discourage cargo-culting new users. BUG=none TEST=none Review URL: http://codereview.chromium.org/9117038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119173 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/lazy_instance.h15
-rw-r--r--base/mac/scoped_nsexception_enabler.mm5
-rw-r--r--base/third_party/dmg_fp/dtoa_wrapper.cc10
-rw-r--r--base/threading/platform_thread_mac.mm5
-rw-r--r--base/threading/platform_thread_posix.cc3
-rw-r--r--base/threading/thread_restrictions.cc6
6 files changed, 21 insertions, 23 deletions
diff --git a/base/lazy_instance.h b/base/lazy_instance.h
index 4ed471a..5ddc002 100644
--- a/base/lazy_instance.h
+++ b/base/lazy_instance.h
@@ -73,11 +73,18 @@ struct DefaultLazyInstanceTraits {
}
};
+// We pull out some of the functionality into non-templated functions, so we
+// can implement the more complicated pieces out of line in the .cc file.
+namespace internal {
+
// Use LazyInstance<T>::Leaky for a less-verbose call-site typedef; e.g.:
// base::LazyInstance<T>::Leaky my_leaky_lazy_instance;
// instead of:
-// base::LazyInstance<T, LeakyLazyInstanceTraits<T> > my_leaky_lazy_instance;
+// base::LazyInstance<T, base::internal::LeakyLazyInstanceTraits<T> >
+// my_leaky_lazy_instance;
// (especially when T is MyLongTypeNameImplClientHolderFactory).
+// Only use this internal::-qualified verbose form to extend this traits class
+// (depending on its implementation details).
template <typename Type>
struct LeakyLazyInstanceTraits {
static const bool kRegisterOnExit = false;
@@ -90,10 +97,6 @@ struct LeakyLazyInstanceTraits {
}
};
-// We pull out some of the functionality into non-templated functions, so we
-// can implement the more complicated pieces out of line in the .cc file.
-namespace internal {
-
// Our AtomicWord doubles as a spinlock, where a value of
// kBeingCreatedMarker means the spinlock is being held for creation.
static const subtle::AtomicWord kLazyInstanceStateCreating = 1;
@@ -124,7 +127,7 @@ class LazyInstance {
// Convenience typedef to avoid having to repeat Type for leaky lazy
// instances.
- typedef LazyInstance<Type, LeakyLazyInstanceTraits<Type> > Leaky;
+ typedef LazyInstance<Type, internal::LeakyLazyInstanceTraits<Type> > Leaky;
Type& Get() {
return *Pointer();
diff --git a/base/mac/scoped_nsexception_enabler.mm b/base/mac/scoped_nsexception_enabler.mm
index 52bddb2b..9898789 100644
--- a/base/mac/scoped_nsexception_enabler.mm
+++ b/base/mac/scoped_nsexception_enabler.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,7 +9,6 @@
// To make the |g_exceptionsAllowed| declaration readable.
using base::LazyInstance;
-using base::LeakyLazyInstanceTraits;
using base::ThreadLocalBoolean;
// When C++ exceptions are disabled, the C++ library defines |try| and
@@ -24,7 +23,7 @@ using base::ThreadLocalBoolean;
namespace {
// Whether to allow NSExceptions to be raised on the current thread.
-LazyInstance<ThreadLocalBoolean, LeakyLazyInstanceTraits<ThreadLocalBoolean> >
+LazyInstance<ThreadLocalBoolean>::Leaky
g_exceptionsAllowed = LAZY_INSTANCE_INITIALIZER;
} // namespace
diff --git a/base/third_party/dmg_fp/dtoa_wrapper.cc b/base/third_party/dmg_fp/dtoa_wrapper.cc
index 4599df4..c314c59 100644
--- a/base/third_party/dmg_fp/dtoa_wrapper.cc
+++ b/base/third_party/dmg_fp/dtoa_wrapper.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@@ -10,17 +10,15 @@
// We need two locks because they're sometimes grabbed at the same time.
// A single lock would lead to an attempted recursive grab.
-static base::LazyInstance<base::Lock,
- base::LeakyLazyInstanceTraits<base::Lock> >
+static base::LazyInstance<base::Lock>::Leaky
dtoa_lock_0 = LAZY_INSTANCE_INITIALIZER;
-static base::LazyInstance<base::Lock,
- base::LeakyLazyInstanceTraits<base::Lock> >
+static base::LazyInstance<base::Lock>::Leaky
dtoa_lock_1 = LAZY_INSTANCE_INITIALIZER;
/*
* This define and the code below is to trigger thread-safe behavior
* in dtoa.cc, per this comment from the file:
- *
+ *
* #define MULTIPLE_THREADS if the system offers preemptively scheduled
* multiple threads. In this case, you must provide (or suitably
* #define) two locks, acquired by ACQUIRE_DTOA_LOCK(n) and freed
diff --git a/base/threading/platform_thread_mac.mm b/base/threading/platform_thread_mac.mm
index 422080f..96c6720 100644
--- a/base/threading/platform_thread_mac.mm
+++ b/base/threading/platform_thread_mac.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -19,8 +19,7 @@ namespace base {
namespace {
-LazyInstance<ThreadLocalPointer<char>,
- LeakyLazyInstanceTraits<ThreadLocalPointer<char> > >
+LazyInstance<ThreadLocalPointer<char> >::Leaky
current_thread_name = LAZY_INSTANCE_INITIALIZER;
} // namespace
diff --git a/base/threading/platform_thread_posix.cc b/base/threading/platform_thread_posix.cc
index 27e666a..978b21b 100644
--- a/base/threading/platform_thread_posix.cc
+++ b/base/threading/platform_thread_posix.cc
@@ -40,8 +40,7 @@ namespace {
#if !defined(OS_MACOSX)
// Mac name code is in in platform_thread_mac.mm.
-LazyInstance<ThreadLocalPointer<char>,
- LeakyLazyInstanceTraits<ThreadLocalPointer<char> > >
+LazyInstance<ThreadLocalPointer<char> >::Leaky
current_thread_name = LAZY_INSTANCE_INITIALIZER;
#endif
diff --git a/base/threading/thread_restrictions.cc b/base/threading/thread_restrictions.cc
index 073349c..b093fb4 100644
--- a/base/threading/thread_restrictions.cc
+++ b/base/threading/thread_restrictions.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -15,10 +15,10 @@ namespace base {
namespace {
-LazyInstance<ThreadLocalBoolean, LeakyLazyInstanceTraits<ThreadLocalBoolean> >
+LazyInstance<ThreadLocalBoolean>::Leaky
g_io_disallowed = LAZY_INSTANCE_INITIALIZER;
-LazyInstance<ThreadLocalBoolean, LeakyLazyInstanceTraits<ThreadLocalBoolean> >
+LazyInstance<ThreadLocalBoolean>::Leaky
g_singleton_disallowed = LAZY_INSTANCE_INITIALIZER;
} // anonymous namespace