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/histogram.h" | 7 #import "base/histogram.h" |
8 #import "base/logging.h" | 8 #import "base/logging.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" |
11 #import "chrome/app/breakpad_mac.h" | 11 #import "chrome/app/breakpad_mac.h" |
12 #import "chrome/browser/app_controller_mac.h" | 12 #import "chrome/browser/app_controller_mac.h" |
13 #import "chrome/browser/cocoa/objc_method_swizzle.h" | 13 #import "chrome/browser/cocoa/objc_method_swizzle.h" |
| 14 #import "chrome/browser/cocoa/objc_zombie.h" |
14 | 15 |
15 // The implementation of NSExceptions break various assumptions in the | 16 // The implementation of NSExceptions break various assumptions in the |
16 // Chrome code. This category defines a replacement for | 17 // Chrome code. This category defines a replacement for |
17 // -initWithName:reason:userInfo: for purposes of forcing a break in | 18 // -initWithName:reason:userInfo: for purposes of forcing a break in |
18 // the debugger when an exception is raised. -raise sounds more | 19 // the debugger when an exception is raised. -raise sounds more |
19 // obvious to intercept, but it doesn't catch the original throw | 20 // obvious to intercept, but it doesn't catch the original throw |
20 // because the objc runtime doesn't use it. | 21 // because the objc runtime doesn't use it. |
21 @interface NSException (NSExceptionSwizzle) | 22 @interface NSException (NSExceptionSwizzle) |
22 - (id)chromeInitWithName:(NSString *)aName | 23 - (id)chromeInitWithName:(NSString *)aName |
23 reason:(NSString *)aReason | 24 reason:(NSString *)aReason |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 [NSException class], | 155 [NSException class], |
155 @selector(initWithName:reason:userInfo:), | 156 @selector(initWithName:reason:userInfo:), |
156 @selector(chromeInitWithName:reason:userInfo:)); | 157 @selector(chromeInitWithName:reason:userInfo:)); |
157 return YES; | 158 return YES; |
158 } | 159 } |
159 | 160 |
160 } // namespace | 161 } // namespace |
161 | 162 |
162 @implementation BrowserCrApplication | 163 @implementation BrowserCrApplication |
163 | 164 |
| 165 + (void)initialize { |
| 166 // Turn all deallocated Objective-C objects into zombies, keeping |
| 167 // the most recent 10,000 of them on the treadmill. |
| 168 DCHECK(ObjcEvilDoers::ZombieEnable(YES, 10000)); |
| 169 } |
| 170 |
164 - init { | 171 - init { |
165 DCHECK(SwizzleNSExceptionInit()); | 172 DCHECK(SwizzleNSExceptionInit()); |
166 return [super init]; | 173 return [super init]; |
167 } | 174 } |
168 | 175 |
169 //////////////////////////////////////////////////////////////////////////////// | 176 //////////////////////////////////////////////////////////////////////////////// |
170 // HISTORICAL COMMENT (by viettrungluu, from | 177 // HISTORICAL COMMENT (by viettrungluu, from |
171 // http://codereview.chromium.org/1520006 with mild editing): | 178 // http://codereview.chromium.org/1520006 with mild editing): |
172 // | 179 // |
173 // A quick summary of the state of things (before the changes to shutdown): | 180 // A quick summary of the state of things (before the changes to shutdown): |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 SetCrashKeyValue(kLastExceptionKey, value); | 338 SetCrashKeyValue(kLastExceptionKey, value); |
332 } | 339 } |
333 | 340 |
334 reportingException = NO; | 341 reportingException = NO; |
335 } | 342 } |
336 | 343 |
337 [super reportException:anException]; | 344 [super reportException:anException]; |
338 } | 345 } |
339 | 346 |
340 @end | 347 @end |
OLD | NEW |