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

Unified Diff: ios/chrome/app/deferred_initialization_runner.h

Issue 2217083002: Add sequential dispatching for InitializationRunner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/BUILD.gn ('k') | ios/chrome/app/deferred_initialization_runner.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/app/deferred_initialization_runner.h
diff --git a/ios/chrome/app/deferred_initialization_runner.h b/ios/chrome/app/deferred_initialization_runner.h
index e1bd59ce5e9006bb2fed80ffb1fd0202fc852000..336fa03be801201ac8697c71f5e4d501c6b2170a 100644
--- a/ios/chrome/app/deferred_initialization_runner.h
+++ b/ios/chrome/app/deferred_initialization_runner.h
@@ -18,6 +18,7 @@
// Returns singleton instance.
+ (DeferredInitializationRunner*)sharedInstance;
+// Deprecated, use |enqueueBlockNamed:block:| instead.
// Schedules |block| to be run after |delaySeconds| on the current queue.
// This |block| is stored as |name| so code can force this initialization to
// be run synchronously if necessary. This method may be called more than
@@ -28,6 +29,12 @@
after:(NSTimeInterval)delaySeconds
block:(ProceduralBlock)block;
+// Stores |block| under |name| to a queue of blocks to run. All blocks are run
+// sequentially with a small delay before the first block and between each
+// successive block. If a block is already registered under |name|, it is
+// replaced with |block| unless it has already been run.
+- (void)enqueueBlockNamed:(NSString*)name block:(ProceduralBlock)block;
+
// Looks up a previously scheduled block of |name|. If block has not been
// run yet, run it synchronously now.
- (void)runBlockIfNecessary:(NSString*)name;
@@ -42,4 +49,15 @@
@end
+@interface DeferredInitializationRunner (ExposedForTesting)
+
+// Time interval between two blocks. Default value is 200ms.
+@property(nonatomic, assign) NSTimeInterval delayBetweenBlocks;
+
+// Time interval before running the first block. To override default value of
+// 3s, set this property before the first call to |-enqueueBlockNamed:block:|.
+@property(nonatomic, assign) NSTimeInterval delayBeforeFirstBlock;
+
+@end
+
#endif // IOS_CHROME_APP_DEFERRED_INITIALIZATION_RUNNER_H_
« no previous file with comments | « ios/chrome/BUILD.gn ('k') | ios/chrome/app/deferred_initialization_runner.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698