aboutsummaryrefslogtreecommitdiff
path: root/src/client/mac
diff options
context:
space:
mode:
authorOlivier Robin <olivierrobin@chromium.org>2019-04-18 18:06:31 +0200
committerMark Mentovai <mark@chromium.org>2019-04-23 13:07:06 +0000
commit1fc9cc0d0e1dfafb8d29dba8d01f09587d870026 (patch)
treead334e68729ce88aec5d750f9be3cd21f838d745 /src/client/mac
parentMake breakpad_unittests work with Chrome's test runner instead of gtest's (diff)
downloadbreakpad-1fc9cc0d0e1dfafb8d29dba8d01f09587d870026.tar.xz
[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 <mark@chromium.org>
Diffstat (limited to 'src/client/mac')
-rw-r--r--src/client/mac/sender/uploader.h17
-rw-r--r--src/client/mac/sender/uploader.mm8
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]];