mirror of
				https://github.com/yuzu-emu/breakpad.git
				synced 2025-11-04 13:04:56 +00:00 
			
		
		
		
	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:
		
							parent
							
								
									46821f78b1
								
							
						
					
					
						commit
						8e28cb3898
					
				| 
						 | 
				
			
			@ -196,8 +196,8 @@ void BreakpadRemoveUploadParameter(BreakpadRef ref, NSString *key);
 | 
			
		|||
 | 
			
		||||
// Method to handle uploading data to the server
 | 
			
		||||
 | 
			
		||||
// Returns if there is some report to send to the server.
 | 
			
		||||
bool BreakpadHasCrashReportToUpload(BreakpadRef ref);
 | 
			
		||||
// Returns the number of crash reports waiting to send to the server.
 | 
			
		||||
int BreakpadGetCrashReportCount(BreakpadRef ref);
 | 
			
		||||
 | 
			
		||||
// Upload next report to the server.
 | 
			
		||||
void BreakpadUploadNextReport(BreakpadRef ref);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -108,6 +108,9 @@
 | 
			
		|||
// Check if there is currently a crash report to upload.
 | 
			
		||||
- (void)hasReportToUpload:(void(^)(BOOL))callback;
 | 
			
		||||
 | 
			
		||||
// Get the number of crash reports waiting to upload.
 | 
			
		||||
- (void)getCrashReportCount:(void(^)(int))callback;
 | 
			
		||||
 | 
			
		||||
@end
 | 
			
		||||
 | 
			
		||||
#endif  // CLIENT_IOS_HANDLER_IOS_BREAKPAD_CONTROLLER_H_
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -232,7 +232,15 @@ NSString* GetPlatform() {
 | 
			
		|||
  NSAssert(started_, @"The controller must be started before "
 | 
			
		||||
                     "hasReportToUpload is called");
 | 
			
		||||
  dispatch_async(queue_, ^{
 | 
			
		||||
      callback(breakpadRef_ && BreakpadHasCrashReportToUpload(breakpadRef_));
 | 
			
		||||
      callback(breakpadRef_ && (BreakpadGetCrashReportCount(breakpadRef_) > 0));
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
- (void)getCrashReportCount:(void(^)(int))callback {
 | 
			
		||||
  NSAssert(started_, @"The controller must be started before "
 | 
			
		||||
                     "getCrashReportCount is called");
 | 
			
		||||
  dispatch_async(queue_, ^{
 | 
			
		||||
      callback(breakpadRef_ ? BreakpadGetCrashReportCount(breakpadRef_) : 0);
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -264,7 +272,7 @@ NSString* GetPlatform() {
 | 
			
		|||
 | 
			
		||||
- (void)sendStoredCrashReports {
 | 
			
		||||
  dispatch_async(queue_, ^{
 | 
			
		||||
      if (!BreakpadHasCrashReportToUpload(breakpadRef_))
 | 
			
		||||
      if (BreakpadGetCrashReportCount(breakpadRef_) == 0)
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
      int timeToWait = [self sendDelay];
 | 
			
		||||
| 
						 | 
				
			
			@ -279,7 +287,7 @@ NSString* GetPlatform() {
 | 
			
		|||
        BreakpadUploadNextReport(breakpadRef_);
 | 
			
		||||
 | 
			
		||||
        // If more reports must be sent, make sure this method is called again.
 | 
			
		||||
        if (BreakpadHasCrashReportToUpload(breakpadRef_))
 | 
			
		||||
        if (BreakpadGetCrashReportCount(breakpadRef_) > 0)
 | 
			
		||||
          timeToWait = uploadIntervalInSeconds_;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue