Roll src/third_party/WebKit 6f84130:7353389 (svn 184386:184391)
[chromium-blink-merge.git] / chrome / common / mac / objc_zombie.h
blob1cfae5655b1e96a538cea38bb22112283d34e201
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
3 // found in the LICENSE file.
5 #ifndef CHROME_COMMON_MAC_OBJC_ZOMBIE_H_
6 #define CHROME_COMMON_MAC_OBJC_ZOMBIE_H_
8 #include "base/basictypes.h"
10 // You should think twice every single time you use anything from this
11 // namespace.
12 namespace ObjcEvilDoers {
14 // Enable zombie object debugging. This implements a variant of Apple's
15 // NSZombieEnabled which can help expose use-after-free errors where messages
16 // are sent to freed Objective-C objects in production builds.
18 // Returns NO if it fails to enable.
20 // When |zombieAllObjects| is YES, all objects inheriting from
21 // NSObject become zombies on -dealloc. If NO, -shouldBecomeCrZombie
22 // is queried to determine whether to make the object a zombie.
24 // |zombieCount| controls how many zombies to store before freeing the
25 // oldest. Set to 0 to free objects immediately after making them
26 // zombies.
27 bool ZombieEnable(bool zombieAllObjects, size_t zombieCount);
29 // Disable zombies.
30 void ZombieDisable();
32 } // namespace ObjcEvilDoers
34 #if defined(OS_MACOSX)
35 #if defined(__OBJC__)
37 #import <Foundation/Foundation.h>
39 @interface NSObject (CrZombie)
40 - (BOOL)shouldBecomeCrZombie;
41 @end
43 #endif // __OBJC__
44 #endif // OS_MACOSX
46 #endif // CHROME_COMMON_MAC_OBJC_ZOMBIE_H_