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

Side by Side Diff: chrome/app/chrome_crash_reporter_client_win.cc

Issue 2487783002: Make Crashpad use the user data dir, rather than always default location (Closed)
Patch Set: install_static for swarming Created 4 years 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // TODO(ananta/scottmg) 5 // TODO(ananta/scottmg)
6 // Add test coverage for Crashpad. 6 // Add test coverage for Crashpad.
7 #include "chrome/app/chrome_crash_reporter_client_win.h" 7 #include "chrome/app/chrome_crash_reporter_client_win.h"
8 8
9 #include <assert.h> 9 #include <assert.h>
10 #include <windows.h> 10 #include <windows.h>
11 #include <shellapi.h> 11 #include <shellapi.h>
12 #include <memory> 12 #include <memory>
13 #include <string> 13 #include <string>
14 14
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/debug/crash_logging.h" 16 #include "base/debug/crash_logging.h"
17 #include "base/debug/leak_annotations.h" 17 #include "base/debug/leak_annotations.h"
18 #include "base/format_macros.h" 18 #include "base/format_macros.h"
19 #include "chrome/common/chrome_result_codes.h" 19 #include "chrome/common/chrome_result_codes.h"
20 #include "chrome/install_static/install_details.h" 20 #include "chrome/install_static/install_details.h"
21 #include "chrome/install_static/install_util.h" 21 #include "chrome/install_static/install_util.h"
22 #include "chrome/install_static/user_data_dir.h"
22 #include "components/crash/content/app/crashpad.h" 23 #include "components/crash/content/app/crashpad.h"
23 #include "components/crash/core/common/crash_keys.h" 24 #include "components/crash/core/common/crash_keys.h"
24 25
25 namespace { 26 namespace {
26 27
27 // TODO(ananta) 28 // TODO(ananta)
28 // When the new crash key map implementation lands, we should remove the 29 // When the new crash key map implementation lands, we should remove the
29 // constants defined below, the RegisterCrashKeysHelper function, the 30 // constants defined below, the RegisterCrashKeysHelper function, the
30 // RegisterCrashKeys function in the crash_keys::CrashReporterClient interface 31 // RegisterCrashKeys function in the crash_keys::CrashReporterClient interface
31 // and the snprintf function defined here. 32 // and the snprintf function defined here.
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 #if !defined(NACL_WIN64) 246 #if !defined(NACL_WIN64)
246 // static 247 // static
247 void ChromeCrashReporterClient::InitializeCrashReportingForProcess() { 248 void ChromeCrashReporterClient::InitializeCrashReportingForProcess() {
248 static ChromeCrashReporterClient* instance = nullptr; 249 static ChromeCrashReporterClient* instance = nullptr;
249 if (instance) 250 if (instance)
250 return; 251 return;
251 252
252 instance = new ChromeCrashReporterClient(); 253 instance = new ChromeCrashReporterClient();
253 ANNOTATE_LEAKING_OBJECT_PTR(instance); 254 ANNOTATE_LEAKING_OBJECT_PTR(instance);
254 255
255 std::string process_type = install_static::GetSwitchValueFromCommandLine( 256 std::wstring process_type = install_static::GetSwitchValueFromCommandLine(
256 ::GetCommandLineA(), install_static::kProcessType); 257 ::GetCommandLine(), install_static::kProcessType);
257 if (process_type != install_static::kCrashpadHandler) { 258 if (process_type != install_static::kCrashpadHandler) {
258 crash_reporter::SetCrashReporterClient(instance); 259 crash_reporter::SetCrashReporterClient(instance);
259 crash_reporter::InitializeCrashpadWithEmbeddedHandler(process_type.empty(), 260 crash_reporter::InitializeCrashpadWithEmbeddedHandler(
260 process_type); 261 process_type.empty(), install_static::UTF16ToUTF8(process_type));
261 } 262 }
262 } 263 }
263 #endif // NACL_WIN64 264 #endif // NACL_WIN64
264 265
265 bool ChromeCrashReporterClient::GetAlternativeCrashDumpLocation( 266 bool ChromeCrashReporterClient::GetAlternativeCrashDumpLocation(
266 base::string16* crash_dir) { 267 base::string16* crash_dir) {
267 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate 268 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate
268 // location to write breakpad crash dumps can be set. 269 // location to write breakpad crash dumps can be set.
269 *crash_dir = 270 *crash_dir =
270 install_static::GetEnvironmentString16(L"BREAKPAD_DUMP_LOCATION"); 271 install_static::GetEnvironmentString16(L"BREAKPAD_DUMP_LOCATION");
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 base::string16* crash_dir) { 364 base::string16* crash_dir) {
364 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate 365 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate
365 // location to write breakpad crash dumps can be set. 366 // location to write breakpad crash dumps can be set.
366 // If this environment variable exists, then for the time being, 367 // If this environment variable exists, then for the time being,
367 // short-circuit how it's handled on Windows. Honoring this 368 // short-circuit how it's handled on Windows. Honoring this
368 // variable is required in order to symbolize stack traces in 369 // variable is required in order to symbolize stack traces in
369 // Telemetry based tests: http://crbug.com/561763. 370 // Telemetry based tests: http://crbug.com/561763.
370 if (GetAlternativeCrashDumpLocation(crash_dir)) 371 if (GetAlternativeCrashDumpLocation(crash_dir))
371 return true; 372 return true;
372 373
373 // TODO(scottmg): Consider supporting --user-data-dir. See 374 *crash_dir = install_static::GetCrashDumpLocation();
374 // https://crbug.com/565446. 375 return true;
375 return install_static::GetDefaultCrashDumpLocation(crash_dir);
376 } 376 }
377 377
378 bool ChromeCrashReporterClient::GetCrashMetricsLocation( 378 bool ChromeCrashReporterClient::GetCrashMetricsLocation(
379 base::string16* metrics_dir) { 379 base::string16* metrics_dir) {
380 return install_static::GetDefaultUserDataDirectory(metrics_dir); 380 return install_static::GetUserDataDirectory(metrics_dir, nullptr);
381 } 381 }
382 382
383 // TODO(ananta) 383 // TODO(ananta)
384 // This function should be removed when the new crash key map implementation 384 // This function should be removed when the new crash key map implementation
385 // lands. 385 // lands.
386 size_t ChromeCrashReporterClient::RegisterCrashKeys() { 386 size_t ChromeCrashReporterClient::RegisterCrashKeys() {
387 return RegisterCrashKeysHelper(); 387 return RegisterCrashKeysHelper();
388 } 388 }
389 389
390 bool ChromeCrashReporterClient::IsRunningUnattended() { 390 bool ChromeCrashReporterClient::IsRunningUnattended() {
391 return install_static::HasEnvironmentVariable16(install_static::kHeadless); 391 return install_static::HasEnvironmentVariable16(install_static::kHeadless);
392 } 392 }
393 393
394 bool ChromeCrashReporterClient::GetCollectStatsConsent() { 394 bool ChromeCrashReporterClient::GetCollectStatsConsent() {
395 return install_static::GetCollectStatsConsent(); 395 return install_static::GetCollectStatsConsent();
396 } 396 }
397 397
398 bool ChromeCrashReporterClient::GetCollectStatsInSample() { 398 bool ChromeCrashReporterClient::GetCollectStatsInSample() {
399 return install_static::GetCollectStatsInSample(); 399 return install_static::GetCollectStatsInSample();
400 } 400 }
401 401
402 bool ChromeCrashReporterClient::EnableBreakpadForProcess( 402 bool ChromeCrashReporterClient::EnableBreakpadForProcess(
403 const std::string& process_type) { 403 const std::string& process_type) {
404 return process_type == install_static::kRendererProcess || 404 // This is not used by Crashpad (at least on Windows).
405 process_type == install_static::kPpapiPluginProcess || 405 NOTREACHED();
406 process_type == install_static::kGpuProcess; 406 return true;
407 } 407 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698