diff options
Diffstat (limited to 'src/client/mac')
-rw-r--r-- | src/client/mac/sender/uploader.h | 17 | ||||
-rw-r--r-- | src/client/mac/sender/uploader.mm | 8 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/client/mac/sender/uploader.h b/src/client/mac/sender/uploader.h index 5f6aa464..0897dade 100644 --- a/src/client/mac/sender/uploader.h +++ b/src/client/mac/sender/uploader.h @@ -42,6 +42,13 @@ extern NSString *const kGoogleServerType; extern NSString *const kSocorroServerType; extern NSString *const kDefaultServerType; +// Optional user-defined function that will be called after a network upload +// of a crash report. +// |report_id| will be the id returned by the server, or "ERR" if an error +// occurred. +// |error| will contain the error, or nil if no error occured. +typedef void (^UploadCompletionBlock)(NSString *reportId, NSError *error); + @interface Uploader : NSObject { @private NSMutableDictionary *parameters_; // Key value pairs of data (STRONG) @@ -61,6 +68,12 @@ extern NSString *const kDefaultServerType; // that are uploaded to the // crash server with the // minidump. + UploadCompletionBlock uploadCompletion_; // A block called on network upload + // completion. Parameters are: + // The report ID returned by the + // server, + // the NSError triggered during + // upload. } - (id)initWithConfigFile:(const char *)configFile; @@ -86,4 +99,8 @@ extern NSString *const kDefaultServerType; // new ID. - (void)handleNetworkResponse:(NSData *)data withError:(NSError *)error; +// Sets the callback to be called after uploading a crash report to the server. +// Only the latest callback registered will be called. +- (void)setUploadCompletionBlock:(UploadCompletionBlock)uploadCompletion; + @end diff --git a/src/client/mac/sender/uploader.mm b/src/client/mac/sender/uploader.mm index c74c0583..08aecf76 100644 --- a/src/client/mac/sender/uploader.mm +++ b/src/client/mac/sender/uploader.mm @@ -511,6 +511,9 @@ NSDictionary *readConfigurationData(const char *configFile) { reportID = [[result stringByTrimmingCharactersInSet:trimSet] UTF8String]; [self logUploadWithID:reportID]; } + if (uploadCompletion_) { + uploadCompletion_([NSString stringWithUTF8String:reportID], error); + } // rename the minidump file according to the id returned from the server NSString *minidumpDir = @@ -548,6 +551,11 @@ NSDictionary *readConfigurationData(const char *configFile) { } //============================================================================= +- (void)setUploadCompletionBlock:(UploadCompletionBlock)uploadCompletion { + uploadCompletion_ = uploadCompletion; +} + +//============================================================================= - (void)report { NSURL *url = [NSURL URLWithString:[parameters_ objectForKey:@BREAKPAD_URL]]; |