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

Side by Side Diff: base/test/ios/wait_util.mm

Issue 2132593002: Remove remaining calls to deprecated MessageLoop methods on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR gab Created 4 years, 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #import "base/test/ios/wait_util.h" 5 #import "base/test/ios/wait_util.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/scoped_nsobject.h" 10 #include "base/mac/scoped_nsobject.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/run_loop.h"
12 #include "base/test/test_timeouts.h" 12 #include "base/test/test_timeouts.h"
13 #include "base/timer/elapsed_timer.h" 13 #include "base/timer/elapsed_timer.h"
14 14
15 namespace base { 15 namespace base {
16 namespace test { 16 namespace test {
17 namespace ios { 17 namespace ios {
18 18
19 TimeDelta TimeUntilCondition(ProceduralBlock action, 19 TimeDelta TimeUntilCondition(ProceduralBlock action,
20 ConditionBlock condition, 20 ConditionBlock condition,
21 MessageLoop* message_loop, 21 MessageLoop* message_loop,
sdefresne 2016/07/12 08:58:29 nit: can you change "message_loop" to a bool and r
fdoray 2016/07/18 20:44:02 I removed changes to this file from this CL. Will
22 TimeDelta timeout) { 22 TimeDelta timeout) {
23 ElapsedTimer timer; 23 ElapsedTimer timer;
24 if (action) 24 if (action)
25 action(); 25 action();
26 if (timeout.is_zero()) 26 if (timeout.is_zero())
27 timeout = TestTimeouts::action_timeout(); 27 timeout = TestTimeouts::action_timeout();
28 const TimeDelta spin_delay(TimeDelta::FromMilliseconds(10)); 28 const TimeDelta spin_delay(TimeDelta::FromMilliseconds(10));
29 while (timer.Elapsed() < timeout && (!condition || !condition())) { 29 while (timer.Elapsed() < timeout && (!condition || !condition())) {
30 SpinRunLoopWithMaxDelay(spin_delay); 30 SpinRunLoopWithMaxDelay(spin_delay);
31 if (message_loop) { 31 if (message_loop) {
32 message_loop->RunUntilIdle(); 32 RunLoop().RunUntilIdle();
33 } 33 }
34 } 34 }
35 TimeDelta elapsed = timer.Elapsed(); 35 TimeDelta elapsed = timer.Elapsed();
36 // If DCHECK is ever hit, check if |action| is doing something that is 36 // If DCHECK is ever hit, check if |action| is doing something that is
37 // taking an unreasonably long time, or if |condition| does not come 37 // taking an unreasonably long time, or if |condition| does not come
38 // true quickly enough. Increase |timeout| only if necessary. 38 // true quickly enough. Increase |timeout| only if necessary.
39 DCHECK(!condition || condition()); 39 DCHECK(!condition || condition());
40 return elapsed; 40 return elapsed;
41 } 41 }
42 42
(...skipping 10 matching lines...) Expand all
53 void SpinRunLoopWithMaxDelay(TimeDelta max_delay) { 53 void SpinRunLoopWithMaxDelay(TimeDelta max_delay) {
54 scoped_nsobject<NSDate> beforeDate( 54 scoped_nsobject<NSDate> beforeDate(
55 [[NSDate alloc] initWithTimeIntervalSinceNow:max_delay.InSecondsF()]); 55 [[NSDate alloc] initWithTimeIntervalSinceNow:max_delay.InSecondsF()]);
56 [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode 56 [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
57 beforeDate:beforeDate]; 57 beforeDate:beforeDate];
58 } 58 }
59 59
60 } // namespace ios 60 } // namespace ios
61 } // namespace test 61 } // namespace test
62 } // namespace base 62 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop/message_pump_glib_unittest.cc ('k') | chrome/app_shim/chrome_main_app_mode_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698