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

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: Created 5 years, 8 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.message_loop()->task_runner()->PostTask(
danakj 2015/04/21 20:16:30 dittos
Sami 2015/04/23 17:48:24 Done.
226 FROM_HERE, base::Bind(&BackInTime, &lock));
224 227
225 TimeTicks start = TimeTicks::Now(); 228 TimeTicks start = TimeTicks::Now();
226 const TimeDelta kWaitTime = TimeDelta::FromMilliseconds(300); 229 const TimeDelta kWaitTime = TimeDelta::FromMilliseconds(300);
227 // Allow for clocking rate granularity. 230 // Allow for clocking rate granularity.
228 const TimeDelta kFudgeTime = TimeDelta::FromMilliseconds(50); 231 const TimeDelta kFudgeTime = TimeDelta::FromMilliseconds(50);
229 232
230 cv.TimedWait(kWaitTime + kFudgeTime); 233 cv.TimedWait(kWaitTime + kFudgeTime);
231 TimeDelta duration = TimeTicks::Now() - start; 234 TimeDelta duration = TimeTicks::Now() - start;
232 235
233 thread.Stop(); 236 thread.Stop();
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 base::AutoLock auto_lock(lock_); 757 base::AutoLock auto_lock(lock_);
755 // Send notification that we completed our "work." 758 // Send notification that we completed our "work."
756 WorkIsCompleted(thread_id); 759 WorkIsCompleted(thread_id);
757 } 760 }
758 } 761 }
759 } 762 }
760 763
761 } // namespace 764 } // namespace
762 765
763 } // namespace base 766 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698