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

Side by Side Diff: base/lazy_instance_unittest.cc

Issue 9055001: Change code in base (primarily unit tests) to use Sleep(TimeDelta). (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Qualify windows Sleep calls to go through PlatformThread. Created 8 years, 11 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 unified diff | Download patch
« no previous file with comments | « base/file_util_unittest.cc ('k') | base/message_loop_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/at_exit.h" 5 #include "base/at_exit.h"
6 #include "base/atomic_sequence_num.h" 6 #include "base/atomic_sequence_num.h"
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/threading/simple_thread.h" 8 #include "base/threading/simple_thread.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace { 11 namespace {
12 12
13 base::AtomicSequenceNumber constructed_seq_(base::LINKER_INITIALIZED); 13 base::AtomicSequenceNumber constructed_seq_(base::LINKER_INITIALIZED);
14 base::AtomicSequenceNumber destructed_seq_(base::LINKER_INITIALIZED); 14 base::AtomicSequenceNumber destructed_seq_(base::LINKER_INITIALIZED);
15 15
16 class ConstructAndDestructLogger { 16 class ConstructAndDestructLogger {
17 public: 17 public:
18 ConstructAndDestructLogger() { 18 ConstructAndDestructLogger() {
19 constructed_seq_.GetNext(); 19 constructed_seq_.GetNext();
20 } 20 }
21 ~ConstructAndDestructLogger() { 21 ~ConstructAndDestructLogger() {
22 destructed_seq_.GetNext(); 22 destructed_seq_.GetNext();
23 } 23 }
24 }; 24 };
25 25
26 class SlowConstructor { 26 class SlowConstructor {
27 public: 27 public:
28 SlowConstructor() : some_int_(0) { 28 SlowConstructor() : some_int_(0) {
29 // Sleep for 1 second to try to cause a race. 29 // Sleep for 1 second to try to cause a race.
30 base::PlatformThread::Sleep(1000); 30 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1));
31 ++constructed; 31 ++constructed;
32 some_int_ = 12; 32 some_int_ = 12;
33 } 33 }
34 int some_int() const { return some_int_; } 34 int some_int() const { return some_int_; }
35 35
36 static int constructed; 36 static int constructed;
37 private: 37 private:
38 int some_int_; 38 int some_int_;
39 }; 39 };
40 40
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 bool deleted2 = false; 133 bool deleted2 = false;
134 { 134 {
135 base::ShadowingAtExitManager shadow; 135 base::ShadowingAtExitManager shadow;
136 static base::LazyInstance<DeleteLogger, 136 static base::LazyInstance<DeleteLogger,
137 base::LeakyLazyInstanceTraits<DeleteLogger> > 137 base::LeakyLazyInstanceTraits<DeleteLogger> >
138 test = LAZY_INSTANCE_INITIALIZER; 138 test = LAZY_INSTANCE_INITIALIZER;
139 test.Get().SetDeletedPtr(&deleted2); 139 test.Get().SetDeletedPtr(&deleted2);
140 } 140 }
141 EXPECT_FALSE(deleted2); 141 EXPECT_FALSE(deleted2);
142 } 142 }
OLDNEW
« no previous file with comments | « base/file_util_unittest.cc ('k') | base/message_loop_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698