From f277ae877c4340dba0c356eab84372405bee6b15 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Wed, 18 Jul 2018 13:52:44 -0600 Subject: [PATCH] Clarify OWSOperation behavior (no behavioral changes) --- SignalServiceKit/src/Util/OWSOperation.h | 16 ++++++++++------ SignalServiceKit/src/Util/OWSOperation.m | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/SignalServiceKit/src/Util/OWSOperation.h b/SignalServiceKit/src/Util/OWSOperation.h index 102f46631..c86c90394 100644 --- a/SignalServiceKit/src/Util/OWSOperation.h +++ b/SignalServiceKit/src/Util/OWSOperation.h @@ -24,22 +24,26 @@ typedef NS_ENUM(NSInteger, OWSOperationState) { // any of the errors were fatal. Fatal errors trump retryable errors. @interface OWSOperation : NSOperation -@property (nullable) NSError *failingError; -@property NSUInteger remainingRetries; +@property (readonly, nullable) NSError *failingError; -#pragma mark - Subclass Overrides +// Defaults to 0, set to greater than 0 in init if you'd like the operation to be retryable. +@property NSUInteger remainingRetries; -// Called one time only -- (nullable NSError *)checkForPreconditionError; +#pragma mark - Mandatory Subclass Overrides // Called every retry, this is where the bulk of the operation's work should go. - (void)run; +#pragma mark - Optional Subclass Overrides + +// Called one time only +- (nullable NSError *)checkForPreconditionError; + // Called at most one time. - (void)didSucceed; // Called at most one time, once retry is no longer possible. -- (void)didFailWithError:(NSError *)error; +- (void)didFailWithError:(NSError *)error NS_SWIFT_NAME(didFail(error:)); #pragma mark - Success/Error - Do Not Override diff --git a/SignalServiceKit/src/Util/OWSOperation.m b/SignalServiceKit/src/Util/OWSOperation.m index e9f02949e..7b081f0b3 100644 --- a/SignalServiceKit/src/Util/OWSOperation.m +++ b/SignalServiceKit/src/Util/OWSOperation.m @@ -13,6 +13,7 @@ NSString *const OWSOperationKeyIsFinished = @"isFinished"; @interface OWSOperation () +@property (nullable) NSError *failingError; @property (atomic) OWSOperationState operationState; @property (nonatomic) OWSBackgroundTask *backgroundTask;