From 976930db64c56d476b02ebe86602a9600248ac7f Mon Sep 17 00:00:00 2001 From: "qsr@chromium.org" Date: Wed, 16 Nov 2011 17:04:28 +0000 Subject: Add an API to Breakpad to upload custom file to the crash server. On iOS, sending logs using the usual breakpad behavior is not possible, because tar is not available. This allow to use Breakpad to send any file to the crash server. R=mark@chromium.org Review URL: http://breakpad.appspot.com/327001 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@885 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/client/ios/Breakpad.h | 5 +++++ src/client/ios/Breakpad.mm | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) (limited to 'src/client/ios') diff --git a/src/client/ios/Breakpad.h b/src/client/ios/Breakpad.h index 685dea32..1483e860 100644 --- a/src/client/ios/Breakpad.h +++ b/src/client/ios/Breakpad.h @@ -196,6 +196,11 @@ bool BreakpadHasCrashReportToUpload(BreakpadRef ref); // Upload next report to the server. void BreakpadUploadNextReport(BreakpadRef ref); +// Upload a file to the server. |data| is the content of the file to sent. +// |server_parameters| is additional server parameters to send. +void BreakpadUploadData(BreakpadRef ref, NSData *data, + NSDictionary *server_parameters); + #ifdef __cplusplus } #endif diff --git a/src/client/ios/Breakpad.mm b/src/client/ios/Breakpad.mm index d2f5652f..0b9cabbb 100644 --- a/src/client/ios/Breakpad.mm +++ b/src/client/ios/Breakpad.mm @@ -152,6 +152,7 @@ class Breakpad { void RemoveKeyValue(NSString *key); NSString *NextCrashReportToUpload(); void UploadNextReport(); + void UploadData(NSData *data, NSDictionary *server_parameters); private: Breakpad() @@ -425,6 +426,25 @@ void Breakpad::UploadNextReport() { } } +//============================================================================= +void Breakpad::UploadData(NSData *data, NSDictionary *server_parameters) { + NSMutableDictionary *config = [NSMutableDictionary dictionary]; + + SimpleStringDictionaryIterator it(*config_params_); + while (const KeyValueEntry *next = it.Next()) { + [config setValue:[NSString stringWithUTF8String:next->GetValue()] + forKey:[NSString stringWithUTF8String:next->GetKey()]]; + } + + Uploader *uploader = + [[[Uploader alloc] initWithConfig:config] autorelease]; + for (NSString *key in server_parameters) { + [uploader addServerParameter:[server_parameters objectForKey:key] + forKey:key]; + } + [uploader uploadData:data]; +} + //============================================================================= bool Breakpad::HandleMinidump(const char *dump_dir, const char *minidump_id) { @@ -681,3 +701,18 @@ void BreakpadUploadNextReport(BreakpadRef ref) { fprintf(stderr, "BreakpadUploadNextReport() : error\n"); } } + +//============================================================================= +void BreakpadUploadData(BreakpadRef ref, NSData *data, + NSDictionary *server_parameters) { + try { + // Not called at exception time + Breakpad *breakpad = (Breakpad *)ref; + + if (breakpad) { + breakpad->UploadData(data, server_parameters); + } + } catch(...) { // don't let exceptions leave this C API + fprintf(stderr, "BreakpadUploadData() : error\n"); + } +} -- cgit v1.2.1