From 1fc9cc0d0e1dfafb8d29dba8d01f09587d870026 Mon Sep 17 00:00:00 2001 From: Olivier Robin Date: Thu, 18 Apr 2019 18:06:31 +0200 Subject: [Breakpad iOS] Add a callback on report upload completion. This CL adds a result callback on report upload completion. On failure, Breakpad deletes the configuration file and does retry to upload a report. Using this callback, the client will be able to log some metrics and to act on upload failure. Bug: 954175 Change-Id: I95a3264b65d4c06ba5d8dde8377440d23f1e2081 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1572661 Reviewed-by: Mark Mentovai --- src/client/ios/BreakpadController.mm | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src/client/ios/BreakpadController.mm') diff --git a/src/client/ios/BreakpadController.mm b/src/client/ios/BreakpadController.mm index 8d499c27..01fb5f13 100644 --- a/src/client/ios/BreakpadController.mm +++ b/src/client/ios/BreakpadController.mm @@ -166,9 +166,9 @@ NSString* GetPlatform() { NSAssert(started_, @"The controller must be started before " "threadUnsafeSendReportWithConfiguration is called"); if (breakpadRef_) { - BreakpadUploadReportWithParametersAndConfiguration(breakpadRef_, - uploadTimeParameters_, - configuration); + BreakpadUploadReportWithParametersAndConfiguration( + breakpadRef_, uploadTimeParameters_, configuration, + uploadCompleteCallback_); } } @@ -195,7 +195,7 @@ NSString* GetPlatform() { NSAssert(!started_, @"The controller must not be started when updateConfiguration is called"); [configuration_ addEntriesFromDictionary:configuration]; - NSString* uploadInterval = + NSString *uploadInterval = [configuration_ valueForKey:@BREAKPAD_REPORT_INTERVAL]; if (uploadInterval) [self setUploadInterval:[uploadInterval intValue]]; @@ -206,7 +206,7 @@ NSString* GetPlatform() { @"The controller must not be started when resetConfiguration is called"); [configuration_ autorelease]; configuration_ = [[[NSBundle mainBundle] infoDictionary] mutableCopy]; - NSString* uploadInterval = + NSString *uploadInterval = [configuration_ valueForKey:@BREAKPAD_REPORT_INTERVAL]; [self setUploadInterval:[uploadInterval intValue]]; [self setParametersToAddAtUploadTime:nil]; @@ -243,6 +243,15 @@ NSString* GetPlatform() { }); } +- (void)setUploadCallback:(BreakpadUploadCompletionCallback)callback { + NSAssert(started_, + @"The controller must not be started before setUploadCallback is " + "called"); + dispatch_async(queue_, ^{ + uploadCompleteCallback_ = callback; + }); +} + - (void)removeUploadParameterForKey:(NSString*)key { NSAssert(started_, @"The controller must be started before " "removeUploadParameterForKey is called"); @@ -345,8 +354,8 @@ NSString* GetPlatform() { // A report can be sent now. if (timeToWait == 0) { [self reportWillBeSent]; - BreakpadUploadNextReportWithParameters(breakpadRef_, - uploadTimeParameters_); + BreakpadUploadNextReportWithParameters(breakpadRef_, uploadTimeParameters_, + uploadCompleteCallback_); // If more reports must be sent, make sure this method is called again. if (BreakpadGetCrashReportCount(breakpadRef_) > 0) -- cgit v1.2.1