| OLD | NEW |
| 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> |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 #if !defined(NACL_WIN64) | 242 #if !defined(NACL_WIN64) |
| 243 // static | 243 // static |
| 244 void ChromeCrashReporterClient::InitializeCrashReportingForProcess() { | 244 void ChromeCrashReporterClient::InitializeCrashReportingForProcess() { |
| 245 static ChromeCrashReporterClient* instance = nullptr; | 245 static ChromeCrashReporterClient* instance = nullptr; |
| 246 if (instance) | 246 if (instance) |
| 247 return; | 247 return; |
| 248 | 248 |
| 249 instance = new ChromeCrashReporterClient(); | 249 instance = new ChromeCrashReporterClient(); |
| 250 ANNOTATE_LEAKING_OBJECT_PTR(instance); | 250 ANNOTATE_LEAKING_OBJECT_PTR(instance); |
| 251 | 251 |
| 252 std::string process_type = install_static::GetSwitchValueFromCommandLine( | 252 std::wstring process_type = install_static::GetSwitchValueFromCommandLine( |
| 253 ::GetCommandLineA(), install_static::kProcessType); | 253 ::GetCommandLine(), install_static::kProcessType); |
| 254 if (process_type != install_static::kCrashpadHandler) { | 254 if (process_type != install_static::kCrashpadHandler) { |
| 255 crash_reporter::SetCrashReporterClient(instance); | 255 crash_reporter::SetCrashReporterClient(instance); |
| 256 crash_reporter::InitializeCrashpadWithEmbeddedHandler(process_type.empty(), | 256 crash_reporter::InitializeCrashpadWithEmbeddedHandler( |
| 257 process_type); | 257 process_type.empty(), install_static::UTF16ToUTF8(process_type)); |
| 258 } | 258 } |
| 259 } | 259 } |
| 260 #endif // NACL_WIN64 | 260 #endif // NACL_WIN64 |
| 261 | 261 |
| 262 bool ChromeCrashReporterClient::GetAlternativeCrashDumpLocation( | 262 bool ChromeCrashReporterClient::GetAlternativeCrashDumpLocation( |
| 263 base::string16* crash_dir) { | 263 base::string16* crash_dir) { |
| 264 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate | 264 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate |
| 265 // location to write breakpad crash dumps can be set. | 265 // location to write breakpad crash dumps can be set. |
| 266 *crash_dir = | 266 *crash_dir = |
| 267 install_static::GetEnvironmentString16(L"BREAKPAD_DUMP_LOCATION"); | 267 install_static::GetEnvironmentString16(L"BREAKPAD_DUMP_LOCATION"); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 base::string16* crash_dir) { | 360 base::string16* crash_dir) { |
| 361 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate | 361 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate |
| 362 // location to write breakpad crash dumps can be set. | 362 // location to write breakpad crash dumps can be set. |
| 363 // If this environment variable exists, then for the time being, | 363 // If this environment variable exists, then for the time being, |
| 364 // short-circuit how it's handled on Windows. Honoring this | 364 // short-circuit how it's handled on Windows. Honoring this |
| 365 // variable is required in order to symbolize stack traces in | 365 // variable is required in order to symbolize stack traces in |
| 366 // Telemetry based tests: http://crbug.com/561763. | 366 // Telemetry based tests: http://crbug.com/561763. |
| 367 if (GetAlternativeCrashDumpLocation(crash_dir)) | 367 if (GetAlternativeCrashDumpLocation(crash_dir)) |
| 368 return true; | 368 return true; |
| 369 | 369 |
| 370 // TODO(scottmg): Consider supporting --user-data-dir. See | 370 return install_static::GetCrashDumpLocation(crash_dir); |
| 371 // https://crbug.com/565446. | |
| 372 return install_static::GetDefaultCrashDumpLocation(crash_dir); | |
| 373 } | 371 } |
| 374 | 372 |
| 375 bool ChromeCrashReporterClient::GetCrashMetricsLocation( | 373 bool ChromeCrashReporterClient::GetCrashMetricsLocation( |
| 376 base::string16* metrics_dir) { | 374 base::string16* metrics_dir) { |
| 377 return install_static::GetDefaultUserDataDirectory(metrics_dir); | 375 *metrics_dir = install_static::InstallDetails::Get().user_data_dir(); |
| 376 return true; |
| 378 } | 377 } |
| 379 | 378 |
| 380 // TODO(ananta) | 379 // TODO(ananta) |
| 381 // This function should be removed when the new crash key map implementation | 380 // This function should be removed when the new crash key map implementation |
| 382 // lands. | 381 // lands. |
| 383 size_t ChromeCrashReporterClient::RegisterCrashKeys() { | 382 size_t ChromeCrashReporterClient::RegisterCrashKeys() { |
| 384 return RegisterCrashKeysHelper(); | 383 return RegisterCrashKeysHelper(); |
| 385 } | 384 } |
| 386 | 385 |
| 387 bool ChromeCrashReporterClient::IsRunningUnattended() { | 386 bool ChromeCrashReporterClient::IsRunningUnattended() { |
| 388 return install_static::HasEnvironmentVariable16(install_static::kHeadless); | 387 return install_static::HasEnvironmentVariable16(install_static::kHeadless); |
| 389 } | 388 } |
| 390 | 389 |
| 391 bool ChromeCrashReporterClient::GetCollectStatsConsent() { | 390 bool ChromeCrashReporterClient::GetCollectStatsConsent() { |
| 392 return install_static::GetCollectStatsConsent(); | 391 return install_static::GetCollectStatsConsent(); |
| 393 } | 392 } |
| 394 | 393 |
| 395 bool ChromeCrashReporterClient::GetCollectStatsInSample() { | 394 bool ChromeCrashReporterClient::GetCollectStatsInSample() { |
| 396 return install_static::GetCollectStatsInSample(); | 395 return install_static::GetCollectStatsInSample(); |
| 397 } | 396 } |
| 398 | 397 |
| 399 bool ChromeCrashReporterClient::EnableBreakpadForProcess( | 398 bool ChromeCrashReporterClient::EnableBreakpadForProcess( |
| 400 const std::string& process_type) { | 399 const std::string& process_type) { |
| 401 return process_type == install_static::kRendererProcess || | 400 // This is not used by Crashpad (at least on Windows). |
| 402 process_type == install_static::kPpapiPluginProcess || | 401 NOTREACHED(); |
| 403 process_type == install_static::kGpuProcess; | 402 return true; |
| 404 } | 403 } |
| OLD | NEW |