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

Side by Side Diff: base/synchronization/condition_variable_unittest.cc

Issue 1100773004: base: Remove most uses of MessageLoopProxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added some missing includes. Created 5 years, 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Multi-threaded tests of ConditionVariable class. 5 // Multi-threaded tests of ConditionVariable class.
6 6
7 #include <time.h> 7 #include <time.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/location.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/single_thread_task_runner.h"
14 #include "base/synchronization/condition_variable.h" 16 #include "base/synchronization/condition_variable.h"
15 #include "base/synchronization/lock.h" 17 #include "base/synchronization/lock.h"
16 #include "base/synchronization/spin_wait.h" 18 #include "base/synchronization/spin_wait.h"
17 #include "base/threading/platform_thread.h" 19 #include "base/threading/platform_thread.h"
18 #include "base/threading/thread.h" 20 #include "base/threading/thread.h"
19 #include "base/threading/thread_collision_warner.h" 21 #include "base/threading/thread_collision_warner.h"
20 #include "base/time/time.h" 22 #include "base/time/time.h"
21 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
22 #include "testing/platform_test.h" 24 #include "testing/platform_test.h"
23 25
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 PLOG(ERROR) << "Could not set time of day. Run as root?"; 215 PLOG(ERROR) << "Could not set time of day. Run as root?";
214 return; 216 return;
215 } 217 }
216 218
217 Lock lock; 219 Lock lock;
218 ConditionVariable cv(&lock); 220 ConditionVariable cv(&lock);
219 lock.Acquire(); 221 lock.Acquire();
220 222
221 Thread thread("Helper"); 223 Thread thread("Helper");
222 thread.Start(); 224 thread.Start();
223 thread.message_loop()->PostTask(FROM_HERE, base::Bind(&BackInTime, &lock)); 225 thread.task_runner()->PostTask(FROM_HERE, base::Bind(&BackInTime, &lock));
224 226
225 TimeTicks start = TimeTicks::Now(); 227 TimeTicks start = TimeTicks::Now();
226 const TimeDelta kWaitTime = TimeDelta::FromMilliseconds(300); 228 const TimeDelta kWaitTime = TimeDelta::FromMilliseconds(300);
227 // Allow for clocking rate granularity. 229 // Allow for clocking rate granularity.
228 const TimeDelta kFudgeTime = TimeDelta::FromMilliseconds(50); 230 const TimeDelta kFudgeTime = TimeDelta::FromMilliseconds(50);
229 231
230 cv.TimedWait(kWaitTime + kFudgeTime); 232 cv.TimedWait(kWaitTime + kFudgeTime);
231 TimeDelta duration = TimeTicks::Now() - start; 233 TimeDelta duration = TimeTicks::Now() - start;
232 234
233 thread.Stop(); 235 thread.Stop();
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 base::AutoLock auto_lock(lock_); 756 base::AutoLock auto_lock(lock_);
755 // Send notification that we completed our "work." 757 // Send notification that we completed our "work."
756 WorkIsCompleted(thread_id); 758 WorkIsCompleted(thread_id);
757 } 759 }
758 } 760 }
759 } 761 }
760 762
761 } // namespace 763 } // namespace
762 764
763 } // namespace base 765 } // namespace base
OLDNEW
« no previous file with comments | « base/synchronization/cancellation_flag_unittest.cc ('k') | base/synchronization/waitable_event_watcher_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698