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

Unified Diff: base/lazy_instance_unittest.cc

Issue 2733283002: Require explicit selection of traits for LazyInstance (Closed)
Patch Set: l10n again Created 3 years, 9 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/lazy_instance.h ('k') | base/metrics/statistics_recorder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/lazy_instance_unittest.cc
diff --git a/base/lazy_instance_unittest.cc b/base/lazy_instance_unittest.cc
index 8947b1291f60d54112fba0f13c72c86c9b29961a..0aa46594657be33c5abba5ccc2c9232311097f5f 100644
--- a/base/lazy_instance_unittest.cc
+++ b/base/lazy_instance_unittest.cc
@@ -45,7 +45,8 @@ int SlowConstructor::constructed = 0;
class SlowDelegate : public base::DelegateSimpleThread::Delegate {
public:
- explicit SlowDelegate(base::LazyInstance<SlowConstructor>* lazy)
+ explicit SlowDelegate(
+ base::LazyInstance<SlowConstructor>::DestructorAtExit* lazy)
: lazy_(lazy) {}
void Run() override {
@@ -54,13 +55,13 @@ class SlowDelegate : public base::DelegateSimpleThread::Delegate {
}
private:
- base::LazyInstance<SlowConstructor>* lazy_;
+ base::LazyInstance<SlowConstructor>::DestructorAtExit* lazy_;
};
} // namespace
-static base::LazyInstance<ConstructAndDestructLogger> lazy_logger =
- LAZY_INSTANCE_INITIALIZER;
+static base::LazyInstance<ConstructAndDestructLogger>::DestructorAtExit
+ lazy_logger = LAZY_INSTANCE_INITIALIZER;
TEST(LazyInstanceTest, Basic) {
{
@@ -81,7 +82,7 @@ TEST(LazyInstanceTest, Basic) {
EXPECT_EQ(4, destructed_seq_.GetNext());
}
-static base::LazyInstance<SlowConstructor> lazy_slow =
+static base::LazyInstance<SlowConstructor>::DestructorAtExit lazy_slow =
LAZY_INSTANCE_INITIALIZER;
TEST(LazyInstanceTest, ConstructorThreadSafety) {
@@ -126,7 +127,8 @@ TEST(LazyInstanceTest, LeakyLazyInstance) {
bool deleted1 = false;
{
base::ShadowingAtExitManager shadow;
- static base::LazyInstance<DeleteLogger> test = LAZY_INSTANCE_INITIALIZER;
+ static base::LazyInstance<DeleteLogger>::DestructorAtExit test =
+ LAZY_INSTANCE_INITIALIZER;
test.Get().SetDeletedPtr(&deleted1);
}
EXPECT_TRUE(deleted1);
@@ -164,9 +166,12 @@ TEST(LazyInstanceTest, Alignment) {
// Create some static instances with increasing sizes and alignment
// requirements. By ordering this way, the linker will need to do some work to
// ensure proper alignment of the static data.
- static LazyInstance<AlignedData<4> > align4 = LAZY_INSTANCE_INITIALIZER;
- static LazyInstance<AlignedData<32> > align32 = LAZY_INSTANCE_INITIALIZER;
- static LazyInstance<AlignedData<4096> > align4096 = LAZY_INSTANCE_INITIALIZER;
+ static LazyInstance<AlignedData<4>>::DestructorAtExit align4 =
+ LAZY_INSTANCE_INITIALIZER;
+ static LazyInstance<AlignedData<32>>::DestructorAtExit align32 =
+ LAZY_INSTANCE_INITIALIZER;
+ static LazyInstance<AlignedData<4096>>::DestructorAtExit align4096 =
+ LAZY_INSTANCE_INITIALIZER;
EXPECT_ALIGNED(align4.Pointer(), 4);
EXPECT_ALIGNED(align32.Pointer(), 32);
« no previous file with comments | « base/lazy_instance.h ('k') | base/metrics/statistics_recorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698