summaryrefslogtreecommitdiffstats
path: root/base/chrome_application_mac.mm
diff options
context:
space:
mode:
authordmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-05 21:53:01 +0000
committerdmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-05 21:53:01 +0000
commitaaa47ee9d83f773d37aa4fd4a04097425ce62063 (patch)
tree9250680ad28ed8c31fdb967b702e2b638bd80347 /base/chrome_application_mac.mm
parent0d6bb06531d9b7d68e6d78b79b4ec29e68a059cb (diff)
downloadchromium_src-aaa47ee9d83f773d37aa4fd4a04097425ce62063.zip
chromium_src-aaa47ee9d83f773d37aa4fd4a04097425ce62063.tar.gz
chromium_src-aaa47ee9d83f773d37aa4fd4a04097425ce62063.tar.bz2
Cleans up our autorelease pool handling by making sure that an autorelease pool isn't created while the app is handling an event sent via -[NSApp sendEvent].
Branches browser/chrome_application_mac into browser/chrome_browser_application and base/chrome_application. Renderers will run as chrome_applications, and browsers will run as chrome_browser_applications. BUG=26418, 25462, 25463, 25465 TEST=1) See bug 25857. 2) Start up. Open 3+ windows. 3)Quit. See bugs for other repro cases. Review URL: http://codereview.chromium.org/345051 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31135 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/chrome_application_mac.mm')
-rw-r--r--base/chrome_application_mac.mm49
1 files changed, 49 insertions, 0 deletions
diff --git a/base/chrome_application_mac.mm b/base/chrome_application_mac.mm
new file mode 100644
index 0000000..d2d8f9f
--- /dev/null
+++ b/base/chrome_application_mac.mm
@@ -0,0 +1,49 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "chrome_application_mac.h"
+
+#include "base/logging.h"
+
+@interface CrApplication ()
+@property(readwrite,
+ getter=isHandlingSendEvent,
+ nonatomic) BOOL handlingSendEvent;
+@end
+
+@implementation CrApplication
+@synthesize handlingSendEvent = handlingSendEvent_;
+
+// Initialize NSApplication using the custom subclass. Check whether NSApp
+// was already initialized using another class, because that would break
+// some things.
++ (NSApplication*)sharedApplication {
+ NSApplication* app = [super sharedApplication];
+ if (![NSApp isKindOfClass:self]) {
+ LOG(ERROR) << "NSApp should be of type " << [[self className] UTF8String]
+ << ", not " << [[NSApp className] UTF8String];
+ DCHECK(false) << "NSApp is of wrong type";
+ }
+ return app;
+}
+
+- (void)sendEvent:(NSEvent*)event {
+ chrome_application_mac::ScopedSendingEvent sendingEventScoper(self);
+ [super sendEvent:event];
+}
+
+@end
+
+namespace chrome_application_mac {
+
+ScopedSendingEvent::ScopedSendingEvent(CrApplication* app) : app_(app) {
+ handling_ = [app_ isHandlingSendEvent];
+ [app_ setHandlingSendEvent:YES];
+}
+
+ScopedSendingEvent::~ScopedSendingEvent() {
+ [app_ setHandlingSendEvent:handling_];
+}
+
+} // namespace chrome_application_mac