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 #ifndef CHROME_BROWSER_UI_COCOA_NSOBJECT_ZOMBIE_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_NSOBJECT_ZOMBIE_H_ |
6 #define CHROME_BROWSER_UI_COCOA_NSOBJECT_ZOMBIE_H_ | 6 #define CHROME_BROWSER_UI_COCOA_NSOBJECT_ZOMBIE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #import <Foundation/Foundation.h> | 9 #import <Foundation/Foundation.h> |
10 | 10 |
11 // You should think twice every single time you use anything from this | 11 // You should think twice every single time you use anything from this |
12 // namespace. | 12 // namespace. |
13 namespace ObjcEvilDoers { | 13 namespace ObjcEvilDoers { |
14 | 14 |
15 // Which version of the runtime to expect when initializing. This | |
16 // decision is left to the caller so that unit tests and production | |
17 // uses can make different decisions. | |
18 enum Runtime { | |
19 RUNTIME_GUESS, | |
Mark Mentovai
2011/06/07 21:42:57
This is only used in test code. Seems like you dup
Scott Hess - ex-Googler
2011/06/07 23:48:21
RUNTIME_10_x is for the specific runtime, while RU
| |
20 RUNTIME_10_5, | |
21 RUNTIME_10_6, | |
22 }; | |
23 | |
15 // Enable zombie object debugging. This implements a variant of Apple's | 24 // Enable zombie object debugging. This implements a variant of Apple's |
16 // NSZombieEnabled which can help expose use-after-free errors where messages | 25 // NSZombieEnabled which can help expose use-after-free errors where messages |
17 // are sent to freed Objective-C objects in production builds. | 26 // are sent to freed Objective-C objects in production builds. |
18 // | 27 // |
19 // Returns NO if it fails to enable. | 28 // Returns NO if it fails to enable. |
20 // | 29 // |
21 // When |zombieAllObjects| is YES, all objects inheriting from | 30 // When |zombieAllObjects| is YES, all objects inheriting from |
22 // NSObject become zombies on -dealloc. If NO, -shouldBecomeCrZombie | 31 // NSObject become zombies on -dealloc. If NO, -shouldBecomeCrZombie |
23 // is queried to determine whether to make the object a zombie. | 32 // is queried to determine whether to make the object a zombie. |
24 // | 33 // |
25 // |zombieCount| controls how many zombies to store before freeing the | 34 // |zombieCount| controls how many zombies to store before freeing the |
26 // oldest. Set to 0 to free objects immediately after making them | 35 // oldest. Set to 0 to free objects immediately after making them |
27 // zombies. | 36 // zombies. |
28 BOOL ZombieEnable(BOOL zombieAllObjects, size_t zombieCount); | 37 BOOL ZombieEnable(Runtime runtime, BOOL zombieAllObjects, size_t zombieCount); |
29 | 38 |
30 // Disable zombies. | 39 // Disable zombies. |
31 void ZombieDisable(); | 40 void ZombieDisable(); |
32 | 41 |
33 } // namespace ObjcEvilDoers | 42 } // namespace ObjcEvilDoers |
34 | 43 |
35 @interface NSObject (CrZombie) | 44 @interface NSObject (CrZombie) |
36 - (BOOL)shouldBecomeCrZombie; | 45 - (BOOL)shouldBecomeCrZombie; |
37 @end | 46 @end |
38 | 47 |
39 #endif // CHROME_BROWSER_UI_COCOA_NSOBJECT_ZOMBIE_H_ | 48 #endif // CHROME_BROWSER_UI_COCOA_NSOBJECT_ZOMBIE_H_ |
OLD | NEW |