| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/chrome/browser/crash_report/crash_report_background_uploader.h" | 5 #import "ios/chrome/browser/crash_report/crash_report_background_uploader.h" |
| 6 | 6 |
| 7 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/scoped_block.h" | 10 #include "base/mac/scoped_block.h" |
| 11 #include "base/mac/scoped_nsobject.h" | 11 #include "base/mac/scoped_nsobject.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/metrics/user_metrics.h" |
| 13 #include "base/metrics/user_metrics_action.h" | 14 #include "base/metrics/user_metrics_action.h" |
| 14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 15 #import "breakpad/src/client/ios/BreakpadController.h" | 16 #import "breakpad/src/client/ios/BreakpadController.h" |
| 16 #include "ios/chrome/browser/experimental_flags.h" | 17 #include "ios/chrome/browser/experimental_flags.h" |
| 17 #include "ios/web/public/user_metrics.h" | |
| 18 | 18 |
| 19 using base::UserMetricsAction; | 19 using base::UserMetricsAction; |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 NSString* const kBackgroundReportUploader = | 23 NSString* const kBackgroundReportUploader = |
| 24 @"com.google.chrome.breakpad.backgroundupload"; | 24 @"com.google.chrome.breakpad.backgroundupload"; |
| 25 const char* const kUMAMobileCrashBackgroundUploadDelay = | 25 const char* const kUMAMobileCrashBackgroundUploadDelay = |
| 26 "CrashReport.CrashBackgroundUploadDelay"; | 26 "CrashReport.CrashBackgroundUploadDelay"; |
| 27 const char* const kUMAMobilePendingReportsOnBackgroundWakeUp = | 27 const char* const kUMAMobilePendingReportsOnBackgroundWakeUp = |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 [[BreakpadController sharedInstance] setUploadingEnabled:NO]; | 307 [[BreakpadController sharedInstance] setUploadingEnabled:NO]; |
| 308 dispatch_async(dispatch_get_main_queue(), ^{ | 308 dispatch_async(dispatch_get_main_queue(), ^{ |
| 309 if (reportToSend) { | 309 if (reportToSend) { |
| 310 if (uploaded) { | 310 if (uploaded) { |
| 311 NSUserDefaults* defaults = | 311 NSUserDefaults* defaults = |
| 312 [NSUserDefaults standardUserDefaults]; | 312 [NSUserDefaults standardUserDefaults]; |
| 313 NSInteger uploadedCrashes = | 313 NSInteger uploadedCrashes = |
| 314 [defaults integerForKey:kReportsUploadedInBackground]; | 314 [defaults integerForKey:kReportsUploadedInBackground]; |
| 315 [defaults setInteger:(uploadedCrashes + 1) | 315 [defaults setInteger:(uploadedCrashes + 1) |
| 316 forKey:kReportsUploadedInBackground]; | 316 forKey:kReportsUploadedInBackground]; |
| 317 web::RecordAction( | 317 base::RecordAction( |
| 318 UserMetricsAction("BackgroundUploadReportSucceeded")); | 318 UserMetricsAction("BackgroundUploadReportSucceeded")); |
| 319 | 319 |
| 320 } else { | 320 } else { |
| 321 web::RecordAction( | 321 base::RecordAction( |
| 322 UserMetricsAction("BackgroundUploadReportAborted")); | 322 UserMetricsAction("BackgroundUploadReportAborted")); |
| 323 } | 323 } |
| 324 } | 324 } |
| 325 if (uploaded && pendingReports) { | 325 if (uploaded && pendingReports) { |
| 326 completionHandler(UIBackgroundFetchResultNewData); | 326 completionHandler(UIBackgroundFetchResultNewData); |
| 327 } else if (pendingReports) { | 327 } else if (pendingReports) { |
| 328 completionHandler(UIBackgroundFetchResultFailed); | 328 completionHandler(UIBackgroundFetchResultFailed); |
| 329 } else { | 329 } else { |
| 330 [[UIApplication sharedApplication] | 330 [[UIApplication sharedApplication] |
| 331 setMinimumBackgroundFetchInterval: | 331 setMinimumBackgroundFetchInterval: |
| (...skipping 21 matching lines...) Expand all Loading... |
| 353 integerForKey:kReportsUploadedInBackground]; | 353 integerForKey:kReportsUploadedInBackground]; |
| 354 return uploadedCrashReportsInBackgroundCount > 0; | 354 return uploadedCrashReportsInBackgroundCount > 0; |
| 355 } | 355 } |
| 356 | 356 |
| 357 + (void)resetReportsUploadedInBackgroundCount { | 357 + (void)resetReportsUploadedInBackgroundCount { |
| 358 [[NSUserDefaults standardUserDefaults] | 358 [[NSUserDefaults standardUserDefaults] |
| 359 removeObjectForKey:kReportsUploadedInBackground]; | 359 removeObjectForKey:kReportsUploadedInBackground]; |
| 360 } | 360 } |
| 361 | 361 |
| 362 @end | 362 @end |
| OLD | NEW |