Chromium Code Reviews| Index: ios/chrome/app/deferred_initialization_runner.mm |
| diff --git a/ios/chrome/app/deferred_initialization_runner.mm b/ios/chrome/app/deferred_initialization_runner.mm |
| index 7e175b4c47d604cae0d502d959e5e4f3231a851b..6f88eb789c0197101d4baaa9b674e80fd966f29e 100644 |
| --- a/ios/chrome/app/deferred_initialization_runner.mm |
| +++ b/ios/chrome/app/deferred_initialization_runner.mm |
| @@ -6,18 +6,20 @@ |
| #include <stdint.h> |
| -#import "base/ios/weak_nsobject.h" |
| #include "base/logging.h" |
| #include "base/mac/scoped_block.h" |
| -#include "base/mac/scoped_nsobject.h" |
| + |
| +#if !defined(__has_feature) || !__has_feature(objc_arc) |
| +#error "This file requires ARC support." |
| +#endif |
| // An object encapsulating the deferred execution of a block of initialization |
| // code. |
| @interface DeferredInitializationBlock : NSObject { |
|
sdefresne
2017/02/21 14:20:25
nit: move this to the @implementation
stkhapugin
2017/02/21 15:47:02
Done.
|
| // A string to reference the initialization block. |
| - base::scoped_nsobject<NSString> _name; |
| + NSString* _name; |
| // A block of code to execute. |
| - base::mac::ScopedBlock<ProceduralBlock> _runBlock; |
| + ProceduralBlock _runBlock; |
| } |
| - (instancetype)init NS_UNAVAILABLE; |
| @@ -46,15 +48,15 @@ |
| DCHECK(block); |
| self = [super init]; |
| if (self) { |
| - _name.reset([name copy]); |
| - _runBlock.reset(block, base::scoped_policy::RETAIN); |
| + _name = [name copy]; |
| + _runBlock = block; |
| } |
| return self; |
| } |
| - (void)run { |
| DCHECK([NSThread isMainThread]); |
| - ProceduralBlock deferredBlock = _runBlock.get(); |
| + ProceduralBlock deferredBlock = _runBlock; |
| if (!deferredBlock) |
| return; |
| deferredBlock(); |
| @@ -62,14 +64,14 @@ |
| } |
| - (void)cancel { |
| - _runBlock.reset(); |
| + _runBlock = nil; |
| } |
| @end |
| @interface DeferredInitializationRunner () { |
| - base::scoped_nsobject<NSMutableArray> _blocksNameQueue; |
| - base::scoped_nsobject<NSMutableDictionary> _runBlocks; |
| + NSMutableArray* _blocksNameQueue; |
| + NSMutableDictionary* _runBlocks; |
| BOOL _isBlockScheduled; |
| } |
| @@ -102,8 +104,8 @@ |
| - (instancetype)init { |
| self = [super init]; |
| if (self) { |
| - _blocksNameQueue.reset([[NSMutableArray array] retain]); |
| - _runBlocks.reset([[NSMutableDictionary dictionary] retain]); |
| + _blocksNameQueue = [NSMutableArray array]; |
| + _runBlocks = [NSMutableDictionary dictionary]; |
| _isBlockScheduled = NO; |
| _delayBetweenBlocks = 0.2; |
| _delayBeforeFirstBlock = 3.0; |
| @@ -117,8 +119,8 @@ |
| [self cancelBlockNamed:name]; |
| [_blocksNameQueue addObject:name]; |
| - base::scoped_nsobject<DeferredInitializationBlock> deferredBlock( |
| - [[DeferredInitializationBlock alloc] initWithName:name block:block]); |
| + DeferredInitializationBlock* deferredBlock = |
| + [[DeferredInitializationBlock alloc] initWithName:name block:block]; |
| [_runBlocks setObject:deferredBlock forKey:name]; |
| if (!_isBlockScheduled) { |
| @@ -137,7 +139,7 @@ |
| [_runBlocks objectForKey:nextBlockName]; |
| DCHECK(nextBlock); |
| - base::WeakNSObject<DeferredInitializationRunner> weakSelf(self); |
| + __weak DeferredInitializationRunner* weakSelf = self; |
| dispatch_after( |
| dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delay * NSEC_PER_SEC)), |