Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(441)

Side by Side Diff: base/mac/scoped_nsautorelease_pool.h

Issue 7474010: mac: Components build for base, easy part (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/mac/os_crash_dumps.h ('k') | base/mac/scoped_nsexception_enabler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 BASE_MAC_SCOPED_NSAUTORELEASE_POOL_H_ 5 #ifndef BASE_MAC_SCOPED_NSAUTORELEASE_POOL_H_
6 #define BASE_MAC_SCOPED_NSAUTORELEASE_POOL_H_ 6 #define BASE_MAC_SCOPED_NSAUTORELEASE_POOL_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/base_api.h"
9 #include "base/basictypes.h" 10 #include "base/basictypes.h"
10 11
11 #if defined(OS_MACOSX) 12 #if defined(OS_MACOSX)
12 #if defined(__OBJC__) 13 #if defined(__OBJC__)
13 @class NSAutoreleasePool; 14 @class NSAutoreleasePool;
14 #else // __OBJC__ 15 #else // __OBJC__
15 class NSAutoreleasePool; 16 class NSAutoreleasePool;
16 #endif // __OBJC__ 17 #endif // __OBJC__
17 #endif // OS_MACOSX 18 #endif // OS_MACOSX
18 19
19 namespace base { 20 namespace base {
20 namespace mac { 21 namespace mac {
21 22
22 // On the Mac, ScopedNSAutoreleasePool allocates an NSAutoreleasePool when 23 // On the Mac, ScopedNSAutoreleasePool allocates an NSAutoreleasePool when
23 // instantiated and sends it a -drain message when destroyed. This allows an 24 // instantiated and sends it a -drain message when destroyed. This allows an
24 // autorelease pool to be maintained in ordinary C++ code without bringing in 25 // autorelease pool to be maintained in ordinary C++ code without bringing in
25 // any direct Objective-C dependency. 26 // any direct Objective-C dependency.
26 // 27 //
27 // On other platforms, ScopedNSAutoreleasePool is an empty object with no 28 // On other platforms, ScopedNSAutoreleasePool is an empty object with no
28 // effects. This allows it to be used directly in cross-platform code without 29 // effects. This allows it to be used directly in cross-platform code without
29 // ugly #ifdefs. 30 // ugly #ifdefs.
30 class ScopedNSAutoreleasePool { 31 class BASE_API ScopedNSAutoreleasePool {
31 public: 32 public:
32 #if !defined(OS_MACOSX) 33 #if !defined(OS_MACOSX)
33 ScopedNSAutoreleasePool() {} 34 ScopedNSAutoreleasePool() {}
34 void Recycle() { } 35 void Recycle() { }
35 #else // OS_MACOSX 36 #else // OS_MACOSX
36 ScopedNSAutoreleasePool(); 37 ScopedNSAutoreleasePool();
37 ~ScopedNSAutoreleasePool(); 38 ~ScopedNSAutoreleasePool();
38 39
39 // Clear out the pool in case its position on the stack causes it to be 40 // Clear out the pool in case its position on the stack causes it to be
40 // alive for long periods of time (such as the entire length of the app). 41 // alive for long periods of time (such as the entire length of the app).
41 // Only use then when you're certain the items currently in the pool are 42 // Only use then when you're certain the items currently in the pool are
42 // no longer needed. 43 // no longer needed.
43 void Recycle(); 44 void Recycle();
44 private: 45 private:
45 NSAutoreleasePool* autorelease_pool_; 46 NSAutoreleasePool* autorelease_pool_;
46 #endif // OS_MACOSX 47 #endif // OS_MACOSX
47 48
48 private: 49 private:
49 DISALLOW_COPY_AND_ASSIGN(ScopedNSAutoreleasePool); 50 DISALLOW_COPY_AND_ASSIGN(ScopedNSAutoreleasePool);
50 }; 51 };
51 52
52 } // namespace mac 53 } // namespace mac
53 } // namespace base 54 } // namespace base
54 55
55 #endif // BASE_MAC_SCOPED_NSAUTORELEASE_POOL_H_ 56 #endif // BASE_MAC_SCOPED_NSAUTORELEASE_POOL_H_
OLDNEW
« no previous file with comments | « base/mac/os_crash_dumps.h ('k') | base/mac/scoped_nsexception_enabler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698