OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #ifndef IOS_CHROME_APP_DEFERRED_INITIALIZATION_RUNNER_H_ | 5 #ifndef IOS_CHROME_APP_DEFERRED_INITIALIZATION_RUNNER_H_ |
6 #define IOS_CHROME_APP_DEFERRED_INITIALIZATION_RUNNER_H_ | 6 #define IOS_CHROME_APP_DEFERRED_INITIALIZATION_RUNNER_H_ |
7 | 7 |
8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
9 | 9 |
10 #include "base/ios/block_types.h" | 10 #include "base/ios/block_types.h" |
11 | 11 |
12 // A singleton object to run initialization code asynchronously. Blocks are | 12 // A singleton object to run initialization code asynchronously. Blocks are |
13 // scheduled to be run after a delay. The block is named when added to the | 13 // scheduled to be run after a delay. The block is named when added to the |
14 // singleton so that other code can force a deferred block to be run | 14 // singleton so that other code can force a deferred block to be run |
15 // synchronously if necessary. | 15 // synchronously if necessary. |
16 @interface DeferredInitializationRunner : NSObject | 16 @interface DeferredInitializationRunner : NSObject |
17 | 17 |
18 // Returns singleton instance. | 18 // Returns singleton instance. |
19 + (DeferredInitializationRunner*)sharedInstance; | 19 + (DeferredInitializationRunner*)sharedInstance; |
20 | 20 |
21 // Deprecated. | |
21 // Schedules |block| to be run after |delaySeconds| on the current queue. | 22 // Schedules |block| to be run after |delaySeconds| on the current queue. |
22 // This |block| is stored as |name| so code can force this initialization to | 23 // This |block| is stored as |name| so code can force this initialization to |
23 // be run synchronously if necessary. This method may be called more than | 24 // be run synchronously if necessary. This method may be called more than |
24 // once with the same |name| parameter. Any block with the same |name| | 25 // once with the same |name| parameter. Any block with the same |name| |
25 // cancels a previously scheduled block of the same |name| if the block has | 26 // cancels a previously scheduled block of the same |name| if the block has |
26 // not been run yet. | 27 // not been run yet. |
27 - (void)runBlockNamed:(NSString*)name | 28 - (void)runBlockNamed:(NSString*)name |
28 after:(NSTimeInterval)delaySeconds | 29 after:(NSTimeInterval)delaySeconds |
29 block:(ProceduralBlock)block; | 30 block:(ProceduralBlock)block; |
30 | 31 |
32 // Adds |block| to a block queue containing all block not run. All blocks in the | |
33 // queue are run sequentially with a small delay between each block. | |
34 // If the queue is empty |block| is run after a small delay. | |
35 // This |block| is stored as |name| so code can force this initialization to | |
36 // be run synchronously if necessary. This method may be called more than | |
37 // once with the same |name| parameter. Any block with the same |name| | |
38 // cancels a previously scheduled block of the same |name| if the block has | |
39 // not been run yet. | |
40 - (void)enqueueBlockNamed:(NSString*)name block:(ProceduralBlock)block; | |
41 | |
31 // Looks up a previously scheduled block of |name|. If block has not been | 42 // Looks up a previously scheduled block of |name|. If block has not been |
32 // run yet, run it synchronously now. | 43 // run yet, run it synchronously now. |
33 - (void)runBlockIfNecessary:(NSString*)name; | 44 - (void)runBlockIfNecessary:(NSString*)name; |
34 | 45 |
35 // Cancels a previously scheduled block of |name|. This is a no-op if the | 46 // Cancels a previously scheduled block of |name|. This is a no-op if the |
36 // block has already been executed. | 47 // block has already been executed. |
37 - (void)cancelBlockNamed:(NSString*)name; | 48 - (void)cancelBlockNamed:(NSString*)name; |
38 | 49 |
39 // Number of blocks that have been registered but not executed yet. | 50 // Number of blocks that have been registered but not executed yet. |
40 // Exposed for testing. | 51 // Exposed for testing. |
41 @property(nonatomic, readonly) NSUInteger numberOfBlocksRemaining; | 52 @property(nonatomic, readonly) NSUInteger numberOfBlocksRemaining; |
42 | 53 |
54 // Time interval between two blocks. Default value is 200ms. | |
55 @property(nonatomic) NSTimeInterval delayBetweenBlocks; | |
56 | |
57 // Time interval before running the first block. Default value is 3s. | |
58 @property(nonatomic) NSTimeInterval delayBeforeFirstBlocks; | |
pkl (ping after 24h if needed)
2016/08/19 23:48:20
Shouldn't this be singular, i.e. delayBeforeFirstB
gambard
2016/09/13 09:59:03
You are right. This makes little sense as public A
| |
59 | |
43 @end | 60 @end |
44 | 61 |
45 #endif // IOS_CHROME_APP_DEFERRED_INITIALIZATION_RUNNER_H_ | 62 #endif // IOS_CHROME_APP_DEFERRED_INITIALIZATION_RUNNER_H_ |
OLD | NEW |