OLD | NEW |
1 // Copyright (c) 2008 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 BASE_SCOPED_NSAUTORELEASE_POOL_H_ | 5 #ifndef BASE_MAC_SCOPED_NSAUTORELEASE_POOL_H_ |
6 #define BASE_SCOPED_NSAUTORELEASE_POOL_H_ | 6 #define BASE_MAC_SCOPED_NSAUTORELEASE_POOL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 | 10 |
11 #if defined(OS_MACOSX) | 11 #if defined(OS_MACOSX) |
12 #if defined(__OBJC__) | 12 #if defined(__OBJC__) |
13 @class NSAutoreleasePool; | 13 @class NSAutoreleasePool; |
14 #else // __OBJC__ | 14 #else // __OBJC__ |
15 class NSAutoreleasePool; | 15 class NSAutoreleasePool; |
16 #endif // __OBJC__ | 16 #endif // __OBJC__ |
17 #endif // OS_MACOSX | 17 #endif // OS_MACOSX |
18 | 18 |
19 namespace base { | 19 namespace base { |
| 20 namespace mac { |
20 | 21 |
21 // On the Mac, ScopedNSAutoreleasePool allocates an NSAutoreleasePool when | 22 // On the Mac, ScopedNSAutoreleasePool allocates an NSAutoreleasePool when |
22 // instantiated and sends it a -drain message when destroyed. This allows an | 23 // instantiated and sends it a -drain message when destroyed. This allows an |
23 // autorelease pool to be maintained in ordinary C++ code without bringing in | 24 // autorelease pool to be maintained in ordinary C++ code without bringing in |
24 // any direct Objective-C dependency. | 25 // any direct Objective-C dependency. |
25 // | 26 // |
26 // On other platforms, ScopedNSAutoreleasePool is an empty object with no | 27 // On other platforms, ScopedNSAutoreleasePool is an empty object with no |
27 // effects. This allows it to be used directly in cross-platform code without | 28 // effects. This allows it to be used directly in cross-platform code without |
28 // ugly #ifdefs. | 29 // ugly #ifdefs. |
29 class ScopedNSAutoreleasePool { | 30 class ScopedNSAutoreleasePool { |
(...skipping 11 matching lines...) Expand all Loading... |
41 // no longer needed. | 42 // no longer needed. |
42 void Recycle(); | 43 void Recycle(); |
43 private: | 44 private: |
44 NSAutoreleasePool* autorelease_pool_; | 45 NSAutoreleasePool* autorelease_pool_; |
45 #endif // OS_MACOSX | 46 #endif // OS_MACOSX |
46 | 47 |
47 private: | 48 private: |
48 DISALLOW_COPY_AND_ASSIGN(ScopedNSAutoreleasePool); | 49 DISALLOW_COPY_AND_ASSIGN(ScopedNSAutoreleasePool); |
49 }; | 50 }; |
50 | 51 |
| 52 } // namespace mac |
51 } // namespace base | 53 } // namespace base |
52 | 54 |
53 #endif // BASE_SCOPED_NSAUTORELEASE_POOL_H_ | 55 #endif // BASE_MAC_SCOPED_NSAUTORELEASE_POOL_H_ |
OLD | NEW |