| 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.h" |
| 14 #include "base/metrics/user_metrics_action.h" | 14 #include "base/metrics/user_metrics_action.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #import "breakpad/src/client/ios/BreakpadController.h" | 16 #import "breakpad/src/client/ios/BreakpadController.h" |
| 17 #include "ios/chrome/browser/experimental_flags.h" | 17 #include "ios/chrome/browser/experimental_flags.h" |
| 18 | 18 |
| 19 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 20 #error "This file requires ARC support." |
| 21 #endif |
| 22 |
| 19 using base::UserMetricsAction; | 23 using base::UserMetricsAction; |
| 20 | 24 |
| 21 namespace { | 25 namespace { |
| 22 | 26 |
| 23 NSString* const kBackgroundReportUploader = | 27 NSString* const kBackgroundReportUploader = |
| 24 @"com.google.chrome.breakpad.backgroundupload"; | 28 @"com.google.chrome.breakpad.backgroundupload"; |
| 25 const char* const kUMAMobileCrashBackgroundUploadDelay = | 29 const char* const kUMAMobileCrashBackgroundUploadDelay = |
| 26 "CrashReport.CrashBackgroundUploadDelay"; | 30 "CrashReport.CrashBackgroundUploadDelay"; |
| 27 const char* const kUMAMobilePendingReportsOnBackgroundWakeUp = | 31 const char* const kUMAMobilePendingReportsOnBackgroundWakeUp = |
| 28 "CrashReport.PendingReportsOnBackgroundWakeUp"; | 32 "CrashReport.PendingReportsOnBackgroundWakeUp"; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 58 BOOL _didFinishEventsCalled; | 62 BOOL _didFinishEventsCalled; |
| 59 } | 63 } |
| 60 | 64 |
| 61 + (instancetype)sharedInstance { | 65 + (instancetype)sharedInstance { |
| 62 static UrlSessionDelegate* instance = [[UrlSessionDelegate alloc] init]; | 66 static UrlSessionDelegate* instance = [[UrlSessionDelegate alloc] init]; |
| 63 return instance; | 67 return instance; |
| 64 } | 68 } |
| 65 | 69 |
| 66 - (void)setSessionCompletionHandler:(ProceduralBlock)completionHandler { | 70 - (void)setSessionCompletionHandler:(ProceduralBlock)completionHandler { |
| 67 DCHECK(completionHandler); | 71 DCHECK(completionHandler); |
| 68 _sessionCompletionHandler.reset(completionHandler, | 72 _sessionCompletionHandler.reset(completionHandler); |
| 69 base::scoped_policy::RETAIN); | |
| 70 _didFinishEventsCalled = NO; | 73 _didFinishEventsCalled = NO; |
| 71 } | 74 } |
| 72 | 75 |
| 73 - (void)URLSession:(NSURLSession*)session | 76 - (void)URLSession:(NSURLSession*)session |
| 74 task:(NSURLSessionTask*)dataTask | 77 task:(NSURLSessionTask*)dataTask |
| 75 didReceiveChallenge:(NSURLAuthenticationChallenge*)challenge | 78 didReceiveChallenge:(NSURLAuthenticationChallenge*)challenge |
| 76 completionHandler: | 79 completionHandler: |
| 77 (void (^)(NSURLSessionAuthChallengeDisposition disposition, | 80 (void (^)(NSURLSessionAuthChallengeDisposition disposition, |
| 78 NSURLCredential* credential))completionHandler { | 81 NSURLCredential* credential))completionHandler { |
| 79 if (![challenge.protectionSpace.authenticationMethod | 82 if (![challenge.protectionSpace.authenticationMethod |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 integerForKey:kReportsUploadedInBackground]; | 356 integerForKey:kReportsUploadedInBackground]; |
| 354 return uploadedCrashReportsInBackgroundCount > 0; | 357 return uploadedCrashReportsInBackgroundCount > 0; |
| 355 } | 358 } |
| 356 | 359 |
| 357 + (void)resetReportsUploadedInBackgroundCount { | 360 + (void)resetReportsUploadedInBackgroundCount { |
| 358 [[NSUserDefaults standardUserDefaults] | 361 [[NSUserDefaults standardUserDefaults] |
| 359 removeObjectForKey:kReportsUploadedInBackground]; | 362 removeObjectForKey:kReportsUploadedInBackground]; |
| 360 } | 363 } |
| 361 | 364 |
| 362 @end | 365 @end |
| OLD | NEW |