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 BASE_MAC_SCOPED_NSAUTORELEASE_POOL_H_
6 #define BASE_MAC_SCOPED_NSAUTORELEASE_POOL_H_
8 #include "base/base_export.h"
9 #include "base/basictypes.h"
12 @
class NSAutoreleasePool
;
14 class NSAutoreleasePool
;
20 // ScopedNSAutoreleasePool allocates an NSAutoreleasePool when instantiated and
21 // sends it a -drain message when destroyed. This allows an autorelease pool to
22 // be maintained in ordinary C++ code without bringing in any direct Objective-C
25 class BASE_EXPORT ScopedNSAutoreleasePool
{
27 ScopedNSAutoreleasePool();
28 ~ScopedNSAutoreleasePool();
30 // Clear out the pool in case its position on the stack causes it to be
31 // alive for long periods of time (such as the entire length of the app).
32 // Only use then when you're certain the items currently in the pool are
36 NSAutoreleasePool
* autorelease_pool_
;
39 DISALLOW_COPY_AND_ASSIGN(ScopedNSAutoreleasePool
);
45 #endif // BASE_MAC_SCOPED_NSAUTORELEASE_POOL_H_