| OLD | NEW |
| 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_UI_COCOA_NSOBJECT_ZOMBIE_H_ | 5 #ifndef CHROME_COMMON_MAC_OBJC_ZOMBIE_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_NSOBJECT_ZOMBIE_H_ | 6 #define CHROME_COMMON_MAC_OBJC_ZOMBIE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #import <Foundation/Foundation.h> | 9 #include "base/basictypes.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 // Enable zombie object debugging. This implements a variant of Apple's | 15 // Enable zombie object debugging. This implements a variant of Apple's |
| 16 // NSZombieEnabled which can help expose use-after-free errors where messages | 16 // NSZombieEnabled which can help expose use-after-free errors where messages |
| 17 // are sent to freed Objective-C objects in production builds. | 17 // are sent to freed Objective-C objects in production builds. |
| 18 // | 18 // |
| 19 // Returns NO if it fails to enable. | 19 // Returns NO if it fails to enable. |
| 20 // | 20 // |
| 21 // When |zombieAllObjects| is YES, all objects inheriting from | 21 // When |zombieAllObjects| is YES, all objects inheriting from |
| 22 // NSObject become zombies on -dealloc. If NO, -shouldBecomeCrZombie | 22 // NSObject become zombies on -dealloc. If NO, -shouldBecomeCrZombie |
| 23 // is queried to determine whether to make the object a zombie. | 23 // is queried to determine whether to make the object a zombie. |
| 24 // | 24 // |
| 25 // |zombieCount| controls how many zombies to store before freeing the | 25 // |zombieCount| controls how many zombies to store before freeing the |
| 26 // oldest. Set to 0 to free objects immediately after making them | 26 // oldest. Set to 0 to free objects immediately after making them |
| 27 // zombies. | 27 // zombies. |
| 28 BOOL ZombieEnable(BOOL zombieAllObjects, size_t zombieCount); | 28 bool ZombieEnable(bool zombieAllObjects, size_t zombieCount); |
| 29 | 29 |
| 30 // Disable zombies. | 30 // Disable zombies. |
| 31 void ZombieDisable(); | 31 void ZombieDisable(); |
| 32 | 32 |
| 33 } // namespace ObjcEvilDoers | 33 } // namespace ObjcEvilDoers |
| 34 | 34 |
| 35 #if defined(OS_MACOSX) |
| 36 #if defined(__OBJC__) |
| 37 |
| 38 #import <Foundation/Foundation.h> |
| 39 |
| 35 @interface NSObject (CrZombie) | 40 @interface NSObject (CrZombie) |
| 36 - (BOOL)shouldBecomeCrZombie; | 41 - (BOOL)shouldBecomeCrZombie; |
| 37 @end | 42 @end |
| 38 | 43 |
| 39 #endif // CHROME_BROWSER_UI_COCOA_NSOBJECT_ZOMBIE_H_ | 44 #endif // __OBJC__ |
| 45 #endif // OS_MACOSX |
| 46 |
| 47 #endif // CHROME_COMMON_MAC_OBJC_ZOMBIE_H_ |
| OLD | NEW |