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
This commit is contained in:
mark@chromium.org
2013-11-20 16:34:13 +00:00
parent 46821f78b1
commit 8e28cb3898
4 changed files with 30 additions and 10 deletions

View File

@@ -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;
}