OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/mac/scoped_nsexception_enabler.h" | 8 #import "base/mac/scoped_nsexception_enabler.h" |
9 #import "base/metrics/histogram.h" | 9 #import "base/metrics/histogram.h" |
10 #import "base/memory/scoped_nsobject.h" | 10 #import "base/memory/scoped_nsobject.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 // -[NSException raise] when DCHECK() is turned on (as opposed to | 189 // -[NSException raise] when DCHECK() is turned on (as opposed to |
190 // replicating the preprocess logic which turns DCHECK() on). | 190 // replicating the preprocess logic which turns DCHECK() on). |
191 BOOL SwizzleNSExceptionInit() { | 191 BOOL SwizzleNSExceptionInit() { |
192 gOriginalInitIMP = ObjcEvilDoers::SwizzleImplementedInstanceMethods( | 192 gOriginalInitIMP = ObjcEvilDoers::SwizzleImplementedInstanceMethods( |
193 [NSException class], | 193 [NSException class], |
194 @selector(initWithName:reason:userInfo:), | 194 @selector(initWithName:reason:userInfo:), |
195 @selector(chromeInitWithName:reason:userInfo:)); | 195 @selector(chromeInitWithName:reason:userInfo:)); |
196 return YES; | 196 return YES; |
197 } | 197 } |
198 | 198 |
199 // Failures for purposes of monitoring success setting up zombies. | |
200 enum ZombieFailure { | |
201 FAILED_10_5, | |
202 FAILED_10_6, | |
203 | |
204 // Add new versions before here. | |
205 FAILED_MAX, | |
206 }; | |
207 | |
208 void RecordZombieFailure(ZombieFailure failure) { | |
209 UMA_HISTOGRAM_ENUMERATION("OSX.ZombieEnableFailure", failure, FAILED_MAX); | |
Mark Mentovai
2011/06/07 21:42:57
I don’t remember if you need to edit some file to
Scott Hess - ex-Googler
2011/06/07 23:48:21
They're reported as hashes, so you need to tell an
| |
210 } | |
211 | |
199 } // namespace | 212 } // namespace |
200 | 213 |
201 @implementation BrowserCrApplication | 214 @implementation BrowserCrApplication |
202 | 215 |
203 + (void)initialize { | 216 + (void)initialize { |
204 // Whitelist releases that are compatible with objc zombies. | 217 // Whitelist releases that are compatible with objc zombies. |
205 int32 major_version = 0, minor_version = 0, bugfix_version = 0; | 218 int32 major_version = 0, minor_version = 0, bugfix_version = 0; |
206 base::SysInfo::OperatingSystemVersionNumbers( | 219 base::SysInfo::OperatingSystemVersionNumbers( |
207 &major_version, &minor_version, &bugfix_version); | 220 &major_version, &minor_version, &bugfix_version); |
208 if (major_version == 10 && (minor_version == 5 || minor_version == 6)) { | 221 |
209 // Turn all deallocated Objective-C objects into zombies, keeping | 222 // Turn all deallocated Objective-C objects into zombies, keeping |
210 // the most recent 10,000 of them on the treadmill. | 223 // the most recent 10,000 of them on the treadmill. |
211 ObjcEvilDoers::ZombieEnable(YES, 10000); | 224 static const size_t kTreadmillSize = 10000; |
225 if (major_version == 10) { | |
226 if (minor_version == 5) { | |
227 if (!ObjcEvilDoers::ZombieEnable(ObjcEvilDoers::RUNTIME_10_5, YES, | |
228 kTreadmillSize)) { | |
229 RecordZombieFailure(FAILED_10_5); | |
230 } | |
231 } else if (minor_version == 6) { | |
232 if (!ObjcEvilDoers::ZombieEnable(ObjcEvilDoers::RUNTIME_10_6, YES, | |
233 kTreadmillSize)) { | |
234 RecordZombieFailure(FAILED_10_6); | |
235 } | |
236 } else if (minor_version > 6) { | |
237 // Assume the future looks like the present. | |
238 if (!ObjcEvilDoers::ZombieEnable(ObjcEvilDoers::RUNTIME_10_6, YES, | |
239 kTreadmillSize)) { | |
240 // Put all future failures into the MAX bin. New OS releases | |
241 // come out infrequently enough that this should always | |
242 // correspond to "Next release", and once the next release | |
243 // happens that bin will get an official name. | |
244 RecordZombieFailure(FAILED_MAX); | |
245 } | |
246 } | |
Scott Hess - ex-Googler
2011/06/07 21:24:51
I am not really happy with this code. But it wasn
Mark Mentovai
2011/06/07 21:42:57
shess wrote:
| |
212 } | 247 } |
213 } | 248 } |
214 | 249 |
215 - init { | 250 - init { |
216 CHECK(SwizzleNSExceptionInit()); | 251 CHECK(SwizzleNSExceptionInit()); |
217 return [super init]; | 252 return [super init]; |
218 } | 253 } |
219 | 254 |
220 //////////////////////////////////////////////////////////////////////////////// | 255 //////////////////////////////////////////////////////////////////////////////// |
221 // HISTORICAL COMMENT (by viettrungluu, from | 256 // HISTORICAL COMMENT (by viettrungluu, from |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
428 if (RenderViewHost* rvh = contents->render_view_host()) { | 463 if (RenderViewHost* rvh = contents->render_view_host()) { |
429 rvh->EnableRendererAccessibility(); | 464 rvh->EnableRendererAccessibility(); |
430 } | 465 } |
431 } | 466 } |
432 } | 467 } |
433 } | 468 } |
434 return [super accessibilitySetValue:value forAttribute:attribute]; | 469 return [super accessibilitySetValue:value forAttribute:attribute]; |
435 } | 470 } |
436 | 471 |
437 @end | 472 @end |
OLD | NEW |