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

Unified Diff: chrome/browser/chrome_browser_application_mac.mm

Issue 345243007: Add ScopedObjCClassSwizzler in base/mac, absorbs objc_method_swizzle and ScopedClassSwizzler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Inlude in shiny new gn base_unittests target Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/mac/scoped_objc_class_swizzler_unittest.mm ('k') | chrome/chrome_common.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chrome_browser_application_mac.mm
diff --git a/chrome/browser/chrome_browser_application_mac.mm b/chrome/browser/chrome_browser_application_mac.mm
index c48d6cc9f29858e75afb2554cc6754b14dd48e21..71c0efa190c1416a113931e4365f2d96dd3cbde4 100644
--- a/chrome/browser/chrome_browser_application_mac.mm
+++ b/chrome/browser/chrome_browser_application_mac.mm
@@ -10,13 +10,13 @@
#import "base/logging.h"
#import "base/mac/scoped_nsexception_enabler.h"
#import "base/mac/scoped_nsobject.h"
+#import "base/mac/scoped_objc_class_swizzler.h"
#import "base/metrics/histogram.h"
#include "base/strings/stringprintf.h"
#import "base/strings/sys_string_conversions.h"
#import "chrome/browser/app_controller_mac.h"
#include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
#include "chrome/common/crash_keys.h"
-#import "chrome/common/mac/objc_method_swizzle.h"
#import "chrome/common/mac/objc_zombie.h"
#include "content/public/browser/browser_accessibility_state.h"
#include "content/public/browser/render_view_host.h"
@@ -63,6 +63,7 @@ static IMP gOriginalInitIMP = NULL;
userInfo:(NSDictionary*)someUserInfo {
// Method only called when swizzled.
DCHECK(_cmd == @selector(initWithName:reason:userInfo:));
+ DCHECK(gOriginalInitIMP);
// Parts of Cocoa rely on creating and throwing exceptions. These are not
// worth bugging-out over. It is very important that there be zero chance that
@@ -235,10 +236,12 @@ void SwizzleInit() {
// Do-nothing wrapper so that we can arrange to only swizzle
// -[NSException raise] when DCHECK() is turned on (as opposed to
// replicating the preprocess logic which turns DCHECK() on).
- gOriginalInitIMP = ObjcEvilDoers::SwizzleImplementedInstanceMethods(
- [NSException class],
- @selector(initWithName:reason:userInfo:),
- @selector(crInitWithName:reason:userInfo:));
+ CR_DEFINE_STATIC_LOCAL(base::mac::ScopedObjCClassSwizzler,
+ swizzle_exception,
+ ([NSException class],
+ @selector(initWithName:reason:userInfo:),
+ @selector(crInitWithName:reason:userInfo:)));
+ gOriginalInitIMP = swizzle_exception.GetOriginalImplementation();
}
} // namespace
« no previous file with comments | « base/mac/scoped_objc_class_swizzler_unittest.mm ('k') | chrome/chrome_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698