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

Unified Diff: chrome/app/breakpad_mac.mm

Issue 53075: First stab at Mac breakpad support. (Closed)
Patch Set: Address John's comments Created 11 years, 9 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 | « chrome/app/breakpad_mac.h ('k') | chrome/app/breakpad_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/app/breakpad_mac.mm
diff --git a/chrome/app/breakpad_mac.mm b/chrome/app/breakpad_mac.mm
new file mode 100644
index 0000000000000000000000000000000000000000..5ffc147df86e24eb9d0e58e99a03b781ff846bd8
--- /dev/null
+++ b/chrome/app/breakpad_mac.mm
@@ -0,0 +1,95 @@
+// 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/app/breakpad_mac.h"
+
+#import <objc/objc-class.h>
+#import <Foundation/Foundation.h>
+
+#import "base/basictypes.h"
+#import "base/logging.h"
+#import "base/scoped_nsautorelease_pool.h"
+
+// TODO(jeremy): Remove this block once we include the breakpad sources
+// in the public tree.
+@interface GoogleBreakpadWrapper : NSObject
+ +(void*)Create:(NSDictionary*) parameters;
+ +(void)Release:(void*) ref;
+@end
+typedef void* GoogleBreakpadRef;
+
+namespace {
+
+// TODO(jeremy): On Windows we store the current URL when a process crashes
+// we probably want to do the same on OS X.
+
+GoogleBreakpadRef gBreakpadRef = NULL;
+
+// Did the user optin for reporting stats.
+bool IsStatsReportingAllowed() {
+ NOTIMPLEMENTED();
+ return true;
+}
+
+} // namespace
+
+bool IsCrashReporterEnabled() {
+ return gBreakpadRef == NULL;
+}
+
+void DestructCrashReporter() {
+ if (gBreakpadRef) {
+ Class breakpad_interface = objc_getClass("GoogleBreakpadWrapper");
+ [breakpad_interface Release:gBreakpadRef];
+ gBreakpadRef = NULL;
+ }
+}
+
+void InitCrashReporter() {
+ DCHECK(gBreakpadRef == NULL);
+ base::ScopedNSAutoreleasePool autorelease_pool;
+
+ // Check for Send stats preference. If preference is not specifically turned
+ // on then disable crash reporting.
+ if (!IsStatsReportingAllowed()) {
+ LOG(WARNING) << "Breakpad disabled";
+ return;
+ }
+
+ NSBundle* main_bundle = [NSBundle mainBundle];
+
+ // Get location of breakpad.
+ NSString* breakpadBundlePath = [[main_bundle privateFrameworksPath]
+ stringByAppendingPathComponent:@"GoogleBreakpad.framework"];
+
+ BOOL is_dir = NO;
+ if (![[NSFileManager defaultManager] fileExistsAtPath:breakpadBundlePath
+ isDirectory:&is_dir] || !is_dir) {
+ return;
+ }
+
+ NSBundle* breakpad_bundle = [NSBundle bundleWithPath:breakpadBundlePath];
+ if (![breakpad_bundle load]) {
+ LOG(ERROR) << "Failed to load Breakpad framework.";
+ return;
+ }
+
+ Class breakpad_interface = [breakpad_bundle
+ classNamed:@"GoogleBreakpadWrapper"];
+
+ if (!breakpad_interface) {
+ LOG(ERROR) << "Failed to find GoogleBreakpadWrapper class.";
+ return;
+ }
+
+ NSDictionary* info_dictionary = [main_bundle infoDictionary];
+ GoogleBreakpadRef breakpad = 0;
+ breakpad = [breakpad_interface Create:info_dictionary];
+ if (!breakpad) {
+ LOG(ERROR) << "Breakpad init failed.";
+ return;
+ }
+
+ gBreakpadRef = breakpad;
+}
« no previous file with comments | « chrome/app/breakpad_mac.h ('k') | chrome/app/breakpad_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698