| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/chrome_browser_application_mac.h" | 5 #import "chrome/browser/chrome_browser_application_mac.h" |
| 6 | 6 |
| 7 #import "base/logging.h" | 7 #import "base/logging.h" |
| 8 #import "base/metrics/histogram.h" | 8 #import "base/metrics/histogram.h" |
| 9 #import "base/scoped_nsobject.h" | 9 #import "base/scoped_nsobject.h" |
| 10 #import "base/sys_string_conversions.h" | 10 #import "base/sys_string_conversions.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 // Update breakpad with the exception info. | 57 // Update breakpad with the exception info. |
| 58 static NSString* const kNSExceptionKey = @"nsexception"; | 58 static NSString* const kNSExceptionKey = @"nsexception"; |
| 59 NSString* value = | 59 NSString* value = |
| 60 [NSString stringWithFormat:@"%@ reason %@", aName, aReason]; | 60 [NSString stringWithFormat:@"%@ reason %@", aName, aReason]; |
| 61 SetCrashKeyValue(kNSExceptionKey, value); | 61 SetCrashKeyValue(kNSExceptionKey, value); |
| 62 | 62 |
| 63 // Force crash for selected exceptions to generate crash dumps. | 63 // Force crash for selected exceptions to generate crash dumps. |
| 64 BOOL fatal = NO; | 64 BOOL fatal = NO; |
| 65 if (aName == NSInternalInconsistencyException) { | 65 if (aName == NSInternalInconsistencyException) { |
| 66 NSString* const kNSMenuItemArrayBoundsCheck = | 66 NSString* const kNSMenuItemArrayBoundsCheck = |
| 67 @"Invalid parameter not satisfying: (index >= 0) && (index < [_itemArr
ay count])"; | 67 @"Invalid parameter not satisfying: (index >= 0) && " |
| 68 @"(index < [_itemArray count])"; |
| 68 if ([aReason isEqualToString:kNSMenuItemArrayBoundsCheck]) { | 69 if ([aReason isEqualToString:kNSMenuItemArrayBoundsCheck]) { |
| 69 fatal = YES; | 70 fatal = YES; |
| 70 } | 71 } |
| 71 } | 72 } |
| 72 | 73 |
| 73 // Dear reader: Something you just did provoked an NSException. | 74 // Dear reader: Something you just did provoked an NSException. |
| 74 // NSException is implemented in terms of setjmp()/longjmp(), | 75 // NSException is implemented in terms of setjmp()/longjmp(), |
| 75 // which does poor things when combined with C++ scoping | 76 // which does poor things when combined with C++ scoping |
| 76 // (destructors are skipped). Chrome should be NSException-free, | 77 // (destructors are skipped). Chrome should be NSException-free, |
| 77 // please check your backtrace and see if you can't file a bug | 78 // please check your backtrace and see if you can't file a bug |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 135 } |
| 135 } | 136 } |
| 136 return kUnknownNSException; | 137 return kUnknownNSException; |
| 137 } | 138 } |
| 138 | 139 |
| 139 void RecordExceptionWithUma(NSException* exception) { | 140 void RecordExceptionWithUma(NSException* exception) { |
| 140 UMA_HISTOGRAM_ENUMERATION("OSX.NSException", | 141 UMA_HISTOGRAM_ENUMERATION("OSX.NSException", |
| 141 BinForException(exception), kUnknownNSException); | 142 BinForException(exception), kUnknownNSException); |
| 142 } | 143 } |
| 143 | 144 |
| 145 void RegisterBrowserCrApp() { |
| 146 [BrowserCrApplication sharedApplication]; |
| 147 }; |
| 148 |
| 144 void Terminate() { | 149 void Terminate() { |
| 145 [NSApp terminate:nil]; | 150 [NSApp terminate:nil]; |
| 146 } | 151 } |
| 147 | 152 |
| 148 void CancelTerminate() { | 153 void CancelTerminate() { |
| 149 [NSApp cancelTerminate:nil]; | 154 [NSApp cancelTerminate:nil]; |
| 150 } | 155 } |
| 151 | 156 |
| 152 } // namespace chrome_browser_application_mac | 157 } // namespace chrome_browser_application_mac |
| 153 | 158 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 SetCrashKeyValue(kLastExceptionKey, value); | 366 SetCrashKeyValue(kLastExceptionKey, value); |
| 362 } | 367 } |
| 363 | 368 |
| 364 reportingException = NO; | 369 reportingException = NO; |
| 365 } | 370 } |
| 366 | 371 |
| 367 [super reportException:anException]; | 372 [super reportException:anException]; |
| 368 } | 373 } |
| 369 | 374 |
| 370 @end | 375 @end |
| OLD | NEW |