| 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" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 static CrashReportBackgroundUploader* instance = | 170 static CrashReportBackgroundUploader* instance = |
| 171 [[CrashReportBackgroundUploader alloc] init]; | 171 [[CrashReportBackgroundUploader alloc] init]; |
| 172 return instance; | 172 return instance; |
| 173 } | 173 } |
| 174 | 174 |
| 175 + (NSURLSession*)BreakpadBackgroundURLSessionWithCompletionHandler: | 175 + (NSURLSession*)BreakpadBackgroundURLSessionWithCompletionHandler: |
| 176 (ProceduralBlock)completionHandler { | 176 (ProceduralBlock)completionHandler { |
| 177 static NSURLSession* session = nil; | 177 static NSURLSession* session = nil; |
| 178 static dispatch_once_t onceToken; | 178 static dispatch_once_t onceToken; |
| 179 dispatch_once(&onceToken, ^{ | 179 dispatch_once(&onceToken, ^{ |
| 180 | |
| 181 // TODO(olivierrobin) When all bots compile with iOS8 release SDK, use | |
| 182 // only backgroundSessionConfigurationWithIdentifier. | |
| 183 NSURLSessionConfiguration* sessionConfig = [NSURLSessionConfiguration | 180 NSURLSessionConfiguration* sessionConfig = [NSURLSessionConfiguration |
| 184 backgroundSessionConfiguration:kBackgroundReportUploader]; | 181 backgroundSessionConfigurationWithIdentifier:kBackgroundReportUploader]; |
| 185 | |
| 186 session = [NSURLSession | 182 session = [NSURLSession |
| 187 sessionWithConfiguration:sessionConfig | 183 sessionWithConfiguration:sessionConfig |
| 188 delegate:[UrlSessionDelegate sharedInstance] | 184 delegate:[UrlSessionDelegate sharedInstance] |
| 189 delegateQueue:[NSOperationQueue mainQueue]]; | 185 delegateQueue:[NSOperationQueue mainQueue]]; |
| 190 }); | 186 }); |
| 191 DCHECK(session); | 187 DCHECK(session); |
| 192 if (completionHandler) { | 188 if (completionHandler) { |
| 193 [[UrlSessionDelegate sharedInstance] | 189 [[UrlSessionDelegate sharedInstance] |
| 194 setSessionCompletionHandler:completionHandler]; | 190 setSessionCompletionHandler:completionHandler]; |
| 195 } | 191 } |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 integerForKey:kReportsUploadedInBackground]; | 353 integerForKey:kReportsUploadedInBackground]; |
| 358 return uploadedCrashReportsInBackgroundCount > 0; | 354 return uploadedCrashReportsInBackgroundCount > 0; |
| 359 } | 355 } |
| 360 | 356 |
| 361 + (void)resetReportsUploadedInBackgroundCount { | 357 + (void)resetReportsUploadedInBackgroundCount { |
| 362 [[NSUserDefaults standardUserDefaults] | 358 [[NSUserDefaults standardUserDefaults] |
| 363 removeObjectForKey:kReportsUploadedInBackground]; | 359 removeObjectForKey:kReportsUploadedInBackground]; |
| 364 } | 360 } |
| 365 | 361 |
| 366 @end | 362 @end |
| OLD | NEW |