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

Side by Side Diff: chrome/app/breakpad_mac.mm

Issue 7849011: Refactor Mac crash key reporting - move to base/mac/crash_logging.{h,mm} (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/app/breakpad_mac.h" 5 #import "chrome/app/breakpad_mac.h"
6 6
7 #include <CoreFoundation/CoreFoundation.h> 7 #include <CoreFoundation/CoreFoundation.h>
8 #import <Foundation/Foundation.h> 8 #import <Foundation/Foundation.h>
9 9
10 #include "base/base_switches.h" 10 #include "base/base_switches.h"
(...skipping 12 matching lines...) Expand all
23 #include "chrome/common/chrome_paths.h" 23 #include "chrome/common/chrome_paths.h"
24 #include "chrome/common/chrome_switches.h" 24 #include "chrome/common/chrome_switches.h"
25 #include "chrome/common/env_vars.h" 25 #include "chrome/common/env_vars.h"
26 #include "chrome/installer/util/google_update_settings.h" 26 #include "chrome/installer/util/google_update_settings.h"
27 #include "policy/policy_constants.h" 27 #include "policy/policy_constants.h"
28 28
29 namespace { 29 namespace {
30 30
31 BreakpadRef gBreakpadRef = NULL; 31 BreakpadRef gBreakpadRef = NULL;
32 32
33 void SetCrashKeyValue(NSString* key, NSString* value) {
34 // Comment repeated from header to prevent confusion:
35 // IMPORTANT: On OS X, the key/value pairs are sent to the crash server
36 // out of bounds and not recorded on disk in the minidump, this means
37 // that if you look at the minidump file locally you won't see them!
38 if (gBreakpadRef == NULL) {
39 return;
40 }
41
42 BreakpadAddUploadParameter(gBreakpadRef, key, value);
43 }
44
45 void ClearCrashKeyValue(NSString* key) {
46 if (gBreakpadRef == NULL) {
47 return;
48 }
49
50 BreakpadRemoveUploadParameter(gBreakpadRef, key);
51 }
52
33 } // namespace 53 } // namespace
34 54
35 bool IsCrashReporterEnabled() { 55 bool IsCrashReporterEnabled() {
36 return gBreakpadRef != NULL; 56 return gBreakpadRef != NULL;
37 } 57 }
38 58
39 void DestructCrashReporter() { 59 void DestructCrashReporter() {
40 if (gBreakpadRef) { 60 if (gBreakpadRef) {
41 BreakpadRelease(gBreakpadRef); 61 BreakpadRelease(gBreakpadRef);
42 gBreakpadRef = NULL; 62 gBreakpadRef = NULL;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 168 }
149 169
150 // Set Breakpad metadata values. These values are added to Info.plist during 170 // Set Breakpad metadata values. These values are added to Info.plist during
151 // the branded Google Chrome.app build. 171 // the branded Google Chrome.app build.
152 SetCrashKeyValue(@"ver", [info_dictionary objectForKey:@BREAKPAD_VERSION]); 172 SetCrashKeyValue(@"ver", [info_dictionary objectForKey:@BREAKPAD_VERSION]);
153 SetCrashKeyValue(@"prod", [info_dictionary objectForKey:@BREAKPAD_PRODUCT]); 173 SetCrashKeyValue(@"prod", [info_dictionary objectForKey:@BREAKPAD_PRODUCT]);
154 SetCrashKeyValue(@"plat", @"OS X"); 174 SetCrashKeyValue(@"plat", @"OS X");
155 175
156 // Enable child process crashes to include the page URL. 176 // Enable child process crashes to include the page URL.
157 // TODO: Should this only be done for certain process types? 177 // TODO: Should this only be done for certain process types?
158 child_process_logging::SetCrashKeyFunctions(SetCrashKeyValue, 178 base::mac::SetCrashKeyFunctions(SetCrashKeyValue,
159 ClearCrashKeyValue); 179 ClearCrashKeyValue);
Scott Hess - ex-Googler 2011/09/08 19:46:46 Oh! I had thought this bug was kinda pedantic, an
160 180
161 if (!is_browser) { 181 if (!is_browser) {
162 // Get the guid from the command line switch. 182 // Get the guid from the command line switch.
163 std::string guid = 183 std::string guid =
164 command_line->GetSwitchValueASCII(switches::kEnableCrashReporter); 184 command_line->GetSwitchValueASCII(switches::kEnableCrashReporter);
165 child_process_logging::SetClientId(guid); 185 child_process_logging::SetClientId(guid);
166 } 186 }
167 } 187 }
168 188
169 void InitCrashProcessInfo() { 189 void InitCrashProcessInfo() {
170 if (gBreakpadRef == NULL) { 190 if (gBreakpadRef == NULL) {
171 return; 191 return;
172 } 192 }
173 193
174 // Determine the process type. 194 // Determine the process type.
175 NSString* process_type = @"browser"; 195 NSString* process_type = @"browser";
176 std::string process_type_switch = 196 std::string process_type_switch =
177 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 197 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
178 switches::kProcessType); 198 switches::kProcessType);
179 if (!process_type_switch.empty()) { 199 if (!process_type_switch.empty()) {
180 process_type = base::SysUTF8ToNSString(process_type_switch); 200 process_type = base::SysUTF8ToNSString(process_type_switch);
181 } 201 }
182 202
183 // Store process type in crash dump. 203 // Store process type in crash dump.
184 SetCrashKeyValue(@"ptype", process_type); 204 SetCrashKeyValue(@"ptype", process_type);
185 } 205 }
186
187 void SetCrashKeyValue(NSString* key, NSString* value) {
188 // Comment repeated from header to prevent confusion:
189 // IMPORTANT: On OS X, the key/value pairs are sent to the crash server
190 // out of bounds and not recorded on disk in the minidump, this means
191 // that if you look at the minidump file locally you won't see them!
192 if (gBreakpadRef == NULL) {
193 return;
194 }
195
196 BreakpadAddUploadParameter(gBreakpadRef, key, value);
197 }
198
199 void ClearCrashKeyValue(NSString* key) {
200 if (gBreakpadRef == NULL) {
201 return;
202 }
203
204 BreakpadRemoveUploadParameter(gBreakpadRef, key);
205 }
206
207 // NOTE(shess): These also exist in breakpad_mac_stubs.mm.
208 ScopedCrashKey::ScopedCrashKey(NSString* key, NSString* value)
209 : crash_key_([key retain]) {
210 SetCrashKeyValue(crash_key_.get(), value);
211 }
212
213 ScopedCrashKey::~ScopedCrashKey() {
214 ClearCrashKeyValue(crash_key_.get());
215 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698