aboutsummaryrefslogtreecommitdiff
path: root/src/client/ios
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@4c0a9323-5329-0410-9bdc-e9ce6186880e>2013-11-20 16:34:13 +0000
committermark@chromium.org <mark@chromium.org@4c0a9323-5329-0410-9bdc-e9ce6186880e>2013-11-20 16:34:13 +0000
commit8e28cb38988455cbdd4fcac2c8dc7301baca009a (patch)
treea98b6d980deaf0f3e974e283e14c764e16926510 /src/client/ios
parentAllow SIGABRT to abort the program. (diff)
downloadbreakpad-8e28cb38988455cbdd4fcac2c8dc7301baca009a.tar.xz
Provide BreakpadGetCrashReportCount() and -[BreakpadController
getCrashReportCount:] This provides the ability for clients to query the number of crash reports that are waiting to upload. Patch by KiYun Roe <kiyun@chromium.org> BUG=547 Review URL: https://breakpad.appspot.com/714002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1234 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/client/ios')
-rw-r--r--src/client/ios/Breakpad.h4
-rw-r--r--src/client/ios/Breakpad.mm19
-rw-r--r--src/client/ios/BreakpadController.h3
-rw-r--r--src/client/ios/BreakpadController.mm14
4 files changed, 30 insertions, 10 deletions
diff --git a/src/client/ios/Breakpad.h b/src/client/ios/Breakpad.h
index c190385c..3bec1a63 100644
--- a/src/client/ios/Breakpad.h
+++ b/src/client/ios/Breakpad.h
@@ -196,8 +196,8 @@ void BreakpadRemoveUploadParameter(BreakpadRef ref, NSString *key);
// Method to handle uploading data to the server
-// Returns if there is some report to send to the server.
-bool BreakpadHasCrashReportToUpload(BreakpadRef ref);
+// Returns the number of crash reports waiting to send to the server.
+int BreakpadGetCrashReportCount(BreakpadRef ref);
// Upload next report to the server.
void BreakpadUploadNextReport(BreakpadRef ref);
diff --git a/src/client/ios/Breakpad.mm b/src/client/ios/Breakpad.mm
index 0b74e323..44a61ff4 100644
--- a/src/client/ios/Breakpad.mm
+++ b/src/client/ios/Breakpad.mm
@@ -162,6 +162,7 @@ class Breakpad {
void SetKeyValue(NSString *key, NSString *value);
NSString *KeyValue(NSString *key);
void RemoveKeyValue(NSString *key);
+ NSArray *CrashReportsToUpload();
NSString *NextCrashReportToUpload();
void UploadNextReport();
void UploadData(NSData *data, NSString *name,
@@ -440,7 +441,7 @@ void Breakpad::RemoveKeyValue(NSString *key) {
}
//=============================================================================
-NSString *Breakpad::NextCrashReportToUpload() {
+NSArray *Breakpad::CrashReportsToUpload() {
NSString *directory = KeyValue(@BREAKPAD_DUMP_DIRECTORY);
if (!directory)
return nil;
@@ -448,7 +449,15 @@ NSString *Breakpad::NextCrashReportToUpload() {
contentsOfDirectoryAtPath:directory error:nil];
NSArray *configs = [dirContents filteredArrayUsingPredicate:[NSPredicate
predicateWithFormat:@"self BEGINSWITH 'Config-'"]];
- NSString *config = [configs lastObject];
+ return configs;
+}
+
+//=============================================================================
+NSString *Breakpad::NextCrashReportToUpload() {
+ NSString *directory = KeyValue(@BREAKPAD_DUMP_DIRECTORY);
+ if (!directory)
+ return nil;
+ NSString *config = [CrashReportsToUpload() lastObject];
if (!config)
return nil;
return [NSString stringWithFormat:@"%@/%@", directory, config];
@@ -779,16 +788,16 @@ void BreakpadRemoveKeyValue(BreakpadRef ref, NSString *key) {
}
//=============================================================================
-bool BreakpadHasCrashReportToUpload(BreakpadRef ref) {
+int BreakpadGetCrashReportCount(BreakpadRef ref) {
try {
// Not called at exception time
Breakpad *breakpad = (Breakpad *)ref;
if (breakpad) {
- return breakpad->NextCrashReportToUpload() != 0;
+ return [breakpad->CrashReportsToUpload() count];
}
} catch(...) { // don't let exceptions leave this C API
- fprintf(stderr, "BreakpadHasCrashReportToUpload() : error\n");
+ fprintf(stderr, "BreakpadGetCrashReportCount() : error\n");
}
return false;
}
diff --git a/src/client/ios/BreakpadController.h b/src/client/ios/BreakpadController.h
index 6e6229a7..eb59e228 100644
--- a/src/client/ios/BreakpadController.h
+++ b/src/client/ios/BreakpadController.h
@@ -108,6 +108,9 @@
// Check if there is currently a crash report to upload.
- (void)hasReportToUpload:(void(^)(BOOL))callback;
+// Get the number of crash reports waiting to upload.
+- (void)getCrashReportCount:(void(^)(int))callback;
+
@end
#endif // CLIENT_IOS_HANDLER_IOS_BREAKPAD_CONTROLLER_H_
diff --git a/src/client/ios/BreakpadController.mm b/src/client/ios/BreakpadController.mm
index 31affa18..ac560d18 100644
--- a/src/client/ios/BreakpadController.mm
+++ b/src/client/ios/BreakpadController.mm
@@ -232,7 +232,15 @@ NSString* GetPlatform() {
NSAssert(started_, @"The controller must be started before "
"hasReportToUpload is called");
dispatch_async(queue_, ^{
- callback(breakpadRef_ && BreakpadHasCrashReportToUpload(breakpadRef_));
+ callback(breakpadRef_ && (BreakpadGetCrashReportCount(breakpadRef_) > 0));
+ });
+}
+
+- (void)getCrashReportCount:(void(^)(int))callback {
+ NSAssert(started_, @"The controller must be started before "
+ "getCrashReportCount is called");
+ dispatch_async(queue_, ^{
+ callback(breakpadRef_ ? BreakpadGetCrashReportCount(breakpadRef_) : 0);
});
}
@@ -264,7 +272,7 @@ NSString* GetPlatform() {
- (void)sendStoredCrashReports {
dispatch_async(queue_, ^{
- if (!BreakpadHasCrashReportToUpload(breakpadRef_))
+ if (BreakpadGetCrashReportCount(breakpadRef_) == 0)
return;
int timeToWait = [self sendDelay];
@@ -279,7 +287,7 @@ NSString* GetPlatform() {
BreakpadUploadNextReport(breakpadRef_);
// If more reports must be sent, make sure this method is called again.
- if (BreakpadHasCrashReportToUpload(breakpadRef_))
+ if (BreakpadGetCrashReportCount(breakpadRef_) > 0)
timeToWait = uploadIntervalInSeconds_;
}