OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "ios/chrome/browser/crash_report/breakpad_helper.h" | 5 #include "ios/chrome/browser/crash_report/breakpad_helper.h" |
6 | 6 |
7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/debug/crash_logging.h" | 12 #include "base/debug/crash_logging.h" |
13 #include "base/files/file_enumerator.h" | 13 #include "base/files/file_enumerator.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
16 #include "base/location.h" | 16 #include "base/location.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/path_service.h" | 18 #include "base/path_service.h" |
19 #include "base/strings/sys_string_conversions.h" | 19 #include "base/strings/sys_string_conversions.h" |
| 20 #include "base/task_scheduler/post_task.h" |
20 #include "ios/chrome/browser/chrome_paths.h" | 21 #include "ios/chrome/browser/chrome_paths.h" |
21 #import "ios/chrome/browser/crash_report/crash_report_user_application_state.h" | 22 #import "ios/chrome/browser/crash_report/crash_report_user_application_state.h" |
22 #include "ios/web/public/web_thread.h" | |
23 | 23 |
24 // TODO(stuartmorgan): Move this up where it belongs once | 24 // TODO(stuartmorgan): Move this up where it belongs once |
25 // http://code.google.com/p/google-breakpad/issues/detail?id=487 | 25 // http://code.google.com/p/google-breakpad/issues/detail?id=487 |
26 // is fixed. For now, put it at the end to avoid compiler errors. | 26 // is fixed. For now, put it at the end to avoid compiler errors. |
27 #import "breakpad/src/client/ios/BreakpadController.h" | 27 #import "breakpad/src/client/ios/BreakpadController.h" |
28 | 28 |
29 #if !defined(__has_feature) || !__has_feature(objc_arc) | 29 #if !defined(__has_feature) || !__has_feature(objc_arc) |
30 #error "This file requires ARC support." | 30 #error "This file requires ARC support." |
31 #endif | 31 #endif |
32 | 32 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 172 |
173 bool IsUploadingEnabled() { | 173 bool IsUploadingEnabled() { |
174 // Return the value cached by CacheUploadingEnabled(). | 174 // Return the value cached by CacheUploadingEnabled(). |
175 return [[NSUserDefaults standardUserDefaults] | 175 return [[NSUserDefaults standardUserDefaults] |
176 boolForKey:kCrashReportsUploadingEnabledKey]; | 176 boolForKey:kCrashReportsUploadingEnabledKey]; |
177 } | 177 } |
178 | 178 |
179 void CleanupCrashReports() { | 179 void CleanupCrashReports() { |
180 base::FilePath crash_directory; | 180 base::FilePath crash_directory; |
181 PathService::Get(ios::DIR_CRASH_DUMPS, &crash_directory); | 181 PathService::Get(ios::DIR_CRASH_DUMPS, &crash_directory); |
182 web::WebThread::PostBlockingPoolTask( | 182 base::PostTaskWithTraits( |
183 FROM_HERE, base::Bind(&DeleteAllReportsInDirectory, crash_directory)); | 183 FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND}, |
| 184 base::BindOnce(&DeleteAllReportsInDirectory, crash_directory)); |
184 } | 185 } |
185 | 186 |
186 void AddReportParameter(NSString* key, NSString* value, bool async) { | 187 void AddReportParameter(NSString* key, NSString* value, bool async) { |
187 if (!g_crash_reporter_enabled) | 188 if (!g_crash_reporter_enabled) |
188 return; | 189 return; |
189 if (async) { | 190 if (async) { |
190 [[BreakpadController sharedInstance] addUploadParameter:value forKey:key]; | 191 [[BreakpadController sharedInstance] addUploadParameter:value forKey:key]; |
191 return; | 192 return; |
192 } | 193 } |
193 dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); | 194 dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 void RestoreDefaultConfiguration() { | 351 void RestoreDefaultConfiguration() { |
351 if (!g_crash_reporter_enabled) | 352 if (!g_crash_reporter_enabled) |
352 return; | 353 return; |
353 [[BreakpadController sharedInstance] stop]; | 354 [[BreakpadController sharedInstance] stop]; |
354 [[BreakpadController sharedInstance] resetConfiguration]; | 355 [[BreakpadController sharedInstance] resetConfiguration]; |
355 [[BreakpadController sharedInstance] start:NO]; | 356 [[BreakpadController sharedInstance] start:NO]; |
356 [[BreakpadController sharedInstance] setUploadingEnabled:NO]; | 357 [[BreakpadController sharedInstance] setUploadingEnabled:NO]; |
357 } | 358 } |
358 | 359 |
359 } // namespace breakpad_helper | 360 } // namespace breakpad_helper |
OLD | NEW |