diff --git a/Parse.xcodeproj/project.pbxproj b/Parse.xcodeproj/project.pbxproj index 18d867a5d..10a5410b1 100644 --- a/Parse.xcodeproj/project.pbxproj +++ b/Parse.xcodeproj/project.pbxproj @@ -163,8 +163,6 @@ 8149163A1B66D44500EFD14F /* AnonymousUtilsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 814915D41B66D44500EFD14F /* AnonymousUtilsTests.m */; }; 8149163B1B66D44500EFD14F /* BaseStateTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 814915D51B66D44500EFD14F /* BaseStateTests.m */; }; 8149163C1B66D44500EFD14F /* BaseStateTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 814915D51B66D44500EFD14F /* BaseStateTests.m */; }; - 8149163D1B66D44500EFD14F /* BlockRetryerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 814915D61B66D44500EFD14F /* BlockRetryerTests.m */; }; - 8149163E1B66D44500EFD14F /* BlockRetryerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 814915D61B66D44500EFD14F /* BlockRetryerTests.m */; }; 8149163F1B66D44500EFD14F /* CloudCodeControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 814915D71B66D44500EFD14F /* CloudCodeControllerTests.m */; }; 814916401B66D44500EFD14F /* CloudCodeControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 814915D71B66D44500EFD14F /* CloudCodeControllerTests.m */; }; 814916411B66D44600EFD14F /* CloudCommandTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 814915D81B66D44500EFD14F /* CloudCommandTests.m */; }; @@ -633,7 +631,6 @@ 81C3826A19CCAD7F0066284A /* PFCategoryLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 8103FA36198FC190000BAE3F /* PFCategoryLoader.m */; }; 81C3826B19CCAD850066284A /* PFThreadsafety.m in Sources */ = {isa = PBXBuildFile; fileRef = 818D049A19A3B84500BEE20F /* PFThreadsafety.m */; }; 81C3826C19CCADA00066284A /* ParseModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 81DDB90C199A3EC200B50F35 /* ParseModule.m */; }; - 81C3826E19CCADA00066284A /* PFBlockRetryer.m in Sources */ = {isa = PBXBuildFile; fileRef = 097952A214CE462B00E6E88C /* PFBlockRetryer.m */; }; 81C3826F19CCADA00066284A /* PFCommandCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 7C1FDDCB14E1B1BD00A77007 /* PFCommandCache.m */; }; 81C3827019CCADA00066284A /* PFDecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 919311D619AE5EB20008FF12 /* PFDecoder.m */; }; 81C3827319CCADA00066284A /* PFInternalUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 09809FB21434F98C00EC3E74 /* PFInternalUtils.m */; }; @@ -782,7 +779,6 @@ 91DF24961A09BAF100CFC7D4 /* PFPinningEventuallyQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 91DF24941A09BAF100CFC7D4 /* PFPinningEventuallyQueue.h */; }; 91DF24971A09BAF100CFC7D4 /* PFPinningEventuallyQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = 91DF24951A09BAF100CFC7D4 /* PFPinningEventuallyQueue.m */; }; 91DF24991A0B0FF200CFC7D4 /* PFEventuallyQueue_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 91DF24981A0B0FF200CFC7D4 /* PFEventuallyQueue_Private.h */; }; - 970110681630B44200AB761E /* PFBlockRetryer.m in Sources */ = {isa = PBXBuildFile; fileRef = 097952A214CE462B00E6E88C /* PFBlockRetryer.m */; }; 970110691630B44200AB761E /* PFCommandCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 7C1FDDCB14E1B1BD00A77007 /* PFCommandCache.m */; }; 9701106E1630B44200AB761E /* PFInternalUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 09809FB21434F98C00EC3E74 /* PFInternalUtils.m */; }; 970110721630B44200AB761E /* PFMulticastDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6390EB1C151EDDA40001B779 /* PFMulticastDelegate.m */; }; @@ -856,7 +852,6 @@ F5B0B2F11B449F1D00F3EBC4 /* PFCoreDataProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 8124C8811B27542A00758E00 /* PFCoreDataProvider.h */; }; F5B0B2F21B449F1D00F3EBC4 /* ParseModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 81DDB90B199A3EC200B50F35 /* ParseModule.h */; }; F5B0B2F31B449F1D00F3EBC4 /* PFAssert.h in Headers */ = {isa = PBXBuildFile; fileRef = 81E2D5AF19DDAAB5009053A1 /* PFAssert.h */; }; - F5B0B2F61B449F1D00F3EBC4 /* PFBlockRetryer.h in Headers */ = {isa = PBXBuildFile; fileRef = 097952A114CE462B00E6E88C /* PFBlockRetryer.h */; }; F5B0B2F81B449F1D00F3EBC4 /* PFDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 919311D519AE5EB20008FF12 /* PFDecoder.h */; }; F5B0B2FA1B449F1D00F3EBC4 /* PFGeoPointPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 09B119FB1488429D002B5594 /* PFGeoPointPrivate.h */; }; F5B0B2FC1B449F1D00F3EBC4 /* PFInternalUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 09809FB11434F98C00EC3E74 /* PFInternalUtils.h */; }; @@ -883,7 +878,6 @@ F5B0B3261B44A33100F3EBC4 /* PFAssert.h in Headers */ = {isa = PBXBuildFile; fileRef = 81E2D5AF19DDAAB5009053A1 /* PFAssert.h */; }; F5B0B3271B44A33100F3EBC4 /* PFAsyncTaskQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = F5C8F2BE1B1F7E6B00CD98E7 /* PFAsyncTaskQueue.h */; }; F5B0B3281B44A33100F3EBC4 /* PFBaseState.h in Headers */ = {isa = PBXBuildFile; fileRef = F586B34E1B1E3BD70082E3BD /* PFBaseState.h */; }; - F5B0B3291B44A33100F3EBC4 /* PFBlockRetryer.h in Headers */ = {isa = PBXBuildFile; fileRef = 097952A114CE462B00E6E88C /* PFBlockRetryer.h */; }; F5B0B32B1B44A33100F3EBC4 /* PFCoreDataProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 8124C8811B27542A00758E00 /* PFCoreDataProvider.h */; }; F5B0B32C1B44A33100F3EBC4 /* PFDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 919311D519AE5EB20008FF12 /* PFDecoder.h */; }; F5B0B32E1B44A33100F3EBC4 /* PFGeoPointPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 09B119FB1488429D002B5594 /* PFGeoPointPrivate.h */; }; @@ -1031,8 +1025,6 @@ 0942999A139C612100DFA018 /* libz.1.1.3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.1.1.3.dylib; path = usr/lib/libz.1.1.3.dylib; sourceTree = SDKROOT; }; 0942999C139C613700DFA018 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; 095ACE9913C69BF700566243 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; - 097952A114CE462B00E6E88C /* PFBlockRetryer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PFBlockRetryer.h; sourceTree = ""; }; - 097952A214CE462B00E6E88C /* PFBlockRetryer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PFBlockRetryer.m; sourceTree = ""; }; 09809FB11434F98C00EC3E74 /* PFInternalUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = PFInternalUtils.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 09809FB21434F98C00EC3E74 /* PFInternalUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = PFInternalUtils.m; sourceTree = ""; }; 09809FB91434F98C00EC3E74 /* Framework.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Framework.plist; sourceTree = ""; }; @@ -1169,7 +1161,6 @@ 814915D31B66D44500EFD14F /* AnonymousAuthenticationProviderTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AnonymousAuthenticationProviderTests.m; sourceTree = ""; }; 814915D41B66D44500EFD14F /* AnonymousUtilsTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AnonymousUtilsTests.m; sourceTree = ""; }; 814915D51B66D44500EFD14F /* BaseStateTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BaseStateTests.m; sourceTree = ""; }; - 814915D61B66D44500EFD14F /* BlockRetryerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BlockRetryerTests.m; sourceTree = ""; }; 814915D71B66D44500EFD14F /* CloudCodeControllerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CloudCodeControllerTests.m; sourceTree = ""; }; 814915D81B66D44500EFD14F /* CloudCommandTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CloudCommandTests.m; sourceTree = ""; }; 814915D91B66D44500EFD14F /* CloudUnitTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CloudUnitTests.m; sourceTree = ""; }; @@ -1692,8 +1683,6 @@ 81E2D5AF19DDAAB5009053A1 /* PFAssert.h */, 816AC9B81A3F48250031D94C /* PFApplication.h */, 816AC9B91A3F48250031D94C /* PFApplication.m */, - 097952A114CE462B00E6E88C /* PFBlockRetryer.h */, - 097952A214CE462B00E6E88C /* PFBlockRetryer.m */, 81068EEF1AE0845D00A34D13 /* PFEncoder.h */, 81068EF01AE0845D00A34D13 /* PFEncoder.m */, 919311D519AE5EB20008FF12 /* PFDecoder.h */, @@ -2147,7 +2136,6 @@ 814915D31B66D44500EFD14F /* AnonymousAuthenticationProviderTests.m */, 814915D41B66D44500EFD14F /* AnonymousUtilsTests.m */, 814915D51B66D44500EFD14F /* BaseStateTests.m */, - 814915D61B66D44500EFD14F /* BlockRetryerTests.m */, 814915D71B66D44500EFD14F /* CloudCodeControllerTests.m */, 814915D81B66D44500EFD14F /* CloudCommandTests.m */, 814915D91B66D44500EFD14F /* CloudUnitTests.m */, @@ -3143,7 +3131,6 @@ F5B0B2F11B449F1D00F3EBC4 /* PFCoreDataProvider.h in Headers */, F5B0B2F21B449F1D00F3EBC4 /* ParseModule.h in Headers */, F5B0B2F31B449F1D00F3EBC4 /* PFAssert.h in Headers */, - F5B0B2F61B449F1D00F3EBC4 /* PFBlockRetryer.h in Headers */, 814BCDF11B4DF63600007B7F /* PFUserState.h in Headers */, F5B0B2F81B449F1D00F3EBC4 /* PFDecoder.h in Headers */, F5B0B2FA1B449F1D00F3EBC4 /* PFGeoPointPrivate.h in Headers */, @@ -3356,7 +3343,6 @@ F5B0B3271B44A33100F3EBC4 /* PFAsyncTaskQueue.h in Headers */, F5B0B3281B44A33100F3EBC4 /* PFBaseState.h in Headers */, F51535091B57240900C49F56 /* PFMutableACLState.h in Headers */, - F5B0B3291B44A33100F3EBC4 /* PFBlockRetryer.h in Headers */, F5B0B32B1B44A33100F3EBC4 /* PFCoreDataProvider.h in Headers */, 814881611B795CD4008763BF /* PFMultiProcessFileLock.h in Headers */, F5B0B32C1B44A33100F3EBC4 /* PFDecoder.h in Headers */, @@ -3788,7 +3774,6 @@ 81E033721B573FC500B25168 /* PFTestSKProductsResponse.m in Sources */, 810ECC741B573CC5002944D4 /* OCMock+Parse.m in Sources */, 81E033711B573FC500B25168 /* PFTestSKProductsRequest.m in Sources */, - 8149163D1B66D44500EFD14F /* BlockRetryerTests.m in Sources */, 811AAF181B72D7E400B1AC1F /* ObjectFilePersistenceControllerTests.m in Sources */, 81E0335C1B573F3E00B25168 /* PFMockURLResponse.m in Sources */, 814916CD1B66D44600EFD14F /* RelationUnitTests.m in Sources */, @@ -3916,7 +3901,6 @@ 814916541B66D44600EFD14F /* DateFormatterTests.m in Sources */, 814916BC1B66D44600EFD14F /* PushStateTests.m in Sources */, 814916461B66D44600EFD14F /* CommandResultTests.m in Sources */, - 8149163E1B66D44500EFD14F /* BlockRetryerTests.m in Sources */, 814916781B66D44600EFD14F /* KeyValueCacheTests.m in Sources */, 814916361B66D44500EFD14F /* AnalyticsUtilitiesTests.m in Sources */, 814916A81B66D44600EFD14F /* PinUnitTests.m in Sources */, @@ -4088,7 +4072,6 @@ 8124C8A11B27BF0900758E00 /* PFSessionController.m in Sources */, 81329E901AE1E8840071EE3E /* PFReachability.m in Sources */, 81C7F4A41AF4220A007B5418 /* PFMutableFileState.m in Sources */, - 81C3826E19CCADA00066284A /* PFBlockRetryer.m in Sources */, 81BF4ABE1B0BF64B00A3D75B /* PFCurrentConfigController.m in Sources */, 81C3824E19CCAD2C0066284A /* PFRole.m in Sources */, 91DF24931A09BA7600CFC7D4 /* PFEventuallyQueue.m in Sources */, @@ -4247,7 +4230,6 @@ 8166FCC71B503886003841A2 /* PFSQLiteStatement.m in Sources */, 81C76EEC1B4B218C0031C2FD /* PFObjectConstants.m in Sources */, 814B64141A769EF500213055 /* PFLogger.m in Sources */, - 970110681630B44200AB761E /* PFBlockRetryer.m in Sources */, F5E8DE1C1B29100000EEA594 /* PFRelationState.m in Sources */, 815619031A1F79AC0076504A /* PFDateFormatter.m in Sources */, 8166FCC31B503886003841A2 /* PFSQLiteDatabaseResult.m in Sources */, diff --git a/Parse/Internal/File/Controller/PFFileController.m b/Parse/Internal/File/Controller/PFFileController.m index 9f5a8afb4..2d9f112f7 100644 --- a/Parse/Internal/File/Controller/PFFileController.m +++ b/Parse/Internal/File/Controller/PFFileController.m @@ -14,7 +14,6 @@ #import "BFTask+Private.h" #import "PFAssert.h" -#import "PFBlockRetryer.h" #import "PFCommandResult.h" #import "PFCommandRunning.h" #import "PFFileManager.h" diff --git a/Parse/Internal/PFBlockRetryer.h b/Parse/Internal/PFBlockRetryer.h deleted file mode 100644 index 17ba4ae7d..000000000 --- a/Parse/Internal/PFBlockRetryer.h +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) 2015-present, Parse, LLC. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -#import - -@class BFTask; - -NS_ASSUME_NONNULL_BEGIN - -typedef BFTask * __nonnull (^PFBlockRetryerBlock)(); - -/*! - This class will retry block for a specified number of times. - */ -@interface PFBlockRetryer : NSObject - -/*! - @abstract Runs the given block repeatedly. - - @discussion Runs the given block repeatedly until either: - - the block returns a successful task - - the block returns a cancelled task - - the block has been run attempts time. - After every run of the block, it waits twice as long as the previous time, - starting with the default initial delay. - - @returns `BFTask` which is the result of last run of the block. - */ -+ (BFTask *)retryBlock:(PFBlockRetryerBlock)block forAttempts:(NSUInteger)attempts; -+ (BFTask *)retryBlock:(PFBlockRetryerBlock)block forAttempts:(NSUInteger)attempts delay:(NSTimeInterval)delay; - -///-------------------------------------- -/// @name Initial Retry Delay -///-------------------------------------- - -+ (void)setInitialRetryDelay:(NSTimeInterval)delay; -+ (NSTimeInterval)initialRetryDelay; - -@end - -NS_ASSUME_NONNULL_END diff --git a/Parse/Internal/PFBlockRetryer.m b/Parse/Internal/PFBlockRetryer.m deleted file mode 100644 index 6e9971c89..000000000 --- a/Parse/Internal/PFBlockRetryer.m +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) 2015-present, Parse, LLC. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -#import "PFBlockRetryer.h" - -#import - -#import "BFTask+Private.h" - -@implementation PFBlockRetryer - -+ (BFTask *)retryBlock:(PFBlockRetryerBlock)block forAttempts:(NSUInteger)attempts { - NSTimeInterval delay = initialRetryDelay_; - delay += initialRetryDelay_ * ((double)arc4random_uniform(0x0FFFF) / 0x0FFFF); - return [self retryBlock:block forAttempts:attempts delay:delay]; -} - -+ (BFTask *)retryBlock:(PFBlockRetryerBlock)block forAttempts:(NSUInteger)attempts delay:(NSTimeInterval)delay { - return [block() continueWithBlock:^id(BFTask *task) { - if (!task.error && !task.exception) { - return task; - } - - if (attempts <= 1) { - return task; - } - - return [[BFTask taskWithDelay:(int)(delay * 1000)] continueWithBlock:^id(BFTask *task) { - return [self retryBlock:block forAttempts:(attempts - 1)]; - }]; - }]; -} - -///-------------------------------------- -#pragma mark - Delay -///-------------------------------------- - -static NSTimeInterval initialRetryDelay_ = 1.0; - -+ (void)setInitialRetryDelay:(NSTimeInterval)newDelay { - initialRetryDelay_ = newDelay; -} - -+ (NSTimeInterval)initialRetryDelay { - return initialRetryDelay_; -} - -@end diff --git a/Parse/Internal/ParseInternal.h b/Parse/Internal/ParseInternal.h index 2a0a585cd..402651af6 100644 --- a/Parse/Internal/ParseInternal.h +++ b/Parse/Internal/ParseInternal.h @@ -17,7 +17,6 @@ #import "PFAssert.h" #import "PFAuthenticationProvider.h" -#import "PFBlockRetryer.h" #import "PFCommandCache.h" #import "PFEventuallyQueue.h" #import "PFFieldOperation.h" diff --git a/Parse/PFFile.m b/Parse/PFFile.m index 1f2db855f..89893dcb5 100644 --- a/Parse/PFFile.m +++ b/Parse/PFFile.m @@ -15,7 +15,6 @@ #import "BFTask+Private.h" #import "PFAssert.h" #import "PFAsyncTaskQueue.h" -#import "PFBlockRetryer.h" #import "PFCommandResult.h" #import "PFCoreManager.h" #import "PFFileController.h" diff --git a/Tests/Unit/BlockRetryerTests.m b/Tests/Unit/BlockRetryerTests.m deleted file mode 100644 index 0b16e97a2..000000000 --- a/Tests/Unit/BlockRetryerTests.m +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright (c) 2015-present, Parse, LLC. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -#import - -#import "PFBlockRetryer.h" -#import "PFTestCase.h" - -@interface BlockRetryerTests : PFTestCase - -@end - -@implementation BlockRetryerTests - -- (void)testInitialDelay { - NSTimeInterval delay = [PFBlockRetryer initialRetryDelay]; - [PFBlockRetryer setInitialRetryDelay:0.1]; - XCTAssertNotEqual(delay, [PFBlockRetryer initialRetryDelay]); -} - -- (void)testRetry { - __block NSUInteger counter = 0; - BFTask *task = [PFBlockRetryer retryBlock:^BFTask *{ - ++counter; - if (counter == 5) { - return [BFTask taskWithResult:@YES]; - } - return [BFTask taskWithError:[NSError errorWithDomain:@"TestDomain" code:100500 userInfo:nil]]; - } forAttempts:5]; - [task waitUntilFinished]; - - XCTAssertEqual(counter, 5); - XCTAssertEqualObjects(task.result, @YES); -} - -- (void)testRetryWithError { - NSError *error = [NSError errorWithDomain:@"TestDomain" code:100500 userInfo:nil]; - BFTask *task = [PFBlockRetryer retryBlock:^BFTask *{ - return [BFTask taskWithError:error]; - } forAttempts:5]; - [task waitUntilFinished]; - XCTAssertEqualObjects(task.error, error); -} - -@end