OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
Paweł Hajdan Jr.
2015/01/30 12:24:29
nit: 2015
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef BASE_TEST_IOS_WAIT_UTIL_H_ | |
6 #define BASE_TEST_IOS_WAIT_UTIL_H_ | |
7 | |
8 #import <Foundation/Foundation.h> | |
9 | |
10 #include "base/ios/block_types.h" | |
11 #include "base/time/time.h" | |
12 | |
13 namespace base { | |
14 | |
15 class MessageLoop; | |
16 | |
17 // Returns the time spent in running |action| plus waiting until |condition| is | |
18 // met. | |
19 // Performs |action| and then spins run loop and runs the |message_loop| until | |
20 // |condition| block returns true. | |
21 // |action| may be nil if no action needs to be performed before the wait loop. | |
22 // |message_loop| can be null if there is no need to spin the message loop. | |
23 // |condition| may be nil if there is no condition to wait for: the run loop | |
24 // will spin until timeout is reached. | |
25 // |timeout| parameter sets the maximum wait time. If |timeout| is not provided, | |
26 // a reasonable default will be used. | |
27 TimeDelta TimeUntilCondition(ProceduralBlock action, | |
28 ConditionBlock condition, | |
29 MessageLoop* message_loop, | |
30 TimeDelta timeout); | |
31 TimeDelta TimeUntilCondition(ProceduralBlock action, ConditionBlock condition); | |
32 | |
33 // Waits until |condition| is met. A |message_loop| to spin and a |timeout| can | |
34 // be optionnally passed. | |
35 void WaitUntilCondition(ConditionBlock condition, | |
36 MessageLoop* message_loop, | |
37 TimeDelta timeout); | |
38 void WaitUntilCondition(ConditionBlock condition, MessageLoop* message_loop); | |
39 void WaitUntilCondition(ConditionBlock condition); | |
40 | |
41 // Spins the run loop for |timeout|. | |
42 void Wait(TimeDelta timeout); | |
43 | |
44 // Lets the run loop of the current thread process other messages | |
45 // within the given maximum delay. | |
46 void SpinRunLoopWithMaxDelay(TimeDelta max_delay); | |
47 | |
48 } // namespace base | |
49 | |
50 #endif // BASE_TEST_IOS_WAIT_UTIL_H_ | |
OLD | NEW |