diff options
author | blundell@chromium.org <blundell@chromium.org@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2014-01-13 10:40:07 +0000 |
---|---|---|
committer | blundell@chromium.org <blundell@chromium.org@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2014-01-13 10:40:07 +0000 |
commit | 12528d19bdf7b00a0f1ad5cd466a12d587189055 (patch) | |
tree | 81b1a95d192cf1873676b41c653213f288f3e307 /src/client/ios | |
parent | Don't do work inside assert(). Ever. (diff) | |
download | breakpad-12528d19bdf7b00a0f1ad5cd466a12d587189055.tar.xz |
Add -[BreakpadController setParametersToAddAtUploadTime:] for iOS.
This provides the ability to add server parameters to a crash report when the
report is uploaded.
Patch by KiYun Roe <kiyun@chromium.org>
BUG=558
R=blundell@chromium.org
Review URL: https://breakpad.appspot.com/974002/
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1271 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/client/ios')
-rw-r--r-- | src/client/ios/Breakpad.h | 4 | ||||
-rw-r--r-- | src/client/ios/Breakpad.mm | 16 | ||||
-rw-r--r-- | src/client/ios/BreakpadController.h | 11 | ||||
-rw-r--r-- | src/client/ios/BreakpadController.mm | 11 |
4 files changed, 33 insertions, 9 deletions
diff --git a/src/client/ios/Breakpad.h b/src/client/ios/Breakpad.h index 3bec1a63..c3362b0f 100644 --- a/src/client/ios/Breakpad.h +++ b/src/client/ios/Breakpad.h @@ -200,7 +200,9 @@ void BreakpadRemoveUploadParameter(BreakpadRef ref, NSString *key); int BreakpadGetCrashReportCount(BreakpadRef ref); // Upload next report to the server. -void BreakpadUploadNextReport(BreakpadRef ref); +// |server_parameters| is additional server parameters to send (optional). +void BreakpadUploadNextReport(BreakpadRef ref, + NSDictionary *server_parameters = nil); // Upload a file to the server. |data| is the content of the file to sent. // |server_parameters| is additional server parameters to send. diff --git a/src/client/ios/Breakpad.mm b/src/client/ios/Breakpad.mm index 3b9f6d3f..2bd7e33b 100644 --- a/src/client/ios/Breakpad.mm +++ b/src/client/ios/Breakpad.mm @@ -152,7 +152,7 @@ class Breakpad { void RemoveKeyValue(NSString *key); NSArray *CrashReportsToUpload(); NSString *NextCrashReportToUpload(); - void UploadNextReport(); + void UploadNextReport(NSDictionary *server_parameters); void UploadData(NSData *data, NSString *name, NSDictionary *server_parameters); NSDictionary *GenerateReport(NSDictionary *server_parameters); @@ -448,13 +448,18 @@ NSString *Breakpad::NextCrashReportToUpload() { } //============================================================================= -void Breakpad::UploadNextReport() { +void Breakpad::UploadNextReport(NSDictionary *server_parameters) { NSString *configFile = NextCrashReportToUpload(); if (configFile) { Uploader *uploader = [[[Uploader alloc] initWithConfigFile:[configFile UTF8String]] autorelease]; - if (uploader) + if (uploader) { + for (NSString *key in server_parameters) { + [uploader addServerParameter:[server_parameters objectForKey:key] + forKey:key]; + } [uploader report]; + } } } @@ -784,13 +789,14 @@ int BreakpadGetCrashReportCount(BreakpadRef ref) { } //============================================================================= -void BreakpadUploadNextReport(BreakpadRef ref) { +void BreakpadUploadNextReport(BreakpadRef ref, + NSDictionary *server_parameters) { try { // Not called at exception time Breakpad *breakpad = (Breakpad *)ref; if (breakpad) { - breakpad->UploadNextReport(); + breakpad->UploadNextReport(server_parameters); } } catch(...) { // don't let exceptions leave this C API fprintf(stderr, "BreakpadUploadNextReport() : error\n"); diff --git a/src/client/ios/BreakpadController.h b/src/client/ios/BreakpadController.h index be072ea9..cf1fa774 100644 --- a/src/client/ios/BreakpadController.h +++ b/src/client/ios/BreakpadController.h @@ -62,6 +62,10 @@ // The interval to wait between two uploads. Value is 0 if no upload must be // done. int uploadIntervalInSeconds_; + + // The dictionary that contains additional server parameters to send when + // uploading crash reports. + NSDictionary* uploadTimeParameters_; } // Singleton. @@ -84,8 +88,11 @@ // will prevent uploads. - (void)setUploadInterval:(int)intervalInSeconds; -// Specify a parameter that will be uploaded to the crash server. See -// |BreakpadAddUploadParameter|. +// Set additional server parameters to send when uploading crash reports. +- (void)setParametersToAddAtUploadTime:(NSDictionary*)uploadTimeParameters; + +// Specify an upload parameter that will be added to the crash report when a +// crash report is generated. See |BreakpadAddUploadParameter|. - (void)addUploadParameter:(NSString*)value forKey:(NSString*)key; // Remove a previously-added parameter from the upload parameter set. See diff --git a/src/client/ios/BreakpadController.mm b/src/client/ios/BreakpadController.mm index 9a6dd814..4571470d 100644 --- a/src/client/ios/BreakpadController.mm +++ b/src/client/ios/BreakpadController.mm @@ -120,6 +120,7 @@ NSString* GetPlatform() { assert(!breakpadRef_); dispatch_release(queue_); [configuration_ release]; + [uploadTimeParameters_ release]; [super dealloc]; } @@ -192,6 +193,7 @@ NSString* GetPlatform() { NSString* uploadInterval = [configuration_ valueForKey:@BREAKPAD_REPORT_INTERVAL]; [self setUploadInterval:[uploadInterval intValue]]; + [self setParametersToAddAtUploadTime:nil]; } - (void)setUploadingURL:(NSString*)url { @@ -209,6 +211,13 @@ NSString* GetPlatform() { uploadIntervalInSeconds_ = 0; } +- (void)setParametersToAddAtUploadTime:(NSDictionary*)uploadTimeParameters { + NSAssert(!started_, @"The controller must not be started when " + "setParametersToAddAtUploadTime is called"); + [uploadTimeParameters_ autorelease]; + uploadTimeParameters_ = [uploadTimeParameters copy]; +} + - (void)addUploadParameter:(NSString*)value forKey:(NSString*)key { NSAssert(started_, @"The controller must be started before addUploadParameter is called"); @@ -291,7 +300,7 @@ NSString* GetPlatform() { // A report can be sent now. if (timeToWait == 0) { [self reportWillBeSent]; - BreakpadUploadNextReport(breakpadRef_); + BreakpadUploadNextReport(breakpadRef_, uploadTimeParameters_); // If more reports must be sent, make sure this method is called again. if (BreakpadGetCrashReportCount(breakpadRef_) > 0) |