summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-09 15:35:47 +0000
committerpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-09 15:35:47 +0000
commit7c32108b22446be27129324ce41d32e9c909e379 (patch)
tree2b18444c829ae9155036ef3c55ab1fb645b9621e /base
parent54131d25aa7e887f89ba25851b983150cd1384a8 (diff)
downloadchromium_src-7c32108b22446be27129324ce41d32e9c909e379.zip
chromium_src-7c32108b22446be27129324ce41d32e9c909e379.tar.gz
chromium_src-7c32108b22446be27129324ce41d32e9c909e379.tar.bz2
Add Recycle() method to scoped autorelease pool to allow cleaning out any junk
created at startup before the main runloop. Correct quit on Mac to let the BrowserProcess shut down the event loop when its refcount goes to zero after cleaning up all browser windows. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9386 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/scoped_nsautorelease_pool.h6
-rw-r--r--base/scoped_nsautorelease_pool.mm11
2 files changed, 17 insertions, 0 deletions
diff --git a/base/scoped_nsautorelease_pool.h b/base/scoped_nsautorelease_pool.h
index 0e779af..64bf9e7 100644
--- a/base/scoped_nsautorelease_pool.h
+++ b/base/scoped_nsautorelease_pool.h
@@ -29,10 +29,16 @@ class ScopedNSAutoreleasePool {
public:
#if !defined(OS_MACOSX)
ScopedNSAutoreleasePool() {}
+ void Recycle() { }
#else // OS_MACOSX
ScopedNSAutoreleasePool();
~ScopedNSAutoreleasePool();
+ // Clear out the pool in case its position on the stack causes it to be
+ // alive for long periods of time (such as the entire length of the app).
+ // Only use then when you're certain the items currently in the pool are
+ // no longer needed.
+ void Recycle();
private:
NSAutoreleasePool* autorelease_pool_;
#endif // OS_MACOSX
diff --git a/base/scoped_nsautorelease_pool.mm b/base/scoped_nsautorelease_pool.mm
index c4ae517..174fb82 100644
--- a/base/scoped_nsautorelease_pool.mm
+++ b/base/scoped_nsautorelease_pool.mm
@@ -6,14 +6,25 @@
#import <Foundation/Foundation.h>
+#include "base/logging.h"
+
namespace base {
ScopedNSAutoreleasePool::ScopedNSAutoreleasePool()
: autorelease_pool_([[NSAutoreleasePool alloc] init]) {
+ DCHECK(autorelease_pool_);
}
ScopedNSAutoreleasePool::~ScopedNSAutoreleasePool() {
[autorelease_pool_ drain];
}
+// Cycle the internal pool, allowing everything there to get cleaned up and
+// start anew.
+void ScopedNSAutoreleasePool::Recycle() {
+ [autorelease_pool_ drain];
+ autorelease_pool_ = [[NSAutoreleasePool alloc] init];
+ DCHECK(autorelease_pool_);
+}
+
} // namespace base