diff options
author | Evan Bernstein <bernsteine@google.com> | 2018-10-04 14:46:45 -0700 |
---|---|---|
committer | Joshua Peraza <jperaza@chromium.org> | 2018-10-08 16:40:19 +0000 |
commit | 315d1368a7f38071b7ff79dd813a07ea9d157a30 (patch) | |
tree | e7bf295658b94e52eed445677e92fcae00afbe4a /src/client/ios/Breakpad.mm | |
parent | Swap MDCVInfoELF::cv_signature if needed. (diff) | |
download | breakpad-315d1368a7f38071b7ff79dd813a07ea9d157a30.tar.xz |
Adds method to get the date of the most recent iOS crash report.
Also adds method to determine if breakpad is started.
Change-Id: I272765e7ac6bbc07d77ca2d8dcc34d51c205116e
Reviewed-on: https://chromium-review.googlesource.com/c/1260625
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Diffstat (limited to 'src/client/ios/Breakpad.mm')
-rw-r--r-- | src/client/ios/Breakpad.mm | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/client/ios/Breakpad.mm b/src/client/ios/Breakpad.mm index c2a4202a..d7dc78c6 100644 --- a/src/client/ios/Breakpad.mm +++ b/src/client/ios/Breakpad.mm @@ -161,6 +161,7 @@ class Breakpad { NSArray *CrashReportsToUpload(); NSString *NextCrashReportToUpload(); NSDictionary *NextCrashReportConfiguration(); + NSDate *DateOfMostRecentCrashReport(); void UploadNextReport(NSDictionary *server_parameters); void UploadReportWithConfiguration(NSDictionary *configuration, NSDictionary *server_parameters); @@ -468,6 +469,30 @@ NSDictionary *Breakpad::NextCrashReportConfiguration() { } //============================================================================= +NSDate *Breakpad::DateOfMostRecentCrashReport() { + NSString *directory = KeyValue(@BREAKPAD_DUMP_DIRECTORY); + if (!directory) { + return nil; + } + NSFileManager *fileManager = [NSFileManager defaultManager]; + NSArray *dirContents = [fileManager contentsOfDirectoryAtPath:directory error:nil]; + NSArray *dumps = [dirContents filteredArrayUsingPredicate:[NSPredicate + predicateWithFormat:@"self ENDSWITH '.dmp'"]]; + NSDate *mostRecentCrashReportDate = nil; + for (NSString *dump in dumps) { + NSString *filePath = [directory stringByAppendingPathComponent:dump]; + NSDate *crashReportDate = + [[fileManager attributesOfItemAtPath:filePath error:nil] fileCreationDate]; + if (!mostRecentCrashReportDate) { + mostRecentCrashReportDate = crashReportDate; + } else if (crashReportDate) { + mostRecentCrashReportDate = [mostRecentCrashReportDate laterDate:crashReportDate]; + } + } + return mostRecentCrashReportDate; +} + +//============================================================================= void Breakpad::HandleNetworkResponse(NSDictionary *configuration, NSData *data, NSError *error) { @@ -841,6 +866,19 @@ NSDictionary *BreakpadGetNextReportConfiguration(BreakpadRef ref) { } //============================================================================= +NSDate *BreakpadGetDateOfMostRecentCrashReport(BreakpadRef ref) { + try { + Breakpad *breakpad = (Breakpad *)ref; + if (breakpad) { + return breakpad->DateOfMostRecentCrashReport(); + } + } catch (...) { // don't let exceptions leave this C API + fprintf(stderr, "BreakpadGetDateOfMostRecentCrashReport() : error\n"); + } + return nil; +} + +//============================================================================= void BreakpadUploadReportWithParametersAndConfiguration( BreakpadRef ref, NSDictionary *server_parameters, |