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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « chrome/app/breakpad_mac.h ('k') | chrome/app/breakpad_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import "chrome/app/breakpad_mac.h"
6
7 #import <objc/objc-class.h>
8 #import <Foundation/Foundation.h>
9
10 #import "base/basictypes.h"
11 #import "base/logging.h"
12 #import "base/scoped_nsautorelease_pool.h"
13
14 // TODO(jeremy): Remove this block once we include the breakpad sources
15 // in the public tree.
16 @interface GoogleBreakpadWrapper : NSObject
17 +(void*)Create:(NSDictionary*) parameters;
18 +(void)Release:(void*) ref;
19 @end
20 typedef void* GoogleBreakpadRef;
21
22 namespace {
23
24 // TODO(jeremy): On Windows we store the current URL when a process crashes
25 // we probably want to do the same on OS X.
26
27 GoogleBreakpadRef gBreakpadRef = NULL;
28
29 // Did the user optin for reporting stats.
30 bool IsStatsReportingAllowed() {
31 NOTIMPLEMENTED();
32 return true;
33 }
34
35 } // namespace
36
37 bool IsCrashReporterEnabled() {
38 return gBreakpadRef == NULL;
39 }
40
41 void DestructCrashReporter() {
42 if (gBreakpadRef) {
43 Class breakpad_interface = objc_getClass("GoogleBreakpadWrapper");
44 [breakpad_interface Release:gBreakpadRef];
45 gBreakpadRef = NULL;
46 }
47 }
48
49 void InitCrashReporter() {
50 DCHECK(gBreakpadRef == NULL);
51 base::ScopedNSAutoreleasePool autorelease_pool;
52
53 // Check for Send stats preference. If preference is not specifically turned
54 // on then disable crash reporting.
55 if (!IsStatsReportingAllowed()) {
56 LOG(WARNING) << "Breakpad disabled";
57 return;
58 }
59
60 NSBundle* main_bundle = [NSBundle mainBundle];
61
62 // Get location of breakpad.
63 NSString* breakpadBundlePath = [[main_bundle privateFrameworksPath]
64 stringByAppendingPathComponent:@"GoogleBreakpad.framework"];
65
66 BOOL is_dir = NO;
67 if (![[NSFileManager defaultManager] fileExistsAtPath:breakpadBundlePath
68 isDirectory:&is_dir] || !is_dir) {
69 return;
70 }
71
72 NSBundle* breakpad_bundle = [NSBundle bundleWithPath:breakpadBundlePath];
73 if (![breakpad_bundle load]) {
74 LOG(ERROR) << "Failed to load Breakpad framework.";
75 return;
76 }
77
78 Class breakpad_interface = [breakpad_bundle
79 classNamed:@"GoogleBreakpadWrapper"];
80
81 if (!breakpad_interface) {
82 LOG(ERROR) << "Failed to find GoogleBreakpadWrapper class.";
83 return;
84 }
85
86 NSDictionary* info_dictionary = [main_bundle infoDictionary];
87 GoogleBreakpadRef breakpad = 0;
88 breakpad = [breakpad_interface Create:info_dictionary];
89 if (!breakpad) {
90 LOG(ERROR) << "Breakpad init failed.";
91 return;
92 }
93
94 gBreakpadRef = breakpad;
95 }
OLDNEW
« 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