summaryrefslogtreecommitdiffstats
path: root/chrome/browser
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 /chrome/browser
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 'chrome/browser')
-rw-r--r--chrome/browser/app_controller_mac.mm1
-rw-r--r--chrome/browser/browser_list.cc4
-rw-r--r--chrome/browser/browser_main_mac.mm13
-rw-r--r--chrome/browser/chrome_application_mac.h42
-rw-r--r--chrome/browser/chrome_browser_application_mac.h39
-rw-r--r--chrome/browser/chrome_browser_application_mac.mm (renamed from chrome/browser/chrome_application_mac.mm)27
-rw-r--r--chrome/browser/chrome_browser_application_mac_unittest.mm (renamed from chrome/browser/chrome_application_mac_unittest.mm)6
-rw-r--r--chrome/browser/cocoa/cocoa_test_helper.h12
-rw-r--r--chrome/browser/cocoa/cocoa_test_helper.mm3
9 files changed, 62 insertions, 85 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index 50973f6..d24cd7a 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -16,7 +16,6 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/browser_window.h"
-#import "chrome/browser/chrome_application_mac.h"
#import "chrome/browser/cocoa/about_window_controller.h"
#import "chrome/browser/cocoa/bookmark_menu_bridge.h"
#import "chrome/browser/cocoa/browser_window_cocoa.h"
diff --git a/chrome/browser/browser_list.cc b/chrome/browser/browser_list.cc
index dd7b9dc..f32ffdd 100644
--- a/chrome/browser/browser_list.cc
+++ b/chrome/browser/browser_list.cc
@@ -19,7 +19,7 @@
#include "chrome/common/result_codes.h"
#if defined(OS_MACOSX)
-#include "chrome/browser/chrome_application_mac.h"
+#include "chrome/browser/chrome_browser_application_mac.h"
#endif
namespace {
@@ -238,7 +238,7 @@ void BrowserList::CloseAllBrowsersAndExit() {
// On the Mac, the application continues to run once all windows are closed.
// Terminate will result in a CloseAllBrowsers(true) call, and additionally,
// will cause the application to exit cleanly.
- CrApplicationCC::Terminate();
+ chrome_browser_application_mac::Terminate();
#endif
}
diff --git a/chrome/browser/browser_main_mac.mm b/chrome/browser/browser_main_mac.mm
index ce5893b..65b6970 100644
--- a/chrome/browser/browser_main_mac.mm
+++ b/chrome/browser/browser_main_mac.mm
@@ -13,7 +13,7 @@
#import "chrome/app/keystone_glue.h"
#import "chrome/browser/app_controller_mac.h"
#include "chrome/browser/browser_main_win.h"
-#import "chrome/browser/chrome_application_mac.h"
+#import "chrome/browser/chrome_browser_application_mac.h"
#include "chrome/browser/metrics/metrics_service.h"
#include "chrome/common/main_function_params.h"
#include "chrome/common/result_codes.h"
@@ -28,15 +28,8 @@ namespace Platform {
// MessageLoop API, which works out ok for us because it's a wrapper around
// CFRunLoop.
void WillInitializeMainMessageLoop(const MainFunctionParams& parameters) {
- // Initialize NSApplication using the custom subclass. Check whether NSApp
- // was already initialized using another class, because that would break
- // some things.
- [CrApplication sharedApplication];
- if (![NSApp isKindOfClass:[CrApplication class]]) {
- LOG(ERROR) << "NSApp should be of type CrApplication, not "
- << [[NSApp className] UTF8String];
- DCHECK(false) << "NSApp is of wrong type";
- }
+ // Initialize NSApplication using the custom subclass.
+ [BrowserCrApplication sharedApplication];
// Before we load the nib, we need to start up the resource bundle so we have
// the strings avaiable for localization.
diff --git a/chrome/browser/chrome_application_mac.h b/chrome/browser/chrome_application_mac.h
deleted file mode 100644
index 60b6438..0000000
--- a/chrome/browser/chrome_application_mac.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// 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.
-
-#ifndef CHROME_BROWSER_CHROME_APPLICATION_MAC_H_
-#define CHROME_BROWSER_CHROME_APPLICATION_MAC_H_
-
-#ifdef __OBJC__
-
-#import <AppKit/AppKit.h>
-
-@interface CrApplication : NSApplication
-@end
-
-// Namespace for exception-reporting helper functions. Exposed for
-// testing purposes.
-namespace CrApplicationNSException {
-
-// Bin for unknown exceptions.
-extern const size_t kUnknownNSException;
-
-// Returns the histogram bin for |exception| if it is one we track
-// specifically, or |kUnknownNSException| if unknown.
-size_t BinForException(NSException* exception);
-
-// Use UMA to track exception occurance.
-void RecordExceptionWithUma(NSException* exception);
-
-} // CrApplicationNSException
-
-#endif // __OBJC__
-
-// CrApplicationCC provides access to CrApplication Objective-C selectors from
-// C++ code.
-namespace CrApplicationCC {
-
-// Calls -[NSApp terminate:].
-void Terminate();
-
-} // namespace CrApplicationCC
-
-#endif // CHROME_BROWSER_CHROME_APPLICATION_MAC_H_
diff --git a/chrome/browser/chrome_browser_application_mac.h b/chrome/browser/chrome_browser_application_mac.h
new file mode 100644
index 0000000..9a1ab9e
--- /dev/null
+++ b/chrome/browser/chrome_browser_application_mac.h
@@ -0,0 +1,39 @@
+// 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.
+
+#ifndef CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_
+#define CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_
+
+#ifdef __OBJC__
+
+#import "base/chrome_application_mac.h"
+
+@interface BrowserCrApplication : CrApplication
+@end
+
+namespace chrome_browser_application_mac {
+
+// Bin for unknown exceptions. Exposed for testing purposes.
+extern const size_t kUnknownNSException;
+
+// Returns the histogram bin for |exception| if it is one we track
+// specifically, or |kUnknownNSException| if unknown. Exposed for testing
+// purposes.
+size_t BinForException(NSException* exception);
+
+// Use UMA to track exception occurance. Exposed for testing purposes.
+void RecordExceptionWithUma(NSException* exception);
+
+} // namespace chrome_browser_application_mac
+
+#endif // __OBJC__
+
+namespace chrome_browser_application_mac {
+
+// Calls -[NSApp terminate:].
+void Terminate();
+
+} // namespace chrome_browser_application_mac
+
+#endif // CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_
diff --git a/chrome/browser/chrome_application_mac.mm b/chrome/browser/chrome_browser_application_mac.mm
index 94c975b..57c6fab 100644
--- a/chrome/browser/chrome_application_mac.mm
+++ b/chrome/browser/chrome_browser_application_mac.mm
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#import "chrome/browser/chrome_application_mac.h"
+#import "chrome/browser/chrome_browser_application_mac.h"
#import "base/histogram.h"
#import "base/logging.h"
@@ -11,7 +11,6 @@
#import "chrome/app/breakpad_mac.h"
#import "chrome/browser/cocoa/chrome_event_processing_window.h"
#import "chrome/browser/cocoa/objc_method_swizzle.h"
-#import "chrome/browser/renderer_host/render_widget_host_view_mac.h"
// The implementation of NSExceptions break various assumptions in the
// Chrome code. This category defines a replacement for
@@ -49,7 +48,7 @@ static IMP gOriginalInitIMP = NULL;
}
@end
-namespace CrApplicationNSException {
+namespace chrome_browser_application_mac {
// Maximum number of known named exceptions we'll support. There is
// no central registration, but I only find about 75 possibilities in
@@ -99,7 +98,11 @@ void RecordExceptionWithUma(NSException* exception) {
histogram.Add(BinForException(exception));
}
-} // CrApplicationNSException
+void Terminate() {
+ [NSApp terminate:nil];
+}
+
+} // namespace chrome_browser_application_mac
namespace {
@@ -133,12 +136,9 @@ BOOL SwizzleNSExceptionInit() {
} // namespace
-@implementation CrApplication
+@implementation BrowserCrApplication
- init {
- // TODO(shess): Push this somewhere where it can apply to the plugin
- // and renderer processes, and where it can intercept uncaught
- // exceptions.
DCHECK(SwizzleNSExceptionInit());
return [super init];
}
@@ -244,6 +244,7 @@ BOOL SwizzleNSExceptionInit() {
}
- (void)sendEvent:(NSEvent*)event {
+ chrome_application_mac::ScopedSendingEvent scoper(self);
// The superclass's |sendEvent:| sends keyboard events to the menu and the key
// view loop before dispatching them to |keyDown:|. Since we want to send keys
// to the renderer before sending them to the menu, and we never want them to
@@ -269,7 +270,7 @@ BOOL SwizzleNSExceptionInit() {
DCHECK(!reportingException);
if (!reportingException) {
reportingException = YES;
- CrApplicationNSException::RecordExceptionWithUma(anException);
+ chrome_browser_application_mac::RecordExceptionWithUma(anException);
// Store some human-readable information in breakpad keys in case
// there is a crash. Since breakpad does not provide infinite
@@ -306,11 +307,3 @@ BOOL SwizzleNSExceptionInit() {
}
@end
-
-namespace CrApplicationCC {
-
-void Terminate() {
- [NSApp terminate:nil];
-}
-
-} // namespace CrApplicationCC
diff --git a/chrome/browser/chrome_application_mac_unittest.mm b/chrome/browser/chrome_browser_application_mac_unittest.mm
index dbc1d90..7fc134e 100644
--- a/chrome/browser/chrome_application_mac_unittest.mm
+++ b/chrome/browser/chrome_browser_application_mac_unittest.mm
@@ -5,10 +5,10 @@
#import <Cocoa/Cocoa.h>
#include "base/histogram.h"
-#import "chrome/browser/chrome_application_mac.h"
+#import "chrome/browser/chrome_browser_application_mac.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace CrApplicationNSException {
+namespace chrome_browser_application_mac {
// Generate an NSException with the given name.
NSException* ExceptionNamed(NSString* name) {
@@ -78,4 +78,4 @@ TEST(ChromeApplicationMacTest, RecordException) {
EXPECT_EQ(4, sample.counts(kUnknownNSException));
}
-} // CrApplicationNSException
+} // chrome_browser_application_mac
diff --git a/chrome/browser/cocoa/cocoa_test_helper.h b/chrome/browser/cocoa/cocoa_test_helper.h
index 5b05505..5f51c54 100644
--- a/chrome/browser/cocoa/cocoa_test_helper.h
+++ b/chrome/browser/cocoa/cocoa_test_helper.h
@@ -8,6 +8,7 @@
#import <Cocoa/Cocoa.h>
#include <vector>
+#import "base/chrome_application_mac.h"
#include "base/debug_util.h"
#include "base/file_path.h"
#include "base/mac_util.h"
@@ -138,14 +139,7 @@ class CocoaTest : public PlatformTest {
class CocoaNoWindowTestHelper {
public:
CocoaNoWindowTestHelper() {
- // Look in the framework bundle for resources.
- FilePath path;
- PathService::Get(base::DIR_EXE, &path);
- path = path.Append(chrome::kFrameworkName);
- mac_util::SetOverrideAppBundlePath(path);
-
- // Bootstrap Cocoa. It's very unhappy without this.
- [NSApplication sharedApplication];
+ CocoaTest::BootstrapCocoa();
// Set the duration of AppKit-evaluated animations (such as frame changes)
// to zero for testing purposes. That way they take effect immediately.
@@ -155,7 +149,7 @@ class CocoaNoWindowTestHelper {
// DEPRECATED
// TODO(dmaclach): remove as soon as I can get my other CLs in that get rid
-// of any dependencies on this. 10/30/09 at the latest.
+// of any dependencies on this. 11/30/09 at the latest.
class CocoaTestHelper : public CocoaNoWindowTestHelper {
public:
CocoaTestHelper() {
diff --git a/chrome/browser/cocoa/cocoa_test_helper.mm b/chrome/browser/cocoa/cocoa_test_helper.mm
index 462b10a..17bba55 100644
--- a/chrome/browser/cocoa/cocoa_test_helper.mm
+++ b/chrome/browser/cocoa/cocoa_test_helper.mm
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#import "chrome/browser/cocoa/cocoa_test_helper.h"
+#import "chrome/browser/chrome_browser_application_mac.h"
#import "base/logging.h"
@implementation CocoaTestHelperWindow
@@ -68,7 +69,7 @@ void CocoaTest::BootstrapCocoa() {
mac_util::SetOverrideAppBundlePath(path);
// Bootstrap Cocoa. It's very unhappy without this.
- [NSApplication sharedApplication];
+ [CrApplication sharedApplication];
}
void CocoaTest::TearDown() {