aboutsummaryrefslogtreecommitdiff
path: root/src/client/ios
diff options
context:
space:
mode:
authorqsr@chromium.org <qsr@chromium.org@4c0a9323-5329-0410-9bdc-e9ce6186880e>2011-11-16 17:04:28 +0000
committerqsr@chromium.org <qsr@chromium.org@4c0a9323-5329-0410-9bdc-e9ce6186880e>2011-11-16 17:04:28 +0000
commit976930db64c56d476b02ebe86602a9600248ac7f (patch)
treeeb0f6ac5c12fdb44b7419fa58bc29105b0689ab2 /src/client/ios
parentFix several error-case leaks on the Mac found by clang analysis (diff)
downloadbreakpad-976930db64c56d476b02ebe86602a9600248ac7f.tar.xz
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
Diffstat (limited to 'src/client/ios')
-rw-r--r--src/client/ios/Breakpad.h5
-rw-r--r--src/client/ios/Breakpad.mm35
2 files changed, 40 insertions, 0 deletions
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()
@@ -426,6 +427,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) {
DEBUGLOG(stderr, "Breakpad: a minidump has been created.\n");
@@ -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");
+ }
+}