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

Unified Diff: base/message_pump_mac.mm

Issue 3805: autorelease message pumps (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/message_pump_libevent.cc ('k') | base/platform_test_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_pump_mac.mm
===================================================================
--- base/message_pump_mac.mm (revision 2601)
+++ base/message_pump_mac.mm (working copy)
@@ -8,6 +8,8 @@
#import <Foundation/Foundation.h>
#include <float.h>
+#include "base/scoped_nsautorelease_pool.h"
+
namespace {
void NoOp(void* info) {
@@ -216,7 +218,13 @@
int last_innermost_quittable = innermost_quittable_;
innermost_quittable_ = nesting_level_ + 1;
- CFRunLoopRun();
+ // This is completely identical to calling CFRunLoopRun(), except autorelease
+ // pool management is introduced.
+ int result;
+ do {
+ ScopedNSAutoreleasePool autorelease_pool;
+ result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, DBL_MAX, false);
+ } while (result != kCFRunLoopRunStopped && result != kCFRunLoopRunFinished);
// Restore the previous state of the object.
innermost_quittable_ = last_innermost_quittable;
@@ -315,7 +323,7 @@
} else {
running_own_loop_ = true;
while (keep_running_) {
- NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
+ ScopedNSAutoreleasePool autorelease_pool;
NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
untilDate:[NSDate distantFuture]
inMode:NSDefaultRunLoopMode
@@ -323,7 +331,6 @@
if (event) {
[NSApp sendEvent:event];
}
- [autorelease_pool drain];
}
keep_running_ = true;
}
« no previous file with comments | « base/message_pump_libevent.cc ('k') | base/platform_test_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698